Home | History | Annotate | Download | only in umount
History log of /src/sbin/umount/umount.c
RevisionDateAuthorComments
 1.56  01-Jul-2025  kre PR bin/59495

Make umount less noisy when a single -v is used (just say
what has been unmounted), and only include details of
running (or not running) external umount_fstype progs
when more than one -v is given.

While here, make it more clear in the messages produce
when the -F (fake it) option is used, that nothing was
actually unmounted (just what would have been).

Man page updated to match.
 1.55  25-Mar-2025  christos move sfs declaration in #ifdef SMALL
 1.54  25-Mar-2025  christos GitHub/31: Ricardo Branco: Add -d flag to umount to detach vnds, like FreeBSD
and Linux.
 1.53  23-Apr-2020  christos branches: 1.53.8;
make umount NAME= work
 1.52  26-Jun-2016  dholland Don't assume that getaddrinfo sets the result pointer to null when it
fails. (In fact it probably doesn't...)
 1.51  26-Jun-2016  dholland Fix previous to avoid using an uninitialized pointer when using -R (raw).
 1.50  26-Jun-2016  dholland If an external unmount program of the form "umount_TYPE" exists
(e.g. umount_ffs, umount_nfs, etc.) exec it instead of calling
unmount(2).

Closes PR 698.

Note that the original plan for the PR also involved adding a generic
facility to store an alternate FS type name in the kernel to use when
unmounting. This was intended to support filesystems implemented as
loopback nfs servers, where the visible mount would be of type "nfs"
pointing at localhost; in that case one would want to be able to
provide an additional string in order to run an unmount program that
would both remove that mount and also shut down the loopback nfs
server daemon.

However, in the 21+ years since the PR was filed, loopback nfs servers
have gone out of favor (for good reasons) so I don't see any need to
worry about this case at present, especially since the PR has been
hanging around this long anyway. (If anyone still has a loopback nfs
server that they want to use a custom unmount program with, file a new
PR and assign it to me and I'll deal with it specifically in the nfs
mount args structure, which unmount already knows how to retrieve and
examine.)

It is my understanding that filesystems implemented with fuse (which
has displaced the loopback nfs server model) can already set the FS
type field so no further work is needed to allow them to use a custom
unmount program. If this is not the case, please let me know and I'll
attend to it.

There is no longer any need that I see to provide a general facility
for storing an alternate filesystem type name.

(One might also ask whether there's any real need for this
functionality at all any more; this is a fair question, but (a) the
change is small and (b) there are certainly cases when doing FS
research where you want a custom unmount program; been there & done
that.)
 1.49  26-Jun-2016  dholland When SMALL, if realpath() fails, warn() using the failing path instead
of the buffer realpath has declined to write anything into.
 1.48  27-Jun-2015  manu Remove useless and harmful sync(2) call in umount(8)

Remove sync(2) call before unmount(2) in umount(8). This sync(2) is useless
since unmount(2) will perform a VFS_SYNC anyway.

But moreover, this sync(2) may be harmful, as there are some situation where
it cannot return (unreachable NFS server, for instance), causing umount -f
to be uneffective.
 1.47  02-Jul-2013  christos branches: 1.47.6;
move proto to small
 1.46  01-Jul-2013  christos Instead of borrowing the mount code to get the nfs arguments, just use
the system call directly. It is shorter and works...
 1.45  29-Jun-2013  christos one copy of the name is enough, and free it.
 1.44  29-Jun-2013  christos Use the protocol we mounted the filesystem with instead of always udp.
(untested, but should fail back to udp).
 1.43  05-Aug-2008  pooka branches: 1.43.18; 1.43.24;
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.42  20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.41  15-Dec-2007  perry branches: 1.41.4; 1.41.8;
convert __attribute__s to applicable cdefs.h macros
 1.40  17-Jul-2007  christos branches: 1.40.4; 1.40.6;
kill MFSNAMELEN
 1.39  16-Jul-2007  pooka Make all mount(2) return value error checks against -1. Some file
systems just checked != 0, breaking MNT_GETARGS. Others worked with < 0,
but make them check against -1 too for consistency. And sprinkle some
stylish line wrapping where appropriate.
 1.38  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.37  31-Jan-2005  erh Fix PR#3205 for the -a case: when the list of mount points comes from the
kernel, always use "raw" mode (-R option) so unmounting odd mount points works.
Also, fix available options in SMALL mode to include -R, not -r.
 1.36  19-Jan-2005  xtraeme Remove main() prototype; WARNS=2
 1.35  01-Sep-2004  chs pass data to a function via an argument instead of via a global variable.
this avoids a name collision with libcurses functions when both are
present in a crunched static binary. part of PR 26458.
 1.34  21-Apr-2004  christos add #ifdef SMALL so that we can use this in the install media.
 1.33  21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.32  12-Mar-2004  dsl stop umount temporarily modifying what might be argv[n].
 1.31  12-Mar-2004  dsl KNF and const sprinkle
 1.30  12-Mar-2004  dsl Fix 'umount host:/filesystem' - it is documented on the man page but hasn't actually
worked for 10 years!
Remove the (broken) code that once supported 'umount /filesystem@host' since that
syntax isn't used anywhere.
Fixes PR bin/22099
 1.29  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.28  20-Jun-2000  fvdl branches: 1.28.2;
Adapt to new RPC interface. Use getaddrinfo(), not gethostbyname().
 1.27  06-Jun-2000  chs change ``-a'' to be a synonym for ``-A''.
addresses PR 7629.
 1.26  09-Nov-1999  drochner branches: 1.26.2;
Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
 1.25  02-Aug-1999  sommerfeld branches: 1.25.4;
Fix PR7747: umount -R dumps core
(fix by Ronald Khoo from PR applied)
 1.24  17-Apr-1998  fair Changes to implement "-R" (raw) option to umount, per PR#4030.
 1.23  01-Apr-1998  kleink No need to include <sys/socketvar.h>.
 1.22  18-Dec-1997  mikel document -F flag; part of PR 4030 from der Mouse
 1.21  01-Nov-1997  drochner Since umount works from the top we have to traverse the information
returned by getmountinfo() from the top too. Otherwise we get
the wrong mount data in case of 2 mounts on 1 pountpoint.
 1.20  16-Sep-1997  lukem branches: 1.20.2;
resolve conflicts from lite-2 merge
 1.19  15-Sep-1997  lukem * cleanup for WARNS=1
* fix .Nm usage
 1.18  21-May-1997  pk Code previous somewhat more compactly.
 1.17  21-May-1997  pk Do not force the ISBLK and ISDIR checks on the mount point.
 1.16  11-May-1996  mycroft Use kernel mount info rather than fstab. From greywolf@starwolf.com, slightly
modified.
 1.15  22-Sep-1995  mycroft Fix the case where stat() fails, so that the file system is still unmounted.
 1.14  18-Jun-1995  cgd don't assume f_fstypename is larger than MFSNAMELEN or is nul-terminated
 1.13  18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.12  30-Jan-1995  mycroft Make arg to selected() const. Disallow multiple `-t' options.
 1.11  30-Jan-1995  mycroft Cosmetic changes to type list parsing.
 1.10  30-Jan-1995  mycroft Be careful to only parse the host name from the mount path for NFS mounts.
 1.9  25-Aug-1994  cgd branches: 1.9.2;
several fixes from Mark Weaver <mhw@cs.brown.edu>, relating to error
reporting. (pr 431)
 1.8  23-Aug-1994  cgd fix from John Kohl to return correct status when unmounting named fs's.
 1.7  08-Jun-1994  mycroft branches: 1.7.2;
Update from 4.4-Lite, with local changes.
 1.6  14-Apr-1994  cgd fs type names, and much clean
 1.5  05-Dec-1993  deraadt should bzero automatic sockaddr's before use
 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.7.2.1  23-Aug-1994  mycroft update from trunk
 1.9.2.2  25-Aug-1994  cgd several fixes from Mark Weaver <mhw@cs.brown.edu>, relating to error
reporting. (pr 431)
 1.9.2.1  25-Aug-1994  cgd file umount.c was added on branch netbsd-1-0 on 1994-08-25 02:14:02 +0000
 1.20.2.1  02-Nov-1997  mellon Pull rev 1.21 up from trunk (drochner)
 1.25.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.26.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.28.2.2  20-Jun-2000  fvdl Adapt to new RPC interface. Use getaddrinfo(), not gethostbyname().
 1.28.2.1  20-Jun-2000  fvdl file umount.c was added on branch netbsd-1-5 on 2000-06-20 00:45:25 +0000
 1.40.6.1  27-Dec-2007  mjf Sync with HEAD.
 1.40.4.1  09-Jan-2008  matt sync with HEAD
 1.41.8.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.41.4.1  28-Sep-2008  mjf Sync with HEAD.
 1.43.24.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.18.1  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.47.6.1  04-Nov-2015  riz Pull up following revision(s) (requested by manu in ticket #882):
sbin/umount/umount.c: revision 1.48
sys/nfs/nfsmount.h: revision 1.53
sys/nfs/nfs_var.h: revision 1.94
sys/nfs/nfs_iod.c: revision 1.7
sys/nfs/nfs_socket.c: revision 1.197
sys/nfs/nfs_bio.c: revision 1.191
sys/nfs/nfs_vfsops.c: revision 1.230
sys/nfs/nfs_clntsocket.c: revision 1.3
Remove useless and harmful sync(2) call in umount(8)
Remove sync(2) call before unmount(2) in umount(8). This sync(2) is useless
since unmount(2) will perform a VFS_SYNC anyway.
But moreover, this sync(2) may be harmful, as there are some situation where
it cannot return (unreachable NFS server, for instance), causing umount -f
to be uneffective.
Fix soft NFS force unmount
For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.
Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.
Reviewed by Chuck Silvers.
 1.53.8.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed