1 /* $NetBSD: mount_efs.c,v 1.3 2007/07/16 17:06:52 pooka Exp $ */
4 * Copyright (c) 2006 Stephen M. Rumble <rumble@ephemeral.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/param.h>
20 #include <sys/mount.h>
21 #include <fs/efs/efs.h>
22 #include <fs/efs/efs_sb.h>
23 #include <fs/efs/efs_mount.h>
34 #include "mountprog.h"
35 #include "mount_efs.h"
37 static const struct mntopt mopts
[] = {
44 static void usage(void);
50 fprintf(stderr
, "usage: %s [-o options] special node\n", getprogname());
55 mount_efs_parseargs(int argc
, char **argv
,
56 struct efs_args
*args
, int *mntflags
,
57 char *canon_dev
, char *canon_dir
)
64 memset(args
, 0, sizeof(*args
));
67 while ((ch
= getopt(argc
, argv
, "o:")) != -1) {
70 mp
= getmntopts(optarg
, mopts
, mntflags
, NULL
);
86 pathadj(argv
[0], canon_dev
);
87 pathadj(argv
[1], canon_dir
);
89 args
->fspec
= canon_dev
;
90 args
->version
= EFS_MNT_VERSION
;
94 mount_efs(int argc
, char **argv
)
96 char special
[MAXPATHLEN
], node
[MAXPATHLEN
];
100 mount_efs_parseargs(argc
, argv
, &args
, &mntflags
, special
, node
);
102 if (mount(MOUNT_EFS
, node
, mntflags
, &args
, sizeof args
) == -1)
103 err(EXIT_FAILURE
, "%s on %s", special
, node
);
110 main(int argc
, char **argv
)
113 setprogname(argv
[0]);
114 return (mount_efs(argc
, argv
));