Magellan Linux

Contents of /tags/udev-166-r1/patches/udev-111-root-link-1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1290 - (show annotations) (download)
Mon Feb 28 20:11:39 2011 UTC (13 years, 2 months ago) by niro
File size: 3412 byte(s)
tagged 'udev-166-r1'
1 diff --git a/extras/root_link/Makefile b/extras/root_link/Makefile
2 new file mode 100644
3 index 0000000..76b475d
4 --- /dev/null
5 +++ b/extras/root_link/Makefile
6 @@ -0,0 +1,69 @@
7 +# Makefile for udev extra invoked from the udev main Makefile
8 +#
9 +# Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
10 +#
11 +# Released under the GNU General Public License, version 2.
12 +#
13 +
14 +PROG = get_dir_major_minor
15 +OBJ =
16 +HEADERS =
17 +GEN_HEADERS =
18 +MAN_PAGES =
19 +
20 +prefix =
21 +etcdir = ${prefix}/etc
22 +sbindir = ${prefix}/sbin
23 +usrbindir = ${prefix}/usr/bin
24 +usrsbindir = ${prefix}/usr/sbin
25 +libudevdir = ${prefix}/lib/udev
26 +mandir = ${prefix}/usr/share/man
27 +configdir = ${etcdir}/udev/
28 +
29 +INSTALL = install -c
30 +INSTALL_PROGRAM = ${INSTALL}
31 +INSTALL_DATA = ${INSTALL} -m 644
32 +INSTALL_SCRIPT = ${INSTALL}
33 +
34 +all: $(PROG) $(MAN_PAGES)
35 +.PHONY: all
36 +.DEFAULT: all
37 +
38 +%.o: %.c $(GEN_HEADERS)
39 + $(E) " CC " $@
40 + $(Q) $(CC) -c $(CFLAGS) $< -o $@
41 +
42 +$(PROG): %: $(HEADERS) %.o $(OBJS)
43 + $(E) " LD " $@
44 + $(Q) $(LD) $(LDFLAGS) $@.o $(OBJS) -o $@ $(LIBUDEV) $(LIB_OBJS)
45 +
46 +# man pages
47 +%.8: %.xml
48 + $(E) " XMLTO " $@
49 + $(Q) xmlto man $?
50 +.PRECIOUS: %.8
51 +
52 +clean:
53 + $(E) " CLEAN "
54 + $(Q) rm -f $(PROG) $(OBJS) $(GEN_HEADERS)
55 +.PHONY: clean
56 +
57 +install-bin: all
58 + $(INSTALL_PROGRAM) -D $(PROG) $(DESTDIR)$(libudevdir)/$(PROG)
59 +.PHONY: install-bin
60 +
61 +uninstall-bin:
62 + - rm $(DESTDIR)$(libudevdir)/$(PROG)
63 +.PHONY: uninstall-bin
64 +
65 +install-man:
66 + @echo "Please create a man page for this tool."
67 +.PHONY: install-man
68 +
69 +uninstall-man:
70 + @echo "Please create a man page for this tool."
71 +.PHONY: uninstall-man
72 +
73 +install-config:
74 + @echo "no config file to install"
75 +.PHONY: install-config
76 diff --git a/extras/root_link/get_dir_major_minor.c b/extras/root_link/get_dir_major_minor.c
77 new file mode 100644
78 index 0000000..1e39411
79 --- /dev/null
80 +++ b/extras/root_link/get_dir_major_minor.c
81 @@ -0,0 +1,48 @@
82 +// print out major/minor nr of the device the supplied dir
83 +// is mounted on
84 +//
85 +// Author: Matthias Schwarzott <zzam@gentoo.org>
86 +
87 +#include <sys/types.h>
88 +#include <sys/stat.h>
89 +#include <unistd.h>
90 +
91 +#include <stdio.h>
92 +#include <stdlib.h>
93 +
94 +// Getting major/minor
95 +#include <sys/sysmacros.h>
96 +int main(int argc, char **argv)
97 +{
98 + struct stat stat_buf;
99 + unsigned int dev_major=0, dev_minor=0;
100 + dev_t dev;
101 +
102 + if (argc != 2) {
103 + printf("Usage:\n");
104 + printf(" get_dir_major_minor <directory>\n");
105 + return EXIT_FAILURE;
106 + }
107 +
108 + if (stat(argv[1], &stat_buf) < 0) {
109 + perror("stat");
110 + return EXIT_FAILURE;
111 + }
112 +
113 + dev = stat_buf.st_dev;
114 +
115 + dev_major = gnu_dev_major(dev);
116 + dev_minor = gnu_dev_minor(dev);
117 +
118 +
119 + if (dev_major == 0) {
120 + fprintf(stderr, "Major number is 0.\n");
121 + return EXIT_FAILURE;
122 + } else
123 + printf("%d %d\n",
124 + dev_major,
125 + dev_minor);
126 +
127 + return EXIT_SUCCESS;
128 +}
129 +
130 diff --git a/extras/root_link/print_root_link_rule.sh b/extras/root_link/print_root_link_rule.sh
131 new file mode 100755
132 index 0000000..c33f290
133 --- /dev/null
134 +++ b/extras/root_link/print_root_link_rule.sh
135 @@ -0,0 +1,13 @@
136 +#!/bin/sh
137 +
138 +PROG=/lib/udev/print_dir_major_minor
139 +[ -x "${PROG}" ] && DEV=$(/lib/udev/print_dir_major_minor /)
140 +if [ $? == 0 ]; then
141 + MAJOR="${DEV##* }"
142 + MINOR="${DEV%% *}"
143 +
144 + echo "# Created by print_root_link_rule"
145 + echo "# This rule should create /dev/root as link to real root device."
146 + echo "SUBSYSTEM==\"block\", ENV{MAJOR}==\"$MAJOR\", ENV{MINOR}==\"$MINOR\", SYMLINK+=\"root\""
147 +fi
148 +