4 # this mimics function of buildroot's makedev
6 # <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>
8 DEBUG=${XMAKEDEV_DEBUG}
11 Usage: ${0##*/} file root
12 read file, and make devs apropriately under 'root'.
15 <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>
16 where name is the file name, type can be one of:
19 c Character special device file
20 b Block special device file
25 error() { echo "$@" 1>&2; exit 1; }
26 fail() { [ $# -eq 0 ] || error "$@" ; exit 1; }
28 [ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; }
29 [ $# -eq 2 ] || { Usage 1>&2; exit 1; }
33 if [ "$1" != "-" ]; then
34 exec < "$1" || fail "failed to redirect input from $1"
38 local mode=$1 uid=$2 gid=$3
40 [ "$mode" = "-" ] || chmod "$mode" "$@" || return
41 [ "$uid" = "-" ] || chown "$uid" "$@" || return
42 [ "$gid" = "-" ] || chgrp "$gid" "$@" || return
52 cd "$root" || fail "failed cd $root"
56 [ -n "$line" ] || continue
59 name=$1; type=$2; mode=$3; uid=$4; gid=$5; major=$6; minor=$7; start=$8; inc=$9; count="${10}"
62 if iswild "$name"; then
64 iswild "$files" && fail "wildcards in wildcards: $files"
69 $DEBUG mkdir -p "${f%/*}" || fail "failed to make ${f%/*}";
71 $DEBUG touch $files &&
72 $DEBUG chmodchown "$mode" "$uid" "$gid" $files ||
73 fail "failed create file $files"
76 $DEBUG mkdir -p $files &&
77 $DEBUG chmodchown "$mode" "$uid" "$gid" $files ||
78 fail "failed create dir $files"
82 $DEBUG mkdir -p "${f%/*}" || fail "failed to make ${f%/*}";
84 if [ "$count" = "-" ]; then
85 $DEBUG mknod $files $type $major $minor ||
87 $DEBUG chmodchown "$mode" "$uid" "$gid" $files ||
88 fail "failed chmodchown '$mode' '$uid' '$gid' $files"
90 [ "$count" = "-" ] && count=1;
92 while [ $i -lt $count ]; do
94 $DEBUG mknod "$fname" "$type" "$major" "$(($minor+($i*$inc)))"
95 $DEBUG chmodchown "$fname" "$mode" "$uid" "$gid"