Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Allow the user to specify the filesystem ID for umapfs at mo...
details: https://anonhg.NetBSD.org/src/rev/d29eab794a7a
branches: trunk
changeset: 453638:d29eab794a7a
user: perseant <perseant%NetBSD.org@localhost>
date: Tue Aug 20 20:18:54 2019 +0000
description:
Allow the user to specify the filesystem ID for umapfs at mount time,
allowing a consistent filesystem ID across reboots. Closes PR #54471.
diffstat:
sbin/mount_umap/mount_umap.8 | 8 +++++++-
sbin/mount_umap/mount_umap.c | 19 ++++++++++++++-----
sys/miscfs/umapfs/umap.h | 9 +++++----
sys/miscfs/umapfs/umap_vfsops.c | 31 +++++++++++++++++++++++++++----
4 files changed, 53 insertions(+), 14 deletions(-)
diffs (195 lines):
diff -r 1cf7e32983d0 -r d29eab794a7a sbin/mount_umap/mount_umap.8
--- a/sbin/mount_umap/mount_umap.8 Tue Aug 20 18:43:57 2019 +0000
+++ b/sbin/mount_umap/mount_umap.8 Tue Aug 20 20:18:54 2019 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount_umap.8,v 1.19 2005/09/11 23:40:43 wiz Exp $
+.\" $NetBSD: mount_umap.8,v 1.20 2019/08/20 20:18:54 perseant Exp $
.\"
.\" Copyright (c) 1992, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@@ -42,6 +42,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl o Ar options
+.Op Fl i Ar fsid
.Fl g Ar gid-mapfile
.Fl u Ar uid-mapfile
.Ar target
@@ -70,6 +71,11 @@
Use the group ID mapping specified in
.Ar gid-mapfile .
This flag is required.
+.It Fl i Ar fsid
+Use the specified
+.Ar fsid
+for the filesystem ID, rather than choosing one at random.
+This is useful if the filesystem is to be exported.
.It Fl o
Options are specified with a
.Fl o
diff -r 1cf7e32983d0 -r d29eab794a7a sbin/mount_umap/mount_umap.c
--- a/sbin/mount_umap/mount_umap.c Tue Aug 20 18:43:57 2019 +0000
+++ b/sbin/mount_umap/mount_umap.c Tue Aug 20 20:18:54 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mount_umap.c,v 1.23 2011/08/29 14:35:03 joerg Exp $ */
+/* $NetBSD: mount_umap.c,v 1.24 2019/08/20 20:18:54 perseant Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)mount_umap.c 8.5 (Berkeley) 4/26/95";
#else
-__RCSID("$NetBSD: mount_umap.c,v 1.23 2011/08/29 14:35:03 joerg Exp $");
+__RCSID("$NetBSD: mount_umap.c,v 1.24 2019/08/20 20:18:54 perseant Exp $");
#endif
#endif /* not lint */
@@ -104,18 +104,22 @@
long d1, d2;
u_long mapdata[MAPFILEENTRIES][2];
u_long gmapdata[GMAPFILEENTRIES][2];
+ u_long fsid;
int ch, count, gnentries, mntflags, nentries;
char *gmapfile, *mapfile, buf[20];
char source[MAXPATHLEN], target[MAXPATHLEN];
mntoptparse_t mp;
- mntflags = 0;
+ fsid = mntflags = 0;
mapfile = gmapfile = NULL;
- while ((ch = getopt(argc, argv, "g:o:u:")) != -1)
+ while ((ch = getopt(argc, argv, "g:i:o:u:")) != -1)
switch (ch) {
case 'g':
gmapfile = optarg;
break;
+ case 'i':
+ fsid = strtoul(optarg, NULL, 16);
+ break;
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, 0);
if (mp == NULL)
@@ -246,7 +250,12 @@
args.mapdata = mapdata;
args.gnentries = gnentries;
args.gmapdata = gmapdata;
+ args.fsid = fsid;
+ printf("sizeof export_args30 = %d, sizeof layer_args = %d, sizeof umap_args = %d\n",
+ (int)sizeof(struct export_args30),
+ (int)sizeof(struct layer_args),
+ (int)sizeof(struct umap_args));
if (mount(MOUNT_UMAP, target, mntflags, &args, sizeof args) == -1)
err(1, "%s on %s", source, target);
if (mntflags & MNT_GETARGS) {
@@ -260,6 +269,6 @@
usage(void)
{
(void)fprintf(stderr,
-"usage: mount_umap [-o options] -g groupmap -u usermap target_fs mount_point\n");
+"usage: mount_umap [-o options] [-i fsid] -g groupmap -u usermap target_fs mount_point\n");
exit(1);
}
diff -r 1cf7e32983d0 -r d29eab794a7a sys/miscfs/umapfs/umap.h
--- a/sys/miscfs/umapfs/umap.h Tue Aug 20 18:43:57 2019 +0000
+++ b/sys/miscfs/umapfs/umap.h Tue Aug 20 20:18:54 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umap.h,v 1.17 2017/04/11 07:51:37 hannken Exp $ */
+/* $NetBSD: umap.h,v 1.18 2019/08/20 20:18:54 perseant Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -51,6 +51,7 @@
int gnentries; /* # of entries in group map array */
u_long (*mapdata)[2]; /* pointer to array of user mappings */
u_long (*gmapdata)[2]; /* pointer to array of group mappings */
+ u_long fsid; /* user-supplied per-fs ident */
};
#ifdef _KERNEL
@@ -94,11 +95,11 @@
#define MOUNTTOUMAPMOUNT(mp) ((struct umap_mount *)((mp)->mnt_data))
#define VTOUMAP(vp) ((struct umap_node *)(vp)->v_data)
#define UMAPTOV(xp) ((xp)->umap_vnode)
-#ifdef UMAPFS_DIAGNOSTIC
+/* #ifdef UMAPFS_DIAGNOSTIC
#define UMAPVPTOLOWERVP(vp) layer_checkvp((vp), __FILE__, __LINE__)
-#else
+#else */
#define UMAPVPTOLOWERVP(vp) (VTOUMAP(vp)->umap_lowervp)
-#endif
+/* #endif */
extern int (**umap_vnodeop_p)(void *);
extern struct vfsops umapfs_vfsops;
diff -r 1cf7e32983d0 -r d29eab794a7a sys/miscfs/umapfs/umap_vfsops.c
--- a/sys/miscfs/umapfs/umap_vfsops.c Tue Aug 20 18:43:57 2019 +0000
+++ b/sys/miscfs/umapfs/umap_vfsops.c Tue Aug 20 20:18:54 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umap_vfsops.c,v 1.100 2019/02/20 10:06:00 hannken Exp $ */
+/* $NetBSD: umap_vfsops.c,v 1.101 2019/08/20 20:18:54 perseant Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.100 2019/02/20 10:06:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.101 2019/08/20 20:18:54 perseant Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -51,6 +51,7 @@
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/namei.h>
+#include <sys/syslog.h>
#include <sys/kauth.h>
#include <sys/module.h>
@@ -79,11 +80,17 @@
#ifdef UMAPFS_DIAGNOSTIC
int i;
#endif
+ fsid_t tfsid;
if (args == NULL)
return EINVAL;
- if (*data_len < sizeof *args)
+ if (*data_len < sizeof *args) {
+#ifdef UMAPFS_DIAGNOSTIC
+ printf("mount_umap: data len %d < args %d\n",
+ (int)*data_len, (int)(sizeof *args));
+#endif
return EINVAL;
+ }
if (mp->mnt_flag & MNT_GETARGS) {
amp = MOUNTTOUMAPMOUNT(mp);
@@ -190,7 +197,23 @@
* Make sure the mount point's sufficiently initialized
* that the node create call will work.
*/
- vfs_getnewfsid(mp);
+ tfsid.__fsid_val[0] = (int32_t)args->fsid;
+ tfsid.__fsid_val[1] = makefstype(MOUNT_UMAP);
+ if (tfsid.__fsid_val[0] == 0) {
+ log(LOG_WARNING, "umapfs: fsid given as 0, ignoring\n");
+ vfs_getnewfsid(mp);
+ } else if (vfs_getvfs(&tfsid)) {
+ log(LOG_WARNING, "umapfs: fsid %x already mounted\n",
+ tfsid.__fsid_val[0]);
+ vfs_getnewfsid(mp);
+ } else {
+ mp->mnt_stat.f_fsidx.__fsid_val[0] = tfsid.__fsid_val[0];
+ mp->mnt_stat.f_fsidx.__fsid_val[1] = tfsid.__fsid_val[1];
+ mp->mnt_stat.f_fsid = tfsid.__fsid_val[0];
+ }
+ log(LOG_DEBUG, "umapfs: using fsid %x/%x\n",
+ mp->mnt_stat.f_fsidx.__fsid_val[0],
+ mp->mnt_stat.f_fsidx.__fsid_val[1]);
mp->mnt_lower = lowerrootvp->v_mount;
amp->umapm_size = sizeof(struct umap_node);
Home |
Main Index |
Thread Index |
Old Index