#3 Problems with 60 char symlinks.

open
nobody
None
5
2013-10-30
2010-07-30
JS Legare
No

Filesystems containing symlinks that are exactly 60 characters long (max length for fast symlinks) cause the output file to fail fsck checks.
Both Linux and e2fsck considers a symlink (with no EA block) with i_blocks == 0 to be "fast". Linux's fs/ext2/symlink.c appears to retrieve the symlink data with a simple cast to char*.

I've attached a patch to write fast symlinks only if the name fits with the terminating null byte.

I've patched 1.4.1 and installed it in /usr/local/bin. The unpatched 1.4.1 sits in /usr/bin:

$ mkdir test_ln
$ cd test_ln
$ ln -s 12345678901234567890123456789012345678901234567890123456789 len_59
$ ln -s 123456789012345678901234567890123456789012345678901234567890 len_60
$ ln -s 1234567890123456789012345678901234567890123456789012345678901 len_61
$ touch 12345678901234567890123456789012345678901234567890123456789
$ touch 123456789012345678901234567890123456789012345678901234567890
$ touch 1234567890123456789012345678901234567890123456789012345678901
$ cd ..
$ /usr/bin/genext2fs -d test_ln -b 500 broken_symlink.raw
$ /usr/local/bin/genext2fs -d test_ln -b 500 fixed.raw
$ sudo losetup -f ./broken_symlink.raw --show
/dev/loop0
$ mkdir mount_test
$ sudo mount /dev/loop0 mount_test
$ cd mount_test
$ sudo stat -c "%N" len_59 len_60 len_61
`len_59' -> `12345678901234567890123456789012345678901234567890123456789'
`len_60' -> `12345678901234567890123456789012345678901234567890123456789'
`len_61' -> `1234567890123456789012345678901234567890123456789012345678901'
$ # Both len_59 and len_60 appear to have the same content
$ cd ..
$ sudo umount mount_test
$ sudo fsck -f /dev/loop0
fsck from util-linux-ng 2.16
e2fsck 1.41.9 (22-Aug-2009)
Filesystem did not have a UUID; generating one.

Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Symlink /len_60 (inode #12) is invalid.
Clear<y>? yes

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/loop0: ***** FILE SYSTEM WAS MODIFIED *****
/dev/loop0: 16/24 files (0.0% non-contiguous), 36/500 blocks

$ sudo losetup -d /dev/loop0
$ sudo losetup -f ./fixed.raw --show
/dev/loop0
$ sudo fsck -f /dev/loop0
fsck from util-linux-ng 2.16
e2fsck 1.41.9 (22-Aug-2009)
Filesystem did not have a UUID; generating one.

Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/loop0: ***** FILE SYSTEM WAS MODIFIED *****
/dev/loop0: 17/24 files (0.0% non-contiguous), 37/500 blocks

Discussion

  • Finn Thain

    Finn Thain - 2013-10-30

    This is fixed in CVS. (Actually, it was fixed a while back.)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks