From owner-svn-src-all@FreeBSD.ORG Thu Sep 30 13:31:36 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24C44106566B; Thu, 30 Sep 2010 13:31:36 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 14D218FC17; Thu, 30 Sep 2010 13:31:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8UDVZ7d070806; Thu, 30 Sep 2010 13:31:35 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8UDVZC0070804; Thu, 30 Sep 2010 13:31:35 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201009301331.o8UDVZC0070804@svn.freebsd.org> From: Jaakko Heinonen Date: Thu, 30 Sep 2010 13:31:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213298 - head/sbin/mount X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2010 13:31:36 -0000 Author: jh Date: Thu Sep 30 13:31:35 2010 New Revision: 213298 URL: http://svn.freebsd.org/changeset/base/213298 Log: Fix printing of the "rw" mount option in fstab(5) format (-p option). fstab(5) format requires that one of "rw", "rq" or "ro" is always specified. PR: bin/123021 Reviewed by: keramida, rodrigc MFC after: 2 weeks Modified: head/sbin/mount/mount.c Modified: head/sbin/mount/mount.c ============================================================================== --- head/sbin/mount/mount.c Thu Sep 30 12:59:56 2010 (r213297) +++ head/sbin/mount/mount.c Thu Sep 30 13:31:35 2010 (r213298) @@ -850,10 +850,18 @@ void putfsent(struct statfs *ent) { struct fstab *fst; - char *opts; + char *opts, *rw; int l; + opts = NULL; + /* flags2opts() doesn't return the "rw" option. */ + if ((ent->f_flags & MNT_RDONLY) != 0) + rw = NULL; + else + rw = catopt(NULL, "rw"); + opts = flags2opts(ent->f_flags); + opts = catopt(rw, opts); if (strncmp(ent->f_mntfromname, "", 7) == 0 || strncmp(ent->f_mntfromname, "", 7) == 0) { @@ -861,10 +869,6 @@ putfsent(struct statfs *ent) +1)); } - /* - * "rw" is not a real mount option; this is why we print NULL as "rw" - * if opts is still NULL here. - */ l = strlen(ent->f_mntfromname); printf("%s%s%s%s", ent->f_mntfromname, l < 8 ? "\t" : "", @@ -876,13 +880,9 @@ putfsent(struct statfs *ent) l < 16 ? "\t" : "", l < 24 ? "\t" : " "); printf("%s\t", ent->f_fstypename); - if (opts == NULL) { - printf("%s\t", "rw"); - } else { - l = strlen(opts); - printf("%s%s", opts, - l < 8 ? "\t" : " "); - } + l = strlen(opts); + printf("%s%s", opts, + l < 8 ? "\t" : " "); free(opts); if ((fst = getfsspec(ent->f_mntfromname)))