Date: Tue, 3 Aug 1999 20:41:00 +1000 From: Bruce Evans <bde@zeta.org.au> To: freebsd-fs@FreeBSD.ORG, krentel@dreamscape.com Subject: Re: link counts in ext2fs are all 0 Message-ID: <199908031041.UAA16747@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>I've noticed that the link counts of files from an EXT2FS filesystem >(mounted in freebsd) all show up as 0. For example, I have a machine >that dual boots between 3.2-release and Red Hat 6.0. I have options >"EXT2FS" compiled into kernel and I mount linux's / partition: > > # mount_ext2fs /dev/da0s1 /mnt > # /bin/ls -l /mnt > total 65 > drwxr-xr-x 0 root wheel 2048 Jul 29 13:22 bin > ... Link counts in ext2fs were broken by the soft updates changes (although soft updates are not implemented for ext2fs). Partial fix: diff -c2 ext2_vfsops.c~ ext2_vfsops.c *** ext2_vfsops.c~ Wed Jun 2 22:19:57 1999 --- ext2_vfsops.c Tue Aug 3 01:44:10 1999 *************** *** 582,585 **** --- 593,597 ---- EXT2_INODE_SIZE * ino_to_fsbo(fs, ip->i_number)), &ip->i_din); + ip->i_effnlink = ip->i_nlink; brelse(bp); vput(vp); *************** *** 1063,1066 **** --- 1077,1081 ---- ext2_ei2di((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE * ino_to_fsbo(fs, ino)), &ip->i_din); + ip->i_effnlink = ip->i_nlink; ip->i_block_group = ino_to_cg(fs, ino); ip->i_next_alloc_block = 0; This works for old links but not for new ones, since ext2_vnops.c doesn't know anything about i_effnlink. E.g., link(2) appears to corrupt the link count (by not changing it), but the problem is magically fixed by umount/mount when the above changes do the translation. Bugs like this show why ext2fs shouldn't use any ufs vnops. (I just noticed some related ones for chflags(2). ext2fs uses ufs_setattr() which writes ffs values without translation. The values appear to change after umount/ mount when they are interpreted as ext2fs ones.) Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908031041.UAA16747>