I have added a new option -p to the mount command. This was
inspired by SunOS version of mount which uses option -p to indicate that the mount information should be printed in fstab format. This is a neat way to create a new fstab file to use later when one has modified the mount points or mount options or added or removed mount some mount points. You just type mount -p > /etc/fstab.new and there is your new fstab file ready to be used though you will of course have to add any necessary noauto flags manually. [Committers note: This also seems to do the wrong thing for AMD mounts, but in the more average case this is a nifty feature nonetheless and one can always edit the bogus entries out] Submitted-By: Jukka Ukkonen <jau@jau.csc.fi>
This commit is contained in:
parent
31a7f355c6
commit
a257a45ecd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17243
@ -39,13 +39,13 @@
|
|||||||
.Nd mount file systems
|
.Nd mount file systems
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm mount
|
.Nm mount
|
||||||
.Op Fl adfruvw
|
.Op Fl adfpruvw
|
||||||
.Op Fl t Ar ufs | lfs | external_type
|
.Op Fl t Ar ufs | lfs | external_type
|
||||||
.Nm mount
|
.Nm mount
|
||||||
.Op Fl dfruvw
|
.Op Fl dfpruvw
|
||||||
.Ar special | node
|
.Ar special | node
|
||||||
.Nm mount
|
.Nm mount
|
||||||
.Op Fl dfruvw
|
.Op Fl dfpruvw
|
||||||
.Op Fl o Ar options
|
.Op Fl o Ar options
|
||||||
.Op Fl t Ar ufs | lfs | external_type
|
.Op Fl t Ar ufs | lfs | external_type
|
||||||
.Ar special node
|
.Ar special node
|
||||||
@ -167,6 +167,10 @@ to execute the equivalent of:
|
|||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
/sbin/mount_mfs -o nosuid -N -s 4000 /dev/dk0b /tmp
|
/sbin/mount_mfs -o nosuid -N -s 4000 /dev/dk0b /tmp
|
||||||
.Ed
|
.Ed
|
||||||
|
.It Fl p
|
||||||
|
Print mount information in fstab format. Implies also the
|
||||||
|
.Fl v
|
||||||
|
option.
|
||||||
.It Fl r
|
.It Fl r
|
||||||
The file system is to be mounted read-only.
|
The file system is to be mounted read-only.
|
||||||
Mount the file system read-only (even the super-user may not write it).
|
Mount the file system read-only (even the super-user may not write it).
|
||||||
|
@ -59,6 +59,9 @@ static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
|
|||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
int debug, verbose, skipvfs;
|
int debug, verbose, skipvfs;
|
||||||
|
int fstab_style = 0;
|
||||||
|
|
||||||
|
static char *mnttype[] = INITMOUNTNAMES;
|
||||||
|
|
||||||
int badvfsname __P((const char *, const char **));
|
int badvfsname __P((const char *, const char **));
|
||||||
int badvfstype __P((int, const char **));
|
int badvfstype __P((int, const char **));
|
||||||
@ -72,6 +75,7 @@ int mountfs __P((const char *, const char *, const char *,
|
|||||||
int, const char *, const char *));
|
int, const char *, const char *));
|
||||||
void prmount __P((const char *, const char *, int));
|
void prmount __P((const char *, const char *, int));
|
||||||
void usage __P((void));
|
void usage __P((void));
|
||||||
|
void putfsent __P((const struct statfs *));
|
||||||
|
|
||||||
/* From mount_ufs.c. */
|
/* From mount_ufs.c. */
|
||||||
int mount_ufs __P((int, char * const *));
|
int mount_ufs __P((int, char * const *));
|
||||||
@ -112,8 +116,12 @@ main(argc, argv)
|
|||||||
options = NULL;
|
options = NULL;
|
||||||
vfslist = NULL;
|
vfslist = NULL;
|
||||||
vfstype = "ufs";
|
vfstype = "ufs";
|
||||||
while ((ch = getopt(argc, argv, "adfo:rwt:uv")) != EOF)
|
while ((ch = getopt(argc, argv, "padfo:rwt:uv")) != EOF)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case 'p':
|
||||||
|
fstab_style = 1;
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
all = 1;
|
all = 1;
|
||||||
break;
|
break;
|
||||||
@ -173,6 +181,15 @@ main(argc, argv)
|
|||||||
fs->fs_mntops))
|
fs->fs_mntops))
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
|
else if (fstab_style) {
|
||||||
|
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
||||||
|
err(1, "getmntinfo");
|
||||||
|
for (i = 0; i < mntsize; i++) {
|
||||||
|
if (badvfstype(mntbuf[i].f_type, vfslist))
|
||||||
|
continue;
|
||||||
|
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");
|
||||||
@ -372,7 +389,12 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
warn("%s", name);
|
warn("%s", name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
prmount(sf.f_mntfromname, sf.f_mntonname, sf.f_flags);
|
|
||||||
|
if (fstab_style)
|
||||||
|
putfsent (&sf);
|
||||||
|
else
|
||||||
|
prmount (sf.f_mntfromname,
|
||||||
|
sf.f_mntonname, sf.f_flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -530,9 +552,48 @@ usage()
|
|||||||
|
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"usage: mount %s %s\n mount %s\n mount %s\n",
|
"usage: mount %s %s\n mount %s\n mount %s\n",
|
||||||
"[-dfruvw] [-o options] [-t ufs | external_type]",
|
"[-dfpruvw] [-o options] [-t ufs | external_type]",
|
||||||
"special node",
|
"special node",
|
||||||
"[-adfruvw] [-t ufs | external_type]",
|
"[-adfpruvw] [-t ufs | external_type]",
|
||||||
"[-dfruvw] special | node");
|
"[-dfpruvw] special | node");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
putfsent (ent)
|
||||||
|
const struct statfs *ent;
|
||||||
|
{
|
||||||
|
struct fstab *fst;
|
||||||
|
|
||||||
|
printf ("%s\t%s\t%s %s",
|
||||||
|
ent->f_mntfromname, ent->f_mntonname,
|
||||||
|
mnttype[ent->f_type],
|
||||||
|
(ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
|
||||||
|
|
||||||
|
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 (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");
|
||||||
|
}
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
.Nd mount file systems
|
.Nd mount file systems
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm mount
|
.Nm mount
|
||||||
.Op Fl adfruvw
|
.Op Fl adfpruvw
|
||||||
.Op Fl t Ar ufs | lfs | external_type
|
.Op Fl t Ar ufs | lfs | external_type
|
||||||
.Nm mount
|
.Nm mount
|
||||||
.Op Fl dfruvw
|
.Op Fl dfpruvw
|
||||||
.Ar special | node
|
.Ar special | node
|
||||||
.Nm mount
|
.Nm mount
|
||||||
.Op Fl dfruvw
|
.Op Fl dfpruvw
|
||||||
.Op Fl o Ar options
|
.Op Fl o Ar options
|
||||||
.Op Fl t Ar ufs | lfs | external_type
|
.Op Fl t Ar ufs | lfs | external_type
|
||||||
.Ar special node
|
.Ar special node
|
||||||
@ -167,6 +167,10 @@ to execute the equivalent of:
|
|||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
/sbin/mount_mfs -o nosuid -N -s 4000 /dev/dk0b /tmp
|
/sbin/mount_mfs -o nosuid -N -s 4000 /dev/dk0b /tmp
|
||||||
.Ed
|
.Ed
|
||||||
|
.It Fl p
|
||||||
|
Print mount information in fstab format. Implies also the
|
||||||
|
.Fl v
|
||||||
|
option.
|
||||||
.It Fl r
|
.It Fl r
|
||||||
The file system is to be mounted read-only.
|
The file system is to be mounted read-only.
|
||||||
Mount the file system read-only (even the super-user may not write it).
|
Mount the file system read-only (even the super-user may not write it).
|
||||||
|
@ -59,6 +59,9 @@ static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
|
|||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
int debug, verbose, skipvfs;
|
int debug, verbose, skipvfs;
|
||||||
|
int fstab_style = 0;
|
||||||
|
|
||||||
|
static char *mnttype[] = INITMOUNTNAMES;
|
||||||
|
|
||||||
int badvfsname __P((const char *, const char **));
|
int badvfsname __P((const char *, const char **));
|
||||||
int badvfstype __P((int, const char **));
|
int badvfstype __P((int, const char **));
|
||||||
@ -72,6 +75,7 @@ int mountfs __P((const char *, const char *, const char *,
|
|||||||
int, const char *, const char *));
|
int, const char *, const char *));
|
||||||
void prmount __P((const char *, const char *, int));
|
void prmount __P((const char *, const char *, int));
|
||||||
void usage __P((void));
|
void usage __P((void));
|
||||||
|
void putfsent __P((const struct statfs *));
|
||||||
|
|
||||||
/* From mount_ufs.c. */
|
/* From mount_ufs.c. */
|
||||||
int mount_ufs __P((int, char * const *));
|
int mount_ufs __P((int, char * const *));
|
||||||
@ -112,8 +116,12 @@ main(argc, argv)
|
|||||||
options = NULL;
|
options = NULL;
|
||||||
vfslist = NULL;
|
vfslist = NULL;
|
||||||
vfstype = "ufs";
|
vfstype = "ufs";
|
||||||
while ((ch = getopt(argc, argv, "adfo:rwt:uv")) != EOF)
|
while ((ch = getopt(argc, argv, "padfo:rwt:uv")) != EOF)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case 'p':
|
||||||
|
fstab_style = 1;
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
all = 1;
|
all = 1;
|
||||||
break;
|
break;
|
||||||
@ -173,6 +181,15 @@ main(argc, argv)
|
|||||||
fs->fs_mntops))
|
fs->fs_mntops))
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
|
else if (fstab_style) {
|
||||||
|
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
|
||||||
|
err(1, "getmntinfo");
|
||||||
|
for (i = 0; i < mntsize; i++) {
|
||||||
|
if (badvfstype(mntbuf[i].f_type, vfslist))
|
||||||
|
continue;
|
||||||
|
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");
|
||||||
@ -372,7 +389,12 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||||||
warn("%s", name);
|
warn("%s", name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
prmount(sf.f_mntfromname, sf.f_mntonname, sf.f_flags);
|
|
||||||
|
if (fstab_style)
|
||||||
|
putfsent (&sf);
|
||||||
|
else
|
||||||
|
prmount (sf.f_mntfromname,
|
||||||
|
sf.f_mntonname, sf.f_flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -530,9 +552,48 @@ usage()
|
|||||||
|
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"usage: mount %s %s\n mount %s\n mount %s\n",
|
"usage: mount %s %s\n mount %s\n mount %s\n",
|
||||||
"[-dfruvw] [-o options] [-t ufs | external_type]",
|
"[-dfpruvw] [-o options] [-t ufs | external_type]",
|
||||||
"special node",
|
"special node",
|
||||||
"[-adfruvw] [-t ufs | external_type]",
|
"[-adfpruvw] [-t ufs | external_type]",
|
||||||
"[-dfruvw] special | node");
|
"[-dfpruvw] special | node");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
putfsent (ent)
|
||||||
|
const struct statfs *ent;
|
||||||
|
{
|
||||||
|
struct fstab *fst;
|
||||||
|
|
||||||
|
printf ("%s\t%s\t%s %s",
|
||||||
|
ent->f_mntfromname, ent->f_mntonname,
|
||||||
|
mnttype[ent->f_type],
|
||||||
|
(ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
|
||||||
|
|
||||||
|
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 (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