svn commit: r259254 - head/sys/fs/devfs
Alexander Motin
mav at FreeBSD.org
Thu Dec 12 11:05:48 UTC 2013
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;
More information about the svn-src-all
mailing list