1#!/bin/sh 2# Ensure that df dereferences symlinks to file system nodes 3 4# Copyright (C) 2013-2023 Free Software Foundation, Inc. 5 6# This program is free software: you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation, either version 3 of the License, or 9# (at your option) any later version. 10 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <https://www.gnu.org/licenses/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ df 21 22file_system=$(df --out=source '.' | tail -n1) || 23 skip_ "cannot determine '.' file system" 24 25ln -s "$file_system" symlink || framework_failure_ 26 27df --out=source,target "$file_system" > exp || 28 skip_ "cannot get info for $file_system" 29df --out=source,target symlink > out || fail=1 30compare exp out || fail=1 31 32# Ensure we output the same values for device nodes and '.' 33# This was not the case in coreutils-8.22 on systems 34# where the device in the mount list was a symlink itself. 35# I.e., '.' => /dev/mapper/fedora-home -> /dev/dm-2 36# Restrict this test to systems with a 1:1 mapping between 37# source and target. This excludes for example BTRFS sub-volumes. 38if test "$(df --output=source | grep -F "$file_system" | wc -l)" = 1; then 39 # Restrict to systems with a single file system root (and have findmnt(1)) 40 if test "$(findmnt -nro FSROOT | uniq | wc -l)" = 1; then 41 df --out=source,target '.' > out || fail=1 42 compare exp out || fail=1 43 fi 44fi 45 46test "$fail" = 1 && dump_mount_list_ 47 48Exit $fail 49