diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-01-11 19:08:10 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2010-01-12 05:50:04 -0500 |
commit | f16fb1cdc99fb1bd62767b133bec6358e7a793e1 (patch) | |
tree | 26919c031614338516abad735d8f80af0ae687e5 /support/include | |
parent | 917cd9a5532d90745d94045f49ee49d0a7636d6d (diff) | |
download | nfs-utils-f16fb1cdc99fb1bd62767b133bec6358e7a793e1.tar.gz nfs-utils-f16fb1cdc99fb1bd62767b133bec6358e7a793e1.tar.xz nfs-utils-f16fb1cdc99fb1bd62767b133bec6358e7a793e1.zip |
libnsm.a: Introduce common routines to handle persistent storage
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>
Diffstat (limited to 'support/include')
-rw-r--r-- | support/include/Makefile.am | 2 | ||||
-rw-r--r-- | support/include/nsm.h | 64 |
2 files changed, 66 insertions, 0 deletions
diff --git a/support/include/Makefile.am b/support/include/Makefile.am index f5a77ec..4b33ee9 100644 --- a/support/include/Makefile.am +++ b/support/include/Makefile.am @@ -9,6 +9,8 @@ noinst_HEADERS = \ nfs_mntent.h \ nfs_paths.h \ nfslib.h \ + nfsrpc.h \ + nsm.h \ rpcmisc.h \ tcpwrapper.h \ xio.h \ diff --git a/support/include/nsm.h b/support/include/nsm.h new file mode 100644 index 0000000..7554493 --- /dev/null +++ b/support/include/nsm.h @@ -0,0 +1,64 @@ +/* + * Copyright 2009 Oracle. All rights reserved. + * + * This file is part of nfs-utils. + * + * nfs-utils is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * nfs-utils is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * NSM for Linux. + */ + +#ifndef NFS_UTILS_SUPPORT_NSM_H +#define NFS_UTILS_SUPPORT_NSM_H + +#include <sys/types.h> +#include <sys/socket.h> +#include <stdbool.h> + +#include <netdb.h> +#include <time.h> + +#include "sm_inter.h" + +typedef unsigned int + (*nsm_populate_t)(const char *hostname, + const struct sockaddr *sap, + const struct mon *mon, + const time_t timestamp); + +/* file.c */ + +extern _Bool nsm_setup_pathnames(const char *progname, + const char *parentdir); +extern _Bool nsm_is_default_parentdir(void); +extern _Bool nsm_drop_privileges(const int pidfd); + +extern int nsm_get_state(_Bool update); +extern void nsm_update_kernel_state(const int state); + +extern unsigned int + nsm_retire_monitored_hosts(void); +extern unsigned int + nsm_load_monitor_list(nsm_populate_t func); +extern unsigned int + nsm_load_notify_list(nsm_populate_t func); + +extern _Bool nsm_insert_monitored_host(const char *hostname, + const struct sockaddr *sap, const struct mon *m); +extern void nsm_delete_monitored_host(const char *hostname); +extern void nsm_delete_notified_host(const char *hostname); + +#endif /* !NFS_UTILS_SUPPORT_NSM_H */ |