X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lib%2Flibnfs-sync.c;h=8ab05d71d1501fe0c388d2ede5513d25f31a7332;hb=1d95217b2f68772857bf7cffc4f1a655e43e80fb;hp=836e1354eaef5683a75c3cdde991390d1e3a0834;hpb=7057e733c1465661c410b65d90e4c5d0939f1617;p=deb_libnfs.git diff --git a/lib/libnfs-sync.c b/lib/libnfs-sync.c index 836e135..8ab05d7 100644 --- a/lib/libnfs-sync.c +++ b/lib/libnfs-sync.c @@ -27,11 +27,11 @@ #ifdef WIN32 #include "win32_compat.h" -#else -#include -#include +#endif + +#ifdef HAVE_NET_IF_H #include -#endif /*WIN32*/ +#endif #ifdef ANDROID #define statvfs statfs @@ -57,6 +57,10 @@ #include #endif +#ifdef HAVE_NETDB_H +#include +#endif + #ifdef HAVE_UNISTD_H #include #endif @@ -65,6 +69,10 @@ #include #endif +#ifdef HAVE_STRINGS_H +#include +#endif + #include #include #include @@ -200,11 +208,18 @@ static void stat_cb(int status, struct nfs_context *nfs, void *data, void *priva nfs_set_error(nfs, "stat call failed with \"%s\"", (char *)data); return; } - - memcpy(cb_data->return_data, data, sizeof(struct stat)); +#ifdef WIN32 + memcpy(cb_data->return_data, data, sizeof(struct __stat64)); +#else + memcpy(cb_data->return_data, data, sizeof(struct stat)); +#endif } +#ifdef WIN32 +int nfs_stat(struct nfs_context *nfs, const char *path, struct __stat64 *st) +#else int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st) +#endif { struct sync_cb_data cb_data; @@ -222,8 +237,6 @@ int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st) } - - /* * open() */ @@ -262,6 +275,38 @@ int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh * return cb_data.status; } +/* + * chdir() + */ +static void chdir_cb(int status, struct nfs_context *nfs, void *data, void *private_data) +{ + struct sync_cb_data *cb_data = private_data; + + cb_data->is_finished = 1; + cb_data->status = status; + + if (status < 0) { + nfs_set_error(nfs, "chdir call failed with \"%s\"", (char *)data); + return; + } +} + +int nfs_chdir(struct nfs_context *nfs, const char *path) +{ + struct sync_cb_data cb_data; + + cb_data.is_finished = 0; + + if (nfs_chdir_async(nfs, path, chdir_cb, &cb_data) != 0) { + nfs_set_error(nfs, "nfs_chdir_async failed with %s", + nfs_get_error(nfs)); + return -1; + } + + wait_for_nfs_reply(nfs, &cb_data); + + return cb_data.status; +}