X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibnfs.c;h=543b0ce9ec89a7293e129213e7158c6d150ded77;hb=728970051cb7420c08c3c4860f09f971880e3244;hp=c3df1df813dd8fa13e42c41cec90b2c14d8e3535;hpb=00748f36c57324ccc2cb21ac9af45d15821cf675;p=deb_libnfs.git diff --git a/lib/libnfs.c b/lib/libnfs.c index c3df1df..543b0ce 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -21,31 +21,39 @@ #include "config.h" #endif -#ifdef HAVE_UNISTD_H -#include +#ifdef AROS +#include "aros_compat.h" #endif #ifdef WIN32 #include "win32_compat.h" #else - #include #include +#endif /*WIN32*/ -#ifdef AROS -#include "aros_compat.h" -#else #ifdef ANDROID -#include #define statvfs statfs -#else -#include -#endif /*ANDROID*/ -#endif /*AROS*/ -#endif /*WIN32*/ +#endif #define _GNU_SOURCE +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_SYS_VFS_H +#include +#endif + +#ifdef HAVE_SYS_STATVFS_H +#include +#endif + +#ifdef HAVE_NETINET_IN_H +#include +#endif + #include #include #include @@ -55,7 +63,6 @@ #include #include #include -#include #include "libnfs-zdr.h" #include "libnfs.h" #include "libnfs-raw.h" @@ -656,8 +663,8 @@ static int nfs_lookuppath_async(struct nfs_context *nfs, const char *path, nfs_c { struct nfs_cb_data *data; - if (path[0] != '/') { - rpc_set_error(nfs->rpc, "Pathname is not absulute %s", path); + if (path[0] != 0 && path[0] != '/') { + rpc_set_error(nfs->rpc, "Pathname is not absolute %s", path); return -1; } @@ -1671,10 +1678,10 @@ static void nfs_create_2_cb(struct rpc_context *rpc, int status, void *command_d } memset(nfsfh, 0, sizeof(struct nfsfh)); - /* steal the filehandle */ - nfsfh->fh.data.data_len = data->fh.data.data_len; - nfsfh->fh.data.data_val = data->fh.data.data_val; - data->fh.data.data_val = NULL; + /* copy the filehandle */ + nfsfh->fh.data.data_len = res->LOOKUP3res_u.resok.object.data.data_len; + nfsfh->fh.data.data_val = malloc(nfsfh->fh.data.data_len); + memcpy(nfsfh->fh.data.data_val, res->LOOKUP3res_u.resok.object.data.data_val, nfsfh->fh.data.data_len); data->cb(0, nfs, nfsfh, data->private_data); free_nfs_cb_data(data); @@ -1727,7 +1734,6 @@ static int nfs_creat_continue_internal(struct nfs_context *nfs, struct nfs_cb_da str = &str[strlen(str) + 1]; - memset(&args, 0, sizeof(CREATE3args)); args.where.dir.data.data_len = data->fh.data.data_len; args.where.dir.data.data_val = data->fh.data.data_val; @@ -1763,7 +1769,7 @@ int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb } *ptr = 0; - /* new_path now points to the parent directory, and beyond the nul terminateor is the new directory to create */ + /* new_path now points to the parent directory, and beyond the nul terminator is the new directory to create */ if (nfs_lookuppath_async(nfs, new_path, cb, private_data, nfs_creat_continue_internal, new_path, free, mode) != 0) { rpc_set_error(nfs->rpc, "Out of memory: failed to start parsing the path components"); return -1;