From 0d8034120b866e11959646bb7beb9f1ca46640c4 Mon Sep 17 00:00:00 2001 From: Stephen Tweedie Date: Wed, 13 Oct 2004 22:34:40 +0000 Subject: [PATCH] Update raw(8) for 2.6 kernels and udev: Handle up to 8192 raw minor devices Don't complain when binding a raw device whose device node does not yet exist (udev will create it.) --- raw-handle-nonpresent-devs.patch | 73 ++++++++++++++++++++++++++++++++ util-linux.spec | 10 ++++- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 raw-handle-nonpresent-devs.patch diff --git a/raw-handle-nonpresent-devs.patch b/raw-handle-nonpresent-devs.patch new file mode 100644 index 0000000..1dd0b76 --- /dev/null +++ b/raw-handle-nonpresent-devs.patch @@ -0,0 +1,73 @@ +--- util-linux-2.12a/disk-utils/raw.c.=K0000=.orig ++++ util-linux-2.12a/disk-utils/raw.c +@@ -31,6 +31,7 @@ + #endif + #define DEVFS_RAWCTLDEV "/dev/raw/rawctl" + ++#define RAW_NR_MINORS 8192 + + char * progname; + int do_query = 0; +@@ -94,7 +95,7 @@ int main(int argc, char *argv[]) + if (do_query_all) { + if (optind < argc) + usage(1); +- for (i=1; i<255; i++) ++ for (i = 1; i < RAW_NR_MINORS; i++) + query(i, 1); + exit(0); + } +@@ -109,9 +110,16 @@ int main(int argc, char *argv[]) + + err = stat(raw_name, &statbuf); + if (err) { +- fprintf (stderr, "Cannot locate raw device '%s' (%s)\n", +- raw_name, strerror(errno)); +- exit(2); ++ int rc; ++ ++ rc = sscanf(raw_name, RAWDEVDIR "raw%d", &raw_minor); ++ if (rc != 1) { ++ fprintf (stderr, ++ "Cannot locate raw device '%s' (%s)\n", ++ raw_name, strerror(errno)); ++ exit(2); ++ } ++ goto skip_test_rawdev; + } + + if (!S_ISCHR(statbuf.st_mode)) { +@@ -127,6 +135,7 @@ int main(int argc, char *argv[]) + + raw_minor = minor(statbuf.st_rdev); + ++skip_test_rawdev: + if (do_query) + return query(raw_minor, 0); + +@@ -193,6 +202,7 @@ void open_raw_ctl(void) + int query(int minor, int quiet) + { + struct raw_config_request rq; ++ static int has_worked = 0; + int err; + + rq.raw_minor = minor; +@@ -200,11 +210,17 @@ int query(int minor, int quiet) + if (err < 0) { + if (quiet && errno == ENODEV) + return 3; ++ if (has_worked && errno == EINVAL) ++ return 0; + fprintf (stderr, + "Error querying raw device (%s)\n", + strerror(errno)); + exit(3); + } ++ /* If one query has worked, mark that fact so that we don't ++ * report spurious fatal errors if raw(8) has been built to ++ * support more raw minor numbers than the kernel has. */ ++ has_worked = 1; + if (quiet && !rq.block_major && !rq.block_minor) + return 0; + printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n", diff --git a/util-linux.spec b/util-linux.spec index 0551cad..cfe3bea 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -12,7 +12,7 @@ Summary: A collection of basic system utilities. Name: util-linux Version: 2.12a -Release: 14 +Release: 15 License: distributable Group: System Environment/Base @@ -91,6 +91,9 @@ Patch158: util-linux-2.12a-moreswaplabel.patch # Patch to enable the pamconsole flag for restricting mounting to users at the console (#133941) Patch159: util-linux-2.12a-console.patch +# Allow raw(8) to bind raw devices whose device nodes do not yet exist. +Patch160: raw-handle-nonpresent-devs.patch + # patches required for NFSv4 support Patch1000: util-linux-2.12-nfsv4.patch @@ -205,6 +208,8 @@ mv MCONFIG.new MCONFIG %patch159 -p1 -b .console +%patch160 -p1 + %patch1000 -p1 -b .nfsv4 %build @@ -573,6 +578,9 @@ fi /sbin/losetup %changelog +* Wed Oct 13 2004 Stephen C. Tweedie - 2.12a-15 +- Add raw patch to allow binding of devices not yet in /dev + * Wed Oct 13 2004 John (J5) Palmieri 2.12a-14 - Add David Zeuthen's patch to enable the pamconsole flag #133941