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:s:v" :
+ "NF:P:T:Ua:b:c:d:e:f:g:h:i:m:s:v" :
"NOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n: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");
_______________________________________________
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"