summaryrefslogtreecommitdiffstats
path: root/src/pmdk/utils/docker/test_package/test_package.c
blob: cf1e7eb8b7d6d85309a730bac78226a63869a6f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018, Intel Corporation */

#include <libpmemobj.h>
#include <stdio.h>
#include <sys/stat.h>

#define LAYOUT_NAME "test"

struct my_root {
	int foo;
};

int
main(int argc, char *argv[])
{
	if (argc < 2) {
		printf("usage: %s file-name\n", argv[0]);
		return 1;
	}

	const char *path = argv[1];

	PMEMobjpool *pop = pmemobj_create(path, LAYOUT_NAME,
			PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR);

	if (pop == NULL) {
		printf("failed to create pool\n");
		return 1;
	}

	PMEMoid root = pmemobj_root(pop, sizeof(struct my_root));
	struct my_root *rootp = pmemobj_direct(root);

	rootp->foo = 10;
	pmemobj_persist(pop, &rootp->foo, sizeof(rootp->foo));

	pmemobj_close(pop);

	return 0;
}