kbuild: add support for squashing uid/gid in gen_initramfs_list.sh

Sometimes it is useful to squash all uid's/gid's to 0:0 regardless of
current owner.  For example, in build systems that get run as arbitrary
users (uClinux-dist).  This adds a special "squash" keyword so you can do
'-g squash -u squash' and have ownership squashed to root.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Mike Frysinger 2007-05-10 22:44:28 -07:00 committed by Sam Ravnborg
parent f2434ec1e0
commit 4c6f2eb979

View file

@ -19,11 +19,11 @@ $0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
-o <file> Create gzipped initramfs file named <file> using -o <file> Create gzipped initramfs file named <file> using
gen_init_cpio and gzip gen_init_cpio and gzip
-u <uid> User ID to map to user ID 0 (root). -u <uid> User ID to map to user ID 0 (root).
<uid> is only meaningful if <cpio_source> <uid> is only meaningful if <cpio_source> is a
is a directory. directory. "squash" forces all files to uid 0.
-g <gid> Group ID to map to group ID 0 (root). -g <gid> Group ID to map to group ID 0 (root).
<gid> is only meaningful if <cpio_source> <gid> is only meaningful if <cpio_source> is a
is a directory. directory. "squash" forces all files to gid 0.
<cpio_source> File list or directory for cpio archive. <cpio_source> File list or directory for cpio archive.
If <cpio_source> is a .cpio file it will be used If <cpio_source> is a .cpio file it will be used
as direct input to initramfs. as direct input to initramfs.
@ -113,8 +113,8 @@ parse() {
local gid="$4" local gid="$4"
local ftype=$(filetype "${location}") local ftype=$(filetype "${location}")
# remap uid/gid to 0 if necessary # remap uid/gid to 0 if necessary
[ "$uid" -eq "$root_uid" ] && uid=0 [ "$root_uid" = "squash" ] && uid=0 || [ "$uid" -eq "$root_uid" ] && uid=0
[ "$gid" -eq "$root_gid" ] && gid=0 [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0
local str="${mode} ${uid} ${gid}" local str="${mode} ${uid} ${gid}"
[ "${ftype}" == "invalid" ] && return 0 [ "${ftype}" == "invalid" ] && return 0