blob: 1e719a4a51060297c83a7e1ccfc2f6a46bd63659 (
plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
#!/bin/bash
#
# Copyright (C) 2022 Masatake YAMATO <yamato@redhat.com>
#
# This file is part of util-linux.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
TS_TOPDIR="${0%/*}/../.."
TS_DESC="MODE and XMODE columns"
. "$TS_TOPDIR"/functions.sh
ts_init "$*"
. "$TS_SELF/lsfd-functions.bash"
ts_check_test_command "$TS_CMD_LSFD"
ts_check_test_command "$TS_HELPER_MKFDS"
ts_check_prog "stat"
ts_cd "$TS_OUTDIR"
INO=$(stat -c '%i' "$TS_HELPER_MKFDS")
PID=
FD=3
EXPR="(FD == 3)"
ts_init_subtest "MODE-r-bit"
{
coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
echo "MODE(r-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
ts_init_subtest "XMODE-r-bit"
{
coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(r-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
EXPR="(FD == $((FD + 1)))"
ts_init_subtest "MODE-w-bit"
{
coproc MKFDS { "$TS_HELPER_MKFDS" pipe-no-fork $FD $((FD + 1)); }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
echo "MODE(w-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
ts_init_subtest "XMODE-w-bit"
{
coproc MKFDS { "$TS_HELPER_MKFDS" pipe-no-fork $FD $((FD + 1)); }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(w-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
EXPR='(ASSOC == "mem") and (INODE == '"$INO"') and (MODE != "r--") and (MODE != "rw-") and (MODE != "rwx")'
ts_init_subtest "MODE-x-bit"
if [ "$QEMU_USER" == "1" ]; then
ts_skip_subtest "running under qemu-user emulation"
else
{
coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
echo "MODE(x-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
fi
ts_init_subtest "XMODE-x-bit"
if [ "$QEMU_USER" == "1" ]; then
ts_skip_subtest "running under qemu-user emulation"
else
{
coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(x-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
fi
FILE=./test_mkfds_make_regular_file
EXPR='(FD == '"$FD"')'
ts_init_subtest "XMODE-D-bit"
{
rm -f "${FILE}"
coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" delete=1; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(D-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
for m in flock-sh posix-r- ofd-r-; do
ts_init_subtest "XMODE-l-bit-$m"
{
rm -f "${FILE}"
coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(l-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "$m lock is not available"
continue
fi
ts_finalize_subtest
done
ts_init_subtest "XMODE-l-bit-lease-r"
f=ro-regular-file-read-lease
touch "$f"
{
coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD file=$f read-lease=1; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(l-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
rm -f "$f"
ts_finalize_subtest
for m in flock-ex posix--w posix-rw ofd--w ofd-rw lease-w; do
ts_init_subtest "XMODE-L-bit-$m"
{
rm -f "${FILE}"
coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(L-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
ts_skip_subtest "$m lock is not available"
continue
fi
ts_finalize_subtest
done
M0=6
M1=9
EXPR="(FD == $M0) or (FD == $M1)"
ts_init_subtest "XMODE-m-bit"
{
coproc MKFDS { "$TS_HELPER_MKFDS" eventpoll $FD $M0 $M1; }
if read -r -u "${MKFDS[0]}" PID; then
"${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
echo "XMODE(m-bit): " $?
echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
ts_finalize_subtest
ts_finalize
|