summaryrefslogtreecommitdiffstats
path: root/utils/mount/network.c
Commit message (Collapse)AuthorAgeFilesLines
* 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: move generic functions to utils.c and network.cKarel Zak2011-04-061-0/+68
| | | | | | | | | Move generic code that could be shared between standard mount.nfs and libmount version to utils.c and network.c. CC: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Don't leak socket in nfs_ca_sockname()Chuck Lever2011-04-061-15/+13
| | | | | | | | | | Ensure the test socket is always closed before nfs_ca_sockname() returns. Otherwise it's orphaned. BugLink: https://bugzilla.linux-nfs.org/show_bug.cgi?id=197 Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount: Recognize zero as a valid value for the port= optionChuck Lever2011-03-031-2/+2
| | | | | | | | | | While zero is not a valid IP port number, zero does represent a valid value for "port=". It means "query rpcbind to discover the actual non-zero port number to use". So the parsing functions that handle "port=" should not flag zero as an invalid value. 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-3/+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: mountproto does not support RDMAChuck Lever2010-10-141-1/+5
| | | | | | | | | | | Clean up. Our client does not support the MNT protocol on RDMA. nfs_mount_protocol() isn't invoked for RDMA mounts (they are shunted off before nfs_options2pmap() is invoked). But in case it ever is, it should return the expected response. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Eliminate compiler warnings in utils/mount/network.cChuck Lever2010-10-141-16/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clean up. network.c: In function get_socket: network.c:431: warning: dereferencing type-punned pointer might break strict-aliasing rules network.c: In function probe_bothports: network.c:759: warning: dereferencing type-punned pointer might break strict-aliasing rules network.c:762: warning: dereferencing type-punned pointer might break strict-aliasing rules network.c: In function nfs_probe_statd: network.c:775: warning: dereferencing type-punned pointer might break strict-aliasing rules network.c: In function nfs_call_umount: network.c:904: warning: dereferencing type-punned pointer might break strict-aliasing rules network.c: In function nfs_ca_sockname: network.c:1106: warning: dereferencing type-punned pointer might break strict-aliasing rules network.c:1112: warning: dereferencing type-punned pointer might break strict-aliasing rules Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Support an "rdma" mount optionChuck Lever2010-09-091-2/+7
| | | | | | | | | | | | | | | | | | The kernel NFS client's mount option parser recognizes a stand-alone "rdma" mount option, similar to the legacy "udp" and "tcp" options. The mount.nfs command text-based mount option parser used to pass "rdma" straight to the kernel, but since we've started handling MNT in the kernel instead of in user space, "rdma" on the command line has not worked. Until now, no-one has noticed, especially since an "rdma" mount option isn't documented in nfs(5). Support "rdma" in mount.nfs command, and document it in nfs(5). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Removed warnings from network.cSteve Dickson2010-08-091-1/+2
| | | | | | | network.c: In function 'nfs_verify_family': network.c:1366: warning: unused parameter 'family' Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: silently fails when the network protocol is not foundSteve Dickson2010-06-221-3/+16
| | | | | | | 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: silently fails when bad option values are givenSteve Dickson2010-06-221-2/+18
| | | | | | | | 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>
* 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-121-10/+8
| | | | | | | | | | | | | | | | | | | | | 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>
* Added the sys/stat.h header file to a number ofSteve Dickson2010-01-221-0/+1
| | | | | | files which ensure the S_ISDIR() macro is defined. Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: Collect socket address helpers into one locationChuck Lever2010-01-151-8/+5
| | | | | | | | | | | | | 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>
* mount.nfs: Remove nfs_name_to_address()Chuck Lever2009-12-111-21/+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: Add new API for getting protocol family from netidsChuck Lever2009-12-111-0/+63
| | | | | | | | 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-111-2/+12
| | | | | | | | 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 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>
* Made some aesthetic changes to the code that setsSteve Dickson2009-11-031-4/+4
| | | | | | the defaults that were a result of the code review. Signed-off-by: Steve Dickson <steved@redhat.com>
* Added wrappers around the setting of default valuesSteve Dickson2009-10-271-8/+23
| | | | | | | 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-3/+13
| | | | | | | 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-221-1/+1
| | | | | | | | | | | 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>
* mount.nfs: Support "-t nfs,vers=4" mounts in the kernelChuck Lever2009-09-141-5/+9
| | | | | | | | | | | | | | 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>
* errno not be set on RPC errorsSteve Dickson2009-07-151-3/+7
| | | | | | | | | | | | Changed both nfs_advise_umount() and nfs_gp_ping() to set the errno by calling CLNT_GETERR() after a CLNT_CALL() error. Also added code to rpc_strerror() that will log the errno value, when set, via strerror(). These changes added essential information to the error message making it much easier to detect errorsuch as "Connection refused" Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: remove unused @addrlen argument from nfs_string_to_sockaddr()Chuck Lever2009-07-141-3/+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: Remove unused @salen parameter from nfs_ca_gai()Chuck Lever2009-07-141-2/+2
| | | | | | | | | Address compiler warning: network.c:1124: warning: unused parameter salen Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Fix some nfs_error() nits in network.cChuck Lever2009-07-141-3/+4
| | | | | | | Fix a couple of nfs_error() call sites in utils/mount/network.c. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* support: Introduce sockaddr helpers to get and set IP port numbersChuck Lever2009-07-141-15/+0
| | | | | | | | | | Introduce address family-agnostic functions that get and set IP port numbers in socket addresses. We can already replace a few similar functions in the mount command, and a few more will come up with statd and sm-notify. 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-99/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.nfs: force rpcbind queries if options aren't specifiedChuck Lever2009-07-141-7/+11
| | | | | | | | | | | | | | | | | nfs_options2pmap() fills in default values if the passed-in mount options don't specify values. This short-circuits the version, port, and transport negotiation logic in nfs_probe_bothports(). Instead, nfs_options2pmap() should plant zeros in these pmap fields to force nfs_probe_bothports() and nfs_advise_mount() to discover, via rpcbind queries, what the server supports. This fixes some scenarios where umount.nfs fails to connect to servers that don't have all rpcbind ports open, in addition to fixing other corner cases during mount.nfs version/protocol negotiation. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: If port= specifies an unregistered port, retry, then failChuck Lever2009-07-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suppose a port= option is specified on the mount command line, but not enough other mount options are specified to avoid an rpcbind query to discover the NFS service. If the NFS service isn't registered on [100003, 3, "tcp", port] (even if the server is listening on the specified port), the legacy mount.nfs command fails immediately with: mount.nfs: mount to NFS server 'server' failed: RPC Error: Success What's more, this mount request should succeeded if an NFS service is registered on the specified port for another version and/or protocol. So instead, let's retry the rpcbind query with the other versions and transport protocols to be absolutely sure that port won't work with either version or transport. Then, if all fails, report: mount.nfs: mount to NFS server 'server' failed: RPC Error: Program not registered This change also affects text-based mounts that require negotiation by the mount.nfs command. Note that if the mount options specify all four pmap parameters for NFS, the rpcbind query for the NFS service is skipped entirely. The mount command then hangs and times out later if NFS service is not listening on the requested tuple. This is unchanged from previous behavior. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mount.nfs: Add more debugging output around nfs_getport()Chuck Lever2009-07-141-4/+24
| | | | | | | | | So we can see how rpcbind queries are failing during mount processing, add some debugging messages (enabled with "mount.nfs -v") around the nfs_getport() calls. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* getport: Clear shared error fields before trying rpcbind queriesChuck Lever2009-07-141-2/+1
| | | | | | | | | Some RPC errors set fields in rpc_createerr.cf_error in addition to cf_stat. Be sure to clear _all_ error fields in rpc_createerr each time through the rpcbind API. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* umount.nfs: Harden umount.nfs error reportingChuck Lever2009-05-181-5/+14
| | | | | | | | | | Add additional error reporting to nfs_advise_umount(). These messages can be displayed if the "-v" option is specified with umount.nfs. Normally these messages do not appear. 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-66/+22
| | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* 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>
* 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.nfs command: Add an AF_INET6-capable version of nfs_call_unmount()Chuck Lever2009-02-171-0/+53
| | | | | | | | | | | | | | | | | | 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>
* text-based mount command: fix return value from po_rightmost()Chuck Lever2009-02-171-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Function to stuff "struct pmap" from mount optionsChuck Lever2009-01-271-0/+214
| | | | | | | | | 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>
* 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>