summaryrefslogtreecommitdiffstats
path: root/utils/mount
Commit message (Collapse)AuthorAgeFilesLines
* mount: silently fails when bad option values are givenSteve Dickson2010-06-222-5/+19
| | | | | | | | mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: Mount should retry unreachable hostsChuck Lever2010-03-191-0/+1
| | | | | | | | | | | | | | | | | | | | | Currently if a server is up but not responding (ie, it answers ARP requests, but not NFS or RPC requests), mount retries or backgrounds itself waiting for the server. If the server is not responding on the network at all, mount fails the mount request immediately. Users might find it more useful if mount retried in both cases. Note that this change means attempting to mount using a misspelled server name will "hang" for the retry amount. I suppose the error message isn't very helpful whether it fails immediately or waits a couple of minutes, though I imagine that an unreachable server is a much more common occurrence than a misspelling. Reported-by: Daniel Goering <g_daniel@gmx.net> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: add and use nfs_authsys_createJeff Layton2010-03-011-3/+12
| | | | | | | | | | | | | | | | | | The current mount, umount and showmount code uses authunix_create_default to get an auth handle. The one provided by glibc returned a truncated list of groups when there were more than 16 groups. libtirpc however currently does an abort() in this case, which causes the program to crash and dump core. nfs-utils just uses these auth handles for the MNT protocol, so the group list doesn't make a lot of difference here. Add a new function that creates an auth handle with a supplemental gids list that consists only of the primary gid. Have nfs-utils use that function anywhere that it currently uses authunix_create_default. Also, have the caller properly check for a NULL return from that function. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: Set protocol family properly for "udp" and "tcp"Chuck Lever2010-02-181-1/+2
| | | | | | | | | | | | | | | | | | | | In nfs_nfs_proto_family(), *family is never set if the legacy "udp" or "tcp" mount options are specified. The result is an error message at umount time, for example: umount.nfs: DNS resolution failed for 2001:5c0:1101:2f00:250:8dff:fe95:5c61: ai_family not supported even if mount was built with IPv6 support. The man page says that "udp" is a synonym for "proto=udp", and likewise for "tcp". Thus, we don't look at config_default_family here, but always use AF_INET explicitly, to be consistent with the meaning of proto=. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: make nfs_{nfs,mount}_proto set errno on errorJeff Layton2010-02-121-6/+18
| | | | | | | | | Have nfs_nfs_proto and nfs_mount_proto set errno to EPROTONOSUPPORT on error. This helps default_value to display sane warning messages. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: return error if proto= option specified IPv6 when IPv6 isn't ↵Jeff Layton2010-02-121-16/+43
| | | | | | | | | | | | | | | supported Right now, there's nothing that expressly forbids someone from specifying proto=tcp6 for instance, even when nfs-utils it built without IPv6 support. This may not work well if (for instance) they are using NFSv3, since statd won't support IPv6. Explicitly return an error if someone specifies an IPv6 proto= or mountproto= option and IPv6 isn't supported. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* This is the second iteration of this patch. The only difference hereJeff Layton2010-02-122-10/+14
| | | | | | | | | | | | | | | | | | | | | is that this one has default_value call nfs_nfs_proto_family regardless of whether IPV6_SUPPORTED is set. When IPv6 is enabled, the Proto= config file option is treated as a netid, and the address family for lookups is selected based on that setting. The Defaultproto= option however still only affects the protocol setting for the sockets (IPPROTO_*) and not the address family. This patch makes it so that if someone sets the "Defaultproto=" option in the nfsmount.conf, it's used to determine the default address family for lookups as well as the protocol type. This gives users a way to force a particular address family to be used universally for mounts and brings the behavior of the Defaultproto= option in line with the Proto= option. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount: Support protocol family negotiationChuck Lever2010-02-121-11/+60
| | | | | | | | | | | | | Jeff Layton pointed out that the current negotiation logic in stropts.c simply doesn't handle the case where a server may have an IPv6 address and an IPv4 address, but only NFS/IPv4 is supported. This is typical of all currently deployed Linux servers. Add support for trying all addresses returned from DNS when "proto=" is not specified on the command line. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount: Set addr= option in nfs_try_mount_foo()Chuck Lever2010-02-121-4/+19
| | | | | | | | | | | | | When retrying a mount request with a different server address, the addr= option may change each time through the fg/bg loop. Instead of setting the addr= option in nfs_validate_options(), set it in nfs_try_mount_v2v3() and nfs_try_mount_v4(). This is much the same thing we did recently with the version-specific mount options which might change each time through the fg/bg retry loop. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount: Replace nfs_lookup() with getaddrinfo(3)Chuck Lever2010-02-121-8/+24
| | | | | | | | | | | | | | Originally I thought it would be best to share the DNS query code between the legacy mount code and the new text-based code, hence the introduction of nfs_lookup(). However, it now appears we want the text-based code to do a little more than take the first address returned by the query. So, let's invoke getaddrinfo(3) directly in stropts.c, and save the returned addrinfo struct until the end of processing. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* text-based mount: Retry when server can't be reachedChuck Lever2010-02-122-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | We want new default behavior from mount.nfs when the server refuses a connection. Since connection refusal can be spurious (for example, if the server is rebooting), mount.nfs should retry. NFS shares that are automatically mounted by /etc/fstab at boot time may be problematic. The new behavior can be disabled by specifying the "retry=0" mount option, or these mounts can be changed to background mounts by specifying the "bg" option. A kernel code change is still required for the mount(2) system call to return ECONNREFUSED for NFSv4 mounts (see 2.6.33). For v2/v3, the version and transport negotiation logic in mount.nfs should drive a retry if the server's rpcbind can't be reached. Note that if a v2/v3 mount request encounters an unregistered NFS service, it will still fail immediately. That wouldn't be too hard to change as well, but there are many more corner cases there where failing immediately is appropriate. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Added the sys/stat.h header file to a number ofSteve Dickson2010-01-222-0/+2
| | | | | | files which ensure the S_ISDIR() macro is defined. Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Configuration file parser ignoring optionsSteve Dickson2010-01-201-5/+21
| | | | | | | | | | When the protocol version is set on the command line, none of the variables set in the configuration file are passed down to the kernel due to a bug in the parsing routine. Tested-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: Collect socket address helpers into one locationChuck Lever2010-01-152-14/+6
| | | | | | | | | | | | | Introduce generic helpers for managing socket addresses. These are general enough that they are useful for pretty much any component of nfs-utils. We also include the definition of nfs_sockaddr here, so it can be shared. See: https://bugzilla.redhat.com/show_bug.cgi?id=448743 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* mount.nfs: don't use IPv6 unless IPV6_SUPPORTED is setJeff Layton2010-01-041-1/+1
| | | | | | | | | | | | | | Commit 1f3fae1fb25168aac187ff1881738c8ad53a8763 made mount.nfs start looking up and trying to use IPv6 addresses when mount.nfs was built against libtirpc (even when --enable-ipv6 wasn't specified). The problem seems to be that nfs_nfs_proto_family() is basing the family on HAVE_LIBTIRPC. I think it should be basing it on IPV6_SUPPORTED instead. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* NFS man page: update nfs(5) with details about IPv6 supportChuck Lever2009-12-111-32/+72
| | | | | | | | | | | Add details to nfs(5) about how to specify raw IPv6 addresses when mounting an NFS server. Mounting via an IPv6 NFS server via hostname should work as it does with IPv4. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Remove nfs_name_to_address()Chuck Lever2009-12-112-22/+2
| | | | | | | Clean up: nfs_name_to_address() has no more callers. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Teach umount.nfs to recognize netids in /etc/mtabChuck Lever2009-12-111-4/+11
| | | | | | | | umount.nfs has to detect the correct address family to use when looking up the server. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: proto=netid forces address family when resolving server namesChuck Lever2009-12-111-8/+23
| | | | | | | | | | | | Using the netid settings, determine the correct address family to use for NFS and MNT server name resolution. Use this family when resolving the server name for the addr= and mountaddr= options. This patch assumes the kernel can recognize a netid, instead of a protocol name, as the value of the proto= options. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Fix sockaddr pointer aliasing in stropts.cChuck Lever2009-12-111-13/+19
| | | | | | | | | | | | | | | | | Using a sockaddr_storage and casting a sockaddr pointer to it breaks C's aliasing rules. See: https://bugzilla.redhat.com/show_bug.cgi?id=448743 Replacing sockaddr_storage makes this code less likely to break when optimized by gcc. It also saves a significant amount of stack space by replacing a 130 byte structure with a union that is less than 32 bytes. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Add new API for getting protocol family from netidsChuck Lever2009-12-112-0/+65
| | | | | | | | Introduce a couple of new functions that extract the protocol family from the value of the proto= and mountproto= mount options. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: make nfs_lookup() globalChuck Lever2009-12-112-2/+14
| | | | | | | | Expose a DNS query API that allows callers to request DNS results from a specific address family. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: support netids in v2/v3 version/transport negotiationChuck Lever2009-12-111-29/+22
| | | | | | | | | | | | | When rewriting mount options during v2/v3 negotiation, restore the correct netids, rather than protocol names, in the rewritten protocol options. If TI-RPC is not available, the traditional behavior is preserved. This patch assumes the kernel can recognize a netid, instead of a protocol name, as the value of the proto= options. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: support netids in nfs_options2pmap()Chuck Lever2009-12-111-22/+6
| | | | | | | | | | | | | When parsing mount options in nfs_options2pmap(), treat the value of proto= (and mountproto=) as a netid by looking it up in local netconfig and protocol databases to convert it to a protocol number. If TI-RPC is not available, the traditional behavior is preserved. The meaning of the "udp" and "tcp" mount options is not affected by this change. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Retry v4 mounts with v3 on ENOENT errorsNeil Brown2009-12-071-2/+3
| | | | | | | | | Retry v4 mounts with a v3 mount when the version is not explicitly specified and the mount fails with ENOENT. The will help deal with Linux servers that do not automatically export a pseudo root Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: NFSv4: fix backgroundingHarshula Jayasuriya2009-11-161-10/+15
| | | | | | | | | | | | | | | he nfsmount() function checks if !bg before running switch(rpc_createerr.cf_stat). On the other hand, the nfs4mount() function does not, and results in exiting the loop on the first iteration even with the bg mount option. NOTE: This and the previous patch ("nfs-utils: mount options can be lost when using bg option") are relevant to non text-based mount options. See https://bugzilla.redhat.com/show_bug.cgi?id=529370 for details. Signed-off-by: Harshula Jayasuriya <harshula@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount options can be lost when using bg optionHarshula Jayasuriya2009-11-162-2/+8
| | | | | | | | | | | | | | | | | | When mounting an NFS export *without* the "bg" option, try_mount() is called only once. Before calling it, the variables mount_opts and extra_opts are set up. Then try_mount() calls nfsmount(), the latter assumes that the aforementioned variables can be modified. Most significantly, it allows the variable extra_opts to be modified. When the "bg" mount option is used *and* the first try_mount() attempt fails, it daemonizes the process and calls try_mount() again, unfortunately, we've lost the required mount options in the variable extra_opts. See https://bugzilla.redhat.com/show_bug.cgi?id=529370 for details. Signed-off-by: Harshula Jayasuriya <harshula@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Assume v2/v3 if mount-related options are presentChuck Lever2009-11-161-0/+12
| | | | | | | | Don't try NFSv4 if any MNT protocol related options were presented by the user. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: Fix po_join() call site in nfs_try_mount_v4()Chuck Lever2009-11-031-1/+2
| | | | | | | Make sure the copied options string is freed in case po_join() fails. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Assume v2/v3 if mount-related options are presentChuck Lever2009-11-031-14/+35
| | | | | | | | Don't try NFSv4 if any MNT protocol related options were presented by the user. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Made some aesthetic changes to the code that setsSteve Dickson2009-11-032-8/+10
| | | | | | the defaults that were a result of the code review. Signed-off-by: Steve Dickson <steved@redhat.com>
* Retry v4 mounts with a v3 mount when the versionSteve Dickson2009-11-031-2/+9
| | | | | | | | is not explicitly specified and the mount fails with ENOENT. The will help deal with Linux servers that do not automatically export a pseudo root Signed-off-by: Steve Dickson <steved@redhat.com>
* Added wrappers around the setting of default valuesSteve Dickson2009-10-272-15/+45
| | | | | | | from the config file which will be compiled out when the config file is not enabled. Signed-off-by: Steve Dickson <steved@redhat.com>
* Added the defaultproto and defaultvers variable to the mountSteve Dickson2009-10-221-4/+18
| | | | | | configuration file. Signed-off-by: Steve Dickson <steved@redhat.com>
* Use the default protocol and version values, when theySteve Dickson2009-10-222-3/+22
| | | | | | | are set in the configuration file, to start the negation with the server Signed-off-by: Steve Dickson <steved@redhat.com>
* Introducing the parsing of both 'defaultvers' and 'defaultproto'Steve Dickson2009-10-223-2/+59
| | | | | | | | | | | config variables which will be used to set the the default version and network protocol. A global variable will be set for each option with the corresponding value. The value will be used as the initial value in the server negation. Signed-off-by: Steve Dickson <steved@redhat.com>
* Make sure all protocol version options are checked in check_vers()Steve Dickson2009-10-091-3/+1
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* Make the network transports value in the mountSteve Dickson2009-10-091-3/+4
| | | | | | | config file case sensitive, since they are in the mount command's parsing code. Signed-off-by: Steve Dickson <steved@redhat.com>
* There are a number of different mount options that can beSteve Dickson2009-10-091-0/+20
| | | | | | | | used to set the protocol version on the command line. The config file code needs to know about each option so the command line value will override the config file value. Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: Support negotiation between v4, v3, and v2Chuck Lever2009-09-291-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When negotiating between v3 and v2, mount.nfs first tries v3, then v2. Take the same approach for v4: try v4 first, then v3, then v2, in order to get the highest NFS version both the client and server support. No MNT request is needed for v4. Since we want to avoid an rpcbind query for the v4 attempt, just go straight for mount(2) without a MNT request or rpcbind negotiation first. If the server reports that v4 is not supported, try lower versions. The decisions made by the fg/bg retry loop have nothing to do with version negotation. To avoid a layering violation, mount.nfs's multi-version negotiation strategy is wholly encapsulated within nfs_try_mount(). Thus, code duplication between nfsmount_fg(), nfsmount_parent(), and nfsmount_child() is avoided. For now, negotiating version 4 is supported only on kernels that can handle the vers=4 option on type "nfs" file systems. At some point we could also allow mount.nfs to switch to an "nfs4" file system in this case. Since mi->version == 0 can now mean v2, v3, or v4, limit the versions tried for RDMA mounts. Today, only version 3 supports RDMA. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* The user's mount options and the set of versions to try should notChuck Lever2009-09-291-24/+106
| | | | | | | | | | | | | | | | | | | change over the course of mount retries. With this patch, each version-specific mount attempt is compartment- alized, and starts from the user's original mount options each time. Thus these attempts can now be safely performed in any order, depending on what the user has requested, what the server advertises, and what is up and running at any given point. Don't regress the fix in commit 23c1a452. For v2/v3 negotation, only the user's mount options are written to /etc/mtab, and not any options that were negotiated by mount.nfs. There's no way to guarantee that the server configuration will be the same at umount time as it was at mount time. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Keep server's address in nfsmount_infoChuck Lever2009-09-291-6/+7
| | | | | | | | We want to pass the server's address around. Put it in the mount context structure. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Add API to duplicate a mount option listChuck Lever2009-09-292-0/+66
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Support "-t nfs,vers=4" mounts in the kernelChuck Lever2009-09-144-7/+22
| | | | | | | | | | | | | | Support "vers=4" in nfs_nfs_version() Skip UMNT call for "-t nfs -o vers=4" mounts For "-t nfs -o vers=4" mounts, we want to skip v2/v3 version/transport negotiation, but be sure to append the "clientaddr" option. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com> Tested-by: Steve Dickson <steved@redhat.com>
* Cleaned up some warnings in the mount config file code.Steve Dickson2009-08-271-0/+2
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* Cleaned up parsing errors to hopeful be more preciseSteve Dickson2009-08-172-4/+5
| | | | | | | Also had mount_config_init() call xlog_open() so the program name is set on xlog() calls. Signed-off-by: Steve Dickson <steved@redhat.com>
* Now that only the Section names are case-insensitiveSteve Dickson2009-08-161-3/+6
| | | | | | | | | the mount code has to make sure the the mount options given to the kernel are in the correct case. Fixed a couple of warnings on #ifndefs Signed-off-by: Steve Dickson <steved@redhat.com>
* The example nfsmount.conf fileSteve Dickson2009-08-162-0/+121
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* The new nfsmount.conf(5) man page and the update toSteve Dickson2009-08-163-0/+95
| | | | | | the nfs(5) man page Signed-off-by: Steve Dickson <steved@redhat.com>
* Added hooks to the mount command that allowSteve Dickson2009-08-163-1/+56
| | | | | | mount options to be set in a configuration file Signed-off-by: Steve Dickson <steved@redhat.com>