date and time created 94/03/27 08:07:46 by bostic
[unix-history] / usr / src / sbin / mount / mount_ufs.c
/*-
* Copyright (c) 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* %sccs.include.redist.c%
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)mount_ufs.c 8.1 (Berkeley) %G%";
#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"
void ufs_usage __P((void));
static struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_UPDATE,
{ NULL }
};
int
mount_ufs(argc, argv)
int argc;
char * const argv[];
{
extern int optreset;
struct ufs_args args;
int ch, mntflags;
char *fs_name;
mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */
while ((ch = getopt(argc, argv, "o:")) != EOF)
switch (ch) {
case 'o':
getmntopts(optarg, mopts, &mntflags);
break;
case '?':
default:
ufs_usage();
}
argc -= optind;
argv += optind;
if (argc != 2)
ufs_usage();
args.fspec = argv[0]; /* The name of the device file. */
fs_name = argv[1]; /* The mount point. */
#define DEFAULT_ROOTUID -2
args.export.ex_root = DEFAULT_ROOTUID;
if (mntflags & MNT_RDONLY)
args.export.ex_flags = MNT_EXRDONLY;
else
args.export.ex_flags = 0;
if (mount(MOUNT_UFS, fs_name, mntflags, &args) < 0) {
(void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name);
switch (errno) {
case EMFILE:
(void)fprintf(stderr, "mount table full.\n");
break;
case EINVAL:
if (mntflags & MNT_UPDATE)
(void)fprintf(stderr,
"Specified device does not match mounted device.\n");
else
(void)fprintf(stderr,
"Incorrect super block.\n");
break;
default:
(void)fprintf(stderr, "%s\n", strerror(errno));
break;
}
return (1);
}
return (0);
}
void
ufs_usage()
{
(void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n");
exit(1);
}