Subject: ancient ufs patch
To: None <tech-kern@netbsd.org>
From: Matt Fredette <fredette@theory.lcs.mit.edu>
List: tech-kern
Date: 07/16/2003 13:48:48
I was trying to read an ancient filesystem, and found that the kernel
couldn't deal with its symlinks. This filesystem is so old that where
the maxsymlinklen field is today, it has all one bits.
ufs_vnops.c is generally good about dealing with mnt_maxsymlinklen <= 0,
but I think I found two places that were missed - in ufs_symlink() and
ufs_readlink(). Since I don't do filesystems, does the attached patch
look ok? It seems to fix the problem. (fsdb and dump had no problems.)
Thanks,
--
Matt Fredette
[snip]
Index: ufs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.102
diff -u -r1.102 ufs_vnops.c
--- ufs_vnops.c 2003/06/29 22:32:48 1.102
+++ ufs_vnops.c 2003/07/16 17:12:34
@@ -1538,7 +1538,8 @@
VN_KNOTE(ap->a_dvp, NOTE_WRITE);
vp = *vpp;
len = strlen(ap->a_target);
- if (len < vp->v_mount->mnt_maxsymlinklen) {
+ if (vp->v_mount->mnt_maxsymlinklen > 0 &&
+ len < vp->v_mount->mnt_maxsymlinklen) {
ip = VTOI(vp);
memcpy((char *)SHORTLINK(ip), ap->a_target, len);
ip->i_size = len;
@@ -1707,7 +1708,7 @@
ip = VTOI(vp);
isize = ip->i_size;
if (isize < vp->v_mount->mnt_maxsymlinklen ||
- (vp->v_mount->mnt_maxsymlinklen == 0 && DIP(ip, blocks) == 0)) {
+ (vp->v_mount->mnt_maxsymlinklen <= 0 && DIP(ip, blocks) == 0)) {
uiomove((char *)SHORTLINK(ip), isize, ap->a_uio);
return (0);
}
[snip]