Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix a ftruncate bug

  • Loading branch information...
commit 0669e9af960de6c7e9460740544a65fbcfa95449 1 parent 5bc6ea9
@redbo redbo authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 cloudfuse.c
View
10 cloudfuse.c
@@ -215,9 +215,10 @@ static int cfs_getattr(const char *path, struct stat *stbuf)
static int cfs_fgetattr(const char *path, struct stat *stbuf, struct fuse_file_info *info)
{
- if (info->fh)
+ openfile *of = (openfile *)(uintptr_t)info->fh;
+ if (of)
{
- stbuf->st_size = file_size(((openfile *)(uintptr_t)info->fh)->fd);
+ stbuf->st_size = file_size(of->fd);
stbuf->st_mode = S_IFREG | 0666;
stbuf->st_nlink = 1;
return 0;
@@ -325,9 +326,10 @@ static int cfs_rmdir(const char *path)
static int cfs_ftruncate(const char *path, off_t size, struct fuse_file_info *info)
{
- if (ftruncate(((openfile *)(uintptr_t)info->fh)->fd, size))
+ openfile *of = (openfile *)(uintptr_t)info->fh;
+ if (ftruncate(of->fd, size))
return -errno;
- lseek(info->fh, 0, SEEK_SET);
+ lseek(of->fd, 0, SEEK_SET);
update_dir_cache(path, size, 0);
return 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.