| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2024 Karel Zak <[email protected]> |
| 5 |
# |
| 6 |
# This file is part of util-linux. |
| 7 |
# |
| 8 |
# This file is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 2 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This file is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
TS_TOPDIR="${0%/*}/../.." |
| 19 |
TS_DESC="X-mount.nocanonicalize" |
| 20 |
|
| 21 |
. "$TS_TOPDIR"/functions.sh |
| 22 |
ts_init "$*" |
| 23 |
|
| 24 |
ts_check_test_command "$TS_CMD_MOUNT" |
| 25 |
ts_check_test_command "$TS_CMD_UMOUNT" |
| 26 |
ts_check_test_command "$TS_CMD_FINDMNT" |
| 27 |
|
| 28 |
ts_skip_nonroot |
| 29 |
|
| 30 |
[ "$("$TS_HELPER_SYSINFO" fsopen-ok)" == "1" ] || ts_skip "no fs-API" |
| 31 |
|
| 32 |
[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT |
| 33 |
|
| 34 |
SYMLINK_A="$TS_OUTDIR/${TS_TESTNAME}-symlink-A" |
| 35 |
SYMLINK_B="$TS_OUTDIR/${TS_TESTNAME}-symlink-B" |
| 36 |
|
| 37 |
FILE_A="$TS_OUTDIR/${TS_TESTNAME}-file-A" |
| 38 |
FILE_B="$TS_OUTDIR/${TS_TESTNAME}-file-B" |
| 39 |
|
| 40 |
rm -f $FILE_A $FILE_B $SYMLINK_A $SYMLINK_B |
| 41 |
|
| 42 |
echo "A-data" > $FILE_A |
| 43 |
echo "B-data" > $FILE_B |
| 44 |
|
| 45 |
ln -s $FILE_A $SYMLINK_A |
| 46 |
ln -s $FILE_B $SYMLINK_B |
| 47 |
|
| 48 |
|
| 49 |
# Symlink converted to file |
| 50 |
# |
| 51 |
ts_init_subtest "file-over-symlink" |
| 52 |
$TS_CMD_MOUNT -o X-mount.nocanonicalize --bind $FILE_A $SYMLINK_B >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 53 |
udevadm settle |
| 54 |
cat $SYMLINK_B >> $TS_OUTPUT |
| 55 |
stat -c '%F' $SYMLINK_B >> $TS_OUTPUT |
| 56 |
$TS_CMD_UMOUNT $SYMLINK_B >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 57 |
ts_finalize_subtest |
| 58 |
|
| 59 |
# File converted to symlink |
| 60 |
# |
| 61 |
ts_init_subtest "symlink-over-file" |
| 62 |
$TS_CMD_MOUNT -o X-mount.nocanonicalize --bind $SYMLINK_A $FILE_B >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 63 |
udevadm settle |
| 64 |
cat $FILE_B >> $TS_OUTPUT |
| 65 |
stat -c '%F' $FILE_B >> $TS_OUTPUT |
| 66 |
$TS_CMD_UMOUNT $FILE_B >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 67 |
ts_finalize_subtest |
| 68 |
|
| 69 |
# Symlink converted to another symlink |
| 70 |
# |
| 71 |
ts_init_subtest "symlink-over-symlink" |
| 72 |
$TS_CMD_MOUNT -o X-mount.nocanonicalize --bind $SYMLINK_A $SYMLINK_B >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 73 |
udevadm settle |
| 74 |
cat $SYMLINK_B >> $TS_OUTPUT |
| 75 |
stat -c '%F' $SYMLINK_B >> $TS_OUTPUT |
| 76 |
$TS_CMD_UMOUNT $SYMLINK_B >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 77 |
ts_finalize_subtest |
| 78 |
|
| 79 |
|
| 80 |
ts_finalize |