From nobody@FreeBSD.org  Tue Oct 28 03:07:00 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 38DA61065681
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Oct 2008 03:07:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 27BC08FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Oct 2008 03:07:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9S36xfR093232
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Oct 2008 03:06:59 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id m9S36xn4093231;
	Tue, 28 Oct 2008 03:06:59 GMT
	(envelope-from nobody)
Message-Id: <200810280306.m9S36xn4093231@www.freebsd.org>
Date: Tue, 28 Oct 2008 03:06:59 GMT
From: Yoshihiro Ota <ota@j.email.ne.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mount_mfs warns "chmod: /usr/ports: Read-only file system"
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128427
>Category:       bin
>Synopsis:       [patch] mdfs(8): mount_mfs warns "chmod: Read-only file system"
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 28 03:10:03 UTC 2008
>Closed-Date:    Tue Sep 20 08:37:18 UTC 2011
>Last-Modified:  Tue Sep 20 08:37:18 UTC 2011
>Originator:     Yoshihiro Ota
>Release:        7.1-PRERELEASE
>Organization:
>Environment:
... 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #441: Sat Oct 25 02:48:52 EDT 2008     root@xxx:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
mdmfs attempts to change permission on read-only file system and gets warning.
>How-To-Repeat:
# grep mfs /etc/fstab 
/dev/md.uzip /usr/ports mfs noauto,ro,-P,-F/usr/uzip/ports-20081003.uzip
# mount /usr/ports/
mount_mfs: chmod: /usr/ports: Read-only file system
# df /usr/ports/
Filesystem    1K-blocks   Used  Avail Capacity  Mounted on
/dev/md1.uzip    911262 462926 375436    55%    /usr/ports

>Fix:
Do not attempt chmod on read-only filesystem.

Patch attached with submission follows:

Index: sbin/mdmfs/mdmfs.c
===================================================================
RCS file: /home/ncvs/src/sbin/mdmfs/mdmfs.c,v
retrieving revision 1.33
diff -u -r1.33 mdmfs.c
--- sbin/mdmfs/mdmfs.c	14 May 2007 19:23:13 -0000	1.33
+++ sbin/mdmfs/mdmfs.c	28 Oct 2008 03:05:30 -0000
@@ -60,6 +60,7 @@
 	bool		 mi_have_gid;
 	mode_t		 mi_mode;
 	bool		 mi_have_mode;
+	bool		 mi_is_readonly;
 };
 
 static	bool debug;		/* Emit debugging information? */
@@ -195,6 +196,8 @@
 			break;
 		case 'o':
 			argappend(&mount_arg, "-o %s", optarg);
+			if(strcmp(optarg, "ro") == 0)
+				mi.mi_is_readonly = true;
 			break;
 		case 'P':
 			newfs = false;
@@ -440,7 +443,8 @@
 static void
 do_mtptsetup(const char *mtpoint, struct mtpt_info *mip)
 {
-
+	if (mip->mi_is_readonly)
+		return;
 	if (mip->mi_have_mode) {
 		debugprintf("changing mode of %s to %o.", mtpoint,
 		    mip->mi_mode);


>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/128427: commit references a PR
Date: Tue, 13 Sep 2011 20:16:21 +0000 (UTC)

 Author: kib
 Date: Tue Sep 13 20:16:11 2011
 New Revision: 225534
 URL: http://svn.freebsd.org/changeset/base/225534
 
 Log:
   Do not try to change the mode or ownership of the root of the mountpoint
   when newly established mdmfs mount is readonly.
   
   PR:	bin/128427
   Tested and reviewed by:	jchandra
   MFC after:	1 week
   Approved by:	re (bz)
 
 Modified:
   head/sbin/mdmfs/mdmfs.c
 
 Modified: head/sbin/mdmfs/mdmfs.c
 ==============================================================================
 --- head/sbin/mdmfs/mdmfs.c	Tue Sep 13 15:57:29 2011	(r225533)
 +++ head/sbin/mdmfs/mdmfs.c	Tue Sep 13 20:16:11 2011	(r225534)
 @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
  
  #include <sys/param.h>
  #include <sys/mdioctl.h>
 +#include <sys/mount.h>
  #include <sys/stat.h>
  #include <sys/wait.h>
  
 @@ -60,6 +61,7 @@ struct mtpt_info {
  	bool		 mi_have_gid;
  	mode_t		 mi_mode;
  	bool		 mi_have_mode;
 +	bool		 mi_forced_pw;
  };
  
  static	bool debug;		/* Emit debugging information? */
 @@ -204,6 +206,7 @@ main(int argc, char **argv)
  				usage();
  			mi.mi_mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
  			mi.mi_have_mode = true;
 +			mi.mi_forced_pw = true;
  			free(set);
  			break;
  		case 'S':
 @@ -223,6 +226,7 @@ main(int argc, char **argv)
  			break;
  		case 'w':
  			extract_ugid(optarg, &mi);
 +			mi.mi_forced_pw = true;
  			break;
  		case 'X':
  			debug = true;
 @@ -443,6 +447,29 @@ do_mount(const char *args, const char *m
  static void
  do_mtptsetup(const char *mtpoint, struct mtpt_info *mip)
  {
 +	struct statfs sfs;
 +
 +	if (!mip->mi_have_mode && !mip->mi_have_uid && !mip->mi_have_gid)
 +		return;
 +
 +	if (!norun) {
 +		if (statfs(mtpoint, &sfs) == -1) {
 +			warn("statfs: %s", mtpoint);
 +			return;
 +		}
 +		if ((sfs.f_flags & MNT_RDONLY) != 0) {
 +			if (mip->mi_forced_pw) {
 +				warnx(
 +	"Not changing mode/owner of %s since it is read-only",
 +				    mtpoint);
 +			} else {
 +				debugprintf(
 +	"Not changing mode/owner of %s since it is read-only",
 +				    mtpoint);
 +			}
 +			return;
 +		}
 +	}
  
  	if (mip->mi_have_mode) {
  		debugprintf("changing mode of %s to %o.", mtpoint,
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: kib 
State-Changed-When: Tue Sep 20 08:37:01 UTC 2011 
State-Changed-Why:  
Fixed in head and 8. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128427 
>Unformatted:
