Commit Graph

76 Commits

Author SHA1 Message Date
Yaroslav Tykhiy
bd20049d27 Add a work-around to make it possible again to remount
NFS root r/w.

The real solution would be to bring the whole nmount(2)
framework, including FS drivers and userland tools, into
a consistent state at last; but things should work in the
meantime, too.

Reported by:	kris
2008-02-18 10:24:47 +00:00
Yaroslav Tykhiy
a83655a35f Back out rev. 1.74 because the kernel isn't ready yet
to see NFS specific string options.
2008-02-18 00:23:28 +00:00
Yaroslav Tykhiy
fb2ae60938 Don't forget to prepare string options for nmount(2).
Otherwise things won't work as intended, e.g., it'll
be impossible to upgrade NFS root mount to read-write.

Reported by:	kris
2008-02-18 00:05:50 +00:00
Kris Kennaway
2427fa1998 Switch the default NFS mount mode from UDP to TCP. UDP mounts are a
historical relic, and are no longer appropriate for either LAN or WAN
mounting.  At modern (gigabit and 10 gigabit) LAN speeds packet loss
from socket buffer fill events is common, and sequence numbers wrap
quickly enough that data corruption is possible.  TCP solves both of
these problems without imposing significant overhead.

MFC after:     1 month
2008-02-11 23:23:21 +00:00
Thomas Quinot
3bbd554a99 Add "fg" option as antonym to "bg"; add "hard" option as antonym to "soft".
This is for better compatibility with other environments (Linux, Solaris,
HP-UX, AIX and Tru64 support these options).

PR:		bin/109924
MFC after:	1 week
2007-03-05 14:47:54 +00:00
Craig Rodrigues
0c269d1f05 Merge mount_nfs4.c and mount_nfs.c into one program.
If argv[0] == "mount_nfs4", then default to mounting NFSv4,
otherwise if argv[0] == "mount_nfs", default to the old mount_nfs behavior.

- Add a -4 option.
- Add the University of Michigan copyright from mount_nfs4.c, for the
  code merged from mount_nfs4.c.

Reviewed by:	rees
2007-01-23 07:17:10 +00:00
Craig Rodrigues
a6b2640236 Pass a string buffer named "errmsg" to nmount().
This will allow the NFS mount code to return a string error message
in addition to returning an error integer value.

Reviewed by:    mohans
MFC after:      1 month
2006-11-29 00:46:30 +00:00
Craig Rodrigues
412ffff0a0 Deduce the "fstype" parameter to pass to nmount() by looking at
the "_nfs" part of argv[0].  This should facilitate unifying mount_nfs
and mount_nfs4 into one binary.

MFC after:	1 month
Reviewed by:	mohans
2006-11-29 00:41:44 +00:00
Craig Rodrigues
b535b298b1 Fix last element of nc_protos[] array to appease GCC. 2006-11-21 02:00:48 +00:00
Craig Rodrigues
c5aa1dc845 Convert mount_nfs from old mount(2) API to new nmount(2) API.
Reviewed by:	mohans
2006-11-21 01:53:18 +00:00
Warner Losh
33924ad466 Minor style(9) and KNF elimination as I prepare to fix a bug. 2006-03-20 21:28:46 +00:00
Xin LI
46b7a14ba4 Use MOPT_END in favor of MOPT_NULL, which better describes the purporse
of the macro.
2005-06-10 09:51:43 +00:00
Xin LI
73ac45052f Add a handy macro to represent null mount option, MOPT_NULL, and make
use of the macro in sbin/mount*'s, by replacing:

	mopts[] = {
	    MOPT_STDOPTS,
	    { NULL }
	}

With:
	mopts[] = {
	    MOPT_STDOPTS,
	    MOPT_NULL
	}

This change will help to reduce the situation that we don't explicitly
initialize "struct mntopt"'s.  It should not contribute to any
functional/logical changes as far as I can tell.
2005-06-01 09:39:36 +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
Tom Rhodes
bd3fc74891 Remove -p from getopt args.
PR:		37221
Submitted by:	Joshua Goodall <joshua@roughtrade.net>
Reviewed by:	rwatson
Approved by:	re (jhb)
2003-05-12 19:48:47 +00:00
David E. O'Brien
c69284ca08 Use __FBSDID() to quiet GCC 3.3 warnings. 2003-05-03 18:41:59 +00:00
Matthew N. Dodd
302f15f9e8 Add mount options 'noinet4' and 'noinet6' which prevent using those
address families.

This is useful for preventing NFS mounts from using IPv6 on hosts
that have both A and AAAA records for the same name.
2003-03-25 01:25:30 +00:00
Matthew N. Dodd
c04affffc1 - Silence warnings (casting, implicit decl., unused var.).
- WARNS=2
2003-03-25 00:16:41 +00:00
Maxime Henrion
fb624dbc80 Removed a debugging printf() left here in peter's
last commit.

Spotted by:	kris
2002-09-14 15:14:29 +00:00
Peter Wemm
4db5660477 Bandaid for mount_nfs segfaulting with the more obscure mount options
in /etc/fstab.  This isn't a real fix though and I'm still not sure
why it started failing.  mount(8) breaks up the nfs args into seperate
repeated '-o option=value' arguments.  But, the altflags variable that
we use to track things is incrementally built up each time we see the
next option and shows us the cumulative set of flags, not just the
flag that we are currently looking at.  As a result, the strstr hack
for looking up flags in a giant -o opt=val,opt=val, etc string was failing
and causing a segfault.  I do not know what changed recently that caused
this to suddenly break, but the code has been rather bogus for some time.
2002-09-06 19:59:29 +00:00
Ian Dowse
fd0b613a7b Unbreak the -c option by not using connect(2) for mount_nfs's
communication with the remote NFS server if this flag is specified.

PR:		bin/42003
Submitted by:	Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
2002-08-26 13:08:23 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Semen Ustimenko
7ed000f774 Fix -o ac(reg|dir)(min|max) options. The appropriate flags weren't
translated from ALTF_* to NFSMNT_* thus these options weren't accepted
by kernel.

PR:		bin/30334
MFC after:	1 week
2002-08-06 20:26:30 +00:00
Maxime Henrion
526ba6d32b Now that the kernel is able to load modules itself,
remove all the code which was trying to do so.
This code was nasty in several ways, it was hiding
the kernel bug where the kernel was unable to properly
load a module, and it was quitting if it wasn't able
to load the module.  The consequence is that an ABI
breakage of the vfsconf API would have broken *every*
mount utility.
2002-08-03 16:03:21 +00:00
Matthew Dillon
3d8f797ac1 Convert old style (type foo *)0 casts to NULLs
PR:		kern/40360
Requested by:	Hiten PAndya via direct email
2002-07-11 17:54:58 +00:00
Warner Losh
854299908c o __P removed
o main prototype removed
2002-03-21 13:14:21 +00:00
David E. O'Brien
3d438ad61f Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
 "register" -- just how many free registers do people think machines have?)
2002-03-20 17:55:10 +00:00
Alfred Perlstein
13190d8754 Allow users to use the 'nolockd' or -L options with mount_nfs in order
to avoid the need for rpc.lockd to perform client locks.  Using
this option a user can revert back to using local locks for NFS mounts
like we did before we had rpc.lockd.
2001-11-12 02:33:52 +00:00
Peter Wemm
9119623471 Userland part of nfs client/server split and cleanup. 2001-09-18 23:34:44 +00:00
Ian Dowse
2bc53e1178 Change the foreground mount behaviour so that we keep retrying
forever by default. This matches what mount_nfs did before revision
1.40, and it is the generally expected behaviour for NFS mounts.

Document the current defaults near the start of the man page and
mention the options that can be used to change them.

Discussed on:	-hackers
2001-07-21 15:38:37 +00:00
Ian Dowse
e16873dad6 Since revision 1.40/1.41, the default behaviour for mount_nfs is
to give up after one attempt unless a background mount is requested.
Background mounts would retry 10000 times (at least 7 days) before
giving up.

For some situations such as diskless terminals, an NFS filesystem
may be critical to the boot process, so neither the "try once" nor
background mounts are appropiate. To cater for this situation,
unbreak the -R (retry count) parameter so that it also works in
the non-background case. Interpret a zero retry count as "retry
forever".

The defaults are now "try once" for non-background mounts and "retry
forever" for background mounts; both can be overridden via -R.
Add a description of this behaviour to the manpage.
2001-07-19 21:11:48 +00:00
Ian Dowse
eca1c24e5a Use the new CLSET_CONNECT clnt_control() request on UDP clients to
ensure that we never proceed with the mount() syscall if the server
is replying from the wrong source address. Previously the userland
RPC call to the remote nfsd would succeed, but the kernel uses
connect() so it would not see the replies, resulting in a hung
mount.
2001-06-23 19:57:20 +00:00
Ian Dowse
a3d8f94bd4 - Split out the {family,socktype}->netid conversion into a separate
function; we now handle unknown protocols more gracefully.

- Cache the return from getnetconfigent() so that we don't have to
  remember to call freenetconfigent() each time. This fixes a memory
  leak that would cause retrying background mount_nfs processes to
  slowly increase their memory usage.
2001-05-13 00:07:03 +00:00
Ian Dowse
ba33efd92c Fix a typo relating to the "-U" (force UDP for mount protocol)
option. When specified, make sure to use the correct netid for the
getnetconfigent() call, and also in error messages.
2001-04-11 00:21:16 +00:00
Ian Dowse
317d5933d4 Split out all the RPC code into a separate function and address a
number of issues:

- Fix background mounts; these were broken in revision 1.40.
- Don't give up before trying all addresses returned by getaddrinfo().
- Use protocol-independent routines where possible.
- Improve error reporting for RPC errors.
- In non-background mode, give up after trying all protocols once.
- Use daemon(3) instead of rolling our own version.
- Never go ahead with the mount() syscall until we have received
  a reply from the remote nfsd; this is especially important with
  non-interruptible mounts, as otherwise a mistyped command might
  require a reboot to correct.

Reviewed by:	alfred, Martin Blapp <mb@imp.ch>
2001-04-10 22:05:47 +00:00
Andrey A. Chernov
deffdffafa - Back out the last (wrong) commit, and readd a modified version
of pingnfsserver(). The pingnfsport() function is now called everytime.
  If we don't get RPC_SUCCESS or RPC_PROGVERSMISMATCH back, there's
  something wrong with the NFS server and we just exit.

- Fix cfs mount on IPv4-only machines

- Fixed the looping when we did not run background mode.

- Fixed a getnameinfo() call with uninitialized adress.
  This is a NetBSD bug I didn't notified :-( Thanks Ian !

- Added some #ifdef NFSKERB

- Removed some unused variables.

- Fixed idention

- Remove unnecessary ":" in openlog ident

Submitted by:	Martin Blapp <mb@imp.ch>
Reviewed by:	Ian Dowse <iedowse@maths.tcd.ie>
2001-03-31 20:45:21 +00:00
Alfred Perlstein
12d6e650c6 fix -o port=xxx 2001-03-25 19:18:43 +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
Matthew Dillon
9c41fc0919 Fix memory leak in mount_nfs's background (-b) mode which occurs when
the mount is not available.

Submitted-by: Jonathan Hanna <pangolin@home.com>
2000-06-11 05:19:58 +00:00
Bruce Evans
3306ebd1a5 Changed setflags() to set_flags(). This fixes part of the world breakage
due to recently incremented namespace pollution in <unistd.h>.
2000-01-28 12:44:50 +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
66a84ea766 Fix an overflow or two and replace a while with a for.
Submitted by:	Martin Blapp <mbr@imp.ch>
1999-10-30 17:56:47 +00:00
Poul-Henning Kamp
73dd316734 mount* fixes from Martin Blapp <mb@imp.ch>:
Made mount more userfriendly (bad slashes are now filtered out)
        and we remove in mount_nfs trailing slashes if there are any.

        Fixed mount_xxx binarys to resolve with realpath(3)
        the mountpoint.

        Translate the deprecated nfs-syntax with '@' to ':' .
        The ':' syntax has now precedence, but '@' still works.
        Notify the user that the '@' syntax should not be used.

PR: 7846
PR: 13692
Submitted by:   Martin Blapp <mb@imp.ch>
Reviewed by:    phk
1999-10-09 11:54:14 +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
Matthew Dillon
fa9f8da4d2 Print a warning that includes the mount source when the foreground
mount fails prior to going into the background when a background NFS
    mount is requested.

PR:		misc/12376
1999-10-02 19:42:46 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Philippe Charnier
46fc8f78df Sync usage string and man page. Correct use of .Nm. Spelling. Remove
unused #includes.
1998-07-06 07:15:53 +00:00
Peter Wemm
c92e3fa533 Support changing the attribute cache limits per-mount. We don't have
many option letters left, I used long names only (like the previous
port= option)
1998-05-19 07:18:28 +00:00
Bruce Evans
743d5543e2 Don't define KERNEL before including <nfs/nfs.h>. It is no longer
necessary.  This fixes warnings about missing forward declarations
for structs in kernel-only prototypes.
1998-02-01 21:53:19 +00:00