In Linux kernel 2.1.20, readlink() on an ext2 file system returns one plus the
length of the link target. Previous kernels and other UNIXes I've checked
return exactly the length of the link target.
Here's a patch to revert to the original behavior:
--- linux/fs/ext2/symlink.c.orig Fri Jan 3 21:19:25 1997
+++ linux/fs/ext2/symlink.c Sun Jan 5 01:18:10 1997
@@ -124,7 +124,7 @@
link = (char *) inode->u.ext2_i.i_data;
/* XXX I hope link is always '\0'-terminated. */
- i = strlen(link)+1;
+ i = strlen(link);
if (i > buflen)
i = buflen;
if (copy_to_user(buffer, link, i))
Nick Duffek
nsd@bbc.com