84
Example 3. Create a libpmemobj (obj) pool using all available capacity within
the /mnt/pmemfs0/ file system using the layout name of “my_layout”
$ pmempool create --layout my_layout –-max-size obj \
/mnt/pmemfs0/pool.obj
Applications can programmatically create pools that do not exist at application start
time using pmemobj_create(). pmemobj_create() has the following arguments:
PMEMobjpool *pmemobj_create(const char *path,
const char *layout, size_t poolsize, mode_t mode);
• path specifies the name of the memory pool file to be created,
including a full or relative path to the file.
• layout specifies the application’s layout type in the form of a string to
identify the pool.
• poolsize specifies the required size for the pool. The memory pool
file is fully allocated to the size poolsize using posix_fallocate(3).
The minimum size for a pool is defined as PMEMOBJ_MIN_POOL in
. If the pool already exists, pmemobj_create() will
return an EEXISTS error. Specifying poolsize as zero will take the
pool size from the file size and will verify that the file appears to be
empty by searching for any nonzero data in the pool header at the
beginning of the file.
• mode specifies the ACL permissions to use when creating the file, as
described by create(2).
Listing 7-1 shows how to create a pool using the pmemobj_create() function.
Listing 7-1. pwriter.c – An example showing how to create a pool using
pmemobj_create()
33 /*
34 * pwriter.c - Write a string to a
35 *
persistent memory pool
36 */
37
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
Example 3. Create a libpmemobj (obj) pool using all available capacity within
the /mnt/pmemfs0/ file system using the layout name of “my_layout”
$ pmempool create --layout my_layout –-max-size obj \
/mnt/pmemfs0/pool.obj
Applications can programmatically create pools that do not exist at application start
time using pmemobj_create(). pmemobj_create() has the following arguments:
PMEMobjpool *pmemobj_create(const char *path,
const char *layout, size_t poolsize, mode_t mode);
• path specifies the name of the memory pool file to be created,
including a full or relative path to the file.
• layout specifies the application’s layout type in the form of a string to
identify the pool.
• poolsize specifies the required size for the pool. The memory pool
file is fully allocated to the size poolsize using posix_fallocate(3).
The minimum size for a pool is defined as PMEMOBJ_MIN_POOL in
return an EEXISTS error. Specifying poolsize as zero will take the
pool size from the file size and will verify that the file appears to be
empty by searching for any nonzero data in the pool header at the
beginning of the file.
• mode specifies the ACL permissions to use when creating the file, as
described by create(2).
Listing 7-1 shows how to create a pool using the pmemobj_create() function.
Listing 7-1. pwriter.c – An example showing how to create a pool using
pmemobj_create()
33 /*
34 * pwriter.c - Write a string to a
35 *
persistent memory pool
36 */
37
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
