-
Notifications
You must be signed in to change notification settings - Fork 3
/
hello.sh
executable file
·72 lines (60 loc) · 1.09 KB
/
hello.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
. ./booze.sh
booze_getattr()
{
local now=`date +%s`
local times="$now $now $now"
local ids="`id -u` `id -g`"
if [ "$1" == "/" ]; then
booze_out="0 $(printf '%o' $((S_IFDIR | 0755))) 2 $ids 0 0 0 $times"
return 0
elif [ "$1" == "/booze" ]; then
booze_out="1 $(printf '%o' $((S_IFREG | 0644))) 1 $ids 0 7 1 $times"
return 0
else
booze_err=-$ENOENT
return 1
fi
}
booze_readdir()
{
booze_out="./../booze"
return 0
}
booze_open()
{
if [ "$1" == "/booze" ]; then
return 0
else
booze_err=-$ENOENT
return 1
fi
}
file=$'Booze!\n'
booze_read()
{
if [ "$1" != "/booze" ]; then
booze_err=-$ENOENT
return 1
fi
local readlen="$2"
local offset="$3"
local filelen="${#file}"
if [ "$offset" -lt "$filelen" ]; then
if [ "$((offset + readlen))" -gt "$filelen" ]; then
readlen="$((filelen - offset))"
fi
data="${file:offset:readlen}"
else
data=""
fi
printf "%s" "$data"
return 0
}
declare -A booze_ops
for name in ${BOOZE_CALL_NAMES[@]}; do
if [ "`type -t booze_$name`" == "function" ]; then
booze_ops[$name]=booze_$name
fi
done
booze booze_ops "$1"