Subject: g/c mountcompatnames[] ?
To: None <tech-kern@netbsd.org>
From: Jaromír <jdolecek@netbsd.org>
List: tech-kern
Date: 06/26/2001 21:03:44
--ELM993582224-1415-1_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
Hi,
I'd like to g/c mountcompatnames[] and appropriate COMPAT_* code
which supports using fs id instead of name for mount. That code
is getting maintanence problem and contains support for some
filesystem types 0.9 didn't support at all. vfs_sysctl() would be
changed to use the values from CTL_VFS_NAMES, so there would
be just one place to make changes to, and only if that filesystem
would support fs-specific sysctls. I'm appending the patch in attachment.
Jaromir
--
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.ics.muni.cz/~dolecek/
NetBSD - just plain best OS! -=*=- Got spare MCA cards or docs? Hand me them!
--ELM993582224-1415-1_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=ISO-8859-2
Content-Disposition: attachment; filename=gcmountcompat.diff
Index: vfs_subr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/vfs_subr.c,v
retrieving revision 1.150
diff -u -p -r1.150 vfs_subr.c
--- vfs_subr.c 2001/06/05 04:42:05 1.150
+++ vfs_subr.c 2001/06/26 19:03:54
@@ -1887,9 +1886,6 @@ vfs_sysctl(name, namelen, oldp, oldlenp,
size_t newlen;
struct proc *p;
{
-#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_44)
- struct vfsconf vfc;
-#endif
struct vfsops *vfsp;
/* all sysctl names at this level are at least name and field */
@@ -1898,10 +1894,14 @@ vfs_sysctl(name, namelen, oldp, oldlenp,
/* Not generic: goes to file system. */
if (name[0] != VFS_GENERIC) {
- if (name[0] >= nmountcompatnames || name[0] < 0 ||
- mountcompatnames[name[0]] == NULL)
+ static const struct ctlname vfsnames[] = CTL_VFS_NAMES;
+ const char *vfsname;
+
+ if (name[0] < 0 || name[0] > VFS_MAXID)
return (EOPNOTSUPP);
- vfsp = vfs_getopsbyname(mountcompatnames[name[0]]);
+
+ vfsname = vfsnames[name[0]].ctl_name;
+ vfsp = vfs_getopsbyname(vfsname);
if (vfsp == NULL || vfsp->vfs_sysctl == NULL)
return (EOPNOTSUPP);
return ((*vfsp->vfs_sysctl)(&name[1], namelen - 1,
@@ -1912,35 +1912,6 @@ vfs_sysctl(name, namelen, oldp, oldlenp,
switch (name[1]) {
case VFS_USERMOUNT:
return sysctl_int(oldp, oldlenp, newp, newlen, &dovfsusermount);
-#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_44)
- case VFS_MAXTYPENUM:
- /*
- * Provided for 4.4BSD-Lite2 compatibility.
- */
- return (sysctl_rdint(oldp, oldlenp, newp, nmountcompatnames));
- case VFS_CONF:
- /*
- * Special: a node, next is a file system name.
- * Provided for 4.4BSD-Lite2 compatibility.
- */
- if (namelen < 3)
- return (ENOTDIR); /* overloaded */
- if (name[2] >= nmountcompatnames || name[2] < 0 ||
- mountcompatnames[name[2]] == NULL)
- return (EOPNOTSUPP);
- vfsp = vfs_getopsbyname(mountcompatnames[name[2]]);
- if (vfsp == NULL)
- return (EOPNOTSUPP);
- vfc.vfc_vfsops = vfsp;
- strncpy(vfc.vfc_name, vfsp->vfs_name, MFSNAMELEN);
- vfc.vfc_typenum = name[2];
- vfc.vfc_refcount = vfsp->vfs_refcount;
- vfc.vfc_flags = 0;
- vfc.vfc_mountroot = vfsp->vfs_mountroot;
- vfc.vfc_next = NULL;
- return (sysctl_rdstruct(oldp, oldlenp, newp, &vfc,
- sizeof(struct vfsconf)));
-#endif
default:
break;
}
Index: vfs_syscalls.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/vfs_syscalls.c,v
retrieving revision 1.166
diff -u -p -r1.166 vfs_syscalls.c
--- vfs_syscalls.c 2001/06/14 20:32:48 1.166
+++ vfs_syscalls.c 2001/06/26 19:03:54
@@ -86,39 +86,6 @@ int dovfsusermount = 0;
* Mount a file system.
*/
-/*
- * This table is used to maintain compatibility with 4.3BSD
- * and NetBSD 0.9 mount syscalls. Note, the order is important!
- *
- * Also note that not all of these had actual numbers in 4.3BSD
- * or NetBSD 0.9!
- */
-const char *mountcompatnames[] = {
- NULL, /* 0 = MOUNT_NONE */
- MOUNT_FFS, /* 1 */
- MOUNT_NFS, /* 2 */
- MOUNT_MFS, /* 3 */
- MOUNT_MSDOS, /* 4 */
- MOUNT_LFS, /* 5 */
- NULL, /* 6 = MOUNT_LOFS */
- MOUNT_FDESC, /* 7 */
- MOUNT_PORTAL, /* 8 */
- MOUNT_NULL, /* 9 */
- MOUNT_UMAP, /* 10 */
- MOUNT_KERNFS, /* 11 */
- MOUNT_PROCFS, /* 12 */
- MOUNT_AFS, /* 13 */
- MOUNT_CD9660, /* 14 = MOUNT_ISOFS */
- MOUNT_UNION, /* 15 */
- MOUNT_ADOSFS, /* 16 */
- MOUNT_EXT2FS, /* 17 */
- MOUNT_CODA, /* 18 */
- MOUNT_FILECORE, /* 19 */
- MOUNT_NTFS, /* 20 */
-};
-const int nmountcompatnames = sizeof(mountcompatnames) /
- sizeof(mountcompatnames[0]);
-
/* ARGSUSED */
int
sys_mount(p, v, retval)
@@ -253,30 +220,10 @@ sys_mount(p, v, retval)
}
error = copyinstr(SCARG(uap, type), fstypename, MFSNAMELEN, NULL);
if (error) {
-#if defined(COMPAT_09) || defined(COMPAT_43)
- /*
- * Historically filesystem types were identified by number.
- * If we get an integer for the filesystem type instead of a
- * string, we check to see if it matches one of the historic
- * filesystem types.
- */
- u_long fsindex = (u_long)SCARG(uap, type);
- if (fsindex >= nmountcompatnames ||
- mountcompatnames[fsindex] == NULL) {
- vput(vp);
- return (ENODEV);
- }
- strncpy(fstypename, mountcompatnames[fsindex], MFSNAMELEN);
-#else
vput(vp);
return (error);
-#endif
}
-#ifdef COMPAT_10
- /* Accept `ufs' as an alias for `ffs'. */
- if (!strncmp(fstypename, "ufs", MFSNAMELEN))
- strncpy(fstypename, "ffs", MFSNAMELEN);
-#endif
+
if ((vfs = vfs_getopsbyname(fstypename)) == NULL) {
vput(vp);
return (ENODEV);
--ELM993582224-1415-1_--