From owner-freebsd-current@FreeBSD.ORG Fri Feb 13 10:50:17 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 44D7016A4CE for ; Fri, 13 Feb 2004 10:50:17 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4003A43D1F for ; Fri, 13 Feb 2004 10:50:17 -0800 (PST) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id 371325C797; Fri, 13 Feb 2004 10:50:17 -0800 (PST) Date: Fri, 13 Feb 2004 19:50:17 +0100 From: Maxime Henrion To: Lukas Ertl Message-ID: <20040213185017.GB35475@elvis.mu.org> References: <20040213173919.F662@korben.in.tern> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040213173919.F662@korben.in.tern> User-Agent: Mutt/1.4.1i cc: current@freebsd.org Subject: Re: DEVFS oddity X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2004 18:50:17 -0000 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