From owner-svn-src-all@FreeBSD.ORG Thu Dec 12 11:05:48 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A7CCADEF; Thu, 12 Dec 2013 11:05:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9412D1471; Thu, 12 Dec 2013 11:05:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBCB5m55064302; Thu, 12 Dec 2013 11:05:48 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBCB5mEs064301; Thu, 12 Dec 2013 11:05:48 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201312121105.rBCB5mEs064301@svn.freebsd.org> From: Alexander Motin Date: Thu, 12 Dec 2013 11:05:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259254 - head/sys/fs/devfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Dec 2013 11:05:48 -0000 Author: mav Date: Thu Dec 12 11:05:48 2013 New Revision: 259254 URL: http://svnweb.freebsd.org/changeset/base/259254 Log: Fix long known bug with handling device aliases residing not in devfs root. Historically creation of device aliases created symbolic links using only name of target device as a link target, not considering current directory. Fix that by adding number of "../" chunks to the terget device name, required to get out of the current directory to devfs root first. MFC after: 1 month Modified: head/sys/fs/devfs/devfs_devs.c Modified: head/sys/fs/devfs/devfs_devs.c ============================================================================== --- head/sys/fs/devfs/devfs_devs.c Thu Dec 12 10:57:16 2013 (r259253) +++ head/sys/fs/devfs/devfs_devs.c Thu Dec 12 11:05:48 2013 (r259254) @@ -486,9 +486,9 @@ devfs_populate_loop(struct devfs_mount * { struct cdev_priv *cdp; struct devfs_dirent *de; - struct devfs_dirent *dd; + struct devfs_dirent *dd, *dt; struct cdev *pdev; - int de_flags, j; + int de_flags, depth, j; char *q, *s; sx_assert(&dm->dm_lock, SX_XLOCKED); @@ -589,9 +589,17 @@ devfs_populate_loop(struct devfs_mount * de->de_mode = 0755; de->de_dirent->d_type = DT_LNK; pdev = cdp->cdp_c.si_parent; - j = strlen(pdev->si_name) + 1; + dt = dd; + depth = 0; + while (dt != dm->dm_rootdir && + (dt = devfs_parent_dirent(dt)) != NULL) + depth++; + j = depth * 3 + strlen(pdev->si_name) + 1; de->de_symlink = malloc(j, M_DEVFS, M_WAITOK); - bcopy(pdev->si_name, de->de_symlink, j); + de->de_symlink[0] = 0; + while (depth-- > 0) + strcat(de->de_symlink, "../"); + strcat(de->de_symlink, pdev->si_name); } else { de->de_uid = cdp->cdp_c.si_uid; de->de_gid = cdp->cdp_c.si_gid;