From: Ronnie Sahlberg Date: Sun, 19 Jun 2011 00:28:25 +0000 (+1000) Subject: Add example for how to call MOUNT/EXPORT and get the exports list using the raw lowle... X-Git-Tag: upstream/1.9.6^2~397 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=440a7dfced274c078b61fdb87301d26a4177fc70;p=deb_libnfs.git Add example for how to call MOUNT/EXPORT and get the exports list using the raw lowlevel api. --- diff --git a/examples/nfsclient-raw.c b/examples/nfsclient-raw.c index 40be303..18b7ae5 100644 --- a/examples/nfsclient-raw.c +++ b/examples/nfsclient-raw.c @@ -44,7 +44,7 @@ struct client { void rquota_getquota_cb(struct rpc_context *rpc _U_, int status, void *data, void *private_data) { struct client *client = private_data; - GETQUOTA1res *res = data; +// GETQUOTA1res *res = data; if (status == RPC_STATUS_ERROR) { printf("rquota/getquota call failed with \"%s\"\n", (char *)data); @@ -158,9 +158,11 @@ void mount_mnt_cb(struct rpc_context *rpc, int status, void *data, void *private } -void mount_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data) + +void mount_export_cb(struct rpc_context *rpc, int status, void *data, void *private_data) { struct client *client = private_data; + exports export = *(exports *)data; if (status == RPC_STATUS_ERROR) { printf("mount null call failed with \"%s\"\n", (char *)data); @@ -171,7 +173,11 @@ void mount_null_cb(struct rpc_context *rpc, int status, void *data, void *privat exit(10); } - printf("Got reply from server for MOUNT/NULL procedure.\n"); + printf("Got reply from server for MOUNT/EXPORT procedure.\n"); + while (export != NULL) { + printf("Export: %s\n", export->ex_dir); + export = export->ex_next; + } printf("Send MOUNT/MNT command for %s\n", client->export); if (rpc_mount_mnt_async(rpc, mount_mnt_cb, client->export, client) != 0) { printf("Failed to send mnt request\n"); @@ -179,6 +185,27 @@ void mount_null_cb(struct rpc_context *rpc, int status, void *data, void *privat } } +void mount_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data) +{ + struct client *client = private_data; + + if (status == RPC_STATUS_ERROR) { + printf("mount null call failed with \"%s\"\n", (char *)data); + exit(10); + } + if (status != RPC_STATUS_SUCCESS) { + printf("mount null call to server %s failed, status:%d\n", client->server, status); + exit(10); + } + + printf("Got reply from server for MOUNT/NULL procedure.\n"); + printf("Send MOUNT/EXPORT command\n"); + if (rpc_mount_export_async(rpc, mount_export_cb, client) != 0) { + printf("Failed to send export request\n"); + exit(10); + } +} + void mount_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data) { struct client *client = private_data; @@ -247,7 +274,7 @@ void pmap_getport1_cb(struct rpc_context *rpc, int status, void *data, void *pri printf("GETPORT returned RPC.RQUOTAD on port:%d\n", client->rquota_port); if (client->rquota_port == 0) { printf("RPC.RQUOTAD is not available on server : %s:%d\n", client->server, client->rquota_port); - exit(10); +// exit(10); } printf("Send getport request asking for MOUNT port\n");