1#!/bin/sh 2# Prior to coreutils-6.5, an inaccessible destination dir (chmod a-x) 3# would cause du to exit prematurely on systems with native openat support. 4 5# Copyright (C) 2006-2023 Free Software Foundation, Inc. 6 7# This program is free software: you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation, either version 3 of the License, or 10# (at your option) any later version. 11 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <https://www.gnu.org/licenses/>. 19 20. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 21print_ver_ du 22skip_if_root_ 23 24mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \ 25 || framework_failure_ 26 27du > ../t 2>&1 && fail=1 28 29# Accept either of the following outputs. 30# You get the first from a system with openat _emulation_ (via /proc), 31# the second from a system with native openat support. 32# FIXME: there may well be a third output, for systems with neither 33# /proc support, nor native openat support. 34 35sed 's/^[0-9][0-9]* //' ../t | sort -u > out 36cat <<\EOF > exp || framework_failure_ 37. 38./a 39./b 40./c 41./d 42./e 43du: cannot read directory './c': Permission denied 44EOF 45 46# Map a diagnostic like this 47# du: cannot access './c/j': Permission denied 48# to this: 49# du: cannot access './c': Permission denied 50# And accept "cannot read directory" in place of "cannot access" 51sed "s,/c/j': ,/c': ," out > t && mv t out 52sed 's,cannot access,cannot read directory,' out > t && mv t out 53 54compare exp out || fail=1 55 56Exit $fail 57