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