* -errno : An error occured.
* data is the error string.
*/
+/* This function is deprecated. Use nfs_fstat64_async() instead */
EXTERN int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
/*
* Sync fstat(nfsfh *)
EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
#endif
+/* nfs_fstat64
+ * 64 bit version of fstat. All fields are always 64bit.
+ * Use these functions instead of nfs_fstat[_async](), especially if you
+ * have weird stat structures.
+ */
+/*
+ * FSTAT()
+ */
+/*
+ * Async fstat(nfsfh *)
+ * Function returns
+ * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
+ * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
+ *
+ * When the callback is invoked, status indicates the result:
+ * 0 : Success.
+ * data is struct stat *
+ * -errno : An error occured.
+ * data is the error string.
+ */
+EXTERN int nfs_fstat64_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
+/*
+ * Sync fstat(nfsfh *)
+ * Function returns
+ * 0 : The operation was successfull.
+ * -errno : The command failed.
+ */
+EXTERN int nfs_fstat64(struct nfs_context *nfs, struct nfsfh *nfsfh, struct nfs_stat_64 *st);
+
/*
return cb_data.status;
}
+/*
+ * fstat64()
+ */
+int nfs_fstat64(struct nfs_context *nfs, struct nfsfh *nfsfh, struct nfs_stat_64 *st)
+{
+ struct sync_cb_data cb_data;
+
+ cb_data.is_finished = 0;
+ cb_data.return_data = st;
+
+ if (nfs_fstat64_async(nfs, nfsfh, stat64_cb, &cb_data) != 0) {
+ nfs_set_error(nfs, "nfs_fstat64_async failed");
+ return -1;
+ }
+
+ wait_for_nfs_reply(nfs, &cb_data);
+
+ return cb_data.status;
+}
+
/*
* pwrite()
return 0;
}
+/*
+ * Async fstat64()
+ */
+int nfs_fstat64_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data)
+{
+ struct nfs_cb_data *data;
+ struct GETATTR3args args;
+
+ data = malloc(sizeof(struct nfs_cb_data));
+ if (data == NULL) {
+ rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_cb_data structure");
+ return -1;
+ }
+ memset(data, 0, sizeof(struct nfs_cb_data));
+ data->nfs = nfs;
+ data->cb = cb;
+ data->private_data = private_data;
+
+ memset(&args, 0, sizeof(GETATTR3args));
+ args.object = nfsfh->fh;
+
+ if (rpc_nfs3_getattr_async(nfs->rpc, nfs_stat64_1_cb, &args, data) != 0) {
+ rpc_set_error(nfs->rpc, "RPC error: Failed to send STAT GETATTR call for %s", data->path);
+ data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data);
+ free_nfs_cb_data(data);
+ return -1;
+ }
+ return 0;
+}
+
/*