From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 15 02:01:34 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CE05737B401; Fri, 15 Aug 2003 02:01:34 -0700 (PDT) Received: from comp.chem.msu.su (comp-ext.chem.msu.su [158.250.32.157]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3F23B43F3F; Fri, 15 Aug 2003 02:01:33 -0700 (PDT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.12.3p2/8.12.3) with ESMTP id h7F91UhV002231; Fri, 15 Aug 2003 13:01:30 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.12.3p2/8.12.3/Submit) id h7F91Up3002230; Fri, 15 Aug 2003 13:01:30 +0400 (MSD) (envelope-from yar) Date: Fri, 15 Aug 2003 13:01:29 +0400 From: Yar Tikhiy To: fs@freebsd.org, hackers@freebsd.org Message-ID: <20030815090129.GA1035@comp.chem.msu.su> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.3i Subject: Mount point mode after mount_mfs(8) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Aug 2003 09:01:35 -0000 Hi folks, As some of you could have noticed, mount_mfs(8) in STABLE will leave the mount point mode 1777, which is not always desired. Doing chmod(1) on it just after mount_mfs(8) isn't elegant due to a race. There is a PR open on the issue -- bin/54897. I've got a patch (see below) that adds a new option to mount_mfs(8), -P mode, to specify the initial mode for the mount point (i.e., for the root directory of the MFS created.) On the one hand, this patch is simple, so it would be rather safe to commit it to STABLE. On the other hand, I feel it shouldn't be committed if the originator of the said PR and yours truly are the only people who need the functionality in question, particularly granted that 4-STABLE is gradually reaching its end of life. Does anybody else think this feature is really needed? -- Yar Index: mkfs.c =================================================================== RCS file: /home/ncvs/src/sbin/newfs/mkfs.c,v retrieving revision 1.29.2.7 diff -u -r1.29.2.7 mkfs.c --- mkfs.c 12 Aug 2003 13:19:17 -0000 1.29.2.7 +++ mkfs.c 12 Aug 2003 13:58:51 -0000 @@ -91,6 +91,7 @@ * variables set up by front end. */ extern int mfs; /* run as the memory based filesystem */ +extern mode_t mfs_mode; /* permission bits for mfs root */ extern char *mfs_mtpt; /* mount point for mfs */ extern struct stat mfs_mtstat; /* stat prior to mount */ extern int Nflag; /* run mkfs without writing file system */ @@ -1009,7 +1010,7 @@ * create the root directory */ if (mfs) - node.di_mode = IFDIR | 01777; + node.di_mode = IFDIR | mfs_mode; else node.di_mode = IFDIR | UMASK; node.di_nlink = PREDEFDIR; Index: newfs.8 =================================================================== RCS file: /home/ncvs/src/sbin/newfs/newfs.8,v retrieving revision 1.26.2.15 diff -u -r1.26.2.15 newfs.8 --- newfs.8 13 May 2003 12:16:08 -0000 1.26.2.15 +++ newfs.8 12 Aug 2003 13:58:51 -0000 @@ -69,6 +69,7 @@ .Nm mount_mfs .Op Fl NU .Op Fl F Ar file +.Op Fl P Ar mode .Op Fl T Ar disktype .Op Fl a Ar maxcontig .Op Fl b Ar block-size @@ -149,6 +150,23 @@ format filesystem. This options is primarily used to build root filesystems that can be understood by older boot ROMs. +.It Fl P Ar mode +Set the file permissions on the root directory of +the file system created by +.Nm mount_mfs +to the specified +.Ar mode . +The +.Ar mode +argument can be in any of the formats recognized by +.Xr chmod 1 . +If a symbolic mode is specified, +the operation characters +.Dq + +and +.Dq - +are interpreted relative to the default mode of +.Dq a=rwxt . .It Fl T Use information for the specified disk from .Pa /etc/disktab Index: newfs.c =================================================================== RCS file: /home/ncvs/src/sbin/newfs/newfs.c,v retrieving revision 1.30.2.9 diff -u -r1.30.2.9 newfs.c --- newfs.c 13 May 2003 12:03:55 -0000 1.30.2.9 +++ newfs.c 12 Aug 2003 13:58:51 -0000 @@ -166,6 +166,7 @@ #define NSECTORS 4096 /* number of sectors */ int mfs; /* run as the memory based filesystem */ +mode_t mfs_mode = 01777; /* permission bits for mfs root */ char *mfs_mtpt; /* mount point for mfs */ struct stat mfs_mtstat; /* stat prior to mount */ int Nflag; /* run without writing file system */ @@ -231,6 +232,7 @@ struct statfs *mp; int fsi, fso, len, n, vflag; char *cp, *s1, *s2, *special, *opstring; + void *set; #ifdef MFS struct vfsconf vfc; int error; @@ -249,7 +251,7 @@ } opstring = mfs ? - "NF:T:Ua:b:c:d:e:f:g:h:i:m:o:s:v" : + "NF:P:T:Ua:b:c:d:e:f:g:h:i:m:o:s:v" : "NOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:"; while ((ch = getopt(argc, argv, opstring)) != -1) switch (ch) { @@ -271,6 +273,12 @@ case 'F': filename = optarg; break; + case 'P': + if ((set = setmode(optarg)) == NULL) + fatal("%s: bad file mode", optarg); + mfs_mode = getmode(set, mfs_mode); + free(set); + break; case 'U': Uflag = 1; break; @@ -758,6 +766,8 @@ fprintf(stderr, "\t-N do not create file system, just print out parameters\n"); fprintf(stderr, "\t-O create a 4.3BSD format filesystem\n"); + if (mfs) + fprintf(stderr, "\t-P permissions for the root directory\n"); fprintf(stderr, "\t-S sector size\n"); #ifdef COMPAT fprintf(stderr, "\t-T disktype\n");