Some more configure checks for headers
[deb_libnfs.git] / lib / libnfs.c
index c07a8e84b60eb7085ec655d789d4eea8badd54ef..c322c377b15d5a858da2e084c0e8aeeb03ee11b8 100644 (file)
 
 #ifdef WIN32
 #include "win32_compat.h"
-#else
-#include <strings.h>
+#endif
+
+#ifdef HAVE_UTIME_H
 #include <utime.h>
-#endif /*WIN32*/
+#endif
 
 #ifdef ANDROID
 #define statvfs statfs
 #include <sys/statvfs.h>
 #endif
 
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -59,7 +68,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <netinet/in.h>
 #include "libnfs-zdr.h"
 #include "libnfs.h"
 #include "libnfs-raw.h"
@@ -660,8 +668,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;
        }
 
@@ -1675,10 +1683,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);
@@ -1731,7 +1739,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;
@@ -1767,7 +1774,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;