Contents of /trunk/udev/patches/udev-114-root-link-2.patch
Parent Directory | Revision Log
Revision 295 -
(show annotations)
(download)
Fri Aug 17 20:32:47 2007 UTC (17 years, 1 month ago) by niro
File size: 4677 byte(s)
Fri Aug 17 20:32:47 2007 UTC (17 years, 1 month ago) by niro
File size: 4677 byte(s)
-updated method to create /dev/root; it is now a symlink and directly created by udev via an injected rule
1 | diff -ruN udev-git/extras/root_link/get_dir_major_minor.c udev-git-try/extras/root_link/get_dir_major_minor.c |
2 | --- udev-git/extras/root_link/get_dir_major_minor.c 1970-01-01 01:00:00.000000000 +0100 |
3 | +++ udev-git-try/extras/root_link/get_dir_major_minor.c 2007-08-16 16:08:30.000000000 +0200 |
4 | @@ -0,0 +1,52 @@ |
5 | +// print out major/minor nr of the device the supplied dir |
6 | +// is mounted on |
7 | +// |
8 | +// This program is free software; you can redistribute it and/or modify it |
9 | +// under the terms of the GNU General Public License as published by the |
10 | +// Free Software Foundation version 2 of the License. |
11 | +// |
12 | +// (c) 2007 Matthias Schwarzott <zzam@gentoo.org> |
13 | + |
14 | +#include <sys/types.h> |
15 | +#include <sys/stat.h> |
16 | +#include <unistd.h> |
17 | + |
18 | +#include <stdio.h> |
19 | +#include <stdlib.h> |
20 | + |
21 | +// Getting major/minor |
22 | +#include <sys/sysmacros.h> |
23 | +int main(int argc, char **argv) |
24 | +{ |
25 | + struct stat stat_buf; |
26 | + unsigned int dev_major=0, dev_minor=0; |
27 | + dev_t dev; |
28 | + |
29 | + if (argc != 2) { |
30 | + printf("Usage:\n"); |
31 | + printf(" get_dir_major_minor <directory>\n"); |
32 | + return EXIT_FAILURE; |
33 | + } |
34 | + |
35 | + if (stat(argv[1], &stat_buf) < 0) { |
36 | + perror("stat"); |
37 | + return EXIT_FAILURE; |
38 | + } |
39 | + |
40 | + dev = stat_buf.st_dev; |
41 | + |
42 | + dev_major = gnu_dev_major(dev); |
43 | + dev_minor = gnu_dev_minor(dev); |
44 | + |
45 | + |
46 | + if (dev_major == 0) { |
47 | + fprintf(stderr, "Major number is 0.\n"); |
48 | + return EXIT_FAILURE; |
49 | + } else |
50 | + printf("%d %d\n", |
51 | + dev_major, |
52 | + dev_minor); |
53 | + |
54 | + return EXIT_SUCCESS; |
55 | +} |
56 | + |
57 | diff -ruN udev-git/extras/root_link/Makefile udev-git-try/extras/root_link/Makefile |
58 | --- udev-git/extras/root_link/Makefile 1970-01-01 01:00:00.000000000 +0100 |
59 | +++ udev-git-try/extras/root_link/Makefile 2007-08-16 15:52:01.000000000 +0200 |
60 | @@ -0,0 +1,70 @@ |
61 | +# Makefile for udev extra invoked from the udev main Makefile |
62 | +# |
63 | +# Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org> |
64 | +# |
65 | +# Released under the GNU General Public License, version 2. |
66 | +# |
67 | + |
68 | +PROG = get_dir_major_minor |
69 | +OBJ = |
70 | +HEADERS = |
71 | +GEN_HEADERS = |
72 | +MAN_PAGES = |
73 | + |
74 | +prefix = |
75 | +etcdir = ${prefix}/etc |
76 | +sbindir = ${prefix}/sbin |
77 | +usrbindir = ${prefix}/usr/bin |
78 | +usrsbindir = ${prefix}/usr/sbin |
79 | +libudevdir = ${prefix}/lib/udev |
80 | +mandir = ${prefix}/usr/share/man |
81 | +configdir = ${etcdir}/udev/ |
82 | + |
83 | +INSTALL = install -c |
84 | +INSTALL_PROGRAM = ${INSTALL} |
85 | +INSTALL_DATA = ${INSTALL} -m 644 |
86 | +INSTALL_SCRIPT = ${INSTALL} |
87 | + |
88 | +all: $(PROG) $(MAN_PAGES) |
89 | +.PHONY: all |
90 | +.DEFAULT: all |
91 | + |
92 | +%.o: %.c $(GEN_HEADERS) |
93 | + $(E) " CC " $@ |
94 | + $(Q) $(CC) -c $(CFLAGS) $< -o $@ |
95 | + |
96 | +$(PROG): %: $(HEADERS) %.o $(OBJS) |
97 | + $(E) " LD " $@ |
98 | + $(Q) $(LD) $(LDFLAGS) $@.o $(OBJS) -o $@ $(LIBUDEV) $(LIB_OBJS) |
99 | + |
100 | +# man pages |
101 | +%.8: %.xml |
102 | + $(E) " XMLTO " $@ |
103 | + $(Q) xmlto man $? |
104 | +.PRECIOUS: %.8 |
105 | + |
106 | +clean: |
107 | + $(E) " CLEAN " |
108 | + $(Q) rm -f $(PROG) $(OBJS) $(GEN_HEADERS) |
109 | +.PHONY: clean |
110 | + |
111 | +install-bin: all |
112 | + $(INSTALL_PROGRAM) -D $(PROG) $(DESTDIR)$(libudevdir)/$(PROG) |
113 | + $(INSTALL_PROGRAM) -D write_root_link_rule $(DESTDIR)$(libudevdir)/ |
114 | +.PHONY: install-bin |
115 | + |
116 | +uninstall-bin: |
117 | + - rm $(DESTDIR)$(libudevdir)/$(PROG) |
118 | +.PHONY: uninstall-bin |
119 | + |
120 | +install-man: |
121 | + @echo "Please create a man page for this tool." |
122 | +.PHONY: install-man |
123 | + |
124 | +uninstall-man: |
125 | + @echo "Please create a man page for this tool." |
126 | +.PHONY: uninstall-man |
127 | + |
128 | +install-config: |
129 | + @echo "no config file to install" |
130 | +.PHONY: install-config |
131 | diff -ruN udev-git/extras/root_link/write_root_link_rule udev-git-try/extras/root_link/write_root_link_rule |
132 | --- udev-git/extras/root_link/write_root_link_rule 1970-01-01 01:00:00.000000000 +0100 |
133 | +++ udev-git-try/extras/root_link/write_root_link_rule 2007-08-16 16:12:23.000000000 +0200 |
134 | @@ -0,0 +1,30 @@ |
135 | +#!/bin/sh |
136 | +# |
137 | +# This script should run before doing udevtrigger at boot. |
138 | +# It will create a rule matching the device directory / is on, and |
139 | +# creating /dev/root symlink pointing on its device node. |
140 | +# |
141 | +# This is especially useful for hal looking at /proc/mounts containing |
142 | +# a line listing /dev/root as device: |
143 | +# /dev/root / reiserfs rw 0 0 |
144 | +# |
145 | +# This program is free software; you can redistribute it and/or modify it |
146 | +# under the terms of the GNU General Public License as published by the |
147 | +# Free Software Foundation version 2 of the License. |
148 | +# |
149 | +# (c) 2007 Matthias Schwarzott <zzam@gentoo.org> |
150 | + |
151 | +PROG=/lib/udev/get_dir_major_minor |
152 | +[ -x "${PROG}" ] && DEV=$(${PROG} "/") |
153 | +if [ $? = 0 ]; then |
154 | + MAJOR="${DEV% *}" |
155 | + MINOR="${DEV#* }" |
156 | + |
157 | + [ -d /dev/.udev/rules.d ] || mkdir -p /dev/.udev/rules.d |
158 | + RULES=/dev/.udev/rules.d/10-root-link.rules |
159 | + |
160 | + echo "# Created by /lib/udev/write_root_link_rule" > "${RULES}" |
161 | + echo "# This rule should create /dev/root as link to real root device." >> "${RULES}" |
162 | + echo "SUBSYSTEM==\"block\", ENV{MAJOR}==\"$MAJOR\", ENV{MINOR}==\"$MINOR\", SYMLINK+=\"root\"" >> "${RULES}" |
163 | +fi |
164 | + |