summaryrefslogtreecommitdiffstats
path: root/support/nfs/getfh.c
diff options
context:
space:
mode:
authorhjl <hjl>1999-10-18 23:21:12 +0000
committerhjl <hjl>1999-10-18 23:21:12 +0000
commit8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9 (patch)
tree0904ef8554ed680fe3244fa618685e1fb7ea148b /support/nfs/getfh.c
downloadnfs-utils-8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9.tar.gz
nfs-utils-8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9.tar.xz
nfs-utils-8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9.zip
Initial revision
Diffstat (limited to 'support/nfs/getfh.c')
-rw-r--r--support/nfs/getfh.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/support/nfs/getfh.c b/support/nfs/getfh.c
new file mode 100644
index 0000000..5a6f1a4
--- /dev/null
+++ b/support/nfs/getfh.c
@@ -0,0 +1,55 @@
+/*
+ * support/nfs/getfh.c
+ *
+ * Get the FH for a given client and directory. This function takes
+ * the NFS protocol version number as an additional argument.
+ *
+ * This function has nothing in common with the SunOS getfh function,
+ * which is a front-end to the RPC mount call.
+ *
+ * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <sys/types.h>
+#include <errno.h>
+#include "nfslib.h"
+
+struct knfs_fh *
+getfh_old (struct sockaddr *addr, dev_t dev, ino_t ino)
+{
+ static union nfsctl_res res;
+ struct nfsctl_arg arg;
+
+ arg.ca_version = NFSCTL_VERSION;
+ arg.ca_getfh.gf_version = 2; /* obsolete */
+ arg.ca_getfh.gf_dev = dev;
+ arg.ca_getfh.gf_ino = ino;
+ memcpy(&arg.ca_getfh.gf_addr, addr, sizeof(struct sockaddr_in));
+
+ if (nfsctl(NFSCTL_GETFH, &arg, &res) < 0)
+ return NULL;
+
+ return &res.cr_getfh;
+}
+
+struct knfs_fh *
+getfh(struct sockaddr *addr, const char *path)
+{
+ static union nfsctl_res res;
+ struct nfsctl_arg arg;
+
+ arg.ca_version = NFSCTL_VERSION;
+ arg.ca_getfd.gd_version = 2; /* obsolete */
+ strncpy(arg.ca_getfd.gd_path, path,
+ sizeof(arg.ca_getfd.gd_path) - 1);
+ arg.ca_getfd.gd_path[sizeof (arg.ca_getfd.gd_path) - 1] = '\0';
+ memcpy(&arg.ca_getfd.gd_addr, addr, sizeof(struct sockaddr_in));
+
+ if (nfsctl(NFSCTL_GETFD, &arg, &res) < 0)
+ return NULL;
+
+ return &res.cr_getfh;
+}