[oe-commits] Richard Tollerton : udev-cache: omit sockets and filesystems mounted under /dev

git at git.openembedded.org git at git.openembedded.org
Sat Aug 23 22:02:47 UTC 2014


Module: openembedded-core.git
Branch: master-next
Commit: e89df123e2ec516ae61763eab3c9e78e067e28d5
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=e89df123e2ec516ae61763eab3c9e78e067e28d5

Author: Richard Tollerton <rich.tollerton at ni.com>
Date:   Fri Aug 22 16:30:52 2014 -0500

udev-cache: omit sockets and filesystems mounted under /dev

Archiving sockets causes tar to report an error and return a nonzero
exit status. Archiving a mounted filesystem is harmless, but may greatly
bloat the size of the cache tarball, and wastes time on boot.

To fix these issues, use `find` to only include the files we want, which
are the file types that udev will create (block/char devices and
symlinks) that are on the same filesystem as /dev.

While we're at it, remove a subshell by archiving /dev as an absolute
path. However, `tar` will complain about stripping the leading slash on
stderr. To inhibit this, `cut` out the leading slash.

An alternative solution is to use `tar --exclude`, but that is modestly
more brittle, since we'd need to explicitly list every socket and
filesystem to exclude. Note that `tar --one-file-system` is
GNU-specific, and tar implementations generally have nothing equivalent
to `find -type`.

If using busybox `find`, this change requires CONFIG_FEATURE_FIND_TYPE=y
and CONFIG_FEATURE_FIND_XDEV=y. If using busybox `tar`, this change
requires CONFIG_FEATURE_TAR_FROM=y.

Signed-off-by: Richard Tollerton <rich.tollerton at ni.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/recipes-core/udev/udev/udev-cache | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index ec07f50..aaf1ddd 100644
--- a/meta/recipes-core/udev/udev/udev-cache
+++ b/meta/recipes-core/udev/udev/udev-cache
@@ -26,7 +26,8 @@ fi
 
 if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then
 	echo "Populating dev cache"
-	(cd /; tar cf "${DEVCACHE_TMP}" dev)
+	find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \
+		| xargs tar cf "${DEVCACHE_TMP}" -T-
 	gzip < "${DEVCACHE_TMP}" > "$DEVCACHE"
 	rm -f "${DEVCACHE_TMP}"
 	mv /dev/shm/udev.cache /etc/udev/cache.data



More information about the Openembedded-commits mailing list