Module Name: src Committed By: riastradh Date: Sat Aug 13 19:40:02 UTC 2011
Modified Files: src/sys/kern: vfs_lookup.c Log Message: Handle absolute symlinks to the root. Fixes panic on `ln -s / foo && cd foo' found by ober by trying to run wine. ok dholland To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/sys/kern/vfs_lookup.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/kern/vfs_lookup.c diff -u src/sys/kern/vfs_lookup.c:1.188 src/sys/kern/vfs_lookup.c:1.189 --- src/sys/kern/vfs_lookup.c:1.188 Wed Aug 10 05:42:32 2011 +++ src/sys/kern/vfs_lookup.c Sat Aug 13 19:40:02 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_lookup.c,v 1.188 2011/08/10 05:42:32 dholland Exp $ */ +/* $NetBSD: vfs_lookup.c,v 1.189 2011/08/13 19:40:02 riastradh Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.188 2011/08/10 05:42:32 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.189 2011/08/13 19:40:02 riastradh Exp $"); #include "opt_magiclinks.h" @@ -1217,6 +1217,20 @@ /* namei_follow unlocks it (ugh) so rele, not put */ vrele(foundobj); foundobj = NULL; + + /* + * If we followed a symlink to `/' and there + * are no more components after the symlink, + * we're done with the loop and what we found + * is the searchdir. + */ + if (cnp->cn_nameptr[0] == '\0') { + foundobj = searchdir; + searchdir = NULL; + cnp->cn_flags |= ISLASTCN; + break; + } + continue; }