X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Fnfsclient-sync.c;h=aeb3eedf4b6ecca8082a51d70234bca67175321e;hb=763cd6e3e2bbb6906186e7ed6a86660276b596b7;hp=00e4c88042eba4a3e50553acb8e79460eb11c03d;hpb=4ed97718b3699a76047741b9c21df7357d8fe513;p=deb_libnfs.git diff --git a/examples/nfsclient-sync.c b/examples/nfsclient-sync.c index 00e4c88..aeb3eed 100644 --- a/examples/nfsclient-sync.c +++ b/examples/nfsclient-sync.c @@ -17,7 +17,14 @@ /* Example program using the highlevel sync interface */ - +#ifdef WIN32 +#include "win32_compat.h" +#else +#include +#include +#include +#endif + #define SERVER "10.1.1.27" #define EXPORT "/VIRTUAL" #define NFSFILE "/BOOKS/Classics/Dracula.djvu.truncated" @@ -28,8 +35,6 @@ #define _GNU_SOURCE #if defined(WIN32) -#include -typedef int off_t; #pragma comment(lib, "ws2_32.lib") WSADATA wsaData; #else @@ -43,8 +48,8 @@ WSADATA wsaData; #include #include #include +#include "libnfs-zdr.h" #include "libnfs.h" -#include /* for authunix_create() */ #include "libnfs-raw.h" #include "libnfs-raw-mount.h" @@ -56,13 +61,28 @@ struct client { }; +void PrintServerList() +{ + struct nfs_server_list *srvrs; + struct nfs_server_list *srv; + + srvrs = nfs_find_local_servers(); + + for (srv=srvrs; srv; srv = srv->next) + { + printf("Found nfs server: %s\n", srv->addr); + + } + free_nfs_srvr_list(srvrs); +} + char buf[3*1024*1024+337]; int main(int argc _U_, char *argv[] _U_) { struct nfs_context *nfs; int i, ret; - off_t offset; + uint64_t offset; struct client client; struct stat st; struct nfsfh *nfsfh; @@ -81,6 +101,9 @@ int main(int argc _U_, char *argv[] _U_) client.server = SERVER; client.export = EXPORT; client.is_finished = 0; + + PrintServerList(); + export = mount_getexports(SERVER); if (export != NULL) { printf("exports on server %s\n", SERVER); @@ -216,7 +239,7 @@ int main(int argc _U_, char *argv[] _U_) while((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) { char filename[1024]; printf("Inode:%d Name:%s ", (int)nfsdirent->inode, nfsdirent->name); - sprintf(&filename, "%s/%s", NFSDIR, nfsdirent->name); + sprintf(filename, "%s/%s", NFSDIR, nfsdirent->name); ret = nfs_open(nfs, filename, O_RDONLY, &nfsfh); if (ret != 0) { printf("Failed to open(%s) %s\n", filename, nfs_get_error(nfs)); @@ -225,7 +248,6 @@ int main(int argc _U_, char *argv[] _U_) ret = nfs_read(nfs, nfsfh, sizeof(buf), buf); if (ret < 0) { printf("Error reading file\n"); - exit(10); } printf("Read %d bytes\n", ret); ret = nfs_close(nfs, nfsfh);