From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 19 14:32:35 2011 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2ACF6106564A for ; Sat, 19 Feb 2011 14:32:35 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi [195.197.172.116]) by mx1.freebsd.org (Postfix) with ESMTP id A62F28FC12 for ; Sat, 19 Feb 2011 14:32:34 +0000 (UTC) Received: from a91-153-123-205.elisa-laajakaista.fi (a91-153-123-205.elisa-laajakaista.fi [91.153.123.205]) by gw02.mail.saunalahti.fi (Postfix) with SMTP id 6A2C4139683; Sat, 19 Feb 2011 16:32:30 +0200 (EET) Date: Sat, 19 Feb 2011 16:32:30 +0200 From: Jaakko Heinonen To: freebsd-hackers@FreeBSD.org Message-ID: <20110219143230.GA1539@a91-153-123-205.elisa-laajakaista.fi> References: <20110114122454.GA4805@jh> <20110119083407.GA51372@crodrigues.org> <20110119151210.GA2182@a91-153-123-205.elisa-laajakaista.fi> <20110125172340.GA1535@a91-153-123-205.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110125172340.GA1535@a91-153-123-205.elisa-laajakaista.fi> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Craig Rodrigues Subject: Re: [patch] nmount ro, rw and negated option handling X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2011 14:32:35 -0000 On 2011-01-25, Jaakko Heinonen wrote: > Another related bug is in vfs_domount_update(): if VFS_MOUNT() succeeds > but vfs_export() fails, old mount flags and options are restored. I > think this shouldn't happen when VFS_MOUNT() has been already > successfully completed and this is the final reason why FFS fs_ronly and > the MNT_RDONLY flag get out of sync. Does the patch below look sane? > > %%% > Index: sys/kern/vfs_mount.c > =================================================================== > --- sys/kern/vfs_mount.c (revision 217792) > +++ sys/kern/vfs_mount.c (working copy) I have committed an updated version as r218852. Unless there are objections, I plan to commit something like this next: Recognize "ro", "rdonly", "norw", "rw" and "noro" as equal options in vfs_equalopts(). This allows vfs_sanitizeopts() to filter redundant occurrences of these options. It was possible that for example both "ro" and "rw" options became active concurrently. PR: kern/133614 %%% Index: sys/kern/vfs_mount.c =================================================================== --- sys/kern/vfs_mount.c (revision 218446) +++ sys/kern/vfs_mount.c (working copy) @@ -175,6 +175,27 @@ vfs_deleteopt(struct vfsoptlist *opts, c } } +static int +vfs_isopt_ro(const char *opt) +{ + + if (strcmp(opt, "ro") == 0 || strcmp(opt, "rdonly") == 0 || + strcmp(opt, "norw") == 0) + return (1); + else + return (0); +} + +static int +vfs_isopt_rw(const char *opt) +{ + + if (strcmp(opt, "rw") == 0 || strcmp(opt, "noro") == 0) + return (1); + else + return (0); +} + /* * Check if options are equal (with or without the "no" prefix). */ @@ -203,6 +224,11 @@ vfs_equalopts(const char *opt1, const ch if (strncmp(opt2, "no", 2) == 0 && strcmp(opt1, opt2 + 2) == 0) return (1); } + /* "ro" / "rdonly" / "norw" / "rw" / "noro" */ + if ((vfs_isopt_ro(opt1) || vfs_isopt_rw(opt1)) && + (vfs_isopt_ro(opt2) || vfs_isopt_rw(opt2))) + return (1); + return (0); } %%% -- Jaakko