Commit Graph

57 Commits

Author SHA1 Message Date
Rick Macklem
49a8bad7d6 Modify umount so that it does not do an Unmount RPC for NFSv4 mounts
and uses TCP for the Unmount RPC if the mount is over TCP.
Without this patch, umount does an Unmount RPC over UDP for all NFS mounts.

Suggested by:	cperciva
Reviewed by:	cperciva
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8503
2016-11-19 23:58:50 +00:00
Edward Tomasz Napierala
debc480e03 Add new unmount(2) flag, MNT_NONBUSY, to check whether there are
any open vnodes before proceeding. Make autounmound(8) use this flag.
Without it, even an unsuccessfull unmount causes filesystem flush,
which interferes with normal operation.

Reviewed by:	kib@
Approved by:	re (gjb@)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D7047
2016-07-07 09:03:57 +00:00
Ulrich Spörlein
e96092e82b Fix type mismatches for malloc(3) and Co.
Found by:	clang static analyzer
Reviewed by:	ed
Differential Revision:	https://reviews.freebsd.org/D4722
2015-12-29 11:24:35 +00:00
Peter Wemm
1b31334c64 Use mount protocol version 3 by default for showmount and umount.
mount_nfs effectively uses mount protocol v3 by default already.
v1 mount protocol is being removed along with nfsv2 by a high profile NFS
appliance vendor and our legacy v1 mount protocol usage causes rpc errors.
2014-08-16 14:56:11 +00:00
Eitan Adler
c27063b934 Fix memory leak in umount.c
PR:		bin/172553
Submitted by:	Erik Cederstrand <erik@cederstrand.dk>
Approved by:	cperciva
MFC after:	3 days
2012-11-15 15:06:21 +00:00
Ed Schouten
1efe3c6b58 Add missing static keywords for global variables to tools in sbin/.
These tools declare global variables without using the static keyword,
even though their use is limited to a single C-file, or without placing
an extern declaration of them in the proper header file.
2011-11-04 13:36:02 +00:00
Kirk McKusick
80bbaeb540 When using -A option (unmount all mounted filesystems), do not attempt
to unmount /dev as it will always fail.
2011-07-14 20:17:05 +00:00
Rick Macklem
b37ce15446 Modify the umount(8) command so that it doesn't do
a sync(2) syscall before unmount(2) for the "-f" case.
This avoids a forced dismount from getting stuck for
an NFS mountpoint in sync() when the server is not
responsive. With this commit, forced dismounts should
normally work for the NFS clients, but can take up to
about 1minute to complete.

PR:		kern/157365
Reviewed by:	kib
MFC after:	2 weeks
2011-05-29 21:13:53 +00:00
Ruslan Ermilov
34ae1bb65b It's possible to unmount multiple items at once, make it clear. 2011-03-24 12:35:09 +00:00
Hajimu UMEMOTO
a505d4352f Introduce '[ipaddr]:path' notation.
Since the existing implementation searches ':' backward, a path which
includes ':' could not be mounted.  You can now mount such path by
enclosing an IP address by '[]'.
Though we should change to search ':' forward, it will break
'ipv6addr:path' which is currently working.  So, it still searches ':'
backward, at least for now.

MFC after:	2 weeks
2010-02-04 15:17:49 +00:00
Ed Schouten
ca25fa25db Let umount build with -Wold-style-definition. 2009-12-30 06:36:42 +00:00
Xin LI
7f471a3289 Make umount(8) WARNS=6 clean:
- Cast delimiter width to integer [1]
 - Solve name conflicts against system header
 - Constify parameters to avoid qualifier conflict

PR:		bin/140017 [1]
Submitted by:	Ulrich Spörlein <uqs spoerlein net> [1]
MFC after:	1 month
Sponsored by:	iXsystems, Inc
2009-12-28 17:57:37 +00:00
Doug Rabson
0775314b63 Don't use sys/nfs/rpcv2.h - it is part of the old kernel RPC implementation
and will be removed.
2009-06-24 18:42:21 +00:00
Ruslan Ermilov
8d646af581 Sync program's usage() with manpage's SYNOPSIS. 2005-02-10 09:19:34 +00:00
Mark Murray
4c723140a4 Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp
2004-04-09 19:58:40 +00:00
Ian Dowse
8b91818711 Don't include the file system ID in the output of `mount -v' if it
is all zeros. The kernel now consistently zeroes FSIDs for non-root
users, so there's no point in printing these. Also fix a misspelling
in a comment.

Submitted by:	Rudolf Cejka <cejkar@fit.vutbr.cz>
Approved by:	re (scottl)
2003-12-05 09:22:40 +00:00
Ian Dowse
0ed25a9ad1 If the unmount by file system ID fails, don't warn before retrying
a non-fsid unmount if the file system ID is all zeros. This is a
temporary workaround for warnings that occur in the vfs.usermount=1
case because non-root users get a zeroed filesystem ID. I have a
more complete fix in the works, but I won't get it done for 5.2.
2003-11-16 16:48:18 +00:00
Ian Dowse
5fff09147f When removing trailing slashes, don't remove the first character
of the name if it is '/'. Also fix a comparison between signed and
unsigned quantities (pointed out by trhodes).
2003-10-29 17:44:36 +00:00
Ian Dowse
eddb48052a Take advantage of the use of file system IDs to simplify umount(8)
and make it work more reliably in a number of cases that have
traditionally been troublesome. The new behaviour is:
 1) If the filesystem can be determined by the fsid or device,
    or uniquely identified by the mountpoint, then just go ahead
    and call unmount(2) using the file system ID.
 2) Otherwise use fstatfs(2) to resolve the path into a file system
    ID (checking with stat(2) that it is a filesystem root directory).

Case 2 can potentially block if an NFS server is down, but it can
always be avoided by using an unambiguous specification. It handles
all the hard cases such as symlinks and mismatches between the mount
list and reality. For example, if a filesystem was mounted as /mnt
inside a chroot, it will show up in the mount list as /mnt, but now
you can unmount it from outside the chroot with "umount /chroot_path/mnt".
2003-07-20 00:11:27 +00:00
Ian Dowse
38f102c2f6 When mount(8) is invoked with the `-v' flag, display the filesystem
ID for each file system in addition to the normal information.

In umount(8), accept filesystem IDs as well as the usual device and
path names. This makes it possible to unambiguously specify which
file system is to be unmounted even when two or more file systems
share the same device and mountpoint names (e.g. NFS mounts from
the same export into different chroots).

Suggested by:	Dan Nelson <dnelson@allantgroup.com>
2003-07-18 17:43:13 +00:00
Ian Dowse
1add162c97 Since checkmntlist() and getmntentry() return a struct statfs that
includes the filesystem type name, remove the "type" output parameter.
2003-07-18 08:01:10 +00:00
Ian Dowse
f73d495f68 When the file system to unmount is specified by device name instead
of by mount point, umount had to take care not to unmount the wrong
file system if another file system was covering the requested one.
Now that the file system to unmount is specified to the kernel using
the filesystem ID, this confusion cannot occur, so remove the code
that checked for it.
2003-07-18 01:10:16 +00:00
Ian Dowse
318f2fb4bf Add a new mount flag MNT_BYFSID that can be used to unmount a file
system by specifying the file system ID instead of a path. Use this
by default in umount(8). This avoids the need to perform any vnode
operations to look up the mount point, so it makes it possible to
unmount a file system whose root vnode cannot be looked up (e.g.
due to a dead NFS server, or a file system that has become detached
from the hierarchy because an underlying file system was unmounted).
It also provides an unambiguous way to specify which file system is
to be unmunted.

Since the ability to unmount using a path name is retained only for
compatibility, that case now just uses a simple string comparison
of the supplied path against f_mntonname of each mounted file system.

Discussed on:	freebsd-arch
mdoc help from:	ru
2003-07-01 17:40:23 +00:00
Matthew N. Dodd
ef258dd967 Implement the '-F' option for mount & umount which allows the user to
specify an alternate fstab file.
2003-04-07 12:56:01 +00:00
Matthew N. Dodd
5c514aeee8 Quiet warning. 2003-04-07 11:44:48 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Maxime Henrion
5965373e69 - Introduce a new struct xvfsconf, the userland version of struct vfsconf.
- Make getvfsbyname() take a struct xvfsconf *.
- Convert several consumers of getvfsbyname() to use struct xvfsconf.
- Correct the getvfsbyname.3 manpage.
- Create a new vfs.conflist sysctl to dump all the struct xvfsconf in the
  kernel, and rewrite getvfsbyname() to use this instead of the weird
  existing API.
- Convert some {set,get,end}vfsent() consumers to use the new vfs.conflist
  sysctl.
- Convert a vfsload() call in nfsiod.c to kldload() and remove the useless
  vfsisloadable() and endvfsent() calls.
- Add a warning printf() in vfs_sysctl() to tell people they are using
  an old userland.

After these changes, it's possible to modify struct vfsconf without
breaking the binary compatibility.  Please note that these changes don't
break this compatibility either.

When bp will have updated mount_smbfs(8) with the patch I sent him, there
will be no more consumers of the {set,get,end}vfsent(), vfsisloadable()
and vfsload() API, and I will promptly delete it.
2002-08-10 20:19:04 +00:00
Tom Rhodes
3468b317cb more file system > filesystem 2002-05-16 04:10:46 +00:00
Ian Dowse
21eff82f63 Oops, fix a missing condition that broke umount's `-h' option. I
had somehow removed an error check in revision 1.26, causing errx()
to be called unconditionally in the -h case.
2001-10-13 02:04:54 +00:00
Ian Dowse
afe1ef249f Fix some bugs and general brain damage in mounttab:
- Declare mtabhead as an extern in mounttab.h and define it only in
  mounttab.c.
- Remove shared global `verbose' and instead pass it as a parameter.
- Remove the `mtabp' argument to read_mtab(). It served no purpose
  whatsoever, although read_mtab() did use it as a temporary local
  variable.
- Don't check for impossible conditions when parsing mounttab, and
  do detect zero-length fields.
- Correctly test for strtoul() failures - just testing ERANGE is wrong.
- Include a field name in syslog errors, and avoid passing NULL to
  a syslog %s field.
- Don't test if arrays are NULL.
- If there are duplicates when writing out mounttab, keep the last
  entry instead of the first, as it will have a later timestamp.
- Fix a few formatting issues.

Update rpc.umntall and umount to match the mounttab interface changes.
2001-07-22 12:17:51 +00:00
Ian Dowse
13e2e1affa Include the remote hostname in RPC-related warning messages. Exit
immediately if a host specified by the -h flag cannot be parsed
instead of attempting to unmount all NFS filesystems, which was
bad.

Add a missing return statement at the end of checkname(); this
could result in a non-zero exit status in some cases even if the
unmount succeeded.

Group two separate NFS-related operations into one block to make
it more obvious that a variable (hostp) is not dereferenced when
uninitialised. Initialise it to NULL anyway to avoid a warning.

Pass in the read_mtab()'s bogus argument as NULL instead of messing
with a local variable to achieve the same effect. A later commit
will clean up this mounttab interface.
2001-07-22 00:45:29 +00:00
Alfred Perlstein
8360efbd6c Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.

  Bring in required TLI library routines to support this.

  Since we don't support TLI we've essentially copied what NetBSD
  has done, adding a thin layer to emulate direct the TLI calls
  into BSD socket calls.

  This is mostly from Sun's tirpc release that was made in 1994,
  however some fixes were backported from the 1999 release (supposedly
  only made available after this porting effort was underway).

  The submitter has agreed to continue on and bring us up to the
  1999 release.

  Several key features are introduced with this update:
    Client calls are thread safe. (1999 code has server side thread
    safe)
    Updated, a more modern interface.

  Many userland updates were done to bring the code up to par with
  the recent RPC API.

  There is an update to the pthreads library, a function
  pthread_main_np() was added to emulate a function of Sun's threads
  library.

  While we're at it, bring in NetBSD's lockd, it's been far too
  long of a wait.

  New rpcbind(8) replaces portmap(8) (supporting communication over
  an authenticated Unix-domain socket, and by default only allowing
  set and unset requests over that channel). It's much more secure
  than the old portmapper.

  Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
  to support TI-RPC and to support IPV6.

  Umount(8) is also fixed to unmount pathnames longer than 80 chars,
  which are currently truncated by the Kernel statfs structure.

Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
Dag-Erling Smørgrav
b6e55a056a Fix comment to match previous commit, as per bde. 2000-09-07 07:03:11 +00:00
Dag-Erling Smørgrav
81667275a9 Don't warn about unknown mount types, since they most likely simply mean
that the right module hasn't been loaded yet (and mount(8) will do so
when necessary).
2000-09-06 17:44:07 +00:00
Matthew Dillon
a69497d73f Finish up umntall support. init now passed an argument to the
rundown script 'reboot' or 'single'.  ISO support (which never
    worked) has been removed from mount_nfs.  mount_nfs and umount
    now use mounttab, which allows umntall to work properly.  The
    rc scripts now call umntall as appropriate.

Submitted by:	Martin Blapp <mb@imp.ch>
1999-11-22 04:23:11 +00:00
Brian Feldman
91a8167829 Fix a logic problem that broke umount -a.
Reported by:	 Martin Blapp <mb@imp.ch>
1999-10-29 09:33:50 +00:00
Brian Feldman
0fe9a7da10 Small bugfixes (point not getting marked in one case, string not NUL and
wrong size in the other.)

Submitted by:	Martin Blapp <mb@imp.ch>
1999-10-23 00:54:58 +00:00
Brian Feldman
0602ee7c29 Fix a few things. Unbogosify a free(), {,UN}MARK with correct args, and
fix count checks.

Submitted by:	Martin Blapp <mb@imp.ch>
1999-10-18 03:52:20 +00:00
Brian Feldman
bc70c1725f quoting << Martin_Blapp
-	Completly changed the internals of umount(8). We do three
	checks now to see if 'argv' is in the mounttable. It they
	all fail, we return to main and print a warning.

-	fixed the umount mount-order. The checks are rather complex
	to do this. Cause umount(8) should also be able to unmount
	several devices at once ('umount -a', 'umount -A',
	'umount /mnt /mnt2'), the mount-order get's important.
	I added checks to mark and unmark already unmounted devices.

- 	Various fixes with nfs-unmounts (no rpc-calls were done,
	or they were done although there was an existing mount).
	Since we allow overlay-mounts, we should also handle them
	properly.

-	Translate the deprecated nfs-syntax with '@' to ':' like
	mount_nfs does. The ':' syntax has now precedence, but '@'
	still works.

-	'umount -v' is now fixed for all cases and doesn't print
	garbage like two times the mountpoint etc.

-	removed non documented and useless umount '-F'.

-	hanged nfsmounts can now unmounted 'without' any problems.
	I've removed stat() and realpath() checks on the mountpoint.
	Instead we just do a realpath() on the basedir of the
	mountpath and add the dirname again.
	Implemented this as an idea from phk. But there are still
	vfs-restrictions if the nfs_mount is busy. If there are
	unwritten metadata on a hanged nfs-mount, and we modify
	nfs_vfsops.c to not return EBUSY, we get a deadlock :(
	The problem has now moved from userland to kernel.

-	removed the BUGS part from the umount(8) manpage.

-	Converted it to ANSI C (more than 60% of the code have
	changed).

Martin_Blapp

Fixed PR's
----------

o [1999/02/03] bin/9893                 NFS umount of regular file impossible

s [1995/11/27] bin/841			stale nfs mounts cannot be umounted

o [1999/08/01] bin/12911	alfred  NFS umounts are not properly done
					if just the mountpoint gets umounted

Only partially solved:
----------------------

The problem is now in kernel:

o [1999/04/07] bin/11005		`umount -f' does not work if the
					NFS-server is down.

PR:		bin/9893 bin/841 bin/12911 bin/11005
Submitted by:	Martin Blapp <mb@imp.ch>
1999-10-17 16:26:58 +00:00
Nick Hibma
ae0c2c7836 Fix -Wall warnings
Submitted-By:  Martin Blapp <mblapp@kassiopeja.lan.attic.ch>
1999-10-08 19:56:45 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Philippe Charnier
adb378ce60 Use errx() instead of err() for malloc failures. -Wall. Do not dot
terminate errx() string. Remove unused #includes. Use .Tn for NFS.
1998-08-03 06:44:46 +00:00
Peter Wemm
428fb2dd11 Fix PR 1607, hopefully without breaking the PR 5208 fixes.
umount() was trying to stat() the mountpoint, this would fail if the
mountpoint was a NFS mountpoint, and the fallback code would try and pass
a hostname:/dir path as the mountpoint to unmount(2), which would fail.

This whole stat() of the name supplied on the command line business is
trouble as it'll wedge on a hung NFS mount.

I'm not entirely sure why we are not simply looking up both arguments
in the mount table and doing the right thing without accessing the
filesystem.  It seems that we're going to a lot of trouble to allow
mountpoints on symlinks and other wierd things.

PR: 1607
1998-05-11 07:38:42 +00:00
Bruce Evans
82000ec41c Fixed the previous fix. The original path was annulled when it
was a directory, so the error message for attempting to unmount
an unmounted-on directory was more broken than before.
1998-02-03 17:23:26 +00:00
Bruce Evans
bd4f43ff72 mount(8) only uses realpath() for the mountpoint, so don't look up the
real path here for the mount device (or path).  This fixes difficulties
unmounting devices that are actually symlinks to real devices.

Also, print the original path instead of the real path in early error
messages.  nfs path handling and later error messages may still be wrong,
probably only in silly cases where the original path is both a symlink
and a remote path.

PR:		5208
1998-01-19 18:48:36 +00:00
Warner Losh
b1a3bc5ea0 style(9) corrections
Submitted by:	bde
1997-12-26 23:28:17 +00:00
Warner Losh
5635438650 Be extra paranoid about trusting the length of the data returned by
gethostbyaddr.
Submitted by:	Julian Assange
1997-12-24 01:00:24 +00:00
Philippe Charnier
210a5dc89f Sync usage string according to man page. 1997-06-19 14:44:24 +00:00
Bruce Evans
d499a0ef65 Merge from Lite2.
- use new getvfsbyname() interface.
- new -A option, like -a except only mounted file systems are unmounted.

All non-cosmetic FreeBSD changes in umount.c, except ignoring of
realpath() failures, went away because they are done better in Lite2.
realpath() failures must be ignored so that non-pathnames like
"<above>:/foo" and "host:/bar" get as far as mount(2).

Reviewed by:	dfr
1997-06-16 11:20:05 +00:00