Bug 26886

Summary: mount -w doesn't work on a normally read-only filesystem
Product: Base System Reporter: Archie Cobbs <archie>
Component: binAssignee: dd <dd>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   

Description Archie Cobbs 2001-04-27 02:00:03 UTC
	The "-w" flag to mount(8) doesn't work if the filesystem
	is marked with the "ro" option in /etc/fstab.

	It seems like "-w" should override /etc/fstab.

Fix: 

$ mount /foo
	$ mount -u /foo
How-To-Repeat: 
	Have an /etc/fstab entry like this:

	  # Device      Mountpoint   FStype  Options         Dump    Pass#
	  /dev/ad0s1e   /foo       ufs     ro              1       1

	With the filesystem unmounted, do this:

	  $ mount -w /foo

	The filesystem is mounted read-only instead of read-write.
Comment 1 dima 2001-04-27 02:35:57 UTC
Archie Cobbs <archie@packetdesign.com> writes:
> 
> >Number:         26886
> >Category:       bin
> >Synopsis:       mount -w doesn't work on a normally read-only filesystem
> >Description:
> 
> 	The "-w" flag to mount(8) doesn't work if the filesystem
> 	is marked with the "ro" option in /etc/fstab.
> 
> 	It seems like "-w" should override /etc/fstab.

Could you please try the attached patch?  (There may be a little fuzz;
I've some local modifications that I had to coerce out of the diff
manually.)

Thanks,

					Dima Dorfman
					dima@unixfreak.org


Index: mount.c
===================================================================
RCS file: /st/src/FreeBSD/src/sbin/mount/mount.c,v
retrieving revision 1.41
diff -u -r1.41 mount.c
--- mount.c	2000/11/22 17:54:56	1.41
+++ mount.c	2001/04/27 01:34:17
@@ -410,6 +412,9 @@
 		optbuf = catopt(optbuf, "force");
 	if (flags & MNT_RDONLY)
 		optbuf = catopt(optbuf, "ro");
+	else
+		remopt(optbuf, "ro");
+
 	/*
 	 * XXX
 	 * The mount_mfs (newfs) command uses -o to select the
Comment 2 dd freebsd_committer freebsd_triage 2001-05-02 03:21:30 UTC
State Changed
From-To: open->analyzed

Problem fixed in -current.  -stable is also affected; I'll MFC this later. 


Comment 3 dd freebsd_committer freebsd_triage 2001-05-02 03:21:30 UTC
Responsible Changed
From-To: freebsd-bugs->dd

My MFC reminder.
Comment 4 dd freebsd_committer freebsd_triage 2001-06-08 02:03:49 UTC
State Changed
From-To: analyzed->closed

MFC'd