[PATCH] mdev: fix bug with minor number parsing
Rob Landley
rob at landley.net
Thu Jan 12 03:10:50 UTC 2006
On Wednesday 11 January 2006 03:36, Frank Sorenson wrote:
> When mdev is reading the "major:minor" from the /sys/.../dev file,
> the last character of the string is '\n', so we don't want it to
> factor into the minor number.
Ack. (I tested this. I know I tested it. Weird.)
> --- busybox-1.1.0/util-linux/mdev.c.orig 2006-01-11 02:18:04.000000000
> -0700 +++ busybox-1.1.0/util-linux/mdev.c 2006-01-11 02:31:56.000000000
> -0700 @@ -50,7 +50,7 @@
> device_name = strrchr(path, '/') + 1;
> type = strncmp(path+5, "block/" ,6) ? S_IFCHR : S_IFBLK;
> major = minor = 0;
> - for (s = temp; *s; s++) {
> + for (s = temp; *s != '\n' ; s++) {
> if (*s == ':') {
> major = minor;
> minor = 0;
>
> Frank
Depending on the \n to be there in future kernels is the kind of brittleness
I'd ordinarily want to avoid, but the busybox "small size" bit definitely
argues in favor of it, so ok. I fixed this in a slightly different way
(--len before null terminating) so that if it ever does get removed our
conversion at least reliably terminates. (Call me weird.)
Rob
--
Steve Ballmer: Innovation! Inigo Montoya: You keep using that word.
I do not think it means what you think it means.
More information about the busybox
mailing list