summaryrefslogtreecommitdiffstats
path: root/utils/mount/stropts.c
Commit message (Collapse)AuthorAgeFilesLines
* mount.nfs: try the next address after mount fails with ETIMEDOUTJeff Layton2012-06-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a NFS mount attempt fails with an ETIMEDOUT error, the mount.nfs code doesn't currently attempt the next address in the list. For a NFSv4 mount the initial mount() call almost always ends up going over NFS_DEF_FG_TIMEOUT_MINUTES and the mount is never retried. For a v3 mount, it ends up continually retrying against the same IPv6 address, and never tries the IPv4 address. Eventually it gives up once it hits the NFS_DEF_FG_TIMEOUT_MINUTES timeout. It's possible that a server is just unreachable via IPv6 (due to a routing misconfiguration for instance), or is dropping IPv6 frames on the floor. In that situation, it might still be reachable via IPv4 and trying the next address could have allowed the mount to succeed. Fix this by treating ETIMEDOUT in a similar fashion to ECONNREFUSED. Have the client try the next address in the list before giving up and returning an error. Our QA folks noticed this after a routing problem in one of our test labs. I was able to reproduce it by having the server drop incoming IPv6 frames from the client's address. With this patch, the mount eventually succeeds over IPv4 instead of returning an error. Cc: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mounts.nfs: v2 and v3 background mounts should retry when server is down.Steve Dickson2012-05-011-2/+4
| | | | | | | | | The point of background mounts is to have the mount retried if the mount fails. This patch allows the v2/v3 background mount to proceed in the case when the server is down by not making EOPNOTSUPP a permanent error. Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Background mounts failing on time out errors.Steve Dickson2011-12-051-0/+2
| | | | | | | | | Mounting with the "-o v3,bg,proto=udp" options will fail, instead of retrying, when the server is down. The reason being nfs_rewrite_pmap_mount_options() does not interrupt RPC timeouts correctly. Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Mount should really return from errno testYang Bai2011-10-181-2/+4
| | | | | | | | | We should only try next address family if we meet ECONNREFUSED or EHOSTUNREACH for v4 or ECONNREFUSED or EOPNOTSUPP or EHOSTUNREACH for v3v2. Before, only a break in swich can not make the program out of for loop. Signed-off-by: Yang Bai <hamo.by@gmail.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Preserve any explicit port=2049 optionBen Hutchings2011-09-141-2/+2
| | | | | | | | If NFS port (2049) is supplied explicitly, don't ignore this setting by requesting it to portmapper again. Signed-off-by: Luk Claes <luk@debian.org> Signed-off-by: Steve Dickson <steved@redhat.com>
* pdate addres for Free Software FoundationNeilBrown2011-08-291-2/+2
| | | | | | | | | | | | License texts contain multiple address for FSF, some wrong. So update them and replace COPYING file with http://www.gnu.org/licenses/gpl-2.0.txt which has a few changes to preamble and commentary. Also remove extra COPYING file from utils/statd/ Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: submarvellous messages from mount.nfsMax Matveev2011-08-161-0/+2
| | | | | | | | | | | | | | | | Consider a setup where mountd on the server is controlled via tcp_wrappers (usual RHEL setup) and will not process calls from a particular client because of something in /etc/hosts.deny. When such client attempts to do v3 mount, the error message printed by mount.nfs is misleading. This patch changes that error message from: mount.nfs: Argument list too long to mount.nfs: access denied by server while mounting server:/export Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: Remove MOUNT_CONFIG warningsSteve Dickson2011-03-051-1/+1
| | | | | | | The following changes are needed to remove compile warnings when MOUNT_CONFIG is not defined Signed-off-by: Steve Dickson <steved@redhat.com>
* Removed a couple warnings from utils/mount/stropts.cSteve Dickson2010-11-221-2/+2
| | | | | | | stropts.c:740:6: warning: 'ret' may be used uninitialized in this function stropts.c:653:6: warning: 'ret' may be used uninitialized in this function Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Fix memory leak in nfs_sys_mount()Chuck Lever2010-11-011-3/+5
| | | | | | | | This appears to have been left behind by last year's adjustments to how the extra_opts string is constructed. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: Fix compiler warning in nfs_parse_retry_option()Chuck Lever2010-11-011-2/+5
| | | | | | | | | | | | stropts.c: In function nfs_parse_retry_option: stropts.c:131: warning: conversion to unsigned int from long int may alter its value Make it more clear what the second argument is for, and flag the switch fallthrough case. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: Remove all uses of AI_ADDRCONFIGChuck Lever2010-11-011-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was reported that, if only "lo" is up, mount.nfs 127.0.0.1:/export /mount fails with "Name or service not known". "man 3 getaddrinfo" says this: If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4 addresses are returned in the list pointed to by res only if the local system has at least one IPv4 address configured, and IPv6 addresses are only returned if the local system has at least one IPv6 address configured. The man page oversimplifies here. A review of glibc shows that getaddrinfo(3) explicitly ignores loopback addresses when deciding whether an IPv4 or IPv6 address is configured. This behavior around loopback is a problem not just for mount.nfs, but also for RPC daemons that have to start up before a system's networking is fully configured and started. Given the history of other problems with AI_ADDRCONFIG and the unpredictable behavior it introduces, let's just remove it everywhere in nfs-utils. This fix addresses: https://bugzilla.linux-nfs.org/show_bug.cgi?id=191 Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Don't do anything fancy if this is a remountChuck Lever2010-09-161-0/+28
| | | | | | | | | | | | | | | | We don't want to append "vers=4" or perform any negotiation if the "remount" mount option was specified. It will just end in tears. This attempts to address https://qa.mandriva.com/show_bug.cgi?id=60311 and https://bugzilla.linux-nfs.org/show_bug.cgi?id=187 Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Refactor mount version and protocol autonegotiationChuck Lever2010-09-161-14/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clean up. I'm beginning to agree with Bruce and Steve's assessment that the fallthrough switch case in nfs_try_mount() is more difficult to read and understand than it needs to be. The logic that manages negotiating NFS version and protocol settings is getting more complex over time anyway. So let's split the autonegotiation piece out of nfs_try_mount(). We can reduce indenting, and use cleaner switch-based logic. Also, adding more comments can only help. Neil also suggested replacing the pre-call "errno = 0" trick. The lower-level functions may try to mount several times (given a list of addresses to try). errno could be set by any of those. The mount request will succeed at some point, and "success" is returned, but errno is still set to some non-zero value. The kernel version check in nfs_try_mount() is more or less loop invariant: it's impossible for the result of that test to change between retries. So we should be able to safely move it to the logic that sets the initial value of mi->version. This patch is not supposed to cause a behavioral change. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Cleaned up a warning from commit 44f09b7Steve Dickson2010-09-091-1/+0
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Prepare way for "vers=4,rdma" mountsChuck Lever2010-09-091-7/+0
| | | | | | | | | | | | | At some point, when the kernel starts to support "vers=4,rdma" mounts, we will want the mount.nfs command to pass "vers=4,rdma" mounts instead of rejecting them. Assuming that the kernel will reject these today with EPROTONOSUPPORT, that would cause the version fallback logic to go to "vers=3,rdma" automatically. So the extra check we have now is not needed anyway. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Use nfs_nfs_protocol() for checking for proto=rdmaChuck Lever2010-09-091-5/+12
| | | | | | | | Clean up: Now that nfs_get_proto() can recognize "rdma" we can re-use nfs_nfs_protocol() instead of ad hoc checks for "proto=rdma". Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: silently fails when the network protocol is not foundSteve Dickson2010-06-221-5/+11
| | | | | | | mount.nfs should display some type of error diagnostics when the network protocol can not be determined. 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>
* 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-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* nfs-utils: Collect socket address helpers into one locationChuck Lever2010-01-151-6/+1
| | | | | | | | | | | | | 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: 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: 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: 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>
* 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-031-4/+6
| | | | | | 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-271-7/+22
| | | | | | | from the config file which will be compiled out when the config file is not enabled. Signed-off-by: Steve Dickson <steved@redhat.com>
* Use the default protocol and version values, when theySteve Dickson2009-10-221-0/+9
| | | | | | | are set in the configuration file, to start the negation with the server 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: Support "-t nfs,vers=4" mounts in the kernelChuck Lever2009-09-141-2/+8
| | | | | | | | | | | | | | 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>
* Don't use initialized garbage for address lengthsSteve Dickson2009-07-151-2/+2
| | | | | | | | | | Make sure address lengths are initialized before call calling nfs_extract_server_addresses() from nfs_rewrite_pmap_mount_options(). Otherwise the length check in nfs_string_to_sockaddr() can fail since its will be using garbage from the stack. Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Fix compiler warning in stropts.cChuck Lever2009-07-141-2/+4
| | | | | | | | | | Address compiler warning: stropts.c: In function ¿nfs_append_generic_address_option¿: stropts.c:138: warning: comparison between signed and unsigned Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: remove unused @addrlen argument from nfs_string_to_sockaddr()Chuck Lever2009-07-141-4/+2
| | | | | | | | | | Address compiler warning: network.c: In function nfs_string_to_sockaddr: network.c:272: warning: unused parameter addrlen Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Don't update extra_opts after text-based negotiationChuck Lever2009-07-141-5/+14
| | | | | | | | | The umount.nfs command will negotiate the mount options again, so all that is needed in /etc/mnttab is the original set of options used for the mount, plus the additional mandatory options like addr=''. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Clean up after restructuring version/protocol negotiationChuck Lever2009-07-141-132/+25
| | | | | | | | | | Fix up comments and function names to reflect the new version/protocol negotiation scheme. We can now remove a bunch of mount processing that is specific to v2/v3, removing about 100 lines of logic from stropts.c. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Clean up nfs_is_permanent_error()Chuck Lever2009-07-141-20/+25
| | | | | | | | | Clean up: Move nfs_is_permanent_error() closer to the functions that call it, and update a documenting comment to reflect recent restructuring in this area. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: rearchitect mount version/protocol negotiation logicChuck Lever2009-07-141-17/+25
| | | | | | | | | | | | | | | | | | | | Text-based mounts try a mount operation first with default settings, then negotiate via rpcbind queries and retry the mount, if the default settings don't work. This method introduces long delays in certain common scenarios, and makes it difficult to tell when it is appropriate to fail immediately or negotiate and retry. To address these behavioral regressions, make text-based mounts operate the same way that legacy mounts work. Perform rpcbind queries with short timeouts first, then use the results to determine transport, version, and port number settings for the mount. This allows the mount.nfs command to detect server settings, or whether negotiation is even possible, quickly. It also makes it simple to determine when to fail vs. when to retry. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: make nfs_options2pmap return errorsChuck Lever2009-07-141-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, nfs_options2pmap() has been passed mount options that have already gone through the kernel's parser successfully. So, it never had to check for invalid mount option values. However, we are about to pass it options that come right from the user. So nfs_options2pmap() will now need to report an error and fail if it encounters a bogus value for any of the options it cares about. ===== Note that nfs_options2pmap() will allow a bogus value for an option if the same option is specified farther to the right with a useable value. For example, if a user specifies "proto=foo,...,tcp" then nfs_options2pmap() uses "tcp" and ignores "proto=foo". However, if the options are specified in the other order: "tcp,...,proto=foo" then nfs_options2pmap() will fail. This is a simple and unambiguous extension of the "rightmost wins" rule. Since mount.nfs strips out these options out and replaces them with the rpcbind-negotiated options before invoking mount(2), the kernel should never receive bogus values for these options from mount.nfs in such cases. This is probably slightly more flexible behavior than the legacy mount implementation, but should be harmless. All mount options unrelated to pmap are ignored by nfs_options2pmap(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: remove legacy version of nfs_name_to_address()Chuck Lever2009-05-181-12/+4
| | | | | | | | | | | | | | | | | | | | | | | Currently we have two separate copies of nfs_name_to_address() since some older glibc's don't define AI_ADDRCONFIG. This means extra work to build- and run-test both functions when code is changed in this area. It is also the case that gethostbyname(3) is deprecated, and should not be used in new code. Remove the legacy code in favor of always using getaddrinfo(3). We can also get rid of nfs_name_to_address()'s @family argument as well. Note also this addresses a bug in nfsumount.c -- it was calling nfs_name_to_address() with AF_UNSPEC unconditionally, even if the legacy version of nfs_name_to_address(), which doesn't support AF_UNSPEC, was in use. 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-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>