]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/mount/rlimit
2eaeb501bee8d5cd64ea4b552a33e7e948f430d2
4 # Copyright (C) 2007 Karel Zak <kzak@redhat.com>
6 # This file is part of util-linux.
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.
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.
20 # The /etc/mtab file should not be modified if RLIMIT_FSIZE (ulimit -f)
21 # is too low, otherwise the file could be corrupted (incomplete write).
22 # The [u]mount(8) has to block SIGXFSZ and check if all writes and fflush
23 # calls are successful.
26 TS_TOPDIR
="${0%/*}/../.."
27 TS_DESC
="rlimit-fsize"
29 .
$TS_TOPDIR/functions.sh
32 ts_check_test_command
"$TS_CMD_MOUNT"
33 ts_check_test_command
"$TS_CMD_UMOUNT"
34 ts_check_prog
"mkfs.ext3"
39 [ -L /etc
/mtab
] && ts_skip
"mtab is symlink"
40 [ "$(stat --format '%s' /etc/mtab)" -gt "1024" ] || ts_skip
"mtab is too small"
44 function mtab_checksum
()
46 md5sum /etc
/mtab |
awk '{printf $1}'
49 DEVICE
=$
(ts_device_init
)
50 [ "$?" == 0 ] || ts_die
"Cannot init device"
52 mkfs.ext3
$DEVICE &> /dev
/null || ts_die
"Cannot make ext3 on $DEVICE" $DEVICE
55 ts_init_subtest
"mount"
56 OLD_SUM
=$
(mtab_checksum
)
57 [ -d "$TS_MOUNTPOINT" ] || mkdir
-p $TS_MOUNTPOINT
60 $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT
62 NEW_SUM
=$
(mtab_checksum
)
63 [ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by mount" >> $TS_OUTPUT
64 ts_is_mounted
$DEVICE || ts_die
"Cannot find $DEVICE in /proc/mounts"
65 $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev
/null
66 ts_is_mounted
$DEVICE && ts_die
"$DEVICE is still mounted"
70 ts_init_subtest
"umount"
71 [ -d "$TS_MOUNTPOINT" ] || mkdir
-p $TS_MOUNTPOINT
72 $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev
/null
73 ts_is_mounted
$DEVICE || ts_die
"Cannot find $DEVICE in /proc/mounts"
74 OLD_SUM
=$
(mtab_checksum
)
77 $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev
/null
79 NEW_SUM
=$
(mtab_checksum
)
80 [ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by umount" >> $TS_OUTPUT
81 if ts_is_mounted
$DEVICE; then
82 echo "FAIL: $DEVICE is still mounted" >> $TS_OUTPUT
83 $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev
/null
86 $TS_CMD_UMOUNT --fake $TS_MOUNTPOINT &> /dev
/null
91 ts_device_deinit
$DEVICE