summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2017-11-30 16:59:07 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-11-30 16:59:07 +1100
commit0d97f635950d6746038ab8c14429be40501369a0 (patch)
treefd92f142a1bfb0b57976fd1a4c2eb50eeefbd918
parenta669f2e0fe2ceb56294cc929131b8361734d4164 (diff)
parentfd98239a8beb83a3b3f61513860edb69123828d8 (diff)
downloadffs-0d97f635950d6746038ab8c14429be40501369a0.zip
ffs-0d97f635950d6746038ab8c14429be40501369a0.tar.gz
Merge branch 'bugfixes' of https://github.com/stewart-ibm/ffs
-rw-r--r--ffs/src/libffs.c16
-rw-r--r--fpart/src/command.c13
2 files changed, 12 insertions, 17 deletions
diff --git a/ffs/src/libffs.c b/ffs/src/libffs.c
index 7e20bef..03ede55 100644
--- a/ffs/src/libffs.c
+++ b/ffs/src/libffs.c
@@ -487,6 +487,10 @@ ffs_t *__ffs_fcreate(FILE *file, off_t offset, uint32_t block_size,
self->hdr->block_size = block_size;
self->hdr->block_count = block_count;
self->hdr->checksum = 0;
+ self->hdr->resvd[0] = 0;
+ self->hdr->resvd[1] = 0;
+ self->hdr->resvd[2] = 0;
+ self->hdr->resvd[3] = 0;
size_t size = self->count * self->hdr->entry_size;
@@ -637,14 +641,6 @@ static int ffs_flush(ffs_t * self)
return -1;
}
- if (fileno(self->file) != -1) {
- if (fsync(fileno(self->file)) < 0) {
- ERRNO(errno);
- return -1;
- }
- }
-
-
self->dirty = false;
return 0;
@@ -763,10 +759,6 @@ int __ffs_fsync(ffs_t * self)
return -1;
}
- if (fileno(self->file) != -1)
- if (fsync(fileno(self->file)) < 0)
- return -1;
-
return 0;
}
diff --git a/fpart/src/command.c b/fpart/src/command.c
index 6b4e56e..81cbc70 100644
--- a/fpart/src/command.c
+++ b/fpart/src/command.c
@@ -172,14 +172,15 @@ int create_regular_file(const char *path, size_t size, char pad)
{
assert(path != NULL);
- RAII(FILE*, file, fopen(path, "w"), fclose);
- if (file == NULL) {
+ int fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR);
+ if (fd == -1) {
ERRNO(errno);
return -1;
}
- if (ftruncate(fileno(file), size) < 0) {
+ if (ftruncate(fd, size) < 0) {
ERRNO(errno);
+ close(fd);
return -1;
}
@@ -188,15 +189,17 @@ int create_regular_file(const char *path, size_t size, char pad)
memset(buf, pad, page_size);
while (0 < size) {
- ssize_t rc = fwrite(buf, 1, min(sizeof(buf), size), file);
- if (rc <= 0 && ferror(file)) {
+ ssize_t rc = write(fd, buf, min(sizeof(buf), size));
+ if (rc <= 0) {
ERRNO(errno);
+ close(fd);
return -1;
}
size -= rc;
}
+ close(fd);
return 0;
}
OpenPOWER on IntegriCloud