diff --git a/ntfsprogs/ntfsmount.c b/ntfsprogs/ntfsmount.c index 62d54036..c7b6de71 100644 --- a/ntfsprogs/ntfsmount.c +++ b/ntfsprogs/ntfsmount.c @@ -183,6 +183,12 @@ static long ntfs_fuse_get_nr_free_clusters(ntfs_volume *vol) return nr_free; } +static __inline__ void ntfs_fuse_mark_free_space_outdate() +{ + /* Mark information about free MFT record and clusters outdate. */ + ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); +} + /** * ntfs_fuse_statfs - return information about mounted NTFS volume * @path: ignored (but fuse requires it) @@ -645,7 +651,7 @@ static int ntfs_fuse_write(const char *org_path, const char *buf, size_t size, } res = total; exit: - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); if (na) ntfs_attr_close(na); if (ni && ntfs_inode_close(ni)) @@ -681,7 +687,7 @@ static int ntfs_fuse_truncate(const char *org_path, off_t size) goto exit; } res = ntfs_attr_truncate(na, size); - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); ntfs_attr_close(na); exit: if (ni && ntfs_inode_close(ni)) @@ -814,8 +820,7 @@ static int ntfs_fuse_mknod(const char *org_path, mode_t mode, dev_t dev) else res = ntfs_fuse_create_stream(path, stream_name, stream_name_len); - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); exit: free(path); if (stream_name_len) @@ -828,8 +833,7 @@ static int ntfs_fuse_symlink(const char *to, const char *from) if (strchr(from, ':') && /* n/a for named data streams. */ ctx->streams == NF_STREAMS_INTERFACE_WINDOWS) return -EINVAL; - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); return ntfs_fuse_create(from, S_IFLNK, 0, to); } @@ -873,8 +877,7 @@ static int ntfs_fuse_link(const char *old_path, const char *new_path) res = -EIO; goto exit; } - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); /* Create hard link. */ if (ntfs_link(ni, dir_ni, uname, uname_len)) res = -errno; @@ -975,8 +978,7 @@ static int ntfs_fuse_unlink(const char *org_path) res = ntfs_fuse_rm(path); else res = ntfs_fuse_rm_stream(path, stream_name, stream_name_len); - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); free(path); if (stream_name_len) free(stream_name); @@ -1001,8 +1003,7 @@ static int ntfs_fuse_mkdir(const char *path, { if (strchr(path, ':') && ctx->streams == NF_STREAMS_INTERFACE_WINDOWS) return -EINVAL; /* n/a for named data streams. */ - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); return ntfs_fuse_create(path, S_IFDIR, 0, NULL); } @@ -1010,8 +1011,7 @@ static int ntfs_fuse_rmdir(const char *path) { if (strchr(path, ':') && ctx->streams == NF_STREAMS_INTERFACE_WINDOWS) return -EINVAL; /* n/a for named data streams. */ - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); return ntfs_fuse_rm(path); } @@ -1257,8 +1257,7 @@ static int ntfs_fuse_setxattr(const char *path, const char *name, res = -EEXIST; goto exit; } - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); if (!na) { if (flags == XATTR_REPLACE) { res = -ENODATA; @@ -1318,8 +1317,7 @@ static int ntfs_fuse_removexattr(const char *path, const char *name) res = -ENODATA; goto exit; } - /* Mark information about free MFT record and clusters outdate. */ - ctx->state |= (NF_FreeClustersOutdate | NF_FreeMFTOutdate); + ntfs_fuse_mark_free_space_outdate(); if (ntfs_attr_rm(na)) res = -errno; else