Permalink
Browse files

fix write

  • Loading branch information...
1 parent 079ca37 commit aee638728268b4f891183f3f4e692e415fb88743 @alperakcan committed Mar 30, 2015
Showing with 15 additions and 46 deletions.
  1. +3 −1 ChangeLog
  2. +5 −0 fuse-ext2/op_read.c
  3. +4 −45 fuse-ext2/op_truncate.c
  4. +3 −0 fuse-ext2/op_write.c
View
@@ -1,5 +1,7 @@
Mon Mar 30 19:17:44 EEST 2015
- - fix write tests for pjdfstest
+ - version 0.0.9
+ - fix write tests for pjdfstest
+ - fix ext2fs_file_*, need to open/release in every file operation
Mon Mar 28 10:21:43 EEST 2015
- version 0.0.8 - lazarus, raised from dead
View
@@ -26,19 +26,24 @@ int op_read (const char *path, char *buf, size_t size, off_t offset, struct fuse
errcode_t rc;
unsigned int bytes;
ext2_file_t efile = EXT2FS_FILE(fi->fh);
+ ext2_filsys e2fs = current_ext2fs();
debugf("enter");
debugf("path = %s", path);
+ efile = do_open(e2fs, path, O_RDONLY);
rc = ext2fs_file_llseek(efile, offset, SEEK_SET, &pos);
if (rc) {
+ do_release(efile);
return -EINVAL;
}
rc = ext2fs_file_read(efile, buf, size, &bytes);
if (rc) {
+ do_release(efile);
return -EIO;
}
+ do_release(efile);
debugf("leave");
return bytes;
@@ -56,12 +56,14 @@ int op_truncate (const char *path, off_t length)
rt = do_readinode(e2fs, path, &ino, &inode);
if (rt) {
debugf("do_readinode(%s, &ino, &vnode); failed", path);
+ do_release(efile);
return rt;
}
inode.i_ctime = e2fs->now ? e2fs->now : time(NULL);
rt = do_writeinode(e2fs, ino, &inode);
if (rt) {
debugf("do_writeinode(e2fs, ino, &inode); failed");
+ do_release(efile);
return -EIO;
}
@@ -77,49 +79,6 @@ int op_truncate (const char *path, off_t length)
int op_ftruncate (const char *path, off_t length, struct fuse_file_info *fi)
{
- int rt;
- errcode_t rc;
- ext2_ino_t ino;
- struct ext2_inode inode;
- ext2_filsys e2fs = current_ext2fs();
- ext2_file_t efile = EXT2FS_FILE(fi->fh);
-
- debugf("enter");
- debugf("path = %s", path);
-
- rt = do_check(path);
- if (rt != 0) {
- debugf("do_check(%s); failed", path);
- return rt;
- }
-
- rt = do_readinode(e2fs, path, &ino, &inode);
- if (rt) {
- debugf("do_readinode(%s, &ino, &vnode); failed", path);
- return rt;
- }
-
- rc = ext2fs_file_set_size2(efile, length);
- if (rc) {
- debugf("ext2fs_file_set_size(efile, %lld); failed: rc: %d", length, rc);
- if (rc == EXT2_ET_FILE_TOO_BIG) {
- return -EFBIG;
- }
- return -EIO;
- }
-
- rt = do_readinode(e2fs, path, &ino, &inode);
- if (rt) {
- debugf("do_readinode(%s, &ino, &vnode); failed", path);
- return rt;
- }
- inode.i_ctime = e2fs->now ? e2fs->now : time(NULL);
- rt = do_writeinode(e2fs, ino, &inode);
- if (rt) {
- debugf("do_writeinode(e2fs, ino, &inode); failed");
- return -EIO;
- }
-
- debugf("leave");
- return 0;
+ (void) fi;
+ return op_truncate(path, length);
}
@@ -72,11 +72,14 @@ int op_write (const char *path, const char *buf, size_t size, off_t offset, stru
{
size_t rt;
ext2_file_t efile = EXT2FS_FILE(fi->fh);
+ ext2_filsys e2fs = current_ext2fs();
debugf("enter");
debugf("path = %s", path);
+ efile = do_open(e2fs, path, O_WRONLY);
rt = do_write(efile, buf, size, offset);
+ do_release(efile);
debugf("leave");
return rt;

0 comments on commit aee6387

Please sign in to comment.