Date: Fri, 13 Feb 2004 19:50:17 +0100 From: Maxime Henrion <mux@freebsd.org> To: Lukas Ertl <l.ertl@univie.ac.at> Cc: current@freebsd.org Subject: Re: DEVFS oddity Message-ID: <20040213185017.GB35475@elvis.mu.org> In-Reply-To: <20040213173919.F662@korben.in.tern> References: <20040213173919.F662@korben.in.tern>
next in thread | previous in thread | raw e-mail | index | archive | help
Lukas Ertl wrote: > Hi, > > I've came across an oddity in devfs. The size of a symlink is the length > of the "symbolic name", not the one of the target. > > Consider: > > $ ls -la /dev/ | grep ^l > lrwxr-xr-x 1 root wheel 3 13 Feb 16:01 dvd@ -> acd0 > lrwxr-xr-x 1 root wheel 4 13 Feb 17:01 kbd0@ -> atkbd0 > lrwxr-xr-x 1 root wheel 3 13 Feb 16:01 log@ -> /var/run/log > lrwxr-xr-x 1 root wheel 4 13 Feb 17:01 net1@ -> net/fxp0 > lrwxr-xr-x 1 root wheel 4 13 Feb 17:01 net2@ -> net/lo0 > lrwxr-xr-x 1 root wheel 4 13 Feb 16:02 net3@ -> net/ndis0 > lrwxr-xr-x 1 root wheel 6 13 Feb 17:01 stderr@ -> fd/2 > lrwxr-xr-x 1 root wheel 5 13 Feb 17:01 stdin@ -> fd/0 > lrwxr-xr-x 1 root wheel 6 13 Feb 17:01 stdout@ -> fd/1 > lrwxr-xr-x 1 root wheel 7 13 Feb 17:01 urandom@ -> random > > against: > > $ ls -l /sys > lrwxr-xr-x 1 root wheel 11 13 Feb 12:12 /sys@ -> usr/src/sys > > Is this considered a bug or a feature? :-) I believe it is a bug. The very simple patch below should fix this (untested). %% Index: devfs_vnops.c =================================================================== RCS file: /space2/ncvs/src/sys/fs/devfs/devfs_vnops.c,v retrieving revision 1.68 diff -u -p -r1.68 devfs_vnops.c --- devfs_vnops.c 2 Jan 2004 19:02:28 -0000 1.68 +++ devfs_vnops.c 13 Feb 2004 18:48:36 -0000 @@ -224,7 +224,7 @@ devfs_getattr(ap) vap->va_gid = de->de_gid; vap->va_mode = de->de_mode; if (vp->v_type == VLNK) - vap->va_size = de->de_dirent->d_namlen; + vap->va_size = strlen(de->de_symlink); else if (vp->v_type == VDIR) vap->va_size = vap->va_bytes = DEV_BSIZE; else %% Cheers, Maxime
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040213185017.GB35475>
