public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Brabec <sbrabec@suse.cz>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: mount: "nofail" and already mounted devices?
Date: Thu, 09 Jan 2014 16:51:54 +0100	[thread overview]
Message-ID: <1389282714.8841.109.camel@oct.suse.cz> (raw)
In-Reply-To: <20140109100254.GD7516@x2.net.home>

Karel Zak wrote:
> On Wed, Jan 08, 2014 at 06:55:41PM +0100, Stanislav Brabec wrote:
> > Attempting to mount of already mounted devices is a common situation in
> > many scripts.
> 
> What about to fix the scripts? :-)
> 
> All you need is to call
> 
>     findmnt --source <dev> --target <mountpoint>

Yes, it is an option.

The new behavior could simplify common situation and also prevent a
race:
if the device is not yet mounted
   mount it
do the work

> > Would be acceptable a patch that adds "already mounted" to "nofail"?
> 
> Maybe.

Well, It could be a straightforward solution (~2 lines change). But it
could break following script (theoretical, a bit dumb and fragile, but
still depending only on documented behavior):

... do some actions that will initiate delayed $DEVICE creation ...
while mount -o nofail $DEVICE /opt ; do
  if test -d /opt/myvendor ; then
    break
  fi
  sleep 1
done

Now imagine, that somebody previously called:
mount $DEVICE /opt

What will happen with the current mount?
The script will fail as expected.

What will happen after such patch?
The script will enter to a dead loop.

> > - Make possible to use "-a" with further arguments.
> 
>   mount -a /foo /bar [...]
> 
> Right? 

Well, it sounds interesting as well, but I was thinking about
(conflicting):
mount -a /dev/device /mountpoint

It can be done both:

mount -a /foo /bar [...]
mount -A /dev/device /mountpoint

-A Do not report errors if the mount point is already used or device is
   already mounted.

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: sbrabec@suse.cz
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76


  reply	other threads:[~2014-01-09 15:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 17:55 mount: "nofail" and already mounted devices? Stanislav Brabec
2014-01-09 10:02 ` Karel Zak
2014-01-09 15:51   ` Stanislav Brabec [this message]
2014-01-09 16:21     ` 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=1389282714.8841.109.camel@oct.suse.cz \
    --to=sbrabec@suse.cz \
    --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