X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Fgetfh.c;h=81266fd9c2d3a9e83c200d66512078f13d9f09e8;hp=5a6f1a40552e3ddbd4d19f599ff09fba2e97fe32;hb=e8a54a3d5e32c9de009f84d1ef3f26d2dffbf226;hpb=8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9 diff --git a/support/nfs/getfh.c b/support/nfs/getfh.c index 5a6f1a4..81266fd 100644 --- a/support/nfs/getfh.c +++ b/support/nfs/getfh.c @@ -10,18 +10,21 @@ * Copyright (C) 1995, 1996 Olaf Kirch */ -#include "config.h" +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include #include "nfslib.h" -struct knfs_fh * +struct nfs_fh_len * getfh_old (struct sockaddr *addr, dev_t dev, ino_t ino) { - static union nfsctl_res res; + union nfsctl_res res; struct nfsctl_arg arg; + static struct nfs_fh_len rfh; arg.ca_version = NFSCTL_VERSION; arg.ca_getfh.gf_version = 2; /* obsolete */ @@ -32,14 +35,17 @@ getfh_old (struct sockaddr *addr, dev_t dev, ino_t ino) if (nfsctl(NFSCTL_GETFH, &arg, &res) < 0) return NULL; - return &res.cr_getfh; + rfh.fh_size = 32; + memcpy(rfh.fh_handle, &res.cr_getfh, 32); + return &rfh; } -struct knfs_fh * +struct nfs_fh_len * getfh(struct sockaddr *addr, const char *path) { - static union nfsctl_res res; + static union nfsctl_res res; struct nfsctl_arg arg; + static struct nfs_fh_len rfh; arg.ca_version = NFSCTL_VERSION; arg.ca_getfd.gd_version = 2; /* obsolete */ @@ -51,5 +57,26 @@ getfh(struct sockaddr *addr, const char *path) if (nfsctl(NFSCTL_GETFD, &arg, &res) < 0) return NULL; - return &res.cr_getfh; + rfh.fh_size = 32; + memcpy(rfh.fh_handle, &res.cr_getfh, 32); + return &rfh; +} + +struct nfs_fh_len * +getfh_size(struct sockaddr *addr, const char *path, int size) +{ + static union nfsctl_res res; + struct nfsctl_arg arg; + + arg.ca_version = NFSCTL_VERSION; + strncpy(arg.ca_getfs.gd_path, path, + sizeof(arg.ca_getfs.gd_path) - 1); + arg.ca_getfs.gd_path[sizeof (arg.ca_getfs.gd_path) - 1] = '\0'; + memcpy(&arg.ca_getfs.gd_addr, addr, sizeof(struct sockaddr_in)); + arg.ca_getfs.gd_maxlen = size; + + if (nfsctl(NFSCTL_GETFS, &arg, &res) < 0) + return NULL; + + return &res.cr_getfs; }