This commit removes --enable-libmount-support-mtab.
The classic /etc/mtab is broken by design. It does not support
namespaces, chroots, etc. The only sane way to keep track of
mounted filesystems is to ask the kernel. It's a bad idea to maintain
a mount table in userspace.
Signed-off-by: Karel Zak <kzak@redhat.com>
[], [enable_libmount_support_mtab=no]
)
-AS_IF([test "x$enable_libmount_support_mtab" = xyes], [
- AC_DEFINE([USE_LIBMOUNT_SUPPORT_MTAB], [1], [Define to 1 if want to support mtab.])
-])
-
dnl
dnl libsmartcols
dnl
assert(cxt);
-#ifdef USE_LIBMOUNT_SUPPORT_MTAB
- if (!cxt->mtab_path) {
- cxt->mtab_path = mnt_get_mtab_path();
- DBG(CXT, ul_debugobj(cxt, "mtab path initialized to: %s", cxt->mtab_path));
- }
-#endif
if (!cxt->utab_path) {
cxt->utab_path = mnt_get_utab_path();
DBG(CXT, ul_debugobj(cxt, "utab path initialized to: %s", cxt->utab_path));
if (!ns_old)
return -MNT_ERR_NAMESPACE;
-#ifdef USE_LIBMOUNT_SUPPORT_MTAB
- mnt_has_regular_mtab(&cxt->mtab_path, &cxt->mtab_writable);
- if (!cxt->mtab_writable)
-#endif
- /* use /run/mount/utab if /etc/mtab is useless */
- mnt_has_regular_utab(&cxt->utab_path, &cxt->utab_writable);
+ mnt_has_regular_utab(&cxt->utab_path, &cxt->utab_writable);
if (!mnt_context_switch_ns(cxt, ns_old))
return -MNT_ERR_NAMESPACE;
} else
res = do_mount_by_pattern(cxt, cxt->fstype_pattern);
-#ifdef USE_LIBMOUNT_SUPPORT_MTAB
- if (mnt_context_get_status(cxt)
- && !mnt_context_is_fake(cxt)
- && !cxt->helper
- && mnt_context_mtab_writable(cxt)) {
-
- int is_rdonly = -1;
-
- DBG(CXT, ul_debugobj(cxt, "checking for RDONLY mismatch"));
-
- /*
- * Mounted by mount(2), do some post-mount checks
- *
- * Kernel can be used to use MS_RDONLY for bind mounts, but the
- * read-only request could be silently ignored. Check it to
- * avoid 'ro' in mtab and 'rw' in /proc/mounts.
- */
- if ((cxt->mountflags & MS_BIND)
- && (cxt->mountflags & MS_RDONLY)) {
-
- if (is_rdonly < 0)
- is_rdonly = mnt_is_readonly(mnt_context_get_target(cxt));
- if (!is_rdonly)
- mnt_context_set_mflags(cxt, cxt->mountflags & ~MS_RDONLY);
- }
-
-
- /* Kernel can silently add MS_RDONLY flag when mounting file
- * system that does not have write support. Check this to avoid
- * 'ro' in /proc/mounts and 'rw' in mtab.
- */
- if (!(cxt->mountflags & (MS_RDONLY | MS_MOVE))
- && !mnt_context_propagation_only(cxt)) {
-
- if (is_rdonly < 0)
- is_rdonly = mnt_is_readonly(mnt_context_get_target(cxt));
- if (is_rdonly)
- mnt_context_set_mflags(cxt, cxt->mountflags | MS_RDONLY);
- }
- }
-#endif
-
/* Cleanup will be immediate on failure, and deferred to umount on success */
if (mnt_context_is_veritydev(cxt))
mnt_context_deferred_delete_veritydev(cxt);
if (filename)
DBG(TAB, ul_debugobj(tb, "%s requested as mtab", filename));
-#ifdef USE_LIBMOUNT_SUPPORT_MTAB
- if (mnt_has_regular_mtab(&filename, NULL)) {
-
- DBG(TAB, ul_debugobj(tb, "force mtab usage [filename=%s]", filename));
-
- rc = mnt_table_parse_file(tb, filename);
-
- /*
- * If @filename forces us to read from /proc then also read
- * utab file to merge userspace mount options.
- */
- if (rc == 0 && is_mountinfo(tb))
- goto read_utab;
-
- if (!rc)
- return 0;
- filename = NULL; /* failed */
- } else
- filename = NULL; /* mtab useless */
-#endif
-
if (!filename || strcmp(filename, _PATH_PROC_MOUNTINFO) == 0) {
filename = _PATH_PROC_MOUNTINFO;
tb->fmt = MNT_FMT_MOUNTINFO;
if (!is_mountinfo(tb))
return 0;
-#ifdef USE_LIBMOUNT_SUPPORT_MTAB
-read_utab:
-#endif
DBG(TAB, ul_debugobj(tb, "mtab parse: #2 read utab"));
if (mnt_table_get_nents(tb) == 0)
/* detect tab filename -- /etc/mtab or /run/mount/utab
*/
-#ifdef USE_LIBMOUNT_SUPPORT_MTAB
- mnt_has_regular_mtab(&path, &rw);
-#endif
- if (!rw) {
- path = NULL;
- mnt_has_regular_utab(&path, &rw);
- if (!rw)
- return -EACCES;
- upd->userspace_only = TRUE;
- }
+ path = NULL;
+ mnt_has_regular_utab(&path, &rw);
+ if (!rw)
+ return -EACCES;
+ upd->userspace_only = TRUE;
upd->filename = strdup(path);
if (!upd->filename)
return -ENOMEM;
#ifdef HAVE_CRYPTSETUP
"verity",
#endif
-#ifdef USE_LIBMOUNT_SUPPORT_MTAB
- "mtab",
-#endif
#ifdef USE_LIBMOUNT_SUPPORT_NAMESPACES
"namespaces",
#endif
fi
}
-function ts_has_mtab_support {
- grep -q '#define USE_LIBMOUNT_SUPPORT_MTAB' ${top_builddir}/config.h
- if [ $? == 0 ]; then
- echo "yes"
- else
- echo "no"
- fi
-}
-
function ts_has_ncurses_support {
grep -q '#define HAVE_LIBNCURSES' ${top_builddir}/config.h
if [ $? == 0 ]; then
ts_scsi_debug_init dev_size_mb=100
DEVNAME=$(basename $TS_DEVICE)
-MOUNTINFO_ONLY=yes
-has_mtab=$( ts_has_mtab_support )
-if [ "$has_mtab" == "yes" ]; then
- MOUNTINFO_ONLY=no
-fi
-
ts_log "Create partitions"
$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
o
ts_log "Do tests..."
-export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
-> $LIBMOUNT_MTAB
-
-# check local mtab of system mountinfo
function is_mounted {
- if [ "$MOUNTINFO_ONLY" = "yes" ]; then
- ts_is_mounted "$1"
- return $?
- fi
- grep -q "$1" $LIBMOUNT_MTAB && return 0
- return 1
+ ts_is_mounted "$1"
+ return $?
}
ts_scsi_debug_init dev_size_mb=100
DEVNAME=$(basename $TS_DEVICE)
-MOUNTINFO_ONLY=yes
-has_mtab=$( ts_has_mtab_support )
-if [ "$has_mtab" == "yes" ]; then
- MOUNTINFO_ONLY=no
-fi
-
ts_log "Create partitions"
$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
o
ts_log "Do tests..."
-export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
-> $LIBMOUNT_MTAB
-
-# check local mtab of system mountinfo
function is_mounted {
- if [ "$MOUNTINFO_ONLY" = "yes" ]; then
- ts_is_mounted "$1"
- return $?
- fi
- grep -q "\(^\| \)$1 " $LIBMOUNT_MTAB && return 0
- return 1
+ ts_is_mounted "$1"
+ return $?
}
# redefined to subtest specific namespace -- it means that $TS_OUTPUT is a
# different file within a subtest.
#
-# - all this test uses global $TS_OUTPUT.{mtab,mountinfo}
-
-export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
-rm -f $LIBMOUNT_MTAB
-> $LIBMOUNT_MTAB
-
-
-#
-# Traditional /etc/mtab
-#
-has_mtab=$( ts_has_mtab_support )
-if [ "$has_mtab" == "yes" ]; then
-
- ts_init_subtest "mtab-mount"
- ts_run $TESTPROG --add /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec"
- ts_run $TESTPROG --add /dev/sdb1 /mnt/bar ext3 "gg=G,ffff=f,ro,noatime"
- ts_run $TESTPROG --add /dev/sda2 /mnt/bar ext3 "rw,noatime"
- ts_run $TESTPROG --add /dev/sda1 /mnt/gogo ext3 "rw,noatime,nosuid"
- ts_run $TESTPROG --add none /proc proc defaults
- cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
- ts_finalize_subtest # checks the mtab
-
- ts_init_subtest "mtab-move"
- ts_run $TESTPROG --move /mnt/foo /mnt/newfoo
- ts_run $TESTPROG --move /mnt/bar /mnt/newbar
- cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
- ts_finalize_subtest # checks the mtab
-
- ts_init_subtest "mtab-remount"
- ts_run $TESTPROG --remount /mnt/newfoo "ro,noatime"
- ts_run $TESTPROG --remount /mnt/bar "rw,atime,nosuid"
- cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
- ts_finalize_subtest # checks the mtab
-
- ts_init_subtest "mtab-umount"
- ts_run $TESTPROG --remove /mnt/bar
- ts_run $TESTPROG --remove /mnt/gogo
- ts_run $TESTPROG --remove /proc
- cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside
- ts_finalize_subtest # checks the mtab
-fi
+# - all this test uses global $TS_OUTPUT.mountinfo
#
# utab
#
-rm -f $LIBMOUNT_MTAB
-ln -s /proc/mounts $LIBMOUNT_MTAB
-
export LIBMOUNT_UTAB=$TS_OUTPUT.utab
rm -f $LIBMOUNT_UTAB
> $LIBMOUNT_UTAB
ts_run $TESTPROG --add /dev/sdb1 /mnt/bar ext3 "ro,user"
ts_run $TESTPROG --add /dev/sda2 /mnt/xyz ext3 "rw,loop=/dev/loop0,uhelper=hal"
ts_run $TESTPROG --add none /proc proc "rw,user"
-cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside
-ts_finalize_subtest # checks the mtab
+cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside
+ts_finalize_subtest # checks the utab
ts_init_subtest "utab-move"
ts_run $TESTPROG --move /mnt/bar /mnt/newbar
ts_run $TESTPROG --move /mnt/xyz /mnt/newxyz
-cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside
-ts_finalize_subtest # checks the mtab
+cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside
+ts_finalize_subtest # checks the utab
ts_init_subtest "utab-remount"
ts_run $TESTPROG --remount /mnt/newbar "ro,noatime"
ts_run $TESTPROG --remount /mnt/newxyz "rw,user"
-cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside
-ts_finalize_subtest # checks the mtab
+cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside
+ts_finalize_subtest # checks the utab
ts_init_subtest "utab-umount"
ts_run $TESTPROG --remove /mnt/newbar
ts_run $TESTPROG --remove /proc
-cp $LIBMOUNT_UTAB $TS_OUTPUT # save the mtab aside
-ts_finalize_subtest # checks the mtab
+cp $LIBMOUNT_UTAB $TS_OUTPUT # save the utab aside
+ts_finalize_subtest # checks the utab
#
# fstab - replace
DEVICE=$TS_LODEV
MTAB_FILE="/proc/mounts"
-has_mtab=$( ts_has_mtab_support )
-if [ "$has_mtab" == "yes" ]; then
- MTAB_FILE="/etc/mtab"
-fi
mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
DEVICE=$TS_LODEV
MTAB_FILE="/proc/mounts"
-has_mtab=$( ts_has_mtab_support )
-if [ "$has_mtab" == "yes" ]; then
- MTAB_FILE="/etc/mtab"
-fi
mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+++ /dev/null
-#!/bin/bash
-
-#
-# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
-#
-# This file is part of util-linux.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This file is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-
-#
-# The /etc/mtab file should not be modified if RLIMIT_FSIZE (ulimit -f)
-# is too low, otherwise the file could be corrupted (incomplete write).
-# The [u]mount(8) has to block SIGXFSZ and check if all writes and fflush
-# calls are successful.
-#
-
-TS_TOPDIR="${0%/*}/../.."
-TS_DESC="rlimit-fsize"
-
-. $TS_TOPDIR/functions.sh
-ts_init "$*"
-
-ts_check_test_command "$TS_CMD_MOUNT"
-ts_check_test_command "$TS_CMD_UMOUNT"
-ts_check_test_command "$TS_HELPER_MD5"
-
-ts_skip_nonroot
-ts_check_losetup
-ts_check_prog "mkfs.ext2"
-
-has_mtab=$( ts_has_mtab_support )
-[ "$has_mtab" == "yes" ] || ts_skip "mtab unsupported"
-
-[ -L /etc/mtab ] && ts_skip "mtab is symlink"
-[ "$(stat --format '%s' /etc/mtab)" -gt "1024" ] || ts_skip "mtab is too small"
-
-function mtab_checksum()
-{
- "$TS_HELPER_MD5" < /etc/mtab
-}
-
-ts_device_init
-DEVICE=$TS_LODEV
-
-mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
-
-
-ts_init_subtest "mount"
-OLD_SUM=$(mtab_checksum)
-[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
-(
- ulimit -f 1
- $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT
-) &> /dev/null
-NEW_SUM=$(mtab_checksum)
-[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by mount" >> $TS_OUTPUT
-ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
-$TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
-ts_is_mounted $DEVICE && ts_die "$DEVICE is still mounted"
-ts_finalize_subtest
-
-
-ts_init_subtest "umount"
-[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
-$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null
-ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
-OLD_SUM=$(mtab_checksum)
-(
- ulimit -f 1
- $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
-) &> /dev/null
-NEW_SUM=$(mtab_checksum)
-[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by umount" >> $TS_OUTPUT
-if ts_is_mounted $DEVICE; then
- echo "FAIL: $DEVICE is still mounted" >> $TS_OUTPUT
- $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
-else
- # repair /etc/mtab
- $TS_CMD_UMOUNT --fake $TS_MOUNTPOINT &> /dev/null
-fi
-ts_finalize_subtest
-
-ts_log "Success"
-ts_finalize
$TS_CMD_UMOUNT --help | grep -q all-targets
[ $? -eq 1 ] && ts_skip "all-targets unsupported"
-has_mtab=$( ts_has_mtab_support )
-if [ "$has_mtab" == "yes" ]; then
- [ -L /etc/mtab ] || ts_skip "regular mtab"
-fi
-
# set global variable TS_DEVICE
ts_scsi_debug_init dev_size_mb=50