1#!/bin/sh
2# Ensure that df dereferences symlinks to disk nodes
3
4# Copyright (C) 2013-2018 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
22disk=$(df --out=source '.' | tail -n1) ||
23  skip_ "cannot determine '.' file system"
24
25ln -s "$disk" symlink || framework_failure_
26
27df --out=source,target "$disk" > exp || skip_ "cannot get info for $disk"
28df --out=source,target symlink > out || fail=1
29compare exp out || fail=1
30
31# Ensure we output the same values for device nodes and '.'
32# This was not the case in coreutil-8.22 on systems
33# where the device in the mount list was a symlink itself.
34# I.e., '.' => /dev/mapper/fedora-home -> /dev/dm-2
35# Restrict this test to systems with a 1:1 mapping between
36# source and target.  This excludes for example BTRFS sub-volumes.
37if test "$(df --output=source | grep -F "$disk" | wc -l)" = 1; then
38  df --out=source,target '.' > out || fail=1
39  compare exp out || fail=1
40fi
41
42test "$fail" = 1 && dump_mount_list_
43
44Exit $fail
45