+ memset(&rfh, 0, sizeof(rfh));
+ rfh.fh_size = 32;
+ memcpy(rfh.fh_handle, &res.cr_getfh, 32);
+ return &rfh;
+}
+
+/**
+ * getfh_size - ask the kernel for a file handle via nfsctl()
+ * @sin: pointer to IPv4 address of a client
+ * @path: pointer to a '\0'-terminated ASCII string containing an pathname
+ * @size: maximum size, in bytes, of the returned file handle
+ *
+ * Returns a pointer to an NFSv3 file handle, or NULL if some error
+ * occurred. errno is set to reflect the specifics of the error.
+ */
+struct nfs_fh_len *
+getfh_size(const struct sockaddr_in *sin, const char *path, const int size)
+{
+ static union nfsctl_res res;
+ struct nfsctl_arg arg;
+
+ if (sin->sin_family != AF_INET) {
+ errno = EAFNOSUPPORT;
+ return NULL;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ memset(&res, 0, sizeof(res));
+
+ 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, sin, sizeof(*sin));
+ arg.ca_getfs.gd_maxlen = size;
+
+ if (nfsctl(NFSCTL_GETFS, &arg, &res) < 0)
+ return NULL;
+
+ return &res.cr_getfs;