Commit e3c1006f authored by Matthieu Dorier's avatar Matthieu Dorier

made bake_makepool zero the pool

parent bf6c4c54
......@@ -8,6 +8,8 @@
#include <assert.h>
#include <libpmemobj.h>
#include <unistd.h>
#include <fcntl.h>
#include <remi/remi-client.h>
#include <remi/remi-server.h>
#include "bake-server.h"
......@@ -85,7 +87,30 @@ int bake_makepool(
PMEMoid root_oid;
bake_root_t *root;
pool = pmemobj_create(pool_name, NULL, pool_size, pool_mode);
int fd = creat(pool_name, pool_mode);
if(fd <= 0) {
fprintf(stderr, "creat failed\n");
return BAKE_ERR_ALLOCATION;
}
char* buf = malloc(1024*1024);
memset(buf,0,1024*1024);
size_t remaining = pool_size;
while(remaining) {
if(remaining >= 1024*1024) {
write(fd, buf, 1024*1024);
remaining -= 1024*1024;
} else {
write(fd, buf, remaining);
remaining = 0;
}
}
free(buf);
close(fd);
pool = pmemobj_create(pool_name, NULL, 0, pool_mode);
if(!pool)
{
fprintf(stderr, "pmemobj_create: %s\n", pmemobj_errormsg());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment