]> git.pld-linux.org Git - packages/util-linux.git/blame - util-linux-raw-handle-nonpresent-devs.patch
- added patch for mount to call mount.<FSTYPE> also for autodetected fs
[packages/util-linux.git] / util-linux-raw-handle-nonpresent-devs.patch
CommitLineData
5545a732
JR
1Allow raw(8) to bind raw devices whose device nodes do not yet exist
2
3--- util-linux-2.12a/disk-utils/raw.c.=K0000=.orig
4+++ util-linux-2.12a/disk-utils/raw.c
5@@ -31,6 +31,7 @@
6 #endif
7 #define DEVFS_RAWCTLDEV "/dev/raw/rawctl"
8
9+#define RAW_NR_MINORS 8192
10
11 char * progname;
12 int do_query = 0;
13@@ -94,7 +95,7 @@ int main(int argc, char *argv[])
14 if (do_query_all) {
15 if (optind < argc)
16 usage(1);
17- for (i=1; i<255; i++)
18+ for (i = 1; i < RAW_NR_MINORS; i++)
19 query(i, 1);
20 exit(0);
21 }
22@@ -109,9 +110,16 @@ int main(int argc, char *argv[])
23
24 err = stat(raw_name, &statbuf);
25 if (err) {
26- fprintf (stderr, "Cannot locate raw device '%s' (%s)\n",
27- raw_name, strerror(errno));
28- exit(2);
29+ int rc;
30+
31+ rc = sscanf(raw_name, RAWDEVDIR "raw%d", &raw_minor);
32+ if (rc != 1) {
33+ fprintf (stderr,
34+ "Cannot locate raw device '%s' (%s)\n",
35+ raw_name, strerror(errno));
36+ exit(2);
37+ }
38+ goto skip_test_rawdev;
39 }
40
41 if (!S_ISCHR(statbuf.st_mode)) {
42@@ -127,6 +135,7 @@ int main(int argc, char *argv[])
43
44 raw_minor = minor(statbuf.st_rdev);
45
46+skip_test_rawdev:
47 if (do_query)
48 return query(raw_minor, 0);
49
50@@ -193,6 +202,7 @@ void open_raw_ctl(void)
51 int query(int minor, int quiet)
52 {
53 struct raw_config_request rq;
54+ static int has_worked = 0;
55 int err;
56
57 rq.raw_minor = minor;
58@@ -200,11 +210,17 @@ int query(int minor, int quiet)
59 if (err < 0) {
60 if (quiet && errno == ENODEV)
61 return 3;
62+ if (has_worked && errno == EINVAL)
63+ return 0;
64 fprintf (stderr,
65 "Error querying raw device (%s)\n",
66 strerror(errno));
67 exit(3);
68 }
69+ /* If one query has worked, mark that fact so that we don't
70+ * report spurious fatal errors if raw(8) has been built to
71+ * support more raw minor numbers than the kernel has. */
72+ has_worked = 1;
73 if (quiet && !rq.block_major && !rq.block_minor)
74 return 0;
75 printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n",
This page took 0.458054 seconds and 4 git commands to generate.