summaryrefslogtreecommitdiffstats
path: root/support/include
Commit message (Collapse)AuthorAgeFilesLines
...
* libnsm.a: Introduce common routines to handle persistent storageChuck Lever2010-01-122-0/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | rpc.statd and sm-notify access the same set of files under /var/lib/nfs/statd, but both have their own code base to handle this. They should share this code. In addition, the on-disk format used by statd and friends is considered a formal interface, so this new code will codify the API and provide documentation for it. The shared code handles switching from the default parent statd directory, reducing privileges at start-up, and managing the NSM state files, in addition to handling normal operations on the monitored host and notification lists on disk. The new code is simply a copy of the same logic that was used in rpc.statd and sm-notify, but wrapped in a nice API. There should be minimal behavioral and no on-disk format changes with the new libnsm.a code. The new code is more careful to check for bad corner cases. Occassionally this code may not allow an operation that was permitted in the past, but hopefully the error reporting has improved enough that it should be easy to track down any problems. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libnfs.a: Provide shared helpers for managing netidsChuck Lever2009-12-111-0/+12
| | | | | | | | Introduce a couple of shared functions that can convert netids to protocol numbers and families, and back. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* statd: Replace note() with xlog() in rpc.statdChuck Lever2009-11-241-4/+0
| | | | | | | | | | | To facilitate code sharing between statd and sm-notify (and with other components of nfs-utils), replace sm-notify's nsm_log() with xlog(). Since opt_quiet is used in only a handful of insignificant cases, it is removed. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Added wrappers around the setting of default valuesSteve Dickson2009-10-271-5/+0
| | | | | | | from the config file which will be compiled out when the config file is not enabled. Signed-off-by: Steve Dickson <steved@redhat.com>
* Introducing the parsing of both 'defaultvers' and 'defaultproto'Steve Dickson2009-10-221-0/+7
| | | | | | | | | | | 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>
* Cleaned up some warnings in the mount config file code.Steve Dickson2009-08-271-0/+1
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* Now that only the Section names are case-insensitiveSteve Dickson2009-08-161-0/+10
| | | | | | | | | 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>
* Added an conditional argument to the Section namesSteve Dickson2009-08-161-1/+1
| | | | | | | | | | | | | | with the format being: [ Section <"argument"> ] This will help group similar functioning Section together. The argument is conditional but must be surrounded by the '"' characters. The new conf_get_section() interface can used to locate a Section by its Section name and/or argument. Signed-off-by: Steve Dickson <steved@redhat.com>
* Move idmapd's configuration file parsing routines intoSteve Dickson2009-08-162-1/+69
| | | | | | | the shared libnfs.a library, making them available to\ other daemons and programs. Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: clean up NFSCTL_* macros for handling protocol bitsJeff Layton2009-08-011-4/+11
| | | | | | | | | | They are a little hard to follow currently. Clean them up and add new macros that can set these bits in addition to the ones that unset them. Also add a new macro that reports when any valid protocol bit is set. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: move nfssvc.c to nfsd dir and clean up linking of nfsdJeff Layton2009-08-011-1/+0
| | | | | | | | | | rpc.nfsd is the only user of nfssvc.c, so we might as well move it out of libnfs.a. Also, don't link in libexport.a and libmisc.a, they aren't needed. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* support: Introduce sockaddr helpers to get and set IP port numbersChuck Lever2009-07-141-0/+10
| | | | | | | | | | 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>
* getport: Clear shared error fields before trying rpcbind queriesChuck Lever2009-07-141-0/+9
| | | | | | | | | 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>
* getport: Remove unneeded @salen argumentsChuck Lever2009-07-141-3/+1
| | | | | | | | Clean up: Now that getnameinfo(3) is no longer used, the @salen argument to nfs_sockaddr2universal() is no longer needed. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* utils/nfsd: add support for minorvers4Benny Halevy2009-05-042-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | minorvers4 can be used to either enable or disable nfsv4.x. If minorvers4 is a positive integer n, in the allowed range (only minorversion 1 is supported for now), the string "+4.n" is appended to the versions string written onto /proc/fs/nfsd/versions. Correspondingly, if minorver4 is a negative integer -n, the string "-4.n" is written. With the default value, minorvers4==0, the minor version setting is not changed. Note that unlike the protocol versions 2, 3, or 4. The minor version setting controls the *maximum* minor version nfsd supports. Particular minor version cannot be controlled on their own. With only minor version 1 supported at the moment the difference doesn't matter, but for future minor versions greater than 1, enabling minor version X will enable support for all minor versions 1 through X. Disabling minor version X will disable support for minor versions X and up, enabling 1 through X-1. Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* support: Provide an API for creating a privileged RPC clientChuck Lever2009-04-181-1/+10
| | | | | | | | | | | | | | We needed to guarantee that some RPC programs, such as PMAP, got an unprivileged port, to prevent exhausting the local privileged port space sending RPC requests that don't need such privileges. nfs_get_rpcclient() provides that feature. However, some RPC programs, such as MNT and UMNT, require a privileged port. So, let's provide an additional API for this that also supports IPv6 and setting a destination port. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Mountd should use separate lockfilesBen Myers2009-04-031-0/+9
| | | | | | | | | | | | | | | | Mountd keeps file descriptors used for locks separate from those used for io and seems to assume that the lock will only be released on close of the file descriptor that was used with fcntl. Actually the lock is released when any file descriptor for that file is closed. When setexportent() is called after xflock() he closes and reopens the io file descriptor and defeats the lock. This patch fixes that by using a separate file for locking, cleaning them up when finished. Signed-off-by: Ben Myers <bpm@sgi.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: Provide type-checked version of svc_getcaller()Chuck Lever2009-03-051-0/+9
| | | | | | | | | | | | | TI-RPC's version of the svc_getcaller() macro points to a sockaddr_in6, not a sockaddr_in, though for AF_INET callers, an AF_INET address resides there. To squelch compiler warnings when the TI-RPC version of the svc_req structure is used, add inline helpers with appropriate type casting. Note that tcp_wrappers support only AF_INET addresses for now. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: Replace getservbyname(3)Chuck Lever2009-03-051-6/+0
| | | | | | | | | The getservbyname(3) function is not re-entrant, and anyway, the man page says it is obsolete. Replace it with a call to getaddrinfo(3). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Exportfs and rpc.mountd optimalizationTomas Richter2009-02-181-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | There were some problems with exportfs and rpc.mountd for long export lists - see https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=76643 I do optimalization as my bachelors thesis (Facuulty of informatics, Masaryk's university Brno, Czech Republic), under lead of Yenya Kasprzak. Both exportfs and rpc.mount build linked list of exports (shared functions in export.c). Every time they are inserting new export into list, they search for same export in list. I replaced linked list by hash table and functions export_add and export_lookup by functions hash_export_add and hash_export_lookup (export.c). Because some other functions required exportlist as linked list, hash table has some implementation modification im comparison with ordinary hash table. It also keeps exports in linked list and has pointer to head of the list. So there's no need of implementation function <for_all_in_hash_table>. Signed-off-by: Tomas Richter <krik3t@gmail.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Introduce rpcbind client utility functionsChuck Lever2008-11-171-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that at least the mount command and the showmount command need to query a server's rpcbind daemon. They need to query over AF_INET6 as well as AF_INET. libtirpc provides an rpcbind query capability with the rpcb_getaddr(3) interface, but it takes a hostname and netconfig entry rather than a sockaddr and a protocol type, and always uses a lengthy timeout. The former is important to the mount command because it sometimes must operate using a specific port and IP address rather than depending on rpcbind and DNS to convert a [hostname, RPC program, netconfig] tuple to a [socket address, port number, transport protocol] tuple. The rpcb_getaddr(3) API also always uses a privileged port (at least for setuid root executables like mount.nfs), which is not required for an rpcbind query. This can exhaust the local system's reserved port space quickly. This patch provides a reserved-port-friendly AF_INET6-capable rpcbind query C API that can be shared among commands and tools in nfs-utils, and allows a query to a specified socket address and port rather than a hostname. In addition to an rpcbind query interface, this patch also provides a facility to ping the remote RPC service to ensure that it is operating as advertised by rpcbind. It's useful to combine an RPC ping with an rpcbind query because in many cases, components of nfs-utils already ping an RPC service immediately after receiving a successful GETPORT result. There are also a handful of utility routines provided, such as a functions that can map between [sockaddr, port] and a universal address. I've made an attempt to make these new functions build and operate on systems that do not have libtirpc. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add AF_INET6-capable API to acquire an RPC CLIENT *Chuck Lever2008-11-171-0/+70
| | | | | | | | | | | | Provide a simple interface that any component of nfs-utils can use to acquire an RPC CLIENT *. This is an AF_INET6-enabled API, and can also handle PF_LOCAL sockets if libtirpc is present on the system. When libtirpc is not available, legacy RPC services will be used instead, and an attempt to connect to an AF_INET6 address will fail. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: make makesock() staticChuck Lever2008-09-261-1/+0
| | | | | | | | | | | | | | | | | | Clean up: The makesock() function can become static since it is only used in rpcmisc.c, where it is defined. Fix some minor nits while we're in the area: o Move it so we can remove it's forward declaration. o Get rid of unneeded newlines in the xlog() format strings. o Use htonl(INADDR_ANY) instead of INADDR_ANY to initialize sin_addr. Should make no run-time difference, but is slightly more proper, as the standard definition of INADDR_ANY is in host byte-order. o Remove the parentheses in the "return" statements. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: Remove unused function rpc_svcrun()Chuck Lever2008-09-261-1/+0
| | | | | | | | Clean up: remove function that has been disabled (via #if 0) for almost a decade. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: remove unused function rpc_logcall()Chuck Lever2008-09-261-1/+0
| | | | | | | Clean up: Eliminate rpc_logcall(), which has no callers. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Remove redundant m_path fieldJ. Bruce Fields2008-08-281-5/+0
| | | | | | | | | | | | | | | | | Contrary to the comment above its definition, the field m_path always has the same value as e_path: the *only* modifications of m_path are all of the form: strncpy(exp->m_export.m_path, exp->m_export.e_path, sizeof (exp->m_export.m_path) - 1); exp->m_export.m_path[sizeof (exp->m_export.m_path) - 1] = '\0'; So m_path is always just a copy of e_path. In places where we need to store a path to a submount of a CROSSMNT-exported filesystem, as in cache.c, we just use a local variable. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Steve Dickson <steved@redhat.com>
* Cleanup xlog logging code to be safe and usable for allKevin Coffman2007-10-151-0/+5
| | | | | | | | | | | | | | | This patch reworks the xlog logging code to avoid rebuilding the message into a fixed size buffer. It also adds two new logging functions xlog_warn and xlog_err which are replacements for idmap_warn and idmap_err. There use to be two different variates of these functions with the only difference being that one flavor tacked on the error string to the end of the message. This responsibility has been pushed to the called of the function since it needlessly complicated the function and required us to rebuild the message strings. Signed-off-by: David P. Quigley <dpquigl@tycho.nsa.gov> Signed-off-by: Kevin Coffman <kwc@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
* Copy new cacheio functions used by svcgssd to nfslibKevin Coffman2007-10-151-0/+5
| | | | | | | | | | Copy private qword_ functions from the svcgssd version into the general nfslib library. Add prototypes as needed. Also, update readline to use a bigger buffer allocation as is needed in the svcgssd version. Signed-off-by: Kevin Coffman <kwc@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
* rpc.mountd: create client_resolve and change client_compose to take a ↵Jeff Layton2007-09-281-1/+2
| | | | | | | | | | | | | | hostent arg This moves the resolution of IP address to hostent into a helper function and has other functions call it. Having client_compose take a hostent arg allows us to avoid an extra hostname lookup in the auth_authenticate codepath as well. Instead of redoing this lookup in client_compose, we can simply reuse the hostent that was already generated in auth_authenticate. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
* rpc.mountd: make exportent->e_hostname a dynamically-allocated stringJeff Layton2007-09-281-1/+1
| | | | | | | | | | | | This makes the e_hostname field of the exportent into a pointer to a dynamically allocated string. This is necessary since this is field is often filled out from the m_hostname. This too adds a few micro-optimizations as we can avoid copying the string in some places and simply pass a pointer to the original string instead. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
* rpc.mountd: Change nfs_client->m_hostname to be a dynamically-allocated stringJeff Layton2007-09-281-1/+1
| | | | | | | | | | | Change nfs_client->m_hostname to be dynamically allocated rather than a fixed length array of size NFSCLNT_IDMAX. This also adds a bit of micro-optimization in a few places since it reduces the amount of string copying that needs to be done. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
* mount.nfs: add EX_SUCCESS exit codeChuck Lever2007-09-251-0/+1
| | | | | | | | | | | | We've had some recent trouble, especially in the umount code, that appears to be due to functions returning a 1 or a 0 return code when they should be returning a mount exit code (such as EX_FAIL) or a 0. To help clearly distinguish these two classes of functions, define an EX_SUCCESS exit code, which is equal to zero. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* libnfs.a: eliminate another dependency on a global variableChuck Lever2007-07-302-31/+0
| | | | | | | | | | | | | | The file support/nfs/fstab.c, which is linked into libnfs.a, depends on the global variable "verbose." This variable is defined and used only in the mount command, and the functions in fstab.c are used only by the mount command. Move fstab.c and support/include/fstab.h to utils/mount. This file placement is also consistent with at least one other mount helper, mount.ocfs2. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* libnfs.a: eliminate conn.c and conn.hChuck Lever2007-07-302-33/+0
| | | | | | | conn.[ch] are now no longer needed. Clean them out and delete them. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* libnfs.a: move get_socket() function to utils/mount/network.cChuck Lever2007-07-301-2/+0
| | | | | | | | | | Now we can address the real problem: that get_socket() depends on the global variable "verbose" which is only available in the mount command. Move get_socket() into utils/mount/network.c, and make it static. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* libnfs.a: move clnt_ping() to utils/mountChuck Lever2007-07-301-2/+0
| | | | | | | | | | Continue clean up of mount functionality in libnfs.a by moving clnt_ping() to utils/mount/network.c. Note that socklen_t is an unsigned int... the i386 gcc compiler threw a signedness warning about the 3rd argument of getsockname(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* libnfs.a: move more mount-only functions out of libnfs.aChuck Lever2007-07-301-2/+0
| | | | | | | Continue clean-up with nfsvers_to_mnt() and mntvers_to_nfs(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* libnfs.a: move mnt_{open, close}clnt calls to utils/mount/network.cChuck Lever2007-07-301-5/+0
| | | | | | | | | | | | | | | | | It turns out that get_socket() accesses a global variable, "verbose," that is only available in the mount command; yet it's in libnfs.a. This creates an undocumented API dependency that will bite someone someday. This mount-specific functionality doesn't really belong in libnfs.a anyway. The simplest way to resolve this is to move all of the functions in support/nfs/conn.c into utils/mount. network.c seems like the logical place to put these. An added benefit is we eventually get to make get_socket() static. Let's start with the mnt_{open,close}clnt functions. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* fix broken compile due to missing pseudoflavors.hJ. Bruce Fields2007-07-211-0/+17
| | | | | | | | Commit e9b0bed761bc77ba046f53be2ec324c4b61357ff should also have added this file. Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
* rpcdebug: Update 'rpcdebug' tool with recently added debugging flagsChuck Lever2007-07-201-1/+3
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* Support sec= option to specify export securityJ. Bruce Fields2007-07-101-0/+10
| | | | | | | | | | | This adds support for reading sec= option and sending security data through cache via "... secinfo n flavor1 flag1 ... flavorN flagN". If sec= is missing, no secinfo option will be passed down. Signed-off-by: Fred Isaman <iisaman@citi.umich.edu> Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
* Make warning about host matching multiple exports more helpful.Neil Brown2007-03-191-1/+3
| | | | | 1/ only warn once per export, as it could get too noisy. 2/ make it a little clearer why this might be a problem.
* Remove nfs_mntent_t in favour of struct mntentNeil Brown2007-03-162-13/+5
| | | | They are identical and the later allows us to use hasmntent.
* Correctly handle "user" and "users" mount options.Neil Brown2007-03-161-0/+7
| | | | | | | | | | | | If "user" or "users" is given, then allow mount.nfs to be run by a non-root user providing that the mountpoint, filesystem, and options exactly match what is found in fstab. For "user", record the user name in mtab so they can unmount the filesystem later. Also alwasys ignore auto, owner, group and their negations as well as "_netdev", "comment" and "loop".
* Make mtab_head staticNeil Brown2007-03-161-1/+0
| | | | It is only used in one place.
* Remove "maptype" supportJ. Bruce Fields2007-03-151-7/+0
| | | | | | | | It appears that this is used only by unfsd, and is obscure enough that we should be able to just rip it out with no special precautions. Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
* Restore use of un-connected socket for UDP mount requests.Neil Brown2007-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | When connecting to an NFSv4 server we need to find out IP address as it would be seen by the server, to register an address for callbacks. This is most easily done by connecting the socket to the servers address and then getting the address of our endpoint. However with a connected UDP socket, replies that come from a different IP address - as can happen with non-Linux multi-homed servers - will be rejected. So if we connected our UDP socket, we need to be sure to disconnect it before using it. This patch adds an option to get_socket to say if we want it connected or not and, in the case where we do, we disconnect a UDP socket after the connection information has been used. Also clean up the error handling in clnt_ping which was getting clumsy.
* Remove rpc.lockdNeil Brown2007-02-222-7/+0
| | | | | | This was only needed for kernels 2.2.14 through 2.2.17. These have long since been superceded, so remove some dead weight.
* Extend the exportfs interface to pass fslocations info into the kernel.Fred Isaman2007-02-222-0/+9
| | | | | | | | | | Extend exportfs interface to pass fslocations info into the kernel, using syntax modelled after AIX. Adds "refer=" and "replicas=" options to /etc/exports to enable use of the kernel fslocation code. Signed-off-by: Fred Isaman <iisaman@citi.umich.edu> Signed-off-by: Kevin Coffman <kwc@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
* Use UUIDs to identify filesystems if kernel supports it.Neil Brown2007-02-121-0/+1
| | | | | | | | | | | This introduces a new dependancy on libblkid. If a filesystem being exported has a UUID that libblkid can extract, then that is passed to the kernel for use in identifying the filesystem in filehandles. This means that 'fsid=' is no longer needed to work around the problem of device numbers changing. fsid= is still needed for fielsystems that have no device, and can now be given 16byute uuid instead of just a 32bit one.