2007-05-22 16:06:24 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2007-07-20 14:43:49 +02:00
|
|
|
#
|
2007-05-22 16:06:24 +02:00
|
|
|
# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
|
2007-07-20 14:43:49 +02:00
|
|
|
#
|
2010-11-30 11:41:59 +01:00
|
|
|
# This file is part of util-linux.
|
2007-07-20 14:43:49 +02:00
|
|
|
#
|
2007-05-22 16:06:24 +02:00
|
|
|
# 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
|
2007-07-20 14:43:49 +02:00
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
2007-05-22 16:06:24 +02:00
|
|
|
# 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.
|
|
|
|
#
|
2014-02-16 23:54:14 +00:00
|
|
|
TS_TOPDIR="${0%/*}/../.."
|
2009-01-20 00:50:01 +01:00
|
|
|
TS_DESC="by label (fstab)"
|
2007-05-22 16:06:24 +02:00
|
|
|
LABEL="testFstabLabel"
|
|
|
|
|
2009-01-20 00:50:01 +01:00
|
|
|
. $TS_TOPDIR/functions.sh
|
2007-06-11 14:45:32 +02:00
|
|
|
ts_init "$*"
|
2007-05-22 16:06:24 +02:00
|
|
|
ts_skip_nonroot
|
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
DEVICE=$(ts_device_init)
|
|
|
|
[ "$?" == 0 ] || ts_die "Cannot init device"
|
|
|
|
|
2008-11-19 18:11:23 +00:00
|
|
|
mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2008-11-19 18:11:23 +00:00
|
|
|
ts_device_has "LABEL" $LABEL $DEVICE \
|
2011-08-17 11:51:19 -04:00
|
|
|
|| ts_die "Cannot find LABEL '$LABEL' on $DEVICE" $DEVICE
|
2007-05-22 16:06:24 +02:00
|
|
|
|
|
|
|
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
|
|
|
|
|
|
|
|
ts_fstab_add "LABEL=$LABEL"
|
|
|
|
|
2007-05-28 15:15:55 +02:00
|
|
|
# variant A)
|
2007-05-22 16:06:24 +02:00
|
|
|
$TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT
|
2011-08-17 11:51:19 -04:00
|
|
|
ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts" $DEVICE
|
2008-11-19 18:11:23 +00:00
|
|
|
$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE" $DEVICE
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2007-05-28 15:15:55 +02:00
|
|
|
# variant B)
|
|
|
|
$TS_CMD_MOUNT -L $LABEL 2>&1 >> $TS_OUTPUT
|
2011-08-17 11:51:19 -04:00
|
|
|
ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE
|
2008-11-19 18:11:23 +00:00
|
|
|
$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE
|
2007-05-22 16:06:24 +02:00
|
|
|
|
2007-05-28 15:15:55 +02:00
|
|
|
# variant C)
|
|
|
|
$TS_CMD_MOUNT LABEL=$LABEL 2>&1 >> $TS_OUTPUT
|
2011-08-17 11:51:19 -04:00
|
|
|
ts_is_mounted $DEVICE || ts_die "C) Cannot find $DEVICE in /proc/mounts" $DEVICE
|
2008-11-19 18:11:23 +00:00
|
|
|
$TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE" $DEVICE
|
2007-05-22 16:06:24 +02:00
|
|
|
|
|
|
|
ts_device_deinit $DEVICE
|
|
|
|
ts_fstab_clean
|
|
|
|
|
|
|
|
ts_log "Success"
|
|
|
|
ts_finalize
|
|
|
|
|