fix: unlink may failed with I/O error

This commit is contained in:
szaka 2007-11-18 22:20:19 +00:00
parent c38e349117
commit 6bbb912bca
2 changed files with 14 additions and 14 deletions

View File

@ -1503,7 +1503,7 @@ search:
*/
if (ni->mrec->link_count) {
ntfs_inode_update_times(ni, NTFS_UPDATE_CTIME);
goto out;
goto ok;
}
ntfs_attr_reinit_search_ctx(actx);
while (!ntfs_attrs_walk(actx)) {
@ -1545,12 +1545,16 @@ search:
"Leaving inconsistent metadata.\n");
}
ni = NULL;
ok:
ntfs_inode_update_times(dir_ni, NTFS_UPDATE_MCTIME);
out:
if (actx)
ntfs_attr_put_search_ctx(actx);
if (ictx)
ntfs_index_ctx_put(ictx);
if (ni && ntfs_inode_close(ni) && !err)
if (ntfs_inode_close(dir_ni) && !err)
err = errno;
if (ntfs_inode_close(ni) && !err)
err = errno;
if (err) {
errno = err;

View File

@ -1276,27 +1276,23 @@ static int ntfs_fuse_rm(const char *org_path)
res = -errno;
goto exit;
}
/* JPA deny unlinking if directory is not writable and executable */
/* JPA deny unlinking if directory is not writable and executable */
if (!ntfs_fuse_fill_security_context(&security)
|| ntfs_allowed_access(&security, path, dir_ni,
S_IEXEC + S_IWRITE + S_ISVTX)) {
|| ntfs_allowed_access(&security, path, dir_ni,
S_IEXEC + S_IWRITE + S_ISVTX)) {
if (ntfs_delete(ni, dir_ni, uname, uname_len))
res = -errno;
else {
/* Inode ctime is updated in ntfs_delete() for hard links. */
ntfs_fuse_update_times(dir_ni, NTFS_UPDATE_MCTIME);
}
/* ntfs_delete() always closes ni and dir_ni */
ni = dir_ni = NULL;
} else
res = -EACCES;
/* ntfs_delete() always closes ni */
ni = NULL;
exit:
if (ni && ntfs_inode_close(ni))
if (ntfs_inode_close(dir_ni))
set_fuse_error(&res);
if (ntfs_inode_close(ni))
set_fuse_error(&res);
free(uname);
if (dir_ni && ntfs_inode_close(dir_ni))
set_fuse_error(&res);
free(path);
return res;
}