NetBSD Problem Report #3711

Received: (qmail 29269 invoked from network); 5 Jun 1997 13:53:57 -0000
Message-Id: <199706051353.PAA00358@leon.math.ntnu.no>
Date: Thu, 5 Jun 1997 15:53:08 +0200 (CEST)
From: <arnej@math.ntnu.no>
Reply-To: arnej@math.ntnu.no
To: gnats-bugs@gnats.netbsd.org
Cc: jarle@runit.sintef.no
Subject: ibcs2 emulation lacks sysfs()
X-Send-Pr-Version: 3.95

>Number:         3711
>Category:       kern
>Synopsis:       ibcs2 emulation lacks sysfs()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 05 07:05:01 +0000 1997
>Closed-Date:    Sat Jul 29 07:34:44 +0000 2017
>Last-Modified:  Sat Jul 29 07:34:44 +0000 2017
>Originator:     Arne H. Juul
>Release:        NetBSD-current as of Jun 5, 1997
>Organization:
	Norwegian University of Technology and Science
>Environment:

System: NetBSD leon.math.ntnu.no 1.2E NetBSD 1.2E (NIKITA) #14: Thu Jun 5 14:39:16 CEST 1997 arnej@leon.math.ntnu.no:/usr/src/sys/arch/i386/compile/NIKITA i386


>Description:
	The IBCS2 emulation environment in NetBSD has stubbed out
	the sysfs() call.  This causes problems for some types of
	programs, in my case AXXiON-NetBackup.

	To implement sysfs() one needs to establish a mapping
	between filesystem-type name and number.  I noticed that
	the FreeBSD emulation already has such a mapping, so I
	extended that emulation a bit and made it common instead
	of making another version.  The mapping should in theory
	be dynamic, but in practice it suffices to add new
	filesystem types as (or preferrably a bit before) they
	are implemented for Net/FreeBSD.

>How-To-Repeat:
	Try to run a SCO (or other ibcs2) program that uses sysfs().
>Fix:
	Apply following patch:

diff -ruN compat.orig/common/Makefile compat/common/Makefile
--- compat.orig/common/Makefile	Sun Jun  1 07:16:22 1997
+++ compat/common/Makefile	Thu Jun  5 14:19:39 1997
@@ -7,7 +7,8 @@

 SRCS=	compat_exec.c compat_util.c kern_exit_43.c kern_info_09.c \
 	kern_info_43.c kern_resource_43.c kern_sig_43.c kern_xxx_12.c \
-	tty_43.c uipc_syscalls_43.c vfs_syscalls_43.c vm_43.c
+	tty_43.c uipc_syscalls_43.c vfs_syscalls_43.c vm_43.c \
+	compat_mnttype.c

 # really, all machines where sizeof(int) != sizeof(long)
 .if (${MACHINE_ARCH} != "alpha")
diff -ruN compat.orig/common/compat_mnttype.c compat/common/compat_mnttype.c
--- compat.orig/common/compat_mnttype.c	Thu Jan  1 01:00:00 1970
+++ compat/common/compat_mnttype.c	Thu Jun  5 14:08:01 1997
@@ -0,0 +1,66 @@
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mount.h>
+#include <compat/common/compat_mnttype.h>
+
+/*
+ * List of filesystem types.  This needs to be updated whenever
+ * a) somebody adds a filesystem to NetBSD
+ * b) somebody adds a filesystem to FreeBSD
+ * Used for binary compatibility modes, primarily with FreeBSD,
+ * but also for SysV, see ibcs2_sys_sysfs().
+ *
+ * LKM filesystems are not supported.
+ */
+static char *netbsd_mount_type[] = {
+		"(none)", /*  0 = MOUNT_NONE */
+		"ffs",	  /*  1 = "Fast" Filesystem */
+		"nfs",	  /*  2 = Network Filesystem */
+		"mfs",	  /*  3 = Memory Filesystem */
+		"msdos",  /*  4 = MSDOS Filesystem */
+		"lfs",	  /*  5 = Log-based Filesystem */
+		"lofs",	  /*  6 = Loopback filesystem */
+		"fdesc",  /*  7 = File Descriptor Filesystem */
+		"portal", /*  8 = Portal Filesystem */
+		"null",	  /*  9 = Minimal Filesystem Layer */
+		"umap",	  /* 10 = User/Group Identifier Remapping Filesystem */
+		"kernfs", /* 11 = Kernel Information Filesystem */
+		"procfs", /* 12 = /proc Filesystem */
+		"afs",	  /* 13 = Andrew Filesystem */
+		"cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
+		"union",  /* 15 = Union (translucent) Filesystem */
+			  /* These filesystems don't exist in NetBSD yet */
+		NULL,     /* 16 = "devfs" - existing device Filesystem */
+		"ext2fs", /* 17 = Linux EXT2FS */
+		"netcon", /* 18 = Netcon Novell filesystem */
+			  /* These filesystems don't exist in FreeBSD */
+		"adosfs", /* 19 = AmigaDOS Filesystem */
+};
+#define NUMFSTYPES 20
+
+int
+convert_mount_type_to_num(const char *name, int *num)
+{
+	int i;
+	for (i=0; i<NUMFSTYPES; i++) {
+		if (!strcmp(name, netbsd_mount_type[i])) {
+			*num = i;
+			return 0;
+		}
+	}
+	return EINVAL;
+}
+
+char *
+convert_mount_type_to_name(int num)
+{
+	if (num>=0 && num<NUMFSTYPES) {
+		return (netbsd_mount_type[num]);
+	}
+	return (NULL);
+}
+
+int get_num_mount_types(void)
+{
+	return NUMFSTYPES;
+}
diff -ruN compat.orig/common/compat_mnttype.h compat/common/compat_mnttype.h
--- compat.orig/common/compat_mnttype.h	Thu Jan  1 01:00:00 1970
+++ compat/common/compat_mnttype.h	Thu Jun  5 10:33:06 1997
@@ -0,0 +1,3 @@
+extern int convert_mount_type_to_num(const char *name, int *num);
+extern char *convert_mount_type_to_name(int num);
+extern int get_num_mount_types(void);
diff -ruN compat.orig/freebsd/freebsd_file.c compat/freebsd/freebsd_file.c
--- compat.orig/freebsd/freebsd_file.c	Fri Jan 31 13:21:23 1997
+++ compat/freebsd/freebsd_file.c	Thu Jun  5 14:19:10 1997
@@ -49,45 +49,12 @@

 #include <compat/freebsd/freebsd_syscallargs.h>
 #include <compat/freebsd/freebsd_util.h>
+#include <compat/common/compat_mnttype.h>

 #define	ARRAY_LENGTH(array)	(sizeof(array)/sizeof(array[0]))

 const char freebsd_emul_path[] = "/emul/freebsd";

-static char * convert_from_freebsd_mount_type __P((int));
-
-static char *
-convert_from_freebsd_mount_type(type)
-	int type;
-{
-	static char *netbsd_mount_type[] = {
-		NULL,     /*  0 = MOUNT_NONE */
-		"ffs",	  /*  1 = "Fast" Filesystem */
-		"nfs",	  /*  2 = Network Filesystem */
-		"mfs",	  /*  3 = Memory Filesystem */
-		"msdos",  /*  4 = MSDOS Filesystem */
-		"lfs",	  /*  5 = Log-based Filesystem */
-		"lofs",	  /*  6 = Loopback filesystem */
-		"fdesc",  /*  7 = File Descriptor Filesystem */
-		"portal", /*  8 = Portal Filesystem */
-		"null",	  /*  9 = Minimal Filesystem Layer */
-		"umap",	  /* 10 = User/Group Identifier Remapping Filesystem */
-		"kernfs", /* 11 = Kernel Information Filesystem */
-		"procfs", /* 12 = /proc Filesystem */
-		"afs",	  /* 13 = Andrew Filesystem */
-		"cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
-		"union",  /* 15 = Union (translucent) Filesystem */
-		NULL,     /* 16 = "devfs" - existing device Filesystem */
-#if 0 /* These filesystems don't exist in FreeBSD */
-		"adosfs", /* ?? = AmigaDOS Filesystem */
-#endif
-	};
-
-	if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type))
-		return (NULL);
-	return (netbsd_mount_type[type]);
-}
-
 int
 freebsd_sys_mount(p, v, retval)
 	struct proc *p;
@@ -105,7 +72,7 @@
 	caddr_t sg = stackgap_init(p->p_emul);
 	struct sys_mount_args bma;

-	if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
+	if ((type = convert_mount_type_to_name(SCARG(uap, type))) == NULL)
 		return ENODEV;
 	s = stackgap_alloc(&sg, MFSNAMELEN + 1);
 	if ((error = copyout(type, s, strlen(type) + 1)) != 0)
diff -ruN compat.orig/ibcs2/ibcs2_misc.c compat/ibcs2/ibcs2_misc.c
--- compat.orig/ibcs2/ibcs2_misc.c	Thu Mar 27 13:20:43 1997
+++ compat/ibcs2/ibcs2_misc.c	Thu Jun  5 14:17:15 1997
@@ -103,6 +103,8 @@
 #include <compat/ibcs2/ibcs2_syscallargs.h>
 #include <compat/ibcs2/ibcs2_sysi86.h>

+#include <compat/common/compat_mnttype.h>
+

 int
 ibcs2_sys_ulimit(p, v, retval)
@@ -1173,6 +1175,10 @@
 	return EINVAL;
 }

+/*
+ * This call takes one, two, or three parameters,
+ * and the types differ.  Yeuch.
+ */
 int
 ibcs2_sys_sysfs(p, v, retval)
 	struct proc *p;
@@ -1184,17 +1190,47 @@
 		syscallarg(caddr_t) d1;
 		syscallarg(char *) buf;
 	} */ *uap = v;
+	int error, i;
+	char fstype[MFSNAMELEN];
+	char *fst;

 #define IBCS2_GETFSIND        1
 #define IBCS2_GETFSTYP        2
 #define IBCS2_GETNFSTYP       3

+extern int convert_mount_type_to_num(const char *name, int *num);
+extern char *convert_mount_type_to_name(int num);
+
 	switch(SCARG(uap, cmd)) {
 	case IBCS2_GETFSIND:
+		if ((error = copyinstr(SCARG(uap, d1), fstype,
+				 sizeof fstype, (u_int *)0)))
+			return (error);
+		/* special case nfs. */
+		if (!strcmp(fstype, "NFS")) strcpy(fstype, "nfs");
+		error = convert_mount_type_to_num(fstype, retval);
+		return (error);
 	case IBCS2_GETFSTYP:
+		i = (int)SCARG(uap, d1);
+		fst = convert_mount_type_to_name(i);
+		if (fst) {
+			/* special case nfs AGAIN. */
+			if (!strcmp(fst, "nfs"))
+				strcpy(fstype, "NFS");
+			else
+				strcpy(fstype, fst);
+			if ((error = copyout(fstype, SCARG(uap, buf),
+						strlen(fstype)+1)))
+				return (error);
+			*retval = 0;
+			return 0;
+		}
+		return EINVAL;
 	case IBCS2_GETNFSTYP:
+		*retval = get_num_mount_types();
+		return 0;
 	}
-	return EINVAL;		/* XXX - TODO */
+	return EINVAL;
 }

 int
diff -ruN compat.orig/ibcs2/ibcs2_stat.c compat/ibcs2/ibcs2_stat.c
--- compat.orig/ibcs2/ibcs2_stat.c	Sat May  4 13:50:20 1996
+++ compat/ibcs2/ibcs2_stat.c	Thu Jun  5 14:17:29 1997
@@ -39,6 +39,7 @@
 #include <sys/malloc.h>
 #include <sys/vnode.h>
 #include <sys/syscallargs.h>
+#include <sys/syslog.h>

 #include <vm/vm.h>

@@ -52,6 +53,8 @@
 #include <compat/ibcs2/ibcs2_util.h>
 #include <compat/ibcs2/ibcs2_utsname.h>

+#include <compat/common/compat_mnttype.h>
+
 static void bsd_stat2ibcs_stat __P((struct ostat *, struct ibcs2_stat *));
 static int cvt_statfs __P((struct statfs *, caddr_t, int));

@@ -81,9 +84,16 @@
 	int len;
 {
 	struct ibcs2_statfs ssfs;
+	int fstyp;

 	bzero(&ssfs, sizeof ssfs);
-	ssfs.f_fstyp = 0;
+	if (convert_mount_type_to_num(sp->f_fstypename, &fstyp)) {
+		log(LOG_WARNING, "Unknown fstypename %s in ibcs2 cvt_statfs\n",
+			sp->f_fstypename);
+		ssfs.f_fstyp = 0;
+	} else {
+		ssfs.f_fstyp = fstyp;
+	}
 	ssfs.f_bsize = sp->f_bsize;
 	ssfs.f_frsize = 0;
 	ssfs.f_blocks = sp->f_blocks;
>Release-Note:
>Audit-Trail:

From: "Chris G. Demetriou" <cgd@pa.dec.com>
To: arnej@math.ntnu.no
Cc: gnats-bugs@gnats.netbsd.org, jarle@runit.sintef.no, netbsd-bugs@netbsd.org
Subject: Re: kern/3711: ibcs2 emulation lacks sysfs() 
Date: Thu, 05 Jun 97 07:30:50 -0700

 > 	To implement sysfs() one needs to establish a mapping
 > 	between filesystem-type name and number.  I noticed that
 > 	the FreeBSD emulation already has such a mapping, so I
 > 	extended that emulation a bit and made it common instead
 > 	of making another version.  The mapping should in theory
 > 	be dynamic, but in practice it suffices to add new
 > 	filesystem types as (or preferrably a bit before) they
 > 	are implemented for Net/FreeBSD.

 This patch, and the understanding behind it, is incorrect.

 That table is necessarily OS-dependent.  It maps from file system type
 to the file system type number that _the target OS_ would use for that
 file system type.

 Those numbers do not necessarily have any similarity in different
 OSes, so the translation table sill have to be different.
 Additionally, the supported file systems in each OS are going to be
 slightly different.  Only file systems which are supported by the
 target OS should be listed in the table.  Others use some undefined or
 reserved (or otherwise 'weird') value.

 So, it's incorrect to attempt to use the FreeBSD table for iBCS2, or
 to generalize it to any other system, for that matter.

 Also, the mapping should _not_ be dynamic, for the reasons cited
 above.

 If the needs of sysfs() are different than what that table was
 intended to do, well, then it should probably use a different
 mechanism.  8-)



 cgd

From: "Arne Henrik Juul" <arnej@math.ntnu.no>
To: "Chris G. Demetriou" <cgd@pa.dec.com>
Cc: gnats-bugs@gnats.netbsd.org, jarle@runit.sintef.no, netbsd-bugs@netbsd.org
Subject: Re: kern/3711: ibcs2 emulation lacks sysfs()
Date: Thu, 5 Jun 1997 19:34:38 +0200

 On Jun 5,  7:30, Chris G. Demetriou wrote:
 > > 	To implement sysfs() one needs to establish a mapping
 > > 	between filesystem-type name and number.  I noticed that
 > > 	the FreeBSD emulation already has such a mapping, so I
 > > 	extended that emulation a bit and made it common instead
 > > 	of making another version.  The mapping should in theory
 > > 	be dynamic, but in practice it suffices to add new
 > > 	filesystem types as (or preferrably a bit before) they
 > > 	are implemented for Net/FreeBSD.
 >
 > This patch, and the understanding behind it, is incorrect.
 >
 > That table is necessarily OS-dependent.  It maps from file system type
 > to the file system type number that _the target OS_ would use for that
 > file system type.
 >
 > Those numbers do not necessarily have any similarity in different
 > OSes, so the translation table sill have to be different.
 > Additionally, the supported file systems in each OS are going to be
 > slightly different.  Only file systems which are supported by the
 > target OS should be listed in the table.  Others use some undefined or
 > reserved (or otherwise 'weird') value.
 >
 > So, it's incorrect to attempt to use the FreeBSD table for iBCS2, or
 > to generalize it to any other system, for that matter.
 >
 > Also, the mapping should _not_ be dynamic, for the reasons cited
 > above.
 >
 > If the needs of sysfs() are different than what that table was
 > intended to do, well, then it should probably use a different
 > mechanism.  8-)

 I agree that the table for FreeBSD was intended to solve a different
 problem.  However, for the purpose of sysfs() we just need a table - any
 table will do - which maps between filesystem type-number and type-name.
 I didn't want to create another table to grow outdated (the FreeBSD one
 was slightly out of date already).

 Any IBCS2 application that needs to treat a specific filesystem type
 would (one hopes) use sysfs() to map name-to-number.  I guess the most
 common use of sysfs would be to map a filesystem type (as returned by
 statfs) to a string, probably for display purposes.  The numbers
 and names are dynamic, I think (at least on SCO).

 It might be that some application might want to recognize the strings
 returned by sysfs().  In that case, we would have to lie to the
 application in some way, I guess.  The most 'equivalent' filesystem
 type is probably NFS, which you might have noticed I already
 did a translation of.  If we wanted to do a better translation we would
 need another (type of) table, but I don't know which other translation
 we should then make; we don't have EAFS or S5 filesystem types, AFAIK.

 I hope this reasoning makes sense  :-)

   -  Arne H. J.

From: Arne Henrik Juul <arnej@stud.math.ntnu.no>
To: gnats-bugs@gnats.netbsd.org
Cc:  Subject: Re: kern/3711: ibcs2 emulation lacks sysfs()
Date: Mon, 20 Oct 1997 13:16:57 +0200

 Here is an updated patch for sysfs() emulation that also
 covers SVR4 emulation, tested on NetBSD/sparc with a
 Solaris program.  This patch updates svr4/syscalls.master
 so one needs to update the dependant syscall files as well.

   -  Arne H. J.

 diff -ruP orig.src/sys/compat/ibcs2/ibcs2_misc.c src/sys/compat/ibcs2/ibcs2_misc.c
 --- orig.src/sys/compat/ibcs2/ibcs2_misc.c	Sat Oct 11 15:18:09 1997
 +++ src/sys/compat/ibcs2/ibcs2_misc.c	Thu Oct 16 16:08:51 1997
 @@ -103,6 +103,7 @@
  #include <compat/ibcs2/ibcs2_syscallargs.h>
  #include <compat/ibcs2/ibcs2_sysi86.h>

 +#include <compat/common/compat_mnttype.h>

  int
  ibcs2_sys_ulimit(p, v, retval)
 @@ -1187,6 +1188,10 @@
  	return EINVAL;
  }

 +/*
 + * This call takes one, two, or three parameters,
 + * and the types differ.  Yeuch.
 + */
  int
  ibcs2_sys_sysfs(p, v, retval)
  	struct proc *p;
 @@ -1198,6 +1203,9 @@
  		syscallarg(caddr_t) d1;
  		syscallarg(char *) buf;
  	} */ *uap = v;
 +	int error, i;
 +	char fstype[MFSNAMELEN];
 +	char *fst;

  #define IBCS2_GETFSIND        1
  #define IBCS2_GETFSTYP        2
 @@ -1205,10 +1213,34 @@

  	switch(SCARG(uap, cmd)) {
  	case IBCS2_GETFSIND:
 +		if ((error = copyinstr(SCARG(uap, d1), fstype,
 +				 sizeof fstype, (u_int *)0)))
 +			return (error);
 +		/* special case nfs. */
 +		if (!strcmp(fstype, "NFS")) strcpy(fstype, "nfs");
 +		error = convert_mount_type_to_num(fstype, retval);
 +		return (error);
  	case IBCS2_GETFSTYP:
 +		i = (int)SCARG(uap, d1);
 +		fst = convert_mount_type_to_name(i);
 +		if (fst) {
 +			/* special case nfs AGAIN. */
 +			if (!strcmp(fst, "nfs"))
 +				strcpy(fstype, "NFS");
 +			else
 +				strcpy(fstype, fst);
 +			if ((error = copyout(fstype, SCARG(uap, buf),
 +						strlen(fstype)+1)))
 +				return (error);
 +			*retval = 0;
 +			return 0;
 +		}
 +		return EINVAL;
  	case IBCS2_GETNFSTYP:
 +		*retval = get_num_mount_types();
 +		return 0;
  	}
 -	return EINVAL;		/* XXX - TODO */
 +	return EINVAL;
  }

  int
 diff -ruP orig.src/sys/compat/common/compat_mnttype.c src/sys/compat/common/compat_mnttype.c
 --- orig.src/sys/compat/common/compat_mnttype.c	Thu Jan  1 01:00:00 1970
 +++ src/sys/compat/common/compat_mnttype.c	Thu Aug 21 01:49:50 1997
 @@ -0,0 +1,66 @@
 +#include <sys/param.h>
 +#include <sys/systm.h>
 +#include <sys/mount.h>
 +#include <compat/common/compat_mnttype.h>
 +
 +/*
 + * List of filesystem types.  This needs to be updated whenever
 + * a) somebody adds a filesystem to NetBSD
 + * b) somebody adds a filesystem to FreeBSD
 + * Used for binary compatibility modes, primarily with FreeBSD,
 + * but also for SysV, see ibcs2_sys_sysfs().
 + *
 + * LKM filesystems are not supported.
 + */
 +static char *netbsd_mount_type[] = {
 +		"(none)", /*  0 = MOUNT_NONE */
 +		"ffs",	  /*  1 = "Fast" Filesystem */
 +		"nfs",	  /*  2 = Network Filesystem */
 +		"mfs",	  /*  3 = Memory Filesystem */
 +		"msdos",  /*  4 = MSDOS Filesystem */
 +		"lfs",	  /*  5 = Log-based Filesystem */
 +		"lofs",	  /*  6 = Loopback filesystem */
 +		"fdesc",  /*  7 = File Descriptor Filesystem */
 +		"portal", /*  8 = Portal Filesystem */
 +		"null",	  /*  9 = Minimal Filesystem Layer */
 +		"umap",	  /* 10 = User/Group Identifier Remapping Filesystem */
 +		"kernfs", /* 11 = Kernel Information Filesystem */
 +		"procfs", /* 12 = /proc Filesystem */
 +		"afs",	  /* 13 = Andrew Filesystem */
 +		"cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
 +		"union",  /* 15 = Union (translucent) Filesystem */
 +			  /* These filesystems don't exist in NetBSD yet */
 +		NULL,     /* 16 = "devfs" - existing device Filesystem */
 +		"ext2fs", /* 17 = Linux EXT2FS */
 +		"netcon", /* 18 = Netcon Novell filesystem */
 +			  /* These filesystems don't exist in FreeBSD */
 +		"adosfs", /* 19 = AmigaDOS Filesystem */
 +};
 +#define NUMFSTYPES 20
 +
 +int
 +convert_mount_type_to_num(const char *name, int *num)
 +{
 +	int i;
 +	for (i=0; i<NUMFSTYPES; i++) {
 +		if (!strcmp(name, netbsd_mount_type[i])) {
 +			*num = i;
 +			return 0;
 +		}
 +	}
 +	return EINVAL;
 +}
 +
 +char *
 +convert_mount_type_to_name(int num)
 +{
 +	if (num>=0 && num<NUMFSTYPES) {
 +		return (netbsd_mount_type[num]);
 +	}
 +	return (NULL);
 +}
 +
 +int get_num_mount_types(void)
 +{
 +	return NUMFSTYPES;
 +}
 diff -ruP orig.src/sys/compat/common/compat_mnttype.h src/sys/compat/common/compat_mnttype.h
 --- orig.src/sys/compat/common/compat_mnttype.h	Thu Jan  1 01:00:00 1970
 +++ src/sys/compat/common/compat_mnttype.h	Thu Aug 21 01:49:50 1997
 @@ -0,0 +1,3 @@
 +extern int convert_mount_type_to_num(const char *name, int *num);
 +extern char *convert_mount_type_to_name(int num);
 +extern int get_num_mount_types(void);
 diff -ruP orig.src/sys/compat/freebsd/freebsd_file.c src/sys/compat/freebsd/freebsd_file.c
 --- orig.src/sys/compat/freebsd/freebsd_file.c	Fri Oct 10 14:22:04 1997
 +++ src/sys/compat/freebsd/freebsd_file.c	Tue Oct 14 02:08:36 1997
 @@ -49,45 +49,12 @@

  #include <compat/freebsd/freebsd_syscallargs.h>
  #include <compat/freebsd/freebsd_util.h>
 +#include <compat/common/compat_mnttype.h>

  #define	ARRAY_LENGTH(array)	(sizeof(array)/sizeof(array[0]))

  const char freebsd_emul_path[] = "/emul/freebsd";

 -static char * convert_from_freebsd_mount_type __P((int));
 -
 -static char *
 -convert_from_freebsd_mount_type(type)
 -	int type;
 -{
 -	static char *netbsd_mount_type[] = {
 -		NULL,     /*  0 = MOUNT_NONE */
 -		"ffs",	  /*  1 = "Fast" Filesystem */
 -		"nfs",	  /*  2 = Network Filesystem */
 -		"mfs",	  /*  3 = Memory Filesystem */
 -		"msdos",  /*  4 = MSDOS Filesystem */
 -		"lfs",	  /*  5 = Log-based Filesystem */
 -		"lofs",	  /*  6 = Loopback filesystem */
 -		"fdesc",  /*  7 = File Descriptor Filesystem */
 -		"portal", /*  8 = Portal Filesystem */
 -		"null",	  /*  9 = Minimal Filesystem Layer */
 -		"umap",	  /* 10 = User/Group Identifier Remapping Filesystem */
 -		"kernfs", /* 11 = Kernel Information Filesystem */
 -		"procfs", /* 12 = /proc Filesystem */
 -		"afs",	  /* 13 = Andrew Filesystem */
 -		"cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
 -		"union",  /* 15 = Union (translucent) Filesystem */
 -		NULL,     /* 16 = "devfs" - existing device Filesystem */
 -#if 0 /* These filesystems don't exist in FreeBSD */
 -		"adosfs", /* ?? = AmigaDOS Filesystem */
 -#endif
 -	};
 -
 -	if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type))
 -		return (NULL);
 -	return (netbsd_mount_type[type]);
 -}
 -
  int
  freebsd_sys_mount(p, v, retval)
  	struct proc *p;
 @@ -105,7 +72,7 @@
  	caddr_t sg = stackgap_init(p->p_emul);
  	struct sys_mount_args bma;

 -	if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
 +	if ((type = convert_mount_type_to_name(SCARG(uap, type))) == NULL)
  		return ENODEV;
  	s = stackgap_alloc(&sg, MFSNAMELEN + 1);
  	if ((error = copyout(type, s, strlen(type) + 1)) != 0)
 diff -ruP orig.src/sys/compat/ibcs2/ibcs2_stat.c src/sys/compat/ibcs2/ibcs2_stat.c
 --- orig.src/sys/compat/ibcs2/ibcs2_stat.c	Sat May  4 13:50:20 1996
 +++ src/sys/compat/ibcs2/ibcs2_stat.c	Tue Oct 14 02:08:39 1997
 @@ -39,6 +39,7 @@
  #include <sys/malloc.h>
  #include <sys/vnode.h>
  #include <sys/syscallargs.h>
 +#include <sys/syslog.h>

  #include <vm/vm.h>

 @@ -52,6 +53,8 @@
  #include <compat/ibcs2/ibcs2_util.h>
  #include <compat/ibcs2/ibcs2_utsname.h>

 +#include <compat/common/compat_mnttype.h>
 +
  static void bsd_stat2ibcs_stat __P((struct ostat *, struct ibcs2_stat *));
  static int cvt_statfs __P((struct statfs *, caddr_t, int));

 @@ -81,9 +84,16 @@
  	int len;
  {
  	struct ibcs2_statfs ssfs;
 +	int fstyp;

  	bzero(&ssfs, sizeof ssfs);
 -	ssfs.f_fstyp = 0;
 +	if (convert_mount_type_to_num(sp->f_fstypename, &fstyp)) {
 +		log(LOG_WARNING, "Unknown fstypename %s in ibcs2 cvt_statfs\n",
 +			sp->f_fstypename);
 +		ssfs.f_fstyp = 0;
 +	} else {
 +		ssfs.f_fstyp = fstyp;
 +	}
  	ssfs.f_bsize = sp->f_bsize;
  	ssfs.f_frsize = 0;
  	ssfs.f_blocks = sp->f_blocks;
 diff -ruP orig.src/sys/compat/svr4/svr4_misc.c src/sys/compat/svr4/svr4_misc.c
 --- src/sys/compat/svr4/svr4_misc.c	Sat Oct 11 15:18:45 1997
 +++ src/sys/compat/svr4/svr4_misc.c	Thu Oct 16 16:29:52 1997
 @@ -80,6 +80,8 @@
  #include <compat/svr4/svr4_sysconfig.h>
  #include <compat/svr4/svr4_acl.h>

 +#include <compat/common/compat_mnttype.h>
 +
  #include <vm/vm.h>

  static __inline clock_t timeval_to_clock_t __P((struct timeval *));
 @@ -1534,6 +1536,63 @@
  	}

  	return 0;
 +}
 +
 +
 +/*
 + * This call takes one, two, or three parameters,
 + * and the types differ.  Yeuch.
 + * Copied directly from ibcs2 emulation.
 + */
 +	int
 +svr4_sys_sysfs(p, v, retval)
 +	struct proc *p;
 +	void *v;
 +	register_t *retval;
 +{
 +	struct svr4_sys_sysfs_args /* {
 +		syscallarg(int) cmd;
 +		syscallarg(caddr_t) d1;
 +		syscallarg(char *) buf;
 +	} */ *uap = v;
 +	int error, i;
 +	char fstype[MFSNAMELEN];
 +	char *fst;
 + 
 +#define SVR4_GETFSIND        1
 +#define SVR4_GETFSTYP        2
 +#define SVR4_GETNFSTYP       3
 +
 +	switch(SCARG(uap, cmd)) {
 +	case SVR4_GETFSIND:
 +		if ((error = copyinstr(SCARG(uap, d1), fstype,
 +				 sizeof fstype, (u_int *)0)))
 +			return (error);
 +		/* special case nfs. */
 +		if (!strcmp(fstype, "NFS")) strcpy(fstype, "nfs");
 +		error = convert_mount_type_to_num(fstype, retval);
 +		return (error);
 +	case SVR4_GETFSTYP:
 +		i = (int)SCARG(uap, d1);
 +		fst = convert_mount_type_to_name(i);
 +		if (fst) {
 +			/* special case nfs AGAIN. */
 +			if (!strcmp(fst, "nfs"))
 +				strcpy(fstype, "NFS");
 +			else
 +				strcpy(fstype, fst);
 +			if ((error = copyout(fstype, SCARG(uap, buf),
 +						strlen(fstype)+1)))
 +				return (error);
 +			*retval = 0;
 +			return 0;
 +		}
 +		return EINVAL;
 +	case SVR4_GETNFSTYP:
 +		*retval = get_num_mount_types();
 +		return 0;
 +	}
 +	return EINVAL;
  }


 diff -ruP orig.src/sys/compat/svr4/syscalls.master src/sys/compat/svr4/syscalls.master
 --- orig.src/sys/compat/svr4/syscalls.master	Wed Oct 15 22:53:39 1997
 +++ src/sys/compat/svr4/syscalls.master	Thu Oct 16 16:29:52 1997
 @@ -151,7 +151,7 @@
  			    int nbytes); }
  82	OBSOL		libattach
  83	OBSOL		libdetach
 -84	UNIMPL		sysfs
 +84	STD		{ int svr4_sys_sysfs(int cmd, caddr_t d1, char *buf); }
  85	STD		{ int svr4_sys_getmsg(int fd, struct svr4_strbuf *ctl, \
  			    struct svr4_strbuf *dat, int *flags); }
  86	STD		{ int svr4_sys_putmsg(int fd, struct svr4_strbuf *ctl, \
 diff -ruP orig.src/sys/compat/svr4/svr4_syscall.h src/sys/compat/svr4/svr4_syscall.h
 --- orig.src/sys/compat/svr4/svr4_syscall.h	Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_syscall.h	Thu Oct 16 16:30:15 1997
 @@ -174,6 +174,9 @@

  				/* 82 is obsolete libattach */
  				/* 83 is obsolete libdetach */
 +/* syscall: "sysfs" ret: "int" args: "int" "caddr_t" "char *" */
 +#define	SVR4_SYS_sysfs	84
 +
  /* syscall: "getmsg" ret: "int" args: "int" "struct svr4_strbuf *" "struct svr4_strbuf *" "int *" */
  #define	SVR4_SYS_getmsg	85

 diff -ruP orig.src/sys/compat/svr4/svr4_syscallargs.h src/sys/compat/svr4/svr4_syscallargs.h
 --- orig.src/sys/compat/svr4/svr4_syscallargs.h	Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_syscallargs.h	Thu Oct 16 16:30:15 1997
 @@ -153,6 +153,12 @@
  	syscallarg(int) nbytes;
  };

 +struct svr4_sys_sysfs_args {
 +	syscallarg(int) cmd;
 +	syscallarg(caddr_t) d1;
 +	syscallarg(char *) buf;
 +};
 +
  struct svr4_sys_getmsg_args {
  	syscallarg(int) fd;
  	syscallarg(struct svr4_strbuf *) ctl;
 diff -ruP orig.src/sys/compat/svr4/svr4_syscalls.c src/sys/compat/svr4/svr4_syscalls.c
 --- orig.src/sys/compat/svr4/svr4_syscalls.c	Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_syscalls.c	Thu Oct 16 16:30:15 1997
 @@ -102,7 +102,7 @@
  	"getdents",			/* 81 = getdents */
  	"#82 (obsolete libattach)",		/* 82 = obsolete libattach */
  	"#83 (obsolete libdetach)",		/* 83 = obsolete libdetach */
 -	"#84 (unimplemented sysfs)",		/* 84 = unimplemented sysfs */
 +	"sysfs",			/* 84 = sysfs */
  	"getmsg",			/* 85 = getmsg */
  	"putmsg",			/* 86 = putmsg */
  	"poll",			/* 87 = poll */
 diff -ruP orig.src/sys/compat/svr4/svr4_sysent.c src/sys/compat/svr4/svr4_sysent.c
 --- orig.src/sys/compat/svr4/svr4_sysent.c	Tue Jul 22 13:21:17 1997
 +++ src/sys/compat/svr4/svr4_sysent.c	Thu Oct 16 16:30:15 1997
 @@ -223,8 +223,8 @@
  	    sys_nosys },			/* 82 = obsolete libattach */
  	{ 0, 0,
  	    sys_nosys },			/* 83 = obsolete libdetach */
 -	{ 0, 0,
 -	    sys_nosys },			/* 84 = unimplemented sysfs */
 +	{ 3, s(struct svr4_sys_sysfs_args),
 +	    svr4_sys_sysfs },			/* 84 = sysfs */
  	{ 4, s(struct svr4_sys_getmsg_args),
  	    svr4_sys_getmsg },			/* 85 = getmsg */
  	{ 4, s(struct svr4_sys_putmsg_args),
State-Changed-From-To: open->closed
State-Changed-By: maxv@NetBSD.org
State-Changed-When: Sat, 29 Jul 2017 07:34:44 +0000
State-Changed-Why:
We won't maintain ibcs2 and svr4 anymore, they are not reliable, and the
patches proposed in this PR are out of date.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.