retry mounting with ro when rw fails

Garrett Cooper yanegomi at gmail.com
Thu Apr 7 20:43:38 UTC 2011


On Thu, Apr 7, 2011 at 10:25 AM, Andriy Gapon <avg at freebsd.org> wrote:
>
> [sorry for double post, it should have been "hackers" not "hardware"]
>
> Guys,
> could you please review and comment on the following patch?
> http://people.freebsd.org/~avg/mount-retry-ro.diff
> Thank you!
>
> The patch consists of two parts.
>
> The first part is in CAM/SCSI to make sure that ENODEV is consistently returned to
> signal that an operation is not supported by a device (in accordance to intro(2))
> and specifically to return ENODEV on write attempt to a read-only or
> write-protected media.  Making this change in SCSI should cover real SCSI devices,
> as well as ATAPI through ahci/siis/atapicam or similar, plus majority (all?) of
> USB Mass Storage devices.
>
> The second part is in vfs_mount code.  The idea is to re-try a mount call if we
> get the ENODEV error, and mounting was not already in read-only mode, and there
> was no explicit rw or noro option; the second try is changed to ro.
>
> I did only basic testing with an SD card in write-protected mode and a USB
> card-reader.  Since I am not very familiar with vfs_mount code I might have missed
> some important details.

    As a generic question / observation, maybe we should just
implement 'errors=remount-ro' (or a reasonable facsimile) like Linux
has in our mount(8) command? Doesn't look like NetBSD, OpenBSD, or
[Open]Solaris sported similar functionality.
Thanks,
-Garrett


More information about the freebsd-fs mailing list