wok-current view linux-source/stuff/rdev @ rev 19227

pinentry, pinentry-gtk: update bdeps
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jun 23 02:28:12 2016 +0300 (2016-06-23)
parents 4d8ac8a31cab
children 8144275286f2
line source
1 #!/bin/sh
3 dev()
4 {
5 for b in $(find /dev -type b); do
6 [ $(stat -c %02t%02T $b) = $1 ] && echo $b && return
7 done
8 echo 0x$1
9 }
11 s=
12 case "$0" in
13 *gs) s=-R;;
14 *ze) s=-r;;
15 *de) s=-v
16 esac
17 set -- $s "$@"
19 o=508
20 i=
21 v=
22 f=
23 while [ -n "$1" ]; do
24 case "$1" in
25 -R) o=498; f="Root flags";;
26 -r) o=504; f="Ramsize";;
27 -v) o=506; f="Video mode";;
28 -o) o=$(($2)); f=" "; shift;;
29 -*) echo "Usage: rdev [-Rrvh] [-o offset] [kernel [data [offset]]]"
30 exit 1;;
31 *) if [ -z "$i" ]; then
32 i="$1"
33 elif [ -z "$v" ]; then
34 [ -b "$1" ] && v=0x$(stat -c %t%02T $1)
35 v=$((${v:-$1}))
36 else
37 o=$(($1))
38 fi
39 esac
40 shift
41 done
43 dd="dd bs=1 conv=notrunc count=2"
44 if [ ! -s "$i" ]; then
45 echo $(dev $(stat -c %04D /)) /
46 elif [ -n "$v" ]; then
47 for i in 1 2; do
48 printf '\\\\x%02X' $(($v&255))
49 v=$(($v>>8))
50 done | xargs echo -en | $dd of=$i seek=$o
51 elif [ -n "$f" ]; then
52 echo $f $($dd if=$i skip=$o | od -dAn)
53 else
54 echo "Root device $(dev $($dd if=$i skip=$o | od -xAn))"
55 fi 2>/dev/null