Skip to contentSkip to conversation

Pull request for branch for-2011.05/dev-handling

GIT PULL New Thomas Petazzoni 2 participants 6 messages Mar 7, 2011 – May 10, 2011 VFS

lore
Share & tools
lore
#0 lore raw

The following changes since commit 0a064b48c9d1044b05aee65272f5af7f28879473:
Gustavo Zacarias (1):

        gst-ffmpeg: bump to version 0.10.11

are available in the git repository at:

git://git.busybox.net/~tpetazzoni/git/buildroot for-2011.05/dev-handling

Thomas Petazzoni (2):
Simplify udev startup script
Allow several device tables and split in two parts our device table

Yegor Yefremov (1):
Create menu entry to select device creation method

 fs/Config.in                        |   41 +++++++-
 fs/common.mk                        |   14 ++-
 linux/linux.mk                      |    7 ++
 package/busybox/S10mdev             |   22 ++++
 package/busybox/busybox.mk          |   15 +++
 package/makedevs/README             |   35 +++++++
 package/udev/S10udev                |   34 -------
 target/generic/device_table.txt     |  186 ++--------------------------------
 target/generic/device_table_dev.txt |  142 ++++++++++++++++++++++++++
 9 files changed, 276 insertions(+), 220 deletions(-)
 create mode 100644 package/busybox/S10mdev
 create mode 100644 package/makedevs/README
 create mode 100644 target/generic/device_table_dev.txt

Thanks,

Signature · 1 line
Thomas Petazzoni
#1 lore raw

PATCH 1/3 Create menu entry to select device creation method

From: Yegor Yefremov <[email protected]>

Four methods for the creation of device files in /dev are now proposed:

- static method uses device table as before
- devtmpfs method enables this feature in kernel
- mdev method adds mdev starting script to the file system and selects mdev itself for installation
- udev method selects udev for installation

All dynamic methods are based on devtmpfs, so one doesn't need to care about /dev folder.

---
 fs/Config.in               |   33 +++++++++++++++++++++++++++------
 linux/linux.mk             |    7 +++++++
 package/busybox/S10mdev    |   22 ++++++++++++++++++++++
 package/busybox/busybox.mk |   15 +++++++++++++++
 4 files changed, 71 insertions(+), 6 deletions(-)
 create mode 100644 package/busybox/S10mdev
fs/Config.in +27 -6
index 188e815..9ac3acc 100644
@@ -15,13 +15,34 @@ config BR2_ROOTFS_POST_BUILD_SCRIPT
 	  only argument. Make sure the exit code of that script is 0,
 	  otherwise make will stop after calling it.
 
+choice
+	prompt "/dev management"
+	default BR2_ROOTFS_DEVICE_CREATION_STATIC
+
+config BR2_ROOTFS_DEVICE_CREATION_STATIC
+	bool "Static using device table"
+
+config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS
+	bool "Dynamic using devtmpfs only"
+
+config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV
+	bool "Dynamic using mdev"
+	select BR2_PACKAGE_BUSYBOX
+
+config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV
+	bool "Dynamic using udev"
+	select BR2_PACKAGE_UDEV
+
+endchoice
+
 config BR2_ROOTFS_DEVICE_TABLE
-       string "Path to the device table"
-       default "target/generic/device_table.txt"
-       help
-         Specify the location of a device table, that will be passed
-         to the makedevs utility to create all the special device
-         files in the target filesystem.
+	string "Path to the device table"
+	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC
+	default "target/generic/device_table.txt"
+	help
+	  Specify the location of a device table, that will be passed
+	  to the makedevs utility to create all the special device
+	  files in the target filesystem.
 
 choice
 	prompt "Root FS skeleton"
linux/linux.mk +7 -0
index 9076fb9..873a9e0 100644
@@ -130,6 +130,13 @@ ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
 	$(call KCONFIG_DISABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_NONE,$(@D)/.config)
 	$(call KCONFIG_ENABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_GZIP,$(@D)/.config)
 endif
+ifneq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
+	$(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config)
+	$(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config)
+endif
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)
+	$(call KCONFIG_SET_OPT,CONFIG_UEVENT_HELPER_PATH,\"/sbin/mdev\",$(@D)/.config)
+endif
 	$(TARGET_MAKE_ENV) $(MAKE) $(LINUX26_MAKE_FLAGS) -C $(@D) oldconfig
 	$(Q)touch $@
 
package/busybox/S10mdev new file +22 -0
new file mode 100644
index 0000000..472810b
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Start mdev....
+#
+
+case "$1" in
+  start)
+ 	echo "Starting mdev..."
+	/sbin/mdev -s
+	;;
+  stop)
+	;;
+  restart|reload)
+	;;
+  *)
+	echo $"Usage: $0 {start|stop|restart}"
+	exit 1
+esac
+
+exit $?
+
+
package/busybox/busybox.mk +15 -0
index 5583bc6..2a1b839 100644
@@ -28,6 +28,19 @@ ifndef BUSYBOX_CONFIG_FILE
 	BUSYBOX_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG))
 endif
 
+# If mdev will be used for device creation enable it and copy S10mdev to /etc/init.d
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)
+define BUSYBOX_INSTALL_MDEV_SCRIPT
+	install -m 0755 package/busybox/S10mdev $(TARGET_DIR)/etc/init.d
+endef
+define BUSYBOX_SET_MDEV
+	$(call KCONFIG_ENABLE_OPT,CONFIG_MDEV,$(BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_CONF,$(BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_EXEC,$(BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_LOAD_FIRMWARE,$(BUSYBOX_BUILD_CONFIG))
+endef
+endif
+
 # If we have external syslogd, force busybox to use it
 ifeq ($(BR2_PACKAGE_SYSKLOGD),y)
 define BUSYBOX_SET_SYSKLOGD
@@ -122,6 +135,7 @@ define BUSYBOX_CONFIGURE_CMDS
 	$(BUSYBOX_SET_IPV6)
 	$(BUSYBOX_SET_RPC)
 	$(BUSYBOX_PREFER_STATIC)
+	$(BUSYBOX_SET_MDEV)
 	$(BUSYBOX_NETKITBASE)
 	$(BUSYBOX_NETKITTELNET)
 	@yes "" | $(MAKE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE="$(TARGET_CROSS)" \
@@ -138,6 +152,7 @@ define BUSYBOX_INSTALL_TARGET_CMDS
 		$(INSTALL) -m 0755 -D package/busybox/udhcpc.script \
 			$(TARGET_DIR)/usr/share/udhcpc/default.script; \
 	fi
+	$(BUSYBOX_INSTALL_MDEV_SCRIPT)
 endef
 
 define BUSYBOX_UNINSTALL_TARGET_CMDS
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 2/3 Simplify udev startup script

In reply to Thomas Petazzoni

The S10udev startup script did useless things such as mounting sysfs, mounting a tmpfs filesystem in /dev/, etc. Those things are already done during in the default inittab.

---
 package/udev/S10udev |   34 ----------------------------------
 1 files changed, 0 insertions(+), 34 deletions(-)
package/udev/S10udev +0 -34
index 6418f63..0d2a23a 100755
@@ -16,12 +16,6 @@
 #	/dev/zero, /dev/null -- that's needed to boot and run this script.
 #
 
-# old kernels don't use udev
-case $(uname -r) in
-    2.6*|2.7*)	;;
-    *)		exit 0;;
-esac
-
 # Check for missing binaries
 UDEV_BIN=/sbin/udevd
 test -x $UDEV_BIN || exit 5
@@ -33,41 +27,13 @@ UDEV_CONFIG=/etc/udev/udev.conf
 test -r $UDEV_CONFIG || exit 6
 . $UDEV_CONFIG
 
-# Directory where sysfs is mounted
-SYSFS_DIR=/sys
-
 case "$1" in
     start)
-        # mount sysfs if it's not yet mounted
-        if [ ! -d $SYSFS_DIR ]; then
-	    echo "${0}: SYSFS_DIR \"$SYSFS_DIR\" not found"
-	    exit 1
-        fi
-        grep -q "^sysfs $SYSFS_DIR" /proc/mounts ||
-	mount -t sysfs /sys /sys ||
-	exit 1
-
-        # mount $udev_root as ramfs if it's not yet mounted
-        # we know 2.6 kernels always support ramfs
-        if [ ! -d $udev_root ]; then
-	    echo "${0}: udev_root \"$udev_root\" not found"
-	    exit 1
-        fi
-        grep -q "^udev $udev_root" /proc/mounts ||
-	mount -t ramfs udev $udev_root ||
-	exit 1
-
-        mkdir $udev_root/pts $udev_root/shm
         mknod -m 0666 /dev/null c 1 3
-        mknod -m 0666 /dev/zero c 1 5
-        mknod -m 0600 /dev/console c 5 1
-
-        # populate /dev (normally)
         echo -n "Populating $udev_root using udev: "
         echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
         $UDEV_BIN -d || (echo "FAIL" && exit 1)
 	$UDEVSTART_BIN || (echo "FAIL" && exit 1)
-	mount -t devpts /dev/pts /dev/pts || (echo "FAIL" && exit 1)
         echo "done"
         ;;
     stop)
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 3/3 Allow several device tables and split in two parts our device table

In reply to Thomas Petazzoni

This allows to have a device table for all directories/files and another device table for the device files themselves. Both are needed for static /dev, but only the first one is needed when devtmpfs/mdev/udev are used.

We take this opportunity to move the documentation of the device table format in a common location, package/makedevs/README.

---
 fs/Config.in                        |   20 +++-
 fs/common.mk                        |   14 ++-
 package/makedevs/README             |   35 +++++++
 target/generic/device_table.txt     |  186 ++--------------------------------
 target/generic/device_table_dev.txt |  142 ++++++++++++++++++++++++++
 5 files changed, 211 insertions(+), 186 deletions(-)
 create mode 100644 package/makedevs/README
 create mode 100644 target/generic/device_table_dev.txt
fs/Config.in +14 -6
index 9ac3acc..636e316 100644
@@ -36,13 +36,21 @@ config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV
 endchoice
 
 config BR2_ROOTFS_DEVICE_TABLE
-	string "Path to the device table"
-	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC
-	default "target/generic/device_table.txt"
+	string "Path to the device tables"
+	default "target/generic/device_table.txt target/generic/device_table_dev.txt" \
+		if BR2_ROOTFS_DEVICE_CREATION_STATIC
+	default "target/generic/device_table.txt" \
+		if (BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV || \
+		    BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV || \
+		    BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS)
 	help
-	  Specify the location of a device table, that will be passed
-	  to the makedevs utility to create all the special device
-	  files in the target filesystem.
+	  Specify a space-separated list of device table locations,
+	  that will be passed to the makedevs utility to create all
+	  the special device files and assign correct owners and
+	  permissions on various files in the target filesystem.
+
+          See package/makedevs/README for details on the usage and
+          syntax of these files.
 
 choice
 	prompt "Root FS skeleton"
fs/common.mk +9 -5
index 92be00c..f105af2 100644
@@ -32,7 +32,8 @@
 # macro will automatically generate a compressed filesystem image.
 
 FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
-ROOTFS_DEVICE_TABLE = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE))
+FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
+ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE))
 
 define ROOTFS_TARGET_INTERNAL
 
@@ -42,17 +43,20 @@ $(eval ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs $(if $(BR2_TARGET
 $(BINARIES_DIR)/rootfs.$(1): $(ROOTFS_$(2)_DEPENDENCIES)
 	@$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
 	$(foreach hook,$(ROOTFS_$(2)_PRE_GEN_HOOKS),$(call $(hook))$(sep))
-	rm -f $(FAKEROOT_SCRIPT)
+	rm -f $(FAKEROOT_SCRIPT) $(FULL_DEVICE_TABLE)
 	touch $(BUILD_DIR)/.fakeroot.00000
 	cat $(BUILD_DIR)/.fakeroot* > $(FAKEROOT_SCRIPT)
 	echo "chown -R 0:0 $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
-ifneq ($(ROOTFS_DEVICE_TABLE),)
-	echo "$(HOST_DIR)/usr/bin/makedevs -d $(ROOTFS_DEVICE_TABLE) $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
+ifneq ($(ROOTFS_DEVICE_TABLES),)
+	for devtable in $(ROOTFS_DEVICE_TABLES) ; do \
+		cat $$$${devtable} >> $(FULL_DEVICE_TABLE) ; \
+	done
+	echo "$(HOST_DIR)/usr/bin/makedevs -d $(FULL_DEVICE_TABLE) $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
 endif
 	echo "$(ROOTFS_$(2)_CMD)" >> $(FAKEROOT_SCRIPT)
 	chmod a+x $(FAKEROOT_SCRIPT)
 	$(HOST_DIR)/usr/bin/fakeroot -- $(FAKEROOT_SCRIPT)
-	- at rm -f $(FAKEROOT_SCRIPT)
+	- at rm -f $(FAKEROOT_SCRIPT) $(FULL_DEVICE_TABLE)
 	$(foreach hook,$(ROOTFS_$(2)_POST_GEN_HOOKS),$(call $(hook))$(sep))
 ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
 	gzip -9 -c $$@ > [email protected]
package/makedevs/README new file +35 -0
new file mode 100644
index 0000000..6c54052
@@ -0,0 +1,35 @@
+When building a target filesystem, it is desirable to not have to
+become root and then run 'mknod' a thousand times.  Using a device
+table you can create device nodes and directories "on the fly".
+
+You can do all sorts of interesting things with a device table file.
+For example, if you want to adjust the permissions on a particular
+file you can just add an entry like:
+
+  /sbin/foobar        f       2755    0       0       -       -       -       -       -
+
+and (assuming the file /sbin/foobar exists) it will be made setuid
+root (regardless of what its permissions are on the host filesystem.
+
+Furthermore, you can use a single table entry to create a many device
+minors.  For example, if I wanted to create /dev/hda and
+/dev/hda[0-15] I could just use the following two table entries:
+
+  /dev/hda    b       640     0       0       3       0       0       0       -
+  /dev/hda    b       640     0       0       3       1       1       1       15
+
+Device table entries take the form of:
+
+<name>    <type>      <mode>  <uid>   <gid>   <major> <minor> <start> <inc>   <count>
+
+where name is the file name,  type can be one of:
+
+      f       A regular file
+      d       Directory
+      c       Character special device file
+      b       Block special device file
+      p       Fifo (named pipe)
+
+uid is the user id for the target file, gid is the group id for the
+target file.  The rest of the entries (major, minor, etc) apply only
+to device special files.
target/generic/device_table.txt +11 -175

194 lines not on this page · raw message

target/generic/device_table_dev.txt new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#4 lore raw
In reply to Thomas Petazzoni
Quoted 9 lines · On Mon, 7 Mar 2011 22:21:22 +0100 Thomas Petazzoni…

The following changes since commit 0a064b48c9d1044b05aee65272f5af7f28879473: Gustavo Zacarias (1):

        gst-ffmpeg: bump to version 0.10.11

are available in the git repository at:

git://git.busybox.net/~tpetazzoni/git/buildroot
for-2011.05/dev-handling

Quoted 7 lines

Thomas Petazzoni (2):
Simplify udev startup script
Allow several device tables and split in two parts our device
table

Yegor Yefremov (1):
Create menu entry to select device creation method

Ping ?

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw
In reply to Thomas Petazzoni
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Thomas> The following changes since commit 0a064b48c9d1044b05aee65272f5af7f28879473:
Thomas> Gustavo Zacarias (1):
Thomas> gst-ffmpeg: bump to version 0.10.11

Thomas> are available in the git repository at:

Thomas> git://git.busybox.net/~tpetazzoni/git/buildroot for-2011.05/dev-handling

I finally got to review/test/commit this. Thanks both, and sorry for the slow response.

Signature · 1 line
Bye, Peter Korsgaard