[PATCH] mdev -s: don't mistake inter-device symlinks for separate devices

Joshua Judson Rosen jrosen at harvestai.com
Tue Jun 16 21:15:38 UTC 2015


ping?

On 2015-06-05 19:07, Joshua Judson Rosen wrote:
> e.g.: don't mistake the /sys/block/mtdblock*/device symlinks
> (which point to the /sys/class/mtd/mtd* character devices)
> as being block devices in their own right.
> 
> This was `OK' until 2013-05-13 ("mdev: use $DEVNAME in uevent...",
> c3cf1e30a3022453311a7e9fe11d94c7a381640e) because the prior behaviour
> of always using basename() meant that all such symlinks lead to
> "/dev/device"....
> 
> Signed-off-by: Joshua Judson Rosen <jrosen at harvestai.com>
> ---
>  util-linux/mdev.c |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/util-linux/mdev.c b/util-linux/mdev.c
> index ca4b915..3c88213 100644
> --- a/util-linux/mdev.c
> +++ b/util-linux/mdev.c
> @@ -559,6 +559,23 @@ static void make_device(char *device_name, char *path, int operation)
>  	 * We also depend on path having writeable space after it.
>  	 */
>  	major = -1;
> +
> +	if ((path_end - path) > 7 && strncmp((path_end - 7), "/device", 7) == 0) {
> +		/* Some wrapper-devices, e.g. /sys/block/mtdblock*, have
> +		   a "device" symlink that points to the lower-level device--
> +		   which either has already been handled separately,
> +		   or will be handled separately.
> +
> +		   When symlink-traversal sends us down that rabbit-hole,
> +		   avoid getting confused and thinking that it's actually
> +		   a distinct device (e.g.: /sys/block/mtdblock1/device
> +		   could trick us into thinking that /dev/mtd1 should be
> +		   a block device when it shouldn't):
> +		 */
> +
> +		return;
> +	}
> +
>  	if (operation == OP_add) {
>  		strcpy(path_end, "/dev");
>  		len = open_read_close(path, path_end + 1, SCRATCH_SIZE - 1);
> 

-- 
"Don't be afraid to ask (λf.((λx.xx) (λr.f(rr))))."


More information about the busybox mailing list