Avoided a double opening of an inode in create()

N2009_11_14_FIXES
jpandre 2009-09-18 16:31:46 +00:00
parent 31f7abf640
commit 12437acea9
2 changed files with 14 additions and 3 deletions

View File

@ -668,8 +668,11 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni)
}
ntfs_index_entry_mark_dirty(ictx);
ntfs_index_ctx_put(ictx);
if ((ni != index_ni) && ntfs_inode_close(index_ni) && !err)
err = errno;
if (ni != index_ni) {
ntfs_inode_update_times(index_ni, NTFS_UPDATE_CTIME);
if (ntfs_inode_close(index_ni) && !err)
err = errno;
}
}
/* Check for real error occurred. */
if (errno != ENOENT) {

View File

@ -1464,9 +1464,17 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
&& (ni->flags & FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED;
NInoSetDirty(ni);
/*
* closing ni will necessitate to open dir_ni to
* synchronize the index, which will update the change
* time again. Better avoid a dangerous double opening.
*/
ntfs_fuse_update_times(dir_ni, NTFS_UPDATE_MCTIME);
if (ntfs_inode_close(dir_ni))
set_fuse_error(&res);
dir_ni = (ntfs_inode*)NULL;
if (ntfs_inode_close(ni))
set_fuse_error(&res);
ntfs_fuse_update_times(dir_ni, NTFS_UPDATE_MCTIME);
} else
res = -errno;
#if POSIXACLS