Pull request for branch for-2011.05/dev-handling
The following changes since commit 0a70aa0cc5d0980e72677869d9d87e0e4e35e483:
webkit: bump to version 1.2.7 (2011-03-31 15:23:13 +0200)
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
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
@@ -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
@@ -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
@@ -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
@@ -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.1
PATCH 2/3 Simplify udev startup script
In reply to Thomas PetazzoniThe 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
@@ -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.1
PATCH 3/3 Allow several device tables and split in two parts our device table
In reply to Thomas PetazzoniThis 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
@@ -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
@@ -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
@@ -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.1
PATCH 1/3 Create menu entry to select device creation method
In reply to Thomas PetazzoniQuoted 74 lines · On Saturday 02 April 2011 18:53:32 Thomas Petazzoni wrote:
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 installationAll dynamic methods are based on devtmpfs, so one doesn't need to care about /dev folder.
Signed-off-by Yegor Yefremov <[email protected]>Signed-off-by Thomas Petazzoni <[email protected]>--- 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/S10mdevfs/Config.in +27
-6@@ -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 +0
-0
linux/linux.mk ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) · line 133
Quoted 4 lines
linux/linux.mk +1
-0@@ -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)
^^^^^^
linux/linux.mk ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) · line 136
Quoted 3 lines
linux/linux.mk +3
-0+ $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config) + $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config) +endif
This should be BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS, no?
linux/linux.mk ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) · line 139
Quoted 3 lines
linux/linux.mk +3
-0+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y) + $(call KCONFIG_SET_OPT,CONFIG_UEVENT_HELPER_PATH,\"/sbin/mdev\",$(@D)/.config) +endif
As I suggest below, I'd move that into the startup script.
Quoted 9 lines
linux/linux.mk +0
-0$(TARGET_MAKE_ENV) $(MAKE) $(LINUX26_MAKE_FLAGS) -C $(@D) oldconfig $(Q)touch $@package/busybox/S10mdev new file +0
-0
package/busybox/S10mdev line 9
Quoted 9 lines
package/busybox/S10mdev new file +9
-0@@ -0,0 +1,22 @@ +#!/bin/sh +# +# Start mdev.... +# + +case "$1" in + start) + echo "Starting mdev..." + /sbin/mdev -s
From busybox/docs/mdev.txt:
Here's a typical code snippet from the init script:
[0] mount -t proc proc /proc
[1] mount -t sysfs sysfs /sys
[2] echo /sbin/mdev > /proc/sys/kernel/hotplug
[3] mdev -s
I see that [2] is done in the kernel's .config. I find it non-obvious, and I would move that to the script above. It makes it easier to follow.
Also, I did not see where /dev is mounted (as a tmpfs). If / is a RO file system, then you can't use dynamic nodes, or you need a RW file system on /dev.
package/busybox/S10mdev line 11
Quoted 2 lines
package/busybox/S10mdev new file +2
-0+ ;; + stop)
For completeness:
echo "/bin/true" > /proc/sys/kernel/hotplug killall mdev
sleep 2 # Leave it some time to proerly quit (adjust delay) killall -9 mdev
package/busybox/S10mdev line 13
Quoted 2 lines
package/busybox/S10mdev new file +2
-0+ ;; + restart|reload)
stop + start, maybe?
Quoted 49 lines
package/busybox/S10mdev new file +9
-0+ ;; + *) + echo $"Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? + +package/busybox/busybox.mk +15
-0@@ -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 · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 3/3 Allow several device tables and split in two parts our device table
In reply to Thomas PetazzoniThomas, All,
Quoted 24 lines · On Saturday 02 April 2011 18:53:34 Thomas Petazzoni wrote:
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.
Signed-off-by Thomas Petazzoni <[email protected]>--- 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.txtfs/Config.in +0
-0
fs/Config.in config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV · line 41
Quoted 9 lines
fs/Config.in +3
-3@@ -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
The 'device_table.txt' file name is misleading. Maybe rename to something
like: permision_table.txt
So you get device_table.txt for creating devices, and permission_table.txt for setting permission.
Yeah, I know, it's the same tool, it's the same format, it's the historical name. So, keep the historical name for devices, as the name implies, and introduce the new names just for permissions.
Bonus: it avoids the huge diff below! ;-)
Quoted 446 lines
fs/Config.in +11
-3+ 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@@ -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@@ -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@@ -1,44 +1,15 @@ -# 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". +# See package/makedevs/README for details # -# This is a sample device table file for use with genext2fs. 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. - -# Have fun -# -Erik Andersen <[email protected]> +# This device table is used to assign proper ownership and permissions +# on various files. It doesn't create any device file, as it is used +# in both static device configurations (where /dev/ is static) and in +# dynamic configurations (where devtmpfs, mdev or udev are used). # - -#<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> -/dev d 755 0 0 - - - - - -/dev/pts d 755 0 0 - - - - - -/dev/shm d 755 0 0 - - - - - -/tmp d 1777 0 0 - - - - - -/etc d 755 0 0 - - - - - -/home/default d 2755 1000 1000 - - - - - -#<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> +# <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> +/dev d 755 0 0 - - - - - +/tmp d 1777 0 0 - - - - - +/etc d 755 0 0 - - - - - +/home/default d 2755 1000 1000 - - - - - /bin/busybox f 4755 0 0 - - - - - /etc/shadow f 600 0 0 - - - - - /etc/passwd f 644 0 0 - - - - -@@ -48,139 +19,4 @@ /etc/network/if-post-down.d d 755 0 0 - - - - - /usr/share/udhcpc/default.script f 755 0 0 - - - - - # uncomment this to allow starting x as non-root -#/usr/X11R6/bin/Xfbdev f 4755 0 0 - - - - - -# Normal system devices -/dev/mem c 640 0 0 1 1 0 0 - -/dev/kmem c 640 0 0 1 2 0 0 - -/dev/null c 666 0 0 1 3 0 0 - -/dev/zero c 666 0 0 1 5 0 0 - -/dev/random c 666 0 0 1 8 0 0 - -/dev/urandom c 666 0 0 1 9 0 0 - -/dev/ram b 640 0 0 1 1 0 0 - -/dev/ram b 640 0 0 1 0 0 1 4 -/dev/loop b 640 0 0 7 0 0 1 2 -/dev/rtc c 640 0 0 10 135 - - - -/dev/console c 666 0 0 5 1 - - - -/dev/tty c 666 0 0 5 0 - - - -/dev/tty c 666 0 0 4 0 0 1 8 -/dev/ttyp c 666 0 0 3 0 0 1 10 -/dev/ptyp c 666 0 0 2 0 0 1 10 -/dev/ptmx c 666 0 0 5 2 - - - -/dev/ttyP c 666 0 0 57 0 0 1 4 -/dev/ttyS c 666 0 0 4 64 0 1 4 -/dev/fb c 640 0 5 29 0 0 1 4 -#/dev/ttySA c 666 0 0 204 5 0 1 3 -/dev/psaux c 666 0 0 10 1 0 0 - -#/dev/ppp c 666 0 0 108 0 - - - -/dev/ttyAM c 666 0 0 204 16 0 1 3 -/dev/ttyCPM c 666 0 0 204 46 0 1 4 -/dev/ttyAMA c 666 0 0 204 64 0 1 4 -/dev/ttySAC c 666 0 0 204 64 0 1 4 -/dev/ttyPSC c 666 0 0 204 148 0 1 4 -/dev/ttyUL c 666 0 0 204 187 0 1 4 -/dev/ttymxc c 666 0 0 207 16 0 1 3 - -# Input stuff -/dev/input d 755 0 0 - - - - - -/dev/input/mice c 640 0 0 13 63 0 0 - -/dev/input/mouse c 660 0 0 13 32 0 1 4 -/dev/input/event c 660 0 0 13 64 0 1 4 -#/dev/input/js c 660 0 0 13 0 0 1 4 - - -# MTD stuff -/dev/mtd c 640 0 0 90 0 0 2 4 -/dev/mtdblock b 640 0 0 31 0 0 1 4 - -#Tun/tap driver -/dev/net d 755 0 0 - - - - - -/dev/net/tun c 660 0 0 10 200 - - - - -# Audio stuff -#/dev/audio c 666 0 29 14 4 - - - -#/dev/audio1 c 666 0 29 14 20 - - - -#/dev/dsp c 666 0 29 14 3 - - - -#/dev/dsp1 c 666 0 29 14 19 - - - -#/dev/sndstat c 666 0 29 14 6 - - - - -# User-mode Linux stuff -#/dev/ubda b 640 0 0 98 0 0 0 - -#/dev/ubda b 640 0 0 98 1 1 1 15 - -# IDE Devices -/dev/hda b 640 0 0 3 0 0 0 - -/dev/hda b 640 0 0 3 1 1 1 15 -/dev/hdb b 640 0 0 3 64 0 0 - -/dev/hdb b 640 0 0 3 65 1 1 15 -#/dev/hdc b 640 0 0 22 0 0 0 - -#/dev/hdc b 640 0 0 22 1 1 1 15 -#/dev/hdd b 640 0 0 22 64 0 0 - -#/dev/hdd b 640 0 0 22 65 1 1 15 -#/dev/hde b 640 0 0 33 0 0 0 - -#/dev/hde b 640 0 0 33 1 1 1 15 -#/dev/hdf b 640 0 0 33 64 0 0 - -#/dev/hdf b 640 0 0 33 65 1 1 15 -#/dev/hdg b 640 0 0 34 0 0 0 - -#/dev/hdg b 640 0 0 34 1 1 1 15 -#/dev/hdh b 640 0 0 34 64 0 0 - -#/dev/hdh b 640 0 0 34 65 1 1 15 - -# SCSI Devices -/dev/sda b 640 0 0 8 0 0 0 - -/dev/sda b 640 0 0 8 1 1 1 15 -/dev/sdb b 640 0 0 8 16 0 0 - -/dev/sdb b 640 0 0 8 17 1 1 15 -#/dev/sdc b 640 0 0 8 32 0 0 - -#/dev/sdc b 640 0 0 8 33 1 1 15 -#/dev/sdd b 640 0 0 8 48 0 0 - -#/dev/sdd b 640 0 0 8 49 1 1 15 -#/dev/sde b 640 0 0 8 64 0 0 - -#/dev/sde b 640 0 0 8 65 1 1 15 -#/dev/sdf b 640 0 0 8 80 0 0 - -#/dev/sdf b 640 0 0 8 81 1 1 15 -#/dev/sdg b 640 0 0 8 96 0 0 - -#/dev/sdg b 640 0 0 8 97 1 1 15 -#/dev/sdh b 640 0 0 8 112 0 0 - -#/dev/sdh b 640 0 0 8 113 1 1 15 -#/dev/sg c 640 0 0 21 0 0 1 15 -#/dev/scd b 640 0 0 11 0 0 1 15 -#/dev/st c 640 0 0 9 0 0 1 8 -#/dev/nst c 640 0 0 9 128 0 1 8 -#/dev/st c 640 0 0 9 32 1 1 4 -#/dev/st c 640 0 0 9 64 1 1 4 -#/dev/st c 640 0 0 9 96 1 1 4 - -# USB block devices (ub driver) -/dev/uba b 640 0 0 180 0 0 0 - -/dev/uba b 640 0 0 180 1 1 1 6 -/dev/ubb b 640 0 0 180 8 0 0 - -/dev/ubb b 640 0 0 180 65 1 1 6 - -# Floppy disk devices -#/dev/fd b 640 0 0 2 0 0 1 2 -#/dev/fd0d360 b 640 0 0 2 4 0 0 - -#/dev/fd1d360 b 640 0 0 2 5 0 0 - -#/dev/fd0h1200 b 640 0 0 2 8 0 0 - -#/dev/fd1h1200 b 640 0 0 2 9 0 0 - -#/dev/fd0u1440 b 640 0 0 2 28 0 0 - -#/dev/fd1u1440 b 640 0 0 2 29 0 0 - -#/dev/fd0u2880 b 640 0 0 2 32 0 0 - -#/dev/fd1u2880 b 640 0 0 2 33 0 0 - - -# All the proprietary cdrom devices in the world -#/dev/aztcd b 640 0 0 29 0 0 0 - -#/dev/bpcd b 640 0 0 41 0 0 0 - -#/dev/capi20 c 640 0 0 68 0 0 1 2 -#/dev/cdu31a b 640 0 0 15 0 0 0 - -#/dev/cdu535 b 640 0 0 24 0 0 0 - -#/dev/cm206cd b 640 0 0 32 0 0 0 - -#/dev/sjcd b 640 0 0 18 0 0 0 - -#/dev/sonycd b 640 0 0 15 0 0 0 - -#/dev/gscd b 640 0 0 16 0 0 0 - -#/dev/sbpcd b 640 0 0 25 0 0 0 - -#/dev/sbpcd b 640 0 0 25 0 0 1 4 -#/dev/mcd b 640 0 0 23 0 0 0 - -#/dev/optcd b 640 0 0 17 0 0 0 - - -# I2C device nodes -/dev/i2c- c 666 0 0 89 0 0 1 4 +#/usr/X11R6/bin/Xfbdev f 4755 0 0 - - - - -target/generic/device_table_dev.txt new file +142
-0@@ -0,0 +1,142 @@ +# See package/makedevs/README for details +# +# This device table is used only to create device files when a static +# device configuration is used (entries in /dev are static). +# +# <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> + +# Normal system devices +/dev/mem c 640 0 0 1 1 0 0 - +/dev/kmem c 640 0 0 1 2 0 0 - +/dev/null c 666 0 0 1 3 0 0 - +/dev/zero c 666 0 0 1 5 0 0 - +/dev/random c 666 0 0 1 8 0 0 - +/dev/urandom c 666 0 0 1 9 0 0 - +/dev/ram b 640 0 0 1 1 0 0 - +/dev/ram b 640 0 0 1 0 0 1 4 +/dev/loop b 640 0 0 7 0 0 1 2 +/dev/rtc c 640 0 0 10 135 - - - +/dev/console c 666 0 0 5 1 - - - +/dev/tty c 666 0 0 5 0 - - - +/dev/tty c 666 0 0 4 0 0 1 8 +/dev/ttyp c 666 0 0 3 0 0 1 10 +/dev/ptyp c 666 0 0 2 0 0 1 10 +/dev/ptmx c 666 0 0 5 2 - - - +/dev/ttyP c 666 0 0 57 0 0 1 4 +/dev/ttyS c 666 0 0 4 64 0 1 4 +/dev/fb c 640 0 5 29 0 0 1 4 +#/dev/ttySA c 666 0 0 204 5 0 1 3 +/dev/psaux c 666 0 0 10 1 0 0 - +#/dev/ppp c 666 0 0 108 0 - - - +/dev/ttyAM c 666 0 0 204 16 0 1 3 +/dev/ttyCPM c 666 0 0 204 46 0 1 4 +/dev/ttyAMA c 666 0 0 204 64 0 1 4 +/dev/ttySAC c 666 0 0 204 64 0 1 4 +/dev/ttyPSC c 666 0 0 204 148 0 1 4 +/dev/ttyUL c 666 0 0 204 187 0 1 4 +/dev/ttymxc c 666 0 0 207 16 0 1 3 + +# Input stuff +/dev/input d 755 0 0 - - - - - +/dev/input/mice c 640 0 0 13 63 0 0 - +/dev/input/mouse c 660 0 0 13 32 0 1 4 +/dev/input/event c 660 0 0 13 64 0 1 4 +#/dev/input/js c 660 0 0 13 0 0 1 4 + + +# MTD stuff +/dev/mtd c 640 0 0 90 0 0 2 4 +/dev/mtdblock b 640 0 0 31 0 0 1 4 + +#Tun/tap driver +/dev/net d 755 0 0 - - - - - +/dev/net/tun c 660 0 0 10 200 - - - + +# Audio stuff +#/dev/audio c 666 0 29 14 4 - - - +#/dev/audio1 c 666 0 29 14 20 - - - +#/dev/dsp c 666 0 29 14 3 - - - +#/dev/dsp1 c 666 0 29 14 19 - - - +#/dev/sndstat c 666 0 29 14 6 - - - + +# User-mode Linux stuff +#/dev/ubda b 640 0 0 98 0 0 0 - +#/dev/ubda b 640 0 0 98 1 1 1 15 + +# IDE Devices +/dev/hda b 640 0 0 3 0 0 0 - +/dev/hda b 640 0 0 3 1 1 1 15 +/dev/hdb b 640 0 0 3 64 0 0 - +/dev/hdb b 640 0 0 3 65 1 1 15 +#/dev/hdc b 640 0 0 22 0 0 0 - +#/dev/hdc b 640 0 0 22 1 1 1 15 +#/dev/hdd b 640 0 0 22 64 0 0 - +#/dev/hdd b 640 0 0 22 65 1 1 15 +#/dev/hde b 640 0 0 33 0 0 0 - +#/dev/hde b 640 0 0 33 1 1 1 15 +#/dev/hdf b 640 0 0 33 64 0 0 - +#/dev/hdf b 640 0 0 33 65 1 1 15 +#/dev/hdg b 640 0 0 34 0 0 0 - +#/dev/hdg b 640 0 0 34 1 1 1 15 +#/dev/hdh b 640 0 0 34 64 0 0 - +#/dev/hdh b 640 0 0 34 65 1 1 15 + +# SCSI Devices +/dev/sda b 640 0 0 8 0 0 0 - +/dev/sda b 640 0 0 8 1 1 1 15 +/dev/sdb b 640 0 0 8 16 0 0 - +/dev/sdb b 640 0 0 8 17 1 1 15 +#/dev/sdc b 640 0 0 8 32 0 0 - +#/dev/sdc b 640 0 0 8 33 1 1 15 +#/dev/sdd b 640 0 0 8 48 0 0 - +#/dev/sdd b 640 0 0 8 49 1 1 15 +#/dev/sde b 640 0 0 8 64 0 0 - +#/dev/sde b 640 0 0 8 65 1 1 15 +#/dev/sdf b 640 0 0 8 80 0 0 - +#/dev/sdf b 640 0 0 8 81 1 1 15 +#/dev/sdg b 640 0 0 8 96 0 0 - +#/dev/sdg b 640 0 0 8 97 1 1 15 +#/dev/sdh b 640 0 0 8 112 0 0 - +#/dev/sdh b 640 0 0 8 113 1 1 15 +#/dev/sg c 640 0 0 21 0 0 1 15 +#/dev/scd b 640 0 0 11 0 0 1 15 +#/dev/st c 640 0 0 9 0 0 1 8 +#/dev/nst c 640 0 0 9 128 0 1 8 +#/dev/st c 640 0 0 9 32 1 1 4 +#/dev/st c 640 0 0 9 64 1 1 4 +#/dev/st c 640 0 0 9 96 1 1 4 + +# USB block devices (ub driver) +/dev/uba b 640 0 0 180 0 0 0 - +/dev/uba b 640 0 0 180 1 1 1 6 +/dev/ubb b 640 0 0 180 8 0 0 - +/dev/ubb b 640 0 0 180 65 1 1 6 + +# Floppy disk devices +#/dev/fd b 640 0 0 2 0 0 1 2 +#/dev/fd0d360 b 640 0 0 2 4 0 0 - +#/dev/fd1d360 b 640 0 0 2 5 0 0 - +#/dev/fd0h1200 b 640 0 0 2 8 0 0 - +#/dev/fd1h1200 b 640 0 0 2 9 0 0 - +#/dev/fd0u1440 b 640 0 0 2 28 0 0 - +#/dev/fd1u1440 b 640 0 0 2 29 0 0 - +#/dev/fd0u2880 b 640 0 0 2 32 0 0 - +#/dev/fd1u2880 b 640 0 0 2 33 0 0 - + +# All the proprietary cdrom devices in the world +#/dev/aztcd b 640 0 0 29 0 0 0 - +#/dev/bpcd b 640 0 0 41 0 0 0 - +#/dev/capi20 c 640 0 0 68 0 0 1 2 +#/dev/cdu31a b 640 0 0 15 0 0 0 - +#/dev/cdu535 b 640 0 0 24 0 0 0 - +#/dev/cm206cd b 640 0 0 32 0 0 0 - +#/dev/sjcd b 640 0 0 18 0 0 0 - +#/dev/sonycd b 640 0 0 15 0 0 0 - +#/dev/gscd b 640 0 0 16 0 0 0 - +#/dev/sbpcd b 640 0 0 25 0 0 0 - +#/dev/sbpcd b 640 0 0 25 0 0 1 4 +#/dev/mcd b 640 0 0 23 0 0 0 - +#/dev/optcd b 640 0 0 17 0 0 0 - + +# I2C device nodes +/dev/i2c- c 666 0 0 89 0 0 1 4
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/3 Create menu entry to select device creation method
In reply to Yann E. MORINHello,
Quoted 7 lines · On Sat, 2 Apr 2011 19:21:50 +0200 "Yann E. MORIN"…
Quoted 1 line
+ifneq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
^^^^^^linux/linux.mk ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) · line 136
Quoted 3 lines
linux/linux.mk +3
-0+ $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config) + $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config) +endifThis should be
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS, no?
This is what I originally implemented, but I was told that using devtmpfs was easier even in the udev/mdev cases for the early boot part (i.e before udev/mdev are working).
See
http://lists.busybox.net/pipermail/buildroot/2010-December/039886.html
for Peter's comment on the matter.
Quoted 5 lines
linux/linux.mk ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) · line 139
Quoted 3 lines
linux/linux.mk +3
-0+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y) + $(call KCONFIG_SET_OPT,CONFIG_UEVENT_HELPER_PATH,\"/sbin/mdev\",$(@D)/.config) +endifAs I suggest below, I'd move that into the startup script.
Hmm, why not.
Quoted 27 lines
Quoted 19 lines
linux/linux.mk +0
-0$(TARGET_MAKE_ENV) $(MAKE) $(LINUX26_MAKE_FLAGS) -C $(@D) oldconfig $(Q)touch $@package/busybox/S10mdev new file +9
-0@@ -0,0 +1,22 @@ +#!/bin/sh +# +# Start mdev.... +# + +case "$1" in + start) + echo "Starting mdev..." + /sbin/mdev -sQuoted 1 line
From
busybox/docs/mdev.txt:Here's a typical code snippet from the init script:
[0] mount -t proc proc /proc
[1] mount -t sysfs sysfs /sys
[2] echo/sbin/mdev>/proc/sys/kernel/hotplug
[3] mdev -s
Quoted 3 lines
I see that [2] is done in the kernel's .config. I find it non-obvious, and I would move that to the script above. It makes it easier to follow.
I guess that's a matter of taste. I have no strong opinion here.
Quoted 3 lines
Also, I did not see where /dev is mounted (as a tmpfs). If / is a RO file system, then you can't use dynamic nodes, or you need a RW file system on /dev.
/dev is a devtmpfs filesystem, thanks to the kernel options that you highlighted above, and it is mounted automatically by the kernel thanks to the CONFIG_DEVTMPFS_MOUNT option.
Quoted 8 lines
package/busybox/S10mdev line 11
Quoted 2 lines
package/busybox/S10mdev new file +2
-0+ ;; + stop)For completeness:
echo "/bin/true" >/proc/sys/kernel/hotplugkillall mdev
sleep 2 # Leave it some time to proerly quit (adjust delay) killall -9 mdev
mdev is not a daemon (contrary to udev), so there's no point in killing it. It's a utility that the kernel runs where there are events to handle.
So I don't think there's a lot of point in having the stop), restart) and reload) commands for mdev.
Regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/3 Create menu entry to select device creation method
Thomas, All,
Quoted 5 lines · On Sunday 03 April 2011 12:18:29 Thomas Petazzoni wrote:
Quoted 2 lines · On Sat, 2 Apr 2011 19:21:50 +0200 "Yann E. MORIN"…
Quoted 1 line
+ifneq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
^^^^^^
Oh, that's an 'ifneq', not an 'ifeq'. Sorry for the noise...
Quoted 9 lines
Quoted 5 lines
linux/linux.mk ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) · line 136
Quoted 3 lines
linux/linux.mk +3
-0+ $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config) + $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config) +endifThis should be
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS, no?This is what I originally implemented, but I was told that using devtmpfs was easier even in the udev/mdev cases for the early boot part (i.e before udev/mdev are working).
So, unless I am totally mistaken, if one chooses devtmpfs with BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS, then devtmpfs is not forced in the kernel's .config.
So even if the user asks for a static /dev, he nonetheless gets a devtmpfs. So what's the point of having both options in BR?
The only difference is that, when _STATIC is selected, the user is offered a choice to specify a device_table, and not when _DEVTMPFS is selected.
What I really find confusing is the config prompts do not actually match the behavior. If I select 'static', I expect to get static, not dynamic (even if only the kernel is involved).
Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
package/busybox/S10mdev new file +4
-0+case "$1" in + start) + echo "Starting mdev..." + /sbin/mdev -sFrom
busybox/docs/mdev.txt:Here's a typical code snippet from the init script:
[0] mount -t proc proc /proc
[1] mount -t sysfs sysfs /sys
[2] echo/sbin/mdev>/proc/sys/kernel/hotplug
[3] mdev -s
Quoted 5 lines
Quoted 3 lines
I see that [2] is done in the kernel's .config. I find it non-obvious, and I would move that to the script above. It makes it easier to follow.
I guess that's a matter of taste. I have no strong opinion here.
At least, add a comment (in S10mdev, or in the config help) stating where the setup is done. I have no strong opinion either, it just took me a while to understand what was going on. And I find it more explicit to get related stuff grouped together when possible.
Quoted 7 lines
Quoted 3 lines
Also, I did not see where /dev is mounted (as a tmpfs). If / is a RO file system, then you can't use dynamic nodes, or you need a RW file system on /dev.
/dev is a devtmpfs filesystem, thanks to the kernel options that you highlighted above, and it is mounted automatically by the kernel thanks to the
CONFIG_DEVTMPFS_MOUNToption.
Right. I missed the ifneq, above...
Quoted 9 lines
Quoted 8 lines
package/busybox/S10mdev line 11
Quoted 2 lines
package/busybox/S10mdev new file +2
-0+ ;; + stop)For completeness:
echo "/bin/true" >/proc/sys/kernel/hotplugkillall mdev
sleep 2 # Leave it some time to proerly quit (adjust delay) killall -9 mdev
Quoted 3 lines
mdev is not a daemon (contrary to udev), so there's no point in killing it. It's a utility that the kernel runs where there are events to handle.
Yeah, right. 'mdev -s' is here to handle coldplug events. My bad.
Quoted 2 lines
So I don't think there's a lot of point in having the stop), restart) and reload) commands for mdev.
Forget my silly comment. So:
Reviewed by: "Yann E. MORIN" <[email protected]>
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/3 Create menu entry to select device creation method
Thomas, All,
Quoted 7 lines · On Sunday 03 April 2011 20:05:00 Yann E. MORIN wrote:
So, unless I am totally mistaken, if one chooses devtmpfs with
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS, then devtmpfs is not forced in the kernel's .config.So even if the user asks for a static /dev, he nonetheless gets a devtmpfs. So what's the point of having both options in BR?
Quoted 6 lines
The only difference is that, when
_STATICis selected, the user is offered a choice to specify adevice_table, and not when_DEVTMPFSis selected.What I really find confusing is the config prompts do not actually match the behavior. If I select 'static', I expect to get static, not dynamic (even if only the kernel is involved).
And forget the above, I forgot to delete it when I saw the 'ifneq' stuff.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 3/3 Allow several device tables and split in two parts our device table
In reply to Thomas PetazzoniQuoted 5 lines · 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.
Quoted 8 lines
We take this opportunity to move the documentation of the device table format in a common location, package/makedevs/README.
Signed-off-by Thomas Petazzoni <[email protected]>---
?fs/Config.in ? ? ? ? ? ? ? ? ? ? ? ?| ? 20 +++- ?fs/common.mk ? ? ? ? ? ? ? ? ? ? ? ?| ? 14 ++- ?package/makedevs/README ? ? ? ? ? ? | ? 35 +++++++
The source file makedevs.c also contains some documentation, with more examples. I think it would be best to keep just one: either the README file (expanded with the documentation in the sources), or the source documentation.
Best regards,
Thomas
Quoted 6 lines
?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 100644target/generic/device_table_dev.txt