From owner-freebsd-fs@FreeBSD.ORG Tue Jun 1 19:06:49 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B9C3106567A for ; Tue, 1 Jun 2010 19:06:49 +0000 (UTC) (envelope-from gleb.kurtsou@gmail.com) Received: from mail-ew0-f209.google.com (mail-ew0-f209.google.com [209.85.219.209]) by mx1.freebsd.org (Postfix) with ESMTP id 9C6CC8FC22 for ; Tue, 1 Jun 2010 19:06:48 +0000 (UTC) Received: by ewy1 with SMTP id 1so1389374ewy.33 for ; Tue, 01 Jun 2010 12:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=vLPztj8QW2BHezYjwzSh/ZaP+L6BY6s89gs8mh5Au1k=; b=SlIGnkiWcHsIPYzCQcWyw/tD2OMaXncux0kOFoXUoMb3t2Ki/UoMX4tbTc4vaA2Io9 Krhmts+IN8SyLhTCcC2mlW5S9PnlqCZbQsNzCe7Kadp+IKtMaQtE2oYc7LP+IJ38G7UM z9kQ0CeBKhotHHAPfbVXWxAdPZfWXQuDCCSV4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=HqaG9R8X1iziaYqBBL1shTsDYbbCtWtR+iqkebYh4PD0LjYf5eXoiVczSHX42RBRJr gA+5p16S5pZQMgHPh5NrJII4hTAikBlsBV1rFeX2SETJwYBoELcF4/2P+AbPK6Hi/7/e YmqAU8eJvHtp1h5hRF8hrKZa+XVIExCXIfaFk= Received: by 10.213.32.197 with SMTP id e5mr3854336ebd.28.1275419207363; Tue, 01 Jun 2010 12:06:47 -0700 (PDT) Received: from localhost (lan-78-157-90-54.vln.skynet.lt [78.157.90.54]) by mx.google.com with ESMTPS id 15sm3921972ewy.0.2010.06.01.12.06.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 01 Jun 2010 12:06:45 -0700 (PDT) Date: Tue, 1 Jun 2010 22:06:58 +0300 From: Gleb Kurtsou To: Andriy Gapon Message-ID: <20100601190658.GA2594@tops.skynet.lt> References: <4C03E9C0.2010602@icyb.net.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4C03E9C0.2010602@icyb.net.ua> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-fs@FreeBSD.org Subject: Re: nullfs distinct path check: take into account filesystems X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jun 2010 19:06:49 -0000 On (31/05/2010 19:54), Andriy Gapon wrote: > > Right now mount_nullfs doesn't allow to, for example, mount / in /tmp/somedir even > if /tmp is a different filesystem. > I think there is no reason to do that and thus propose the following patch. Why don't we remove mount_nullfs entirely? Such check is trivial to do in kernel, all is needed is to change mntopts and add compatibility shims. Take a look at pefs_mount if interested: http://github.com/glk/pefs/blob/master/sys/fs/pefs/pefs_vfsops.c There is no mount_pefs and 'pefs mount' command exec's /sbin/mount, 'mount -t pefs' is supported as well; search for pefs_mount in: http://github.com/glk/pefs/blob/master/sbin/pefs/pefs_ctl.c Thanks, Gleb. > > diff --git a/sbin/mount_nullfs/mount_nullfs.c b/sbin/mount_nullfs/mount_nullfs.c > index abca9fa..4bd426f 100644 > --- a/sbin/mount_nullfs/mount_nullfs.c > +++ b/sbin/mount_nullfs/mount_nullfs.c > @@ -46,6 +46,7 @@ static const char rcsid[] = > > #include > #include > +#include > #include > > #include > @@ -62,7 +63,8 @@ struct mntopt mopts[] = { > MOPT_END > }; > > -int subdir(const char *, const char *); > +static int samefs(const char *p1, const char *p2); > +static int subdir(const char *, const char *); > static void usage(void) __dead2; > > int > @@ -93,7 +95,8 @@ main(int argc, char *argv[]) > (void)checkpath(argv[0], target); > (void)checkpath(argv[1], source); > > - if (subdir(target, source) || subdir(source, target)) > + if (samefs(target, source) > + && (subdir(target, source) || subdir(source, target))) > errx(EX_USAGE, "%s (%s) and %s are not distinct paths", > argv[0], target, argv[1]); > > @@ -116,6 +119,21 @@ main(int argc, char *argv[]) > } > > int > +samefs(const char *p1, const char *p2) > +{ > + struct stat sb; > + uint32_t fsid1; > + uint32_t fsid2; > + > + stat(p1, &sb); > + fsid1 = sb.st_dev; > + stat(p2, &sb); > + fsid2 = sb.st_dev; > + > + return (fsid1 == fsid2); > +} > + > +int > subdir(const char *p, const char *dir) > { > int l; > > -- > Andriy Gapon > _______________________________________________ > freebsd-fs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org"