Finished (?) merging with Lite2: cleaned up #include mess; fixed merging
errors (mis-sorted prototypes, duplicated MNT_NOATIME, duplicated NULL mntopts fixup). Updated getopt() usage. Fixed style bugs in FreeBSD changes (one or two per line for putfsent() stuff).
This commit is contained in:
parent
0ef3fb2233
commit
74cf460b66
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23805
@ -43,9 +43,8 @@ static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
|
|||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -59,8 +58,7 @@ static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
|
|||||||
|
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
int debug, verbose;
|
int debug, fstab_style, verbose;
|
||||||
int fstab_style = 0;
|
|
||||||
|
|
||||||
int checkvfsname __P((const char *, const char **));
|
int checkvfsname __P((const char *, const char **));
|
||||||
char *catopt __P((char *, const char *));
|
char *catopt __P((char *, const char *));
|
||||||
@ -73,8 +71,8 @@ void mangle __P((char *, int *, const char **));
|
|||||||
int mountfs __P((const char *, const char *, const char *,
|
int mountfs __P((const char *, const char *, const char *,
|
||||||
int, const char *, const char *));
|
int, const char *, const char *));
|
||||||
void prmount __P((struct statfs *));
|
void prmount __P((struct statfs *));
|
||||||
void usage __P((void));
|
|
||||||
void putfsent __P((const struct statfs *));
|
void putfsent __P((const struct statfs *));
|
||||||
|
void usage __P((void));
|
||||||
|
|
||||||
/* From mount_ufs.c. */
|
/* From mount_ufs.c. */
|
||||||
int mount_ufs __P((int, char * const *));
|
int mount_ufs __P((int, char * const *));
|
||||||
@ -95,7 +93,6 @@ static struct opt {
|
|||||||
{ MNT_RDONLY, "read-only" },
|
{ MNT_RDONLY, "read-only" },
|
||||||
{ MNT_SYNCHRONOUS, "synchronous" },
|
{ MNT_SYNCHRONOUS, "synchronous" },
|
||||||
{ MNT_UNION, "union" },
|
{ MNT_UNION, "union" },
|
||||||
{ MNT_NOATIME, "noatime" },
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,12 +113,8 @@ main(argc, argv)
|
|||||||
options = NULL;
|
options = NULL;
|
||||||
vfslist = NULL;
|
vfslist = NULL;
|
||||||
vfstype = "ufs";
|
vfstype = "ufs";
|
||||||
while ((ch = getopt(argc, argv, "padfo:rwt:uv")) != EOF)
|
while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'p':
|
|
||||||
fstab_style = 1;
|
|
||||||
verbose = 1;
|
|
||||||
break;
|
|
||||||
case 'a':
|
case 'a':
|
||||||
all = 1;
|
all = 1;
|
||||||
break;
|
break;
|
||||||
@ -135,6 +128,10 @@ main(argc, argv)
|
|||||||
if (*optarg)
|
if (*optarg)
|
||||||
options = catopt(options, optarg);
|
options = catopt(options, optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
fstab_style = 1;
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
init_flags |= MNT_RDONLY;
|
init_flags |= MNT_RDONLY;
|
||||||
break;
|
break;
|
||||||
@ -177,9 +174,9 @@ main(argc, argv)
|
|||||||
if (hasopt(fs->fs_mntops, "noauto"))
|
if (hasopt(fs->fs_mntops, "noauto"))
|
||||||
continue;
|
continue;
|
||||||
if (mountfs(fs->fs_vfstype, fs->fs_spec,
|
if (mountfs(fs->fs_vfstype, fs->fs_spec,
|
||||||
fs->fs_file, init_flags, options,
|
fs->fs_file, init_flags, options,
|
||||||
fs->fs_mntops))
|
fs->fs_mntops))
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
else if (fstab_style) {
|
else if (fstab_style) {
|
||||||
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
||||||
@ -187,14 +184,14 @@ main(argc, argv)
|
|||||||
for (i = 0; i < mntsize; i++) {
|
for (i = 0; i < mntsize; i++) {
|
||||||
if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
|
if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
|
||||||
continue;
|
continue;
|
||||||
putfsent (&mntbuf[i]);
|
putfsent(&mntbuf[i]);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
||||||
err(1, "getmntinfo");
|
err(1, "getmntinfo");
|
||||||
for (i = 0; i < mntsize; i++) {
|
for (i = 0; i < mntsize; i++) {
|
||||||
if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
|
if (checkvfsname(mntbuf[i].f_fstypename,
|
||||||
|
vfslist))
|
||||||
continue;
|
continue;
|
||||||
prmount(&mntbuf[i]);
|
prmount(&mntbuf[i]);
|
||||||
}
|
}
|
||||||
@ -288,8 +285,6 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
const char *vfstype, *spec, *name, *options, *mntopts;
|
const char *vfstype, *spec, *name, *options, *mntopts;
|
||||||
int flags;
|
int flags;
|
||||||
{
|
{
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
/* List of directories containing mount_xxx subcommands. */
|
/* List of directories containing mount_xxx subcommands. */
|
||||||
static const char *edirs[] = {
|
static const char *edirs[] = {
|
||||||
_PATH_SBIN,
|
_PATH_SBIN,
|
||||||
@ -297,6 +292,7 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
const char *argv[100], **edir;
|
const char *argv[100], **edir;
|
||||||
|
struct stat sb;
|
||||||
struct statfs sf;
|
struct statfs sf;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int argc, i, status;
|
int argc, i, status;
|
||||||
@ -312,9 +308,6 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mntopts == NULL)
|
|
||||||
mntopts = "";
|
|
||||||
|
|
||||||
name = mntpath;
|
name = mntpath;
|
||||||
|
|
||||||
if (mntopts == NULL)
|
if (mntopts == NULL)
|
||||||
@ -415,7 +408,7 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
if (fstab_style)
|
if (fstab_style)
|
||||||
putfsent (&sf);
|
putfsent(&sf);
|
||||||
else
|
else
|
||||||
prmount(&sf);
|
prmount(&sf);
|
||||||
}
|
}
|
||||||
@ -529,43 +522,36 @@ usage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
putfsent (ent)
|
putfsent(ent)
|
||||||
const struct statfs *ent;
|
const struct statfs *ent;
|
||||||
{
|
{
|
||||||
struct fstab *fst;
|
struct fstab *fst;
|
||||||
|
|
||||||
printf ("%s\t%s\t%s %s",
|
printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname,
|
||||||
ent->f_mntfromname, ent->f_mntonname,
|
ent->f_fstypename, (ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
|
||||||
ent->f_fstypename,
|
|
||||||
(ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
|
|
||||||
|
|
||||||
if (ent->f_flags & MNT_SYNCHRONOUS)
|
/* XXX should use optnames[] - put shorter names in it. */
|
||||||
printf (",sync");
|
if (ent->f_flags & MNT_SYNCHRONOUS)
|
||||||
|
printf(",sync");
|
||||||
|
if (ent->f_flags & MNT_NOEXEC)
|
||||||
|
printf(",noexec");
|
||||||
|
if (ent->f_flags & MNT_NOSUID)
|
||||||
|
printf(",nosuid");
|
||||||
|
if (ent->f_flags & MNT_NODEV)
|
||||||
|
printf(",nodev");
|
||||||
|
if (ent->f_flags & MNT_UNION)
|
||||||
|
printf(",union");
|
||||||
|
if (ent->f_flags & MNT_ASYNC)
|
||||||
|
printf(",async");
|
||||||
|
if (ent->f_flags & MNT_NOATIME)
|
||||||
|
printf(",noatime");
|
||||||
|
|
||||||
if (ent->f_flags & MNT_NOEXEC)
|
if (fst = getfsspec(ent->f_mntfromname))
|
||||||
printf (",noexec");
|
printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
||||||
|
else if (fst = getfsfile(ent->f_mntonname))
|
||||||
if (ent->f_flags & MNT_NOSUID)
|
printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
||||||
printf (",nosuid");
|
else if (ent->f_type == MOUNT_UFS)
|
||||||
|
printf("\t1 1\n");
|
||||||
if (ent->f_flags & MNT_NODEV)
|
else
|
||||||
printf (",nodev");
|
printf("\t0 0\n");
|
||||||
|
|
||||||
if (ent->f_flags & MNT_UNION)
|
|
||||||
printf (",union");
|
|
||||||
|
|
||||||
if (ent->f_flags & MNT_ASYNC)
|
|
||||||
printf (",async");
|
|
||||||
|
|
||||||
if (ent->f_flags & MNT_NOATIME)
|
|
||||||
printf (",noatime");
|
|
||||||
|
|
||||||
if (fst = getfsspec (ent->f_mntfromname))
|
|
||||||
printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
|
||||||
else if (fst = getfsfile (ent->f_mntonname))
|
|
||||||
printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
|
||||||
else if (ent->f_type == MOUNT_UFS)
|
|
||||||
printf ("\t1 1\n");
|
|
||||||
else
|
|
||||||
printf ("\t0 0\n");
|
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,8 @@ static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
|
|||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -59,8 +58,7 @@ static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
|
|||||||
|
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
int debug, verbose;
|
int debug, fstab_style, verbose;
|
||||||
int fstab_style = 0;
|
|
||||||
|
|
||||||
int checkvfsname __P((const char *, const char **));
|
int checkvfsname __P((const char *, const char **));
|
||||||
char *catopt __P((char *, const char *));
|
char *catopt __P((char *, const char *));
|
||||||
@ -73,8 +71,8 @@ void mangle __P((char *, int *, const char **));
|
|||||||
int mountfs __P((const char *, const char *, const char *,
|
int mountfs __P((const char *, const char *, const char *,
|
||||||
int, const char *, const char *));
|
int, const char *, const char *));
|
||||||
void prmount __P((struct statfs *));
|
void prmount __P((struct statfs *));
|
||||||
void usage __P((void));
|
|
||||||
void putfsent __P((const struct statfs *));
|
void putfsent __P((const struct statfs *));
|
||||||
|
void usage __P((void));
|
||||||
|
|
||||||
/* From mount_ufs.c. */
|
/* From mount_ufs.c. */
|
||||||
int mount_ufs __P((int, char * const *));
|
int mount_ufs __P((int, char * const *));
|
||||||
@ -95,7 +93,6 @@ static struct opt {
|
|||||||
{ MNT_RDONLY, "read-only" },
|
{ MNT_RDONLY, "read-only" },
|
||||||
{ MNT_SYNCHRONOUS, "synchronous" },
|
{ MNT_SYNCHRONOUS, "synchronous" },
|
||||||
{ MNT_UNION, "union" },
|
{ MNT_UNION, "union" },
|
||||||
{ MNT_NOATIME, "noatime" },
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,12 +113,8 @@ main(argc, argv)
|
|||||||
options = NULL;
|
options = NULL;
|
||||||
vfslist = NULL;
|
vfslist = NULL;
|
||||||
vfstype = "ufs";
|
vfstype = "ufs";
|
||||||
while ((ch = getopt(argc, argv, "padfo:rwt:uv")) != EOF)
|
while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'p':
|
|
||||||
fstab_style = 1;
|
|
||||||
verbose = 1;
|
|
||||||
break;
|
|
||||||
case 'a':
|
case 'a':
|
||||||
all = 1;
|
all = 1;
|
||||||
break;
|
break;
|
||||||
@ -135,6 +128,10 @@ main(argc, argv)
|
|||||||
if (*optarg)
|
if (*optarg)
|
||||||
options = catopt(options, optarg);
|
options = catopt(options, optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
fstab_style = 1;
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
init_flags |= MNT_RDONLY;
|
init_flags |= MNT_RDONLY;
|
||||||
break;
|
break;
|
||||||
@ -177,9 +174,9 @@ main(argc, argv)
|
|||||||
if (hasopt(fs->fs_mntops, "noauto"))
|
if (hasopt(fs->fs_mntops, "noauto"))
|
||||||
continue;
|
continue;
|
||||||
if (mountfs(fs->fs_vfstype, fs->fs_spec,
|
if (mountfs(fs->fs_vfstype, fs->fs_spec,
|
||||||
fs->fs_file, init_flags, options,
|
fs->fs_file, init_flags, options,
|
||||||
fs->fs_mntops))
|
fs->fs_mntops))
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
else if (fstab_style) {
|
else if (fstab_style) {
|
||||||
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
||||||
@ -187,14 +184,14 @@ main(argc, argv)
|
|||||||
for (i = 0; i < mntsize; i++) {
|
for (i = 0; i < mntsize; i++) {
|
||||||
if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
|
if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
|
||||||
continue;
|
continue;
|
||||||
putfsent (&mntbuf[i]);
|
putfsent(&mntbuf[i]);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
||||||
err(1, "getmntinfo");
|
err(1, "getmntinfo");
|
||||||
for (i = 0; i < mntsize; i++) {
|
for (i = 0; i < mntsize; i++) {
|
||||||
if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
|
if (checkvfsname(mntbuf[i].f_fstypename,
|
||||||
|
vfslist))
|
||||||
continue;
|
continue;
|
||||||
prmount(&mntbuf[i]);
|
prmount(&mntbuf[i]);
|
||||||
}
|
}
|
||||||
@ -288,8 +285,6 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
const char *vfstype, *spec, *name, *options, *mntopts;
|
const char *vfstype, *spec, *name, *options, *mntopts;
|
||||||
int flags;
|
int flags;
|
||||||
{
|
{
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
/* List of directories containing mount_xxx subcommands. */
|
/* List of directories containing mount_xxx subcommands. */
|
||||||
static const char *edirs[] = {
|
static const char *edirs[] = {
|
||||||
_PATH_SBIN,
|
_PATH_SBIN,
|
||||||
@ -297,6 +292,7 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
const char *argv[100], **edir;
|
const char *argv[100], **edir;
|
||||||
|
struct stat sb;
|
||||||
struct statfs sf;
|
struct statfs sf;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int argc, i, status;
|
int argc, i, status;
|
||||||
@ -312,9 +308,6 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mntopts == NULL)
|
|
||||||
mntopts = "";
|
|
||||||
|
|
||||||
name = mntpath;
|
name = mntpath;
|
||||||
|
|
||||||
if (mntopts == NULL)
|
if (mntopts == NULL)
|
||||||
@ -415,7 +408,7 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
if (fstab_style)
|
if (fstab_style)
|
||||||
putfsent (&sf);
|
putfsent(&sf);
|
||||||
else
|
else
|
||||||
prmount(&sf);
|
prmount(&sf);
|
||||||
}
|
}
|
||||||
@ -529,43 +522,36 @@ usage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
putfsent (ent)
|
putfsent(ent)
|
||||||
const struct statfs *ent;
|
const struct statfs *ent;
|
||||||
{
|
{
|
||||||
struct fstab *fst;
|
struct fstab *fst;
|
||||||
|
|
||||||
printf ("%s\t%s\t%s %s",
|
printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname,
|
||||||
ent->f_mntfromname, ent->f_mntonname,
|
ent->f_fstypename, (ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
|
||||||
ent->f_fstypename,
|
|
||||||
(ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
|
|
||||||
|
|
||||||
if (ent->f_flags & MNT_SYNCHRONOUS)
|
/* XXX should use optnames[] - put shorter names in it. */
|
||||||
printf (",sync");
|
if (ent->f_flags & MNT_SYNCHRONOUS)
|
||||||
|
printf(",sync");
|
||||||
|
if (ent->f_flags & MNT_NOEXEC)
|
||||||
|
printf(",noexec");
|
||||||
|
if (ent->f_flags & MNT_NOSUID)
|
||||||
|
printf(",nosuid");
|
||||||
|
if (ent->f_flags & MNT_NODEV)
|
||||||
|
printf(",nodev");
|
||||||
|
if (ent->f_flags & MNT_UNION)
|
||||||
|
printf(",union");
|
||||||
|
if (ent->f_flags & MNT_ASYNC)
|
||||||
|
printf(",async");
|
||||||
|
if (ent->f_flags & MNT_NOATIME)
|
||||||
|
printf(",noatime");
|
||||||
|
|
||||||
if (ent->f_flags & MNT_NOEXEC)
|
if (fst = getfsspec(ent->f_mntfromname))
|
||||||
printf (",noexec");
|
printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
||||||
|
else if (fst = getfsfile(ent->f_mntonname))
|
||||||
if (ent->f_flags & MNT_NOSUID)
|
printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
||||||
printf (",nosuid");
|
else if (ent->f_type == MOUNT_UFS)
|
||||||
|
printf("\t1 1\n");
|
||||||
if (ent->f_flags & MNT_NODEV)
|
else
|
||||||
printf (",nodev");
|
printf("\t0 0\n");
|
||||||
|
|
||||||
if (ent->f_flags & MNT_UNION)
|
|
||||||
printf (",union");
|
|
||||||
|
|
||||||
if (ent->f_flags & MNT_ASYNC)
|
|
||||||
printf (",async");
|
|
||||||
|
|
||||||
if (ent->f_flags & MNT_NOATIME)
|
|
||||||
printf (",noatime");
|
|
||||||
|
|
||||||
if (fst = getfsspec (ent->f_mntfromname))
|
|
||||||
printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
|
||||||
else if (fst = getfsfile (ent->f_mntonname))
|
|
||||||
printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno);
|
|
||||||
else if (ent->f_type == MOUNT_UFS)
|
|
||||||
printf ("\t1 1\n");
|
|
||||||
else
|
|
||||||
printf ("\t0 0\n");
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user