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 + +#include +#include +#include + +#include +#include + +// Getting major/minor +#include +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 \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 +# +# 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 + +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 +