Util-Linux package development
 help / color / mirror / Atom feed
From: Ruediger Meier <sweet_f_a@gmx.de>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: about test mount/rlimit
Date: Thu, 2 Apr 2015 12:05:20 +0200	[thread overview]
Message-ID: <201504021205.21264.sweet_f_a@gmx.de> (raw)
In-Reply-To: <20150402083349.GD2097@ws.net.home>

On Thursday 02 April 2015, Karel Zak wrote:
> On Wed, Apr 01, 2015 at 02:04:27PM +0200, Ruediger Meier wrote:
> > ts_init_subtest "umount"
> > [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
> > $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null
> > OLD_SUM=$(mtab_checksum)
> > (
> >         ulimit -f 1
> >         $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
> > ) &> /dev/null
> > NEW_SUM=$(mtab_checksum)
> > $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
> > [ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by umount" >>
> > $TS_OUTPUT
> > ts_finalize_subtest
> > ...........
> >
> > I do not fully understand what is expected. Obviously the first
> > "umount" should NOT modify /etc/mtab. But should it umount or not,
> > or doesn't matter? Why we call a second umount then?
>
> I guess the second umount is just copy & past (from mount test) and

Ah, now it makes sense. So the first umount should work and we could
check "ismounted" too.
BTW could it be that in past "umount" always removed the mtab entry
like "--fake" still does for umounted devices?

> it's there to be sure that the device has been really unmounted (and
> this is unnecessary because ts_device_deinit() calls umount too).


> > The problem is that in case that the first umount works we are
> > leaving the test with a broken mtab file. This is not nice and also
> > problematic because later tests may find a mounted /dev/loop0 in
> > /etc/mtab.
>
> It would be probably better to replace the second umount with "umount
> --fake" to only remove entry from mtab.

Ah that's good. I'll send a patch with some other fixes later.
The umount part would look like this: 

 	$TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
 ) &> /dev/null
 NEW_SUM=$(mtab_checksum)
-$TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
 [ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by umount" >> $TS_OUTPUT
+ts_is_mounted $DEVICE && echo "FAIL: $DEVICE is still mounted" >> $TS_OUTPUT
+# repair /etc/mtab
+$TS_CMD_UMOUNT --fake $TS_MOUNTPOINT &> /dev/null
+ts_is_mounted $DEVICE && ts_die "$DEVICE is still mounted"
 ts_finalize_subtest

> > Should we restore the original mtab? I guess it's a bit unsafe to
> > copy back a backed up one. Or is there a way to "repair/sync"
> > from /proc/mounts.?
>
> Don't use /proc/mounts. It's bad idea as the files maybe very
> different.
>
> use the --fake or you can try to redirect libmount to use
> non-standard mtab by env. variable LIBMOUNT_MTAB=, but it will
> increase complexity of the test.
>
>     Karel

  reply	other threads:[~2015-04-02 10:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 12:04 about test mount/rlimit Ruediger Meier
2015-04-02  8:33 ` Karel Zak
2015-04-02 10:05   ` Ruediger Meier [this message]
2015-04-02 10:41     ` Ruediger Meier
2015-04-02 10:57     ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201504021205.21264.sweet_f_a@gmx.de \
    --to=sweet_f_a@gmx.de \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox