From: Andrew Morton <akpm@linux-foundation.org>
To: Philippe De Muyter <phdm@macqel.be>
Cc: linux-kernel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Dave Chinner <david@fromorbit.com>,
linux-fsdevel@vger.kernel.org, torvalds@linux-foundation.org,
Karel Zak <kzak@redhat.com>
Subject: Re: [PATCH PING] VFS: mount must return EACCES, not EROFS
Date: Tue, 8 Jul 2014 14:02:18 -0700 [thread overview]
Message-ID: <20140708140218.ce415094dd073a3ddbd98eeb@linux-foundation.org> (raw)
In-Reply-To: <20140703162919.GA16315@frolo.macqel>
On Thu, 3 Jul 2014 18:29:19 +0200 Philippe De Muyter <phdm@macqel.be> wrote:
> On Wed, Jul 02, 2014 at 12:46:51PM -0700, Andrew Morton wrote:
> > On Fri, 27 Jun 2014 10:20:58 +0200 Philippe De Muyter <phdm@macqel.be> wrote:
> >
> > > Currently, the initial mount of the root file system by the linux
> > > kernel fails with a cryptic message instead of being retried with
> > > the MS_RDONLY flag set, when the device is read-only and the
> > > combination of block driver and filesystem driver yields EROFS.
> > >
> > > I do not know if POSIX mandates that mount(2) must fail with EACCES, nor
> > > if linux aims to strict compliance with POSIX on that point. Consensus
> > > amongst the messages that I have read so far seems to show that linux
> > > kernel hackers feel that EROFS is a more appropriate error code than
> > > EACCES in that case.
> >
> > Isn't the core problem that "the combination of block driver and
> > filesystem driver yields EROFS"? That the fs should instead be
> > returning EACCESS in this case?
>
> Does POSIX or Linux mandate that it should ?
>
> >
> > What fs and block driver are we talking about here, anyway?
>
> The problem happened to me with a f2fs filesystem on a sd-card that was
> accidentally write-protected and that was put in a SD-card slot (mmc block
> driver).
>
> I retested using mount(8) with a similar now intentionnaly write-protected
> sd card in a usb reader (usb_storage driver ?) with vfat, f2fs and ext4
> filesystems with the following results :
>
> mywdesk:~ # strace -e mount mount /dev/sdb1 /mnt
> mount("/dev/sdb1", "/mnt", "vfat", MS_MGC_VAL, NULL) = -1 EROFS (Read-only file system)
> mount: /dev/sdb1 is write-protected, mounting read-only
> mount("/dev/sdb1", "/mnt", "vfat", MS_MGC_VAL|MS_RDONLY, NULL) = 0
> +++ exited with 0 +++
> mywdesk:~ # umount /mnt
> mywdesk:~ # strace -e mount mount -t f2fs /dev/sdb2 /mnt
> mount("/dev/sdb2", "/mnt", "f2fs", MS_MGC_VAL, NULL) = -1 EROFS (Read-only file system)
> mount: /dev/sdb2 is write-protected, mounting read-only
> mount("/dev/sdb2", "/mnt", "f2fs", MS_MGC_VAL|MS_RDONLY, NULL) = 0
> +++ exited with 0 +++
> mywdesk:~ # umount /mnt
> mywdesk:~ # strace -e mount mount /dev/sdb3 /mnt
> mount("/dev/sdb3", "/mnt", "ext4", MS_MGC_VAL, NULL) = -1 EROFS (Read-only file system)
> mount: /dev/sdb3 is write-protected, mounting read-only
> mount("/dev/sdb3", "/mnt", "ext4", MS_MGC_VAL|MS_RDONLY, NULL) = 0
> +++ exited with 0 +++
> mywdesk:~ #
>
> All three file-systems (vfat, f2fs & ext4) yield EROFS.
>
> I also quickly grepped for occurences of EROFS under fs/, and found no check
> to replace EROFS by EACCES,
> while the same grep under drivers/{block,cdrom,ide,md,memstick, mtd,
> s390/block,scsi,usb} gives plenty of "return -EROFS;"
>
> So, if no filesystem driver replaces EROFS by EACCES and many block drivers
> return EROFS, it seems to me that many combinations will yield EROFS.
hm. I'm thinking that in an ideal world, those block drivers will
return -EACCES rather than -EROFS. You open() a read-only device for
rw, you get "permission denied".
Al, speak to us.
next prev parent reply other threads:[~2014-07-08 21:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 16:12 [PATCH] init/do_mounts.c: treat EROFS like EACCES Philippe De Muyter
2014-06-19 21:19 ` Andrew Morton
2014-06-19 23:09 ` Dave Chinner
2014-06-20 8:39 ` [PATCH] VFS: mount must return EACCES, not EROFS Philippe De Muyter
2014-06-27 8:20 ` [PATCH PING] " Philippe De Muyter
2014-07-02 19:46 ` Andrew Morton
2014-07-03 16:29 ` Philippe De Muyter
2014-07-08 21:02 ` Andrew Morton [this message]
2014-07-15 10:05 ` Philippe De Muyter
2014-06-20 13:13 ` [PATCH] init/do_mounts.c: treat EROFS like EACCES Philippe De Muyter
2014-06-23 9:22 ` 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=20140708140218.ce415094dd073a3ddbd98eeb@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=kzak@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phdm@macqel.be \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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