Module Name: src Committed By: zafer Date: Sat Aug 11 20:16:21 UTC 2018
Modified Files: src/sys/ufs/lfs: lfs_vnops.c Log Message: In lfs_mkdir fix wrong return path in case of EMLINK which causes a panic. Also, check earlier before setting up dirop. To generate a diff of this commit: cvs rdiff -u -r1.321 -r1.322 src/sys/ufs/lfs/lfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/lfs/lfs_vnops.c diff -u src/sys/ufs/lfs/lfs_vnops.c:1.321 src/sys/ufs/lfs/lfs_vnops.c:1.322 --- src/sys/ufs/lfs/lfs_vnops.c:1.321 Sun Aug 20 05:37:03 2017 +++ src/sys/ufs/lfs/lfs_vnops.c Sat Aug 11 20:16:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vnops.c,v 1.321 2017/08/20 05:37:03 maya Exp $ */ +/* $NetBSD: lfs_vnops.c,v 1.322 2018/08/11 20:16:21 zafer Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -125,7 +125,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.321 2017/08/20 05:37:03 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.322 2018/08/11 20:16:21 zafer Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -959,6 +959,11 @@ lfs_mkdir(void *v) if (fs->lfs_ronly) { return EROFS; } + + if ((nlink_t)dp->i_nlink >= LINK_MAX) { + return EMLINK; + } + dirblksiz = fs->um_dirblksiz; /* XXX dholland 20150911 I believe this to be true, but... */ //KASSERT(dirblksiz == LFS_DIRBLKSIZ); @@ -967,11 +972,6 @@ lfs_mkdir(void *v) if (error) return error; - if ((nlink_t)dp->i_nlink >= LINK_MAX) { - error = EMLINK; - goto out; - } - /* * Must simulate part of lfs_makeinode here to acquire the inode, * but not have it entered in the parent directory. The entry is