- Return ENOENT when trying to add files to removed (but open) directories.
- Add test58 to test this behavior.
This commit is contained in:
@@ -77,6 +77,11 @@ PUBLIC int fs_link()
|
||||
if( (ip = get_inode(fs_dev, fs_m_in.REQ_DIR_INO)) == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
if (ip->i_links_count == NO_LINK) { /* Dir does not actually exist */
|
||||
put_inode(ip);
|
||||
return(ENOENT);
|
||||
}
|
||||
|
||||
/* If 'name2' exists in full (even if no space) set 'r' to error. */
|
||||
if ((new_ip = advance(ip, string, IGN_PERM)) == NULL) {
|
||||
r = err_code;
|
||||
@@ -349,6 +354,14 @@ PUBLIC int fs_rename()
|
||||
/* Get new dir inode */
|
||||
if( (new_dirp = get_inode(fs_dev, (ino_t) fs_m_in.REQ_REN_NEW_DIR)) == NULL)
|
||||
r = err_code;
|
||||
|
||||
if (new_dirp->i_links_count == NO_LINK) { /* Dir does not actually exist */
|
||||
put_inode(old_ip);
|
||||
put_inode(old_dirp);
|
||||
put_inode(new_dirp);
|
||||
return(ENOENT);
|
||||
}
|
||||
|
||||
new_ip = advance(new_dirp, new_name, IGN_PERM); /* not required to exist */
|
||||
|
||||
/* However, if the check failed because the file does exist, don't continue.
|
||||
|
||||
@@ -286,6 +286,11 @@ PRIVATE struct inode *new_node(struct inode *ldirp,
|
||||
register struct inode *rip;
|
||||
register int r;
|
||||
|
||||
if (ldirp->i_links_count == NO_LINK) { /* Dir does not actually exist */
|
||||
err_code = ENOENT;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Get final component of the path. */
|
||||
rip = advance(ldirp, string, IGN_PERM);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user