Module Name:    othersrc
Committed By:   pooka
Date:           Thu Apr  9 10:37:04 UTC 2009

Modified Files:
        othersrc/lib/libfsu_mount: Makefile fsu_mount.c
Added Files:
        othersrc/lib/libfsu_mount: mount_sysvbfs.c mount_sysvbfs.h

Log Message:
support sysvbfs


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/lib/libfsu_mount/Makefile
cvs rdiff -u -r1.5 -r1.6 othersrc/lib/libfsu_mount/fsu_mount.c
cvs rdiff -u -r0 -r1.1 othersrc/lib/libfsu_mount/mount_sysvbfs.c \
    othersrc/lib/libfsu_mount/mount_sysvbfs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/lib/libfsu_mount/Makefile
diff -u othersrc/lib/libfsu_mount/Makefile:1.3 othersrc/lib/libfsu_mount/Makefile:1.4
--- othersrc/lib/libfsu_mount/Makefile:1.3	Wed Apr  1 16:01:40 2009
+++ othersrc/lib/libfsu_mount/Makefile	Thu Apr  9 10:37:04 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2009/04/01 16:01:40 pooka Exp $
+#	$NetBSD: Makefile,v 1.4 2009/04/09 10:37:04 pooka Exp $
 #
 
 .include <bsd.own.mk>
@@ -11,7 +11,8 @@
 LIB=		fsu_mount
 SRCS=		fsu_mount.c mount_cd9660.c mount_ext2fs.c mount_hfs.c  \
 		mount_msdos.c mount_tmpfs.c mount_efs.c mount_ffs.c \
-		mount_lfs.c mount_ntfs.c mount_udf.c pathadj.c fattr.c
+		mount_lfs.c mount_ntfs.c mount_udf.c pathadj.c fattr.c \
+		mount_sysvbfs.c
 
 INCS=		fsu_mount.h
 MAN=		fsu_mount.3

Index: othersrc/lib/libfsu_mount/fsu_mount.c
diff -u othersrc/lib/libfsu_mount/fsu_mount.c:1.5 othersrc/lib/libfsu_mount/fsu_mount.c:1.6
--- othersrc/lib/libfsu_mount/fsu_mount.c:1.5	Wed Apr  1 16:01:40 2009
+++ othersrc/lib/libfsu_mount/fsu_mount.c	Thu Apr  9 10:37:04 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fsu_mount.c,v 1.5 2009/04/01 16:01:40 pooka Exp $ */
+/* $NetBSD: fsu_mount.c,v 1.6 2009/04/09 10:37:04 pooka Exp $ */
 
 /*
  * Copyright (c) 2008 Arnaud Ysmal.  All Rights Reserved.
@@ -38,6 +38,7 @@
 #include <fs/hfs/hfs.h>
 #include <msdosfs/msdosfsmount.h>
 #include <ntfs/ntfsmount.h>
+#include <fs/sysvbfs/sysvbfs_args.h>
 #include <fs/tmpfs/tmpfs_args.h>
 #include <fs/udf/udf_mount.h>
 
@@ -53,6 +54,7 @@
 #include "mount_lfs.h"
 #include "mount_msdos.h"
 #include "mount_ntfs.h"
+#include "mount_sysvbfs.h"
 #include "mount_tmpfs.h"
 #include "mount_udf.h"
 #ifdef WITH_SYSPUFFS
@@ -79,6 +81,7 @@
 	struct hfs_args args_hfs;
 	struct msdosfs_args args_msdos;
 	struct ntfs_args args_ntfs;
+	struct sysvbfs_args args_sysvbfs;
 	struct tmpfs_args args_tmpfs;
 	struct udf_args args_udf;
 #ifdef WITH_SYSPUFFS
@@ -116,6 +119,8 @@
 	  (parseargs_fp)mount_udf_parseargs,		0 },
 	{ MOUNT_EFS,	&args.args_efs,		sizeof(struct efs_args),
 	  (parseargs_fp)mount_efs_parseargs,		0 },
+	{ MOUNT_SYSVBFS,&args.args_sysvbfs,	sizeof(struct sysvbfs_args),
+	  (parseargs_fp)mount_sysvbfs_parseargs,	0 },
 	{ MOUNT_TMPFS,	&args.args_tmpfs,	sizeof(struct tmpfs_args),
 	  (parseargs_fp)mount_tmpfs_parseargs,		0 },
 #ifdef WITH_SYSPUFFS

Added files:

Index: othersrc/lib/libfsu_mount/mount_sysvbfs.c
diff -u /dev/null othersrc/lib/libfsu_mount/mount_sysvbfs.c:1.1
--- /dev/null	Thu Apr  9 10:37:04 2009
+++ othersrc/lib/libfsu_mount/mount_sysvbfs.c	Thu Apr  9 10:37:04 2009
@@ -0,0 +1,168 @@
+/*	$NetBSD: mount_sysvbfs.c,v 1.1 2009/04/09 10:37:04 pooka Exp $	*/
+
+/* From:
+ *	NetBSD: mount_sysvbfs.c,v 1.7 2008/09/04 12:07:58 pooka Exp
+ */
+
+/*-
+ * Copyright (c) 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1993, 1994\
+ The Regents of the University of California.  All rights reserved.");
+#endif /* not lint */
+
+#ifndef lint
+__RCSID("$NetBSD: mount_sysvbfs.c,v 1.1 2009/04/09 10:37:04 pooka Exp $");
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/mount.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <mntopts.h>
+
+#include "mountprog.h"
+#include "mount_sysvbfs.h"
+
+static const struct mntopt mopts[] = {
+	MOPT_STDOPTS,
+	MOPT_UPDATE,
+	MOPT_GETARGS,
+	MOPT_NULL,
+};
+
+#ifndef USE_UKFS
+
+static void
+sysvbfs_usage(void)
+{
+
+	(void)fprintf(stderr, "usage: %s [-o options] special node\n",
+	    getprogname());
+	exit(EXIT_FAILURE);
+}
+#endif
+
+#ifndef MOUNT_NOMAIN
+int
+main(int argc, char **argv)
+{
+
+	return mount_sysvbfs(argc, argv);
+}
+#endif
+
+int
+mount_sysvbfs_parseargs(int argc, char **argv,
+	struct sysvbfs_args *args, int *mntflags,
+	char *canon_dev, char *canon_dir)
+{
+	int ch;
+	mntoptparse_t mp;
+
+	*mntflags = 0;
+	optind = optreset = 1;		/* Reset for parse of new argv. */
+	while ((ch = getopt(argc, argv, "o:")) != -1)
+		switch (ch) {
+		case 'o':
+			mp = getmntopts(optarg, mopts, mntflags, 0);
+			if (mp == NULL)
+				err(1, "getmntopts");
+			freemntopts(mp);
+			break;
+		case '?':
+		default:
+#ifdef USE_UKFS
+			warn("usage");
+			return 1;
+#else
+			sysvbfs_usage();
+#endif
+		}
+	argc -= optind;
+	argv += optind;
+
+#ifdef USE_UKFS
+	if (argc != 2) {
+		warn("usage");
+		return 1;
+	}
+#else
+	if (argc != 2)
+		sysvbfs_usage();
+#endif
+
+	pathadj(argv[0], canon_dev);
+	args->fspec = canon_dev;
+	pathadj(argv[1], canon_dir);
+
+	return 0;
+}
+
+int
+mount_sysvbfs(int argc, char *argv[])
+{
+	struct sysvbfs_args args;
+	char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
+	const char *errcause;
+	int mntflags;
+
+	mount_sysvbfs_parseargs(argc, argv, &args, &mntflags,
+	    canon_dev, canon_dir);
+
+	if (mount(MOUNT_SYSVBFS, canon_dir, mntflags, &args, sizeof args)==-1) {
+		switch (errno) {
+		case EMFILE:
+			errcause = "mount table full";
+			break;
+		case EINVAL:
+			if (mntflags & MNT_UPDATE)
+				errcause =
+			    "specified device does not match mounted device";
+			else
+				errcause = "incorrect super block";
+			break;
+		default:
+			errcause = strerror(errno);
+			break;
+		}
+		errx(EXIT_FAILURE, "%s on %s: %s",
+		    canon_dev, canon_dir, errcause);
+	}
+	exit(EXIT_SUCCESS);
+}
Index: othersrc/lib/libfsu_mount/mount_sysvbfs.h
diff -u /dev/null othersrc/lib/libfsu_mount/mount_sysvbfs.h:1.1
--- /dev/null	Thu Apr  9 10:37:04 2009
+++ othersrc/lib/libfsu_mount/mount_sysvbfs.h	Thu Apr  9 10:37:04 2009
@@ -0,0 +1,37 @@
+/*	$NetBSD: mount_sysvbfs.h,v 1.1 2009/04/09 10:37:04 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SBIN_MOUNT_SYSVBFS_MOUNT_SYSVBFS_H_
+#define _SBIN_MOUNT_SYSVBFS_MOUNT_SYSVBFS_H_
+
+#include <fs/sysvbfs/sysvbfs_args.h>
+
+int     mount_sysvbfs(int, char **);
+int	mount_sysvbfs_parseargs(int, char **, struct sysvbfs_args *, int *,
+				char *, char *);
+
+#endif /* _SBIN_MOUNT_SYSVBFS_MOUNT_SYSVBFS_H_ */

Reply via email to