[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    RE: mdev change no longer supporting v2.6.2x kernels by using /sys/dev
From:       "Vladislav Grishenko" <themiron.ru () gmail ! com>
Date:       2017-03-31 12:20:16
Message-ID: 009e01d2aa19$2858fab0$790af010$ () gmail ! com
[Download RAW message or body]

This is a multipart message in MIME format.


Hi,

FYI, here's the patch for adding back pre-2.6.26 kernel support and fix some char \
devices creation as block ones.

Best Regards, Vladislav Grishenko

-----Original Message-----
From: busybox [mailto:busybox-bounces@busybox.net] On Behalf Of Rob Landley
Sent: Friday, March 31, 2017 4:10 AM
To: Peter Korsgaard <peter@korsgaard.com>; Ralf Friedl <Ralf.Friedl@online.de>
Cc: busybox@busybox.net
Subject: Re: mdev change no longer supporting v2.6.2x kernels by using /sys/dev

On 03/30/2017 02:34 PM, Peter Korsgaard wrote:
> > > > > > "Ralf" == Ralf Friedl <Ralf.Friedl@online.de> writes:
> 
> Hi,
> 
> > > /sys/dev support got added in 2.6.27-rc1 (July 2008), E.G. ~9 years ago:
> 
> > Busybox is often used in embedded devices, where kernels (and other  
> > software) are not changed that often. Firmware may contain kernel  > 
> modules without full source, so a change to a newer kernel is not an  
> > option. As an example, I have a router with kernel 2.6.13. I can't  
> > update the kernel, but I can replace the busybox with a newer 
> version  > (and much more applets) than the original.
> 
> True, but generally you will run into a number of issues when you 
> combine SW components of significant different "age". E.G. lots of 
> modern user space requires new kernel features, either explicitly or 
> simply because nobody has tested it on such old systems.

My old rule of thumb back in the day was trying to support 7 year old build and \
deployment environments:

  http://lists.busybox.net/pipermail/busybox/2006-September/058440.html

This is 2 years beyond that.

Just FYI,

Rob
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


["0001-busybox-mdev-recover-pre-2.6.26-kernel-support.patch" (application/octet-stream)]

From cb19a7cad53b6e19560f3dd243c0f54e5b7547af Mon Sep 17 00:00:00 2001
From: Vladislav Grishenko <themiron@mail.ru>
Date: Thu, 15 Dec 2016 20:43:35 +0500
Subject: [PATCH] busybox: mdev: recover pre-2.6.26 kernel support

Unfortunately the legacy kernel v2.6.2x is not enough old to to be buried,
so recover /sys/class & /sys/block scanning code after commit
20a3262cd756aadf8771969a4764cd3c571f0a3e.

Also, it's known some block device partitions have parent device relative
symlinks that point to corresponding char ones and that's why these char
devices are treated as partitions and created early as block devices,
not char.
For example, /sys/block/mtdblockN/device symlink points to parent device
/sys/class/mtd/mtdN, and since /sys/block goes before /sys/class,
/sys/class/mtd/mtdN are seen as /sys/block/mtdblockN/../../class/mtd/mtdN
and treated as block, consequent /sys/class/mtd gives nothing because the
device has already created.
Use of realpath on block devices allows to normalize the path.

function                                             old     new   delta
mdev_main                                           1357    1459    +102
.rodata                                           150837  150876     +39
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 141/0)             Total: 141 bytes

Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
---
 util-linux/mdev.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index a59115dd4..d34781dc7 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -823,16 +823,14 @@ static int FAST_FUNC fileAction(const char *fileName,
 	int res;
 
 	/* Is it a ".../dev" file? (len check is for paranoid reasons) */
-	if (strcmp(fileName + len, "/dev") != 0 || len >= PATH_MAX - 32)
+	if (strcmp(fileName + len, "/dev") != 0 || len >= PATH_MAX)
 		return FALSE; /* not .../dev */
 
 	strcpy(path, fileName);
-	path[len] = '\0';
 
 	/* Read ".../subsystem" symlink in the same directory where ".../dev" is */
-	strcpy(subsys, path);
-	strcpy(subsys + len, "/subsystem");
-	res = readlink(subsys, subsys, sizeof(subsys)-1);
+	strcpy(path + len, "/subsystem");
+	res = readlink(path, subsys, sizeof(subsys)-1);
 	if (res > 0) {
 		subsys[res] = '\0';
 		free(G.subsystem);
@@ -849,6 +847,14 @@ static int FAST_FUNC fileAction(const char *fileName,
 		}
 	}
 
+	path[len] = '\0';
+
+	/* Use real path of /sys/block/... symlinks
+	 * to differ partitions from parent bus/char devices
+	 */
+	if (strncmp(path, "/sys/block", 10) == 0 && realpath(path, subsys) != NULL)
+		strcpy(path, subsys);
+
 	make_device(/*DEVNAME:*/ NULL, path, OP_add);
 
 	return TRUE;
@@ -1074,6 +1080,24 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 
 		putenv((char*)"ACTION=add");
 
+		if (access("/sys/dev", F_OK) != 0) {
+			/* Scan /sys/class only if /sys/dev doesn't exist
+			 * on pre-2.6.26 kernels.
+			 */
+			if (access("/sys/class/block", F_OK) != 0) {
+				/* Scan obsolete /sys/block only if /sys/class/block
+				 * doesn't exist. Otherwise we'll have dupes.
+				 * Also, do not complain if it doesn't exist.
+				 * Some people configure kernel to have no blockdevs.
+				 */
+				recursive_action("/sys/block",
+					 ACTION_RECURSE | ACTION_FOLLOWLINKS | ACTION_QUIET,
+					 fileAction, dirAction, temp, 0);
+			}
+			recursive_action("/sys/class",
+				 ACTION_RECURSE | ACTION_FOLLOWLINKS,
+				 fileAction, dirAction, temp, 0);
+		} else
 		/* Create all devices from /sys/dev hierarchy */
 		recursive_action("/sys/dev",
 				 ACTION_RECURSE | ACTION_FOLLOWLINKS,
-- 
2.11.GIT



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic