Home | History | Annotate | Download | only in mount
History log of /src/sbin/mount/mount.c
RevisionDateAuthorComments
 1.108  01-Jul-2025  kre PR bin/59494

Cause "mount -v [spec] filesystem" to indicate only what was
mounted (and where), to obtain all the rest of the data that
used to be printed, -v must be given twice.

Implemented differently from the patch given in the PR from
greywolf, but the same idea.

While here, avoid the -d option, after indicating what mount
command would have been run, but wasn't, going on to attempt
to report statistics on the never mounted filesystem, and
instead getting those from the intended mount point.

Update the man page to match.
 1.107  07-Dec-2021  christos remove impossible test.
 1.106  02-Dec-2021  christos PR/56529: RVP: mount should try ffs when DIOCGWEDGEINFO returns an empty
dkw_ptype.
 1.105  21-Nov-2021  simonb Add some { } around an if body that is followed by an "else {".
 1.104  04-Jun-2021  simonb Remove the warning about autoselecting nfs based on : or @.

Ok jmcneill@, mrg@.
 1.103  18-Oct-2020  mlelstv branches: 1.103.4;
Make command line arguments -r and -w actually override defaults from fstab,
previously -w would only cancel a preceeding -r.

No longer strip -o rw.
 1.102  09-Oct-2016  christos try to be more clear about what is not found.
 1.101  08-Oct-2016  maya change warning message

previously attempting to use mount -t ext2 like myself would result in
the warning "mount: mount_ext2 not found for /mnt", which (if you're me)
can be misunderstood as "/mnt is not an ext2 filesystem"...

change it to "mount: mount_ext2 not found"
 1.100  04-Jan-2015  pooka branches: 1.100.2;
gcc 4.9 produces vfork clobberation warnings for "name" and "buflen".
Since there's no performance reason to use vfork here, just replace it
with fork and be done with warnings once and for all.
 1.99  05-Oct-2013  ast No code change: corrected spelling in comment, removed trailing white spaces.
 1.98  24-Jan-2013  christos use return instead of exit.
 1.97  14-Jun-2012  christos branches: 1.97.2;
don't print the NULL, but the error
 1.96  09-Apr-2012  mlelstv return exit code from mount_XXXX again
 1.95  07-Apr-2012  christos use getfsspecname
 1.94  07-Apr-2012  christos Accept NAME=label for special so that we can wire down our wedges.
 1.93  29-Aug-2011  joerg branches: 1.93.2;
Use __dead
 1.92  13-Jan-2011  pooka In case we are union-mounting /, don't force MNT_UPDATE. This makes
the following work:

mount -t tmpfs -o union tmpfs /

(some caveats are implied, such as if you "mkdir /usr" you're
screwed, but then again you'll get there with "rm -rf /usr" even
without union -- we supply rope)

per discussion with zafer, use case for jibbed
 1.91  14-Jan-2010  pooka Remove puffs| from vfstype before making comparison to determine if
fs is mounted.

Fixes slightly-miscategorized kern/37626.
 1.90  14-Jan-2010  pooka If getargs and vfs has PUFFS_TYPEPREFIX, use mount_puffs to query args.
 1.89  04-May-2009  yamt disable automatic mountd reloading for now because it makes the service
temporary unavailable. PR/41331 from FUKAUMI Naoki.
 1.88  11-Jan-2009  pooka branches: 1.88.2;
Support mount -o rump, which uses the rump server instead of using
the kernel service. E.g. "mount -t efs -o rump /dev/sgidev /mnt"
runs effectively "rump_efs /dev/sgidev /mnt".
 1.87  11-Jan-2009  pooka Warn that autoselecting nfs based on : or @ in the device path will
be removed in a future release.
 1.86  05-Aug-2008  pooka branches: 1.86.2;
Refactor mount utilities to provide a mount_fs_parseargs() routine.
Use this routine both in mount_fs and rump_fs to provide equivalent
command line parameters and therefore usage interchangeability.
While doing this, combine some common mountgoop to mountprog.h
 1.85  20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.84  17-Jul-2007  christos branches: 1.84.12; 1.84.16;
cast sizeof() to int for printf widths.
 1.83  17-Jul-2007  christos kill MFSTYPENAME
 1.82  16-Oct-2006  christos sprinkle volatile.
 1.81  04-May-2006  christos since yamt prohibits any flag with MNT_GETARGS, don't set MNT_UPDATE for
/ when we do getargs.
 1.80  21-Mar-2006  christos Coverity CID 1688: Fix memory leak.
 1.79  17-Mar-2006  rumble Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.
 1.78  27-Jun-2005  christos Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
 1.77  18-Mar-2005  lukem Fix core dump when doing
mount fileserver:/somepath
by not passing a NULL pointer to getfsfile(3).
(Bug was introduced in rev 1.74 as part of fix for PR 28644.)
 1.76  05-Feb-2005  xtraeme branches: 1.76.2;
Kill __P(), use ANSI function declarations.
 1.75  31-Jan-2005  he Move local variable declaration to variable declaration section at
top of function, and at least away from after active code within
a block. Fixes build problem with gcc 2 (for vax).
 1.74  31-Jan-2005  erh PR #28644: Use realpath to make mount more forgiving of non-canonical
mount paths entered on the command line.
 1.73  25-Sep-2004  thorpej Try the DIOCGWEDGEINFO ioctl first. If that succeeds (i.e. the block
device is a wedge), use the partition type string from the dkwedge_info
structure to get the file system type.
 1.72  19-Aug-2004  christos Handle RESCUEDIR
 1.71  30-Apr-2004  enami Print fsid on verbose printing. It is useful when debugging nfs.
 1.70  22-Apr-2004  hannken Use PRIu64 to printf uint64_t. Compiles again on sparc64.
 1.69  21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.68  27-Mar-2004  cgd Recognize 'from_mount' as the device, which is especially useful when
putting root on NFS. (From my PR, 20305.)
 1.67  19-Sep-2003  itojun realloc pedant
 1.66  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.65  19-Jan-2003  jdolecek do not link all mount programs into single image; the total size difference
isn't really that huge now that these are compiled as dynamic
 1.64  23-Sep-2002  enami Cosmetic changes.
 1.63  23-Sep-2002  enami Properly terminate the output from mount -v.
 1.62  21-Sep-2002  christos make sure options is not NULL before we look in it. Thanks Charles.
 1.61  21-Sep-2002  christos MNT_GETARGS support
 1.60  23-Aug-2002  lukem if _PATH_RESCUE is defined, try that before _PATH_SBIN & _PATH_USRSBIN
 1.59  21-May-2002  nathanw When attempting to guess the filesystem type from the disklabel, don't
consider a out-of-range partition letter at the end of the special
device node to be a fatal error; just return NULL and let the caller
fall back to FFS.

This fixes the "mount -u /kern/rootdev /" done by the script installer.

XXX this is still gross, and breaks things like
"mount /my/strange/dev/path/b /mnt". Perhaps it should stat the node
and use the minor number as an index instead?
 1.58  30-Jan-2002  christos Use __MNT_FLAGS from <sys/mount.h> instead of rolling our own list. Also
when -v is used, print even the silent flags.
 1.57  20-Dec-2001  soren Sync getopt() / man page with actual getopt options.
 1.56  18-Feb-2001  tsutsui Add x_mount, which does not include any MOUNT_PROGS.
Installer does not require all vfs progs and all binaries
are crunched after all.
 1.55  01-Nov-2000  enami Factor out some function declarations into a header file.
 1.54  01-Nov-2000  enami When failed to read disklabel to deduce filesystem type,
- don't warn. It's just too verbose when we know there is
no disklabel and want to use the default filesystem type.
- close the file descriptor so that further mount success.
 1.53  01-Nov-2000  enami Cosmetic changes.
 1.52  30-Oct-2000  jdolecek mount(8) now includes code for all mount_*(8) but mount_portal(8) and
mount_mfs(8); the mount_*(8) are hardlinked to mount (appropriate mount routine
is called depending on program name) - this saves approx. 1.7MB of /sbin
space
mount.c: make all local symbols static
 1.51  11-Oct-2000  abs When determining the filesystem type automatically, only try the raw device
for the disklabel if the given device fails with EBUSY. Also make disklabel
errors non fatal (just fall back to ffs as per pre-autofilesystem behaviour)
Based on further discussion with Launey Thomas <ljt@alum.mit.edu>
 1.50  10-Oct-2000  is Format string cleanups by Bill Sommerfeld.
 1.49  02-Oct-2000  abs When opening a partition to automatically determine the filesystem type,
always use the raw partition in case it is already mounted and this is
an 'update' mount. Patch from Launey Thomas <ljt@alum.mit.edu>
 1.48  18-Sep-2000  abs If device and mountpoint are given without -t, and without a : in the
device, check the disklabel for filesystem type. Fall back to ffs as ever.
 1.47  16-Nov-1999  enami branches: 1.47.4;
If we didn't print an open paren, no need to print a closing paren
(by backing out part of previous commit).
 1.46  15-Nov-1999  fvdl Print softdep information. Also print sync+async writes in verbose mode.
 1.45  01-Dec-1998  kenh branches: 1.45.2; 1.45.4; 1.45.8;
Add support for a new flag: "nodevmtime". This sets the MNT_NODEVMTIME mount
flag.
 1.44  25-Aug-1998  ross from Erik Bertelsen <erik@mediator.uni-c.dk>
{ put } { in } { lots } { of } { these } { to } { shut } { up } { egcs }
 1.43  26-Jul-1998  mycroft const poisoning.
 1.42  06-May-1998  ross Rewrite options and fstype handling for upgrade mounts.
 1.41  23-Nov-1997  enami Add MNT_SYMPERM to optnames[].
 1.40  05-Nov-1997  cgd lint
 1.39  01-Nov-1997  drochner Take out last change (wait for mount_mfs completion).
I changed it in mount_mfs instead.
 1.38  01-Nov-1997  drochner Fix a problem with asynchronous processing of mfs mounts: Calls to
statfs() or getmountinfo() did not tell about the freshly mounted
ramdisk.
XXX Imo, "mount_mfs" should not return before the mount is done.
This is the only place where this can be done cleanly. But this would
require a substancial restructuring of "newfs". For now, wait in "mount"
until the filesystem appears.
 1.37  01-Nov-1997  drochner Fix a misbehaviour introduced in rev. 1.34 - mountfs() returned in
"verbose" mode after printing the exec args.
This invalidates most of my comment in the previous commit. (Not all,
there are still bogosities with mount_mfs.)
 1.36  01-Nov-1997  drochner When checking whether a filesystem is already mounted (for -a), get and
check all mounts (getmntinfo), not only the top one (statfs).
Otherwise we might miss lower level mounts on the same mountpoint.
XXX "mount" behaves differently with the "verbose" flag (-v) in some
cases, probably due to asynchronous calls to fs dependant mount programs.
 1.35  31-Oct-1997  mycroft Import modified mangle() from mount(8).
Also rewrite catopt() with a more sane interface.
 1.34  29-Oct-1997  christos PR/2974: VaX#n8: fix the rest of the problems that were not addressed by 4384.
- vfork exit -> _exit
- debug and verbose consistency with fsck.
 1.33  29-Oct-1997  christos PR/4384: Brian Grayson: Pass the real argv[0] to the exec'ed child.
Also while I am here, remove bogus XXX comment about mount_mfs.
 1.32  16-Sep-1997  lukem branches: 1.32.2;
resolve conflicts from lite-2 import, with two major modifications
that require all of /sbin/mount_* and /sbin/umount to be modified:
* incorporate vfslist.c, adding checkvfsname() and makevfslist()
* getmntopts() now takes 4 args (adding int *altflagp)
 1.31  15-Sep-1997  lukem * getopt returns -1 not EOF
* use .Nm correctly
 1.30  30-Jul-1997  christos When we mount -u and there is no vfstype specified, deduce the vfstype from
statfs.
 1.29  04-Jul-1997  christos Fix warnings.
 1.28  31-May-1997  pk More accurate failure message for unknown filesystem types, as
suggested in PR#1274.
 1.27  17-May-1997  pk NULL => 0 (Arne Juul; PR#3629)
 1.26  10-Mar-1997  mikel add support for MNT_NOATIME; from Lennart Augustsson in PR bin/3304.
 1.25  23-Oct-1996  cgd recognize MNT_NOCOREDUMP and print the 'nocoredump' flag for file
systems which have MNT_NOCOREDUMP set.
 1.24  18-Nov-1995  cgd Recognize all mount flags exported from the kernel (but only print the
ones that we used to print). Note unrecognized flags(s) when printing
mount list.
 1.23  22-Aug-1995  jtc Call mount_ffs instead of mount_ufs; PR #1379
 1.22  12-Jul-1995  cgd fix a goof in my previous code, that i thought of while reading pr 749.
add a -A flag, which does the same thing as '-a', but doesn't check for
remounts.
 1.21  12-Jul-1995  cgd remove FFS mounting code from mount(8); there are now _no_ 'internal' mount
types. when using mount(8) with '-a', do _NOT_ remount file systems
that have been mounted once already. (This cannot be 100% precisely
determined (thanks to mfs, union fs, and similar file systems which
don't use a 'real' mounted-from node), and changed options cannot be updated
with mount -a. however, options wouldn't be updated with the old mount -a
anyway, and this solves several annoyances.
 1.20  04-Jul-1995  ghudson Give an argument to the warning message for when realpath() fails.
 1.19  22-Jun-1995  cgd specify precision, not minimum field width. pointed out by John Kohl
 1.18  18-Jun-1995  cgd don't assume f_fstypename is larger than MFSNAMELEN or is nul-terminated
 1.17  28-May-1995  jtc sys_siglist[] -> strsignal()
 1.16  18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.15  30-Jan-1995  mycroft Change type list code to match umount(8).
 1.14  18-Dec-1994  cgd compile against new headers
 1.13  29-Aug-1994  mycroft branches: 1.13.2;
Display type of mount; suggested by Thomas Eberhardt.
 1.12  08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.11  18-Apr-1994  cgd allow external mount types, even if LETS_GET_SMALL
 1.10  15-Apr-1994  cgd oops, forgot one
 1.9  14-Apr-1994  cgd fs type names, and much clean
 1.8  05-Jan-1994  cgd update for new (actually old... *sigh*) mount flags
 1.7  05-Dec-1993  deraadt should bzero automatic sockaddr's before use
 1.6  07-Sep-1993  ws Changes to VFS readdir semantics
NFS changes for better cookie support
ISOFS changes for better Rockridge support and support for generation numbers
 1.5  03-Aug-1993  mycroft Recognize `noauto' (and `auto', just for symmetry) in fstab.
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 1.3  23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2  22-Mar-1993  cgd added rcs ids to all files
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  16-Sep-1997  lukem imported from lite-2
 1.1.1.2  13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.2.2  29-Aug-1994  mycroft Display type of mount; suggested by Thomas Eberhardt.
 1.13.2.1  29-Aug-1994  mycroft file mount.c was added on branch netbsd-1-0 on 1994-08-29 02:38:01 +0000
 1.32.2.3  08-May-1998  mycroft Pull up 1.42, per request of ross.
 1.32.2.2  02-Nov-1997  mellon Pull rev 1.36, 1.37, 1.38 and 1.39 up from trunk (drochner)
 1.32.2.1  31-Oct-1997  mellon Pull rev 1.33, 1.34 and 1.35 up from trunk (mycroft)
 1.45.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.45.4.1  19-Oct-1999  fvdl Bring in Kirk McKusick's FFS softdep code on a branch.
 1.45.2.1  10-Oct-2000  he Pull up revision 1.50 (via patch, requested by is):
Format string cleanup.
 1.47.4.2  26-Feb-2001  he Pull up revisions 1.48-1.49,1.51,1.54 (via patch, requested by abs):
If both special and node are given (but no type), the disklabel
is checked for the file system type before falling back to ffs.
 1.47.4.1  18-Oct-2000  tv Pullup sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.76.2.1  19-Mar-2005  tron Pull up revision 1.77 (requested by lukem in ticket #10):
Fix core dump when doing
mount fileserver:/somepath
by not passing a NULL pointer to getfsfile(3).
(Bug was introduced in rev 1.74 as part of fix for PR 28644.)
 1.84.16.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.84.12.2  17-Jan-2009  mjf Sync with HEAD.
 1.84.12.1  28-Sep-2008  mjf Sync with HEAD.
 1.86.2.2  22-Jan-2009  snj Pull up following revision(s) (requested by pooka in ticket #288):
include/mntopts.h: revision 1.12
sbin/mount/mount.8: revision 1.63
sbin/mount/mount.c: revision 1.88
Support mount -o rump, which uses the rump server instead of using
the kernel service. E.g. "mount -t efs -o rump /dev/sgidev /mnt"
runs effectively "rump_efs /dev/sgidev /mnt".
 1.86.2.1  16-Jan-2009  bouyer Pull up following revision(s) (requested by pooka in ticket #266):
sbin/mount/mount.c: revision 1.87
Warn that autoselecting nfs based on : or @ in the device path will
be removed in a future release.
 1.88.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.93.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.93.2.2  30-Oct-2012  yamt sync with head
 1.93.2.1  17-Apr-2012  yamt sync with head
 1.97.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.97.2.1  25-Feb-2013  tls resync with head
 1.100.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.103.4.1  06-Jun-2021  cjep sync with head

RSS XML Feed