mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-03 09:00:21 +00:00
Fix last commit based on feedback from Guido, Bruce and Terry.
Specifically, the test was in the wrong place, lacked a cast, didn't unlock the node, and exited to bad rather than abortit. Now we don't allow renaming of a file with LINK_MAX references. Move the test to earlier in the code as it is closer to where ip is obtained, as that is the style of the rest of the function. Didn't fix the problems bruce pointed out in the rename man page to include EMLINK, nor address his complaints about how the whole idea of incrementing the link count during a rename is potentially asking for trouble. Also didn't try to correct potential problem Terry pointed out with decrements not being similarly protected against underflow.
This commit is contained in:
parent
c177a86b92
commit
00db131a60
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44291
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95
|
||||
* $Id: ufs_vnops.c,v 1.108 1999/02/25 05:35:53 dillon Exp $
|
||||
* $Id: ufs_vnops.c,v 1.109 1999/02/25 09:52:46 imp Exp $
|
||||
*/
|
||||
|
||||
#include "opt_quota.h"
|
||||
@ -978,6 +978,11 @@ ufs_rename(ap)
|
||||
goto abortit;
|
||||
dp = VTOI(fdvp);
|
||||
ip = VTOI(fvp);
|
||||
if ((nlink_t) ip->i_nlink >= LINK_MAX) {
|
||||
VOP_UNLOCK(fvp, 0, p);
|
||||
error = EMLINK;
|
||||
goto abortit;
|
||||
}
|
||||
if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND))
|
||||
|| (dp->i_flags & APPEND)) {
|
||||
VOP_UNLOCK(fvp, 0, p);
|
||||
@ -1017,10 +1022,6 @@ ufs_rename(ap)
|
||||
* completing our work, the link count
|
||||
* may be wrong, but correctable.
|
||||
*/
|
||||
if (ip->i_nlink >= LINK_MAX) {
|
||||
error = EMLINK;
|
||||
goto bad;
|
||||
}
|
||||
ip->i_effnlink++;
|
||||
ip->i_nlink++;
|
||||
ip->i_flag |= IN_CHANGE;
|
||||
|
Loading…
Reference in New Issue
Block a user