summaryrefslogtreecommitdiffstats
path: root/utils/mount
Commit message (Collapse)AuthorAgeFilesLines
...
* umount.nfs: Fix return value of nfs_mount_protocol()Chuck Lever2009-04-181-1/+1
| | | | | | | | Fix a copy-paste error introduced in nfs_mount_protocol(). It should return an IPPROTO_ number, not an NFS version number. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* umount.nfs: Use a privileged port when sending UMNT requestsChuck Lever2009-04-181-1/+1
| | | | | | | | | | | Turns out we do actually need to use a privileged port for UMNT. The Linux rpc.mountd complains if an ephemeral source port is used: Apr 17 15:52:19 ingres mountd[2061]: refused unmount request from 192.168.0.59 for /export (/export): illegal port 60932 Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* In recent Fedora builds, the '-D _FORTIFY_SOURCE=2' compileSteve Dickson2009-03-231-2/+6
| | | | | | | | flag has been set. This cause warnings to be generated when return values from reads/writes (and other calls) are not checked. The patch address those warnings. Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: squelch compiler warning for TI-RPC buildsChuck Lever2009-03-051-2/+3
| | | | | | | | | | | | | | | | | | | | | | The printf format string in nfs_pp_debug() assumes the @program and @version arguments are unsigned long, because the legacy RPC headers define both rpcprog_t and rpcvers_t as unsigned long types. However, the TI-RPC headers define both types as uint32_t, which requires a different printf format type. If we replace the legacy headers with TI-RPC headers, this type mismatch generates compiler warnings that are nothing but noise. We are about to provide a switch at ./configure time to allow the use of either the legacy RPC headers or the TI-RPC headers, so we need a printf format that works in both cases. To squelch the compiler warnings that occur when using the TI-RPC headers, cast both arguments in the fprintf statement to the widest of the two types ("unsigned long" or "uint32_t"). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs(5): document new [no]resvport optionChuck Lever2009-03-041-0/+14
| | | | | | | Kernel 2.6.25 deprecates intr/nointr. Reflect this change in nfs(5). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs(5): document new [no]resvport optionChuck Lever2009-03-041-0/+66
| | | | | | | | Kernel 2.6.28 adds a new mount option: [no]resvport. Document the new option in the nfs(5) man page. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* The legacy version of nfs_name_to_address() returned an incorrectChuck Lever2009-03-041-1/+1
| | | | | | | value for the size of the returned address. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* umount command: remove do_nfs_umount23 functionChuck Lever2009-02-171-93/+0
| | | | | | | Remove do_nfs_umount23() now that it is unused. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* umount.nfs command: Support AF_INET6 server addressesChuck Lever2009-02-171-4/+99
| | | | | | | | | | | | | | | | | | | | | | | Replace existing mount option parser in nfsumount.c with the new pmap stuffer function nfs_options2pmap(). Mount option parsing for umount.nfs now works the same as it does for mount option rewriting in the text-based mount.nfs command. This adds a number of new features: 1. The new logic supports resolving AF_INET6 server addresses 2. Support is added for the recently introduced "mountaddr" option. 3. Parsing numeric option values is much more careful 4. Option parsing no longer uses xmalloc/xstrdup, so it won't fail silently if memory can't be allocated 5. Mount program number set in /etc/rpc is respected 6. Mount doesn't exit with EX_USAGE if the hostname lookup fails Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* umount.nfs command: Add an AF_INET6-capable version of nfs_call_unmount()Chuck Lever2009-02-172-1/+56
| | | | | | | | | | | | | | | | | | We need an AF_INET6-capable version of nfs_call_unmount() to allow the umount.nfs command to support unmounting NFS servers over IPv6. The legacy mount.nfs command still likes to use nfs_call_umount(), so we leave it in place and introduce a new API that can take a "struct sockaddr *". The umount.nfs command will invoke this new API, but we'll leave the legacy mount.nfs command and the umount.nfs4 command alone. The umount.nfs4 command does not need this support because NFSv4 unmount operations are entirely local. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* The mount sockaddr len (mnt_salen) is not be set inSteve Dickson2009-02-171-2/+3
| | | | | | | | nfs_extract_server_addresses() which causes the mount.nfs command to segmentation fault when a NFS server only supports UDP mounts. Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: fix return value from po_rightmost()Chuck Lever2009-02-174-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recently commit 0dcb83a8 changed the po_rightmost() function to distinguish among several possible mount options by taking a table containing the alternatives, and returning the table index of the entry which is rightmost in the mount option string. If it didn't find any mount option that matches an entry from the passed-in table, it returned zero. This was the same behavior it had before, when it only checked for two options at a time. It returned PO_NEITHER_FOUND, which was zero. Since this is C, however, zero also happens to be a valid index into the passed-in array of options. Modify the po_rightmost() function to return -1 if the entry wasn't found, and fix up the callers to look for a C-style array index that starts at zero. Thanks to Steve Dickson for troubleshooting the problem. His solution was merely to bump the return value, as callers already expected an ordinal index instead of a C-style index. I prefer this equivalent but slightly more extensive change because it makes the behavior of po_rightmost() more closely match how humans understand C arrays to work. Let's address some of the confusion that caused this bug, as well as fixing the run-time behavior. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: support AF_INET6 in rewrite_mount_options()Chuck Lever2009-01-271-25/+49
| | | | | | | | | | Now that we have an AF_INET6-capable probe_bothports(), we can support AF_INET6 when rewriting text-based NFS mount options. This should be adequate to support NFS transport protocol and version negotiation with AF_INET6 NFS servers. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: fix mount option rewriting logicChuck Lever2009-01-271-34/+79
| | | | | | | Fix a bunch of corner cases in the text-based mount option rewriting logic. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount options: Use new pmap stuffer when rewriting mount optionsChuck Lever2009-01-271-63/+5
| | | | | | | | | | | all nfs_options2pmap() in nfs_rewrite_mount_options() instead of open-coding the logic to convert mount options to a pmap struct. The new nfs_options2pmap() function is more careful about avoiding invalid mount option values, and handles multiply-specified transport protocol options correctly. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: Function to stuff "struct pmap" from mount optionsChuck Lever2009-01-272-0/+219
| | | | | | | | | Both the text-based mount.nfs command and the umount.nfs command need to fill in a pmap structure based on string mount options. Introduce a shared function that can do this. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: make po_rightmost() work for N optionsChuck Lever2009-01-273-24/+41
| | | | | | | | | | | Sometimes we need to choose the rightmost option among multiple different mount options. For example, we want to find the rightmost of "proto," "tcp," and "udp". Or, the rightmost of "vers," "nfsvers," "v2," and "v3". Update po_rightmost() to choose among N options instead of just two. Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: Random clean upChuck Lever2009-01-061-1/+2
| | | | | | | Fix some documenting comments and an error message in configure.ac. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: use gethostbyname(3) when building on old systemsChuck Lever2009-01-061-0/+56
| | | | | | | | | | | | | | | | | | Glibc's getaddrinfo(3) implementation was added over time. Some old versions support AI_ADDRCONFIG, but don't define it in header files. Some older versions don't support AI_ADDRCONFIG at all. Let's add specific checks to configure.ac to see that the local getaddrinfo(3) implementation is complete. If it isn't, we will make available a resolver that uses gethostbyname(3) and disable IPv6 entirely. This patch should apply to 1.1.4 as well as the current nfs-utils repo. The next patch has a fix for the getaddrinfo(3) call added since 1.1.4 in support/nfs/getport.c. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: revert recent fix for build problems on old systemsChuck Lever2009-01-061-18/+0
| | | | | | | | | | | | | | Revert the patch that added local definitions of AI_ADDRCONFIG and friends to utils/mount/network.c. While old header versions don't have those flags, even older versions of getaddrinfo(3) don't support those flags at all. The result is this error: mount.nfs: DNS resolution failed for 10.10.10.10: Bad value for ai_flags Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: use po_get_numeric() for handling retryChuck Lever2008-12-171-9/+11
| | | | | | | | Replace the logic in nfs_parse_retry_option() with a call to the new po_get_numeric() function. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount command: add function to parse numeric mount optionsChuck Lever2008-12-172-0/+58
| | | | | | | | Introduce a function that is especially for parsing keyword mount options that take a numeric value. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: AF_INET6 support for probe_bothports()Chuck Lever2008-12-112-21/+68
| | | | | | | | | | | | | | | | Introduce an AF_INET6 capable probe_bothports() API. This means replacing "struct sockaddr_in *" arguments with a "struct sockaddr *" and a socklen_t arguments. These functions often combine a "struct sockaddr_in" and a "struct pmap" into a single "clnt_addr_t" argument. Instead of modifying "clnt_addr_t" and all the legacy code that uses it, I'm going to create a new probe_bothports() API for the text-based mount command that takes a "struct sockaddr *" and sockaddr length, and leave the existing probe_bothports() interface, which takes "clnt_addr_t" arguments, for legacy use. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: support AF_INET6 in probe_nfsport() and probe_mntport()Chuck Lever2008-12-111-16/+42
| | | | | | | | Flesh out support for AF_INET6 in the intermediate helper functions probe_nfsport() and probe_mntport(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: full support for AF_INET6 addresses in probe_port()Chuck Lever2008-12-111-10/+44
| | | | | | | | Now that probe_port() uses an AF_INET6-capable rpcbind query and RPC ping, finish updating probe_port() to support AF_INET6 addresses fully. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: remove local getport() implementationChuck Lever2008-12-021-74/+2
| | | | | | | | Eliminate local getport() implementation from utils/mount/network.c, as it is no longer used. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: Replace clnt_ping() and getport() calls in probe_port()Chuck Lever2008-12-021-14/+29
| | | | | | | | | | | Update the mount command's probe_port() function to call the new shared rpcbind query and RPC ping functions. This provides immediate support for rpcbind v3/v4 queries, and paves the way for supporting AF_INET6 in the probe_bothports() path. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: Use nfs_error() instead of perror()Chuck Lever2008-12-021-1/+2
| | | | | | | | So we can ensure that error output is directed appropriately, use nfs_error() instead of perror() in start_statd(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount command: Use nfs_pmap_getport() in probe_statd()Chuck Lever2008-12-021-18/+16
| | | | | | | | Repace the getport() and clnt_ping() calls in probe_statd() with their new shared equivalents. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Ensure statd gets started if required when non-rootNeil Brown2008-11-261-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | user mounts an NFS filesystem. The first time an NFS filesystem is mounted, we start statd from /sbin/mount.nfs. If this first time is a non-root user doing the mount, (thanks to e.g. the 'users' option in /etc/fstab) then we need to be sure that the 'setuid' status from mount.nfs is inherited through to rpc.statd so that it runs as root. There are two places where we loose our setuid status due to the shell (/bin/sh) discarding. 1/ mount.nfs uses "system" to run /usr/sbin/start-statd. This runs a shell which is likely to drop privileges. So change that code to use 'fork' and 'execl' explicitly. 2/ start-statd is a shell script. To convince the shell to allow the program to run in privileged mode, we need to add a "-p" flag. We could just call setuid(getuid()) at some appropriate time, and it might be worth doing that as well, however I think that getting rid of 'system()' is a good idea and once that is done, the adding of '-p' is trivial and sufficient. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs(5): Clarify behavior of the mountproto= and proto= optionsChuck Lever2008-10-081-0/+85
| | | | | | | | Document the interaction between the mountproto= and the proto= mount options in a new subsection of nfs(5). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs(5): Replace the term "netid" in mount option descriptionsChuck Lever2008-09-291-8/+8
| | | | | | | | | | | | | | | | | | | | | | | TI-RPC introduced the concept of "netid" which is a string that is mapped to a set of transport capabilities via a netconfig database. RPC services register a netid and bindaddr with their local rpcbind daemon to advertise their ability to support particular transports. Mike Eisler noted that the use of the term "netid" in nfs(5) is not appropriate, since Linux does not treat the value of the proto= or mountproto= options as a netid proper, but rather to select a particular transport capability provided locally on the client. The Linux NFS client currently uses a simple internal mapping between these names and its own transport capabilities rather than using the names as part of an rpcbind query, thus these strings are really not netids. They are more akin to what TI-RPC calls "protocol names". Remove the term "netid" from nfs(5) for now. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Cc: Mike Eisler <mike.eisler@netapp.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs(5): Replace the term "netid" in mount option descriptionsChuck Lever2008-09-291-6/+6
| | | | | | | | | | | | Mike Eisler noted that the use of the term "netid" in the descriptions of the "proto=" option is not appropriate, since Linux does not allow "udp6" or "tcp6". Replaced the term "netid" with "transport" in nfs(5). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Tom Talpey <Thomas.Talpey@netapp.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: enable retry for nfs23 to set the correct protocol for mount.Neil Brown2008-08-281-2/+4
| | | | | | | | | | Use a connected port when talking to portmap via UDP. This allows us to get ICMP errors reported back so we can avoid timeouts. Also catch the error (RPC_CANTRECV) properly in getport. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs command: old glibc missing some flagsChuck Lever2008-07-311-0/+18
| | | | | | | | | | | | | | | | Old versions of glibc (< 2.4) have a getaddrinfo(3) implementation, but do not include public definitions of the AI_V4MAPPED, AI_ALL, and AI_ADDRCONFIG flags because it was believed that these flags were not standardized. However, these flags have standard definitions both in POSIX 1003 and in RFCs, and were thus included in later releases of glibc. To allow the mount.nfs command to build on systems with these older versions of glibc, add conditional definitions for these flags in utils/mount/network.c. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs(5) man page: Add documentation for the "mountproto=" optionChuck Lever2008-07-251-0/+19
| | | | | | | | Looks like mountproto= was never documented in nfs(5). Add a paragraph that describes it in the "nfs mount options" section. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* If portmap is not listening on UDP (as apparently happens withNeil Brown2008-07-161-4/+15
| | | | | | | | | | | | | | | | | | | MS-Windows-Server2003R2SP2), then nfs mounts have to be mounted with -o mountproto=tcp to succeed. In this case a umount will still try UDP and will fail to contact the server. It will still succeed with the local unmount (after a timeout) but exits with a non-zero exit status. This causes /bin/mount to retry so we get a strange error about the filesystem not being mounted. So: get umount to use tcp if "mountproto=tcp" appears in mtab ignore any failure message from the server that would overwrite a success message from the local umount syscall. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* If an NFS server is only listening on TCP for portmap (as apparentlyNeil Brown2008-07-162-2/+29
| | | | | | | | | | | | | | | MS-Windows-Server2003R2SP2 does), mount doesn't cope. There is retry logic in case the initial choice of version/etc doesn't work, but it doesn't cope with mountd needing tcp. So: Fix probe_port so that a TIMEDOUT error doesn't simply abort but probes with other protocols (e.g. tcp). Fix rewrite_mount_options to extract the mountproto option before doing a probe, then set mountproto (and mount prot) based on the result. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* Clean up: Include the bare minimum of legacy RPC headers inChuck Lever2008-07-156-24/+9
| | | | | | | utils/mount/network.h. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Clean up: remove unneeded headers from utils/mount/stropts.c.Chuck Lever2008-07-151-11/+3
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Clean up: rename a couple of functions in utils/mount/stropts.c to matchChuck Lever2008-07-151-9/+9
| | | | | | | the naming convention of the others. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Clean up: remove unused IPv4-only functions used by the text-based mountChuck Lever2008-07-153-54/+0
| | | | | | | command. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Traditionally the mount command has looked for a ":" to separate theChuck Lever2008-07-155-82/+288
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | server's hostname from the export path in the mounted on device name, like this: mount server:/export /mounted/on/dir The server's hostname is "server" and the export path is "/export". You can also substitute a specific IPv4 network address for the server hostname, like this: mount 192.168.0.55:/export /mounted/on/dir Raw IPv6 addresses present a problem, however, because they look something like this: fe80::200:5aff:fe00:30b Note the use of colons. To get around the presence of colons, copy the Solaris convention used for raw NFS server IPv6 addresses, which is to wrap the raw IPv6 address with square brackets. This is also suggested in RFC 4038. Introduce a new device name parser that can support traditional device names and square brackets. Place the parser in a separate source file so both the mount and umount paths can derive the server's hostname and export pathname the same way. Bonus points: add a check for NFS URLs and display an appropriate error message in that case. This is cleaner than failing with "unknown host: nfs". Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Change the fix_mounthost_option() function to support resolving IPv6Chuck Lever2008-07-151-12/+21
| | | | | | | addresses. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Change the append_clientaddr_option() function to support sending eitherChuck Lever2008-07-151-14/+12
| | | | | | | | | | | IPv4 or IPv6 addresses to the kernel via the "clientaddr=" option. If the mount.nfs4 command can't determine an appropriate callback address, it used to fail the mount request. This new function simply sends an ANY address instead, so the mount request succeeds, but delegation is disabled. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Change the append_addr_option() function to support sending either IPv4Chuck Lever2008-07-151-15/+6
| | | | | | | or IPv6 addresses to the kernel via the "addr=" option. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* There are three helpers that convert sockaddr-style addresses to textChuck Lever2008-07-151-0/+31
| | | | | | | | | | | addresses, then construct mount options to pass these addresses to the kernel. The tail of each of these helpers does exactly the same thing, so introduce a helper that handles the common code. Magically, the new helper supports IPv6 as well as IPv4. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Introduce IPv6-enabled version of get_client_address. The legacy mountChuck Lever2008-07-152-0/+120
| | | | | | | | | | | | | | command could use this eventually as well. If this new function fails to discover an appropriate callback address, it fills in an ANY address to indicate to the server that it should not call the client back (ie delegations are disabled in this case). The user can specify a callback address via the clientaddr= mount option in this case to enable delegation. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Introduce two new functions to convert a sockaddr to a presentation formatChuck Lever2008-07-152-0/+96
| | | | | | | string and back. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add #include directives for additional header files needed to support IPv6Chuck Lever2008-07-152-1/+7
| | | | | | | | networking. This is a separate patch so subsequent patches can be reordered without collision. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>