Win32 changes, include files we need when compiling under win32
[deb_libnfs.git] / include / libnfs.h
index 2debb8b7660e9a6130e1b50bd920c47a9081e478..2038d8a0a335800217dba3b080f594e94c12464e 100644 (file)
 #include <stdint.h>
 
 struct nfs_context;
+struct rpc_context;
+
+#if defined(WIN32)
+struct statvfs {
+       uint32_t        f_bsize;
+       uint32_t        f_frsize;
+       uint64_t        f_blocks;
+       uint64_t        f_bfree;
+       uint64_t        f_bavail;
+       uint32_t        f_files;
+       uint32_t        f_ffree;
+       uint32_t        f_favail;
+       uint32_t        f_fsid; 
+       uint32_t        f_flag;
+       uint32_t        f_namemax;
+};
+struct utimbuf {
+       time_t actime;
+       time_t modtime;
+};
+#define R_OK   4
+#define W_OK   2
+#define X_OK   1
+#endif
 
 /*
  * Used for interfacing the async version of the api into an external eventsystem
@@ -46,6 +70,10 @@ char *nfs_get_error(struct nfs_context *nfs);
  */
 typedef void (*nfs_cb)(int err, struct nfs_context *nfs, void *data, void *private_data);
 
+/*
+ * Callback for all ASYNC rpc functions
+ */
+typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *private_data);
 
 
 
@@ -67,6 +95,16 @@ void nfs_destroy_context(struct nfs_context *nfs);
 
 struct nfsfh;
 
+/*
+ * Get the maximum supported READ3 size by the server
+ */
+size_t nfs_get_readmax(struct nfs_context *nfs);
+
+/*
+ * Get the maximum supported WRITE3 size by the server
+ */
+size_t nfs_get_writemax(struct nfs_context *nfs);
+
 
 /*
  * MOUNT THE EXPORT
@@ -83,14 +121,14 @@ struct nfsfh;
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *export, nfs_cb cb, void *private_data);
+int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data);
 /*
  * Sync nfs mount.
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_mount_sync(struct nfs_context *nfs, const char *server, const char *export);
+int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname);
 
 
 
@@ -118,7 +156,7 @@ int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *p
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_stat_sync(struct nfs_context *nfs, const char *path, struct stat *st);
+int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st);
 
 
 /*
@@ -143,7 +181,7 @@ int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, voi
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_fstat_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
+int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
 
 
 
@@ -173,7 +211,7 @@ int nfs_open_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb c
  *      0 : The operation was successfull. *nfsfh is filled in.
  * -errno : The command failed.
  */
-int nfs_open_sync(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
+int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
 
 
 
@@ -201,7 +239,7 @@ int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, voi
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_close_sync(struct nfs_context *nfs, struct nfsfh *nfsfh);
+int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh);
 
 
 /*
@@ -228,7 +266,7 @@ int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset,
  *    >=0 : numer of bytes read.
  * -errno : An error occured.
  */
-int nfs_pread_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
+int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
 
 
 
@@ -256,7 +294,7 @@ int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, n
  *    >=0 : numer of bytes read.
  * -errno : An error occured.
  */
-int nfs_read_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
+int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
 
 
 
@@ -284,7 +322,7 @@ int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset,
  *    >=0 : numer of bytes written.
  * -errno : An error occured.
  */
-int nfs_pwrite_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
+int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
 
 
 /*
@@ -310,7 +348,7 @@ int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count,
  *    >=0 : numer of bytes written.
  * -errno : An error occured.
  */
-int nfs_write_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
+int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
 
 
 /*
@@ -336,7 +374,7 @@ int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset,
  *    >=0 : numer of bytes read.
  * -errno : An error occured.
  */
-int nfs_lseek_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, off_t *current_offset);
+int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, off_t *current_offset);
 
 
 /*
@@ -361,7 +399,7 @@ int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, voi
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_fsync_sync(struct nfs_context *nfs, struct nfsfh *nfsfh);
+int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh);
 
 
 
@@ -387,7 +425,7 @@ int nfs_truncate_async(struct nfs_context *nfs, const char *path, off_t length,
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_truncate_sync(struct nfs_context *nfs, const char *path, off_t length);
+int nfs_truncate(struct nfs_context *nfs, const char *path, off_t length);
 
 
 
@@ -413,7 +451,7 @@ int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t leng
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_ftruncate_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length);
+int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length);
 
 
 
@@ -442,7 +480,7 @@ int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_mkdir_sync(struct nfs_context *nfs, const char *path);
+int nfs_mkdir(struct nfs_context *nfs, const char *path);
 
 
 
@@ -468,7 +506,7 @@ int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_rmdir_sync(struct nfs_context *nfs, const char *path);
+int nfs_rmdir(struct nfs_context *nfs, const char *path);
 
 
 
@@ -496,7 +534,7 @@ int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_creat_sync(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
+int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
 
 
 
@@ -525,7 +563,7 @@ int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_unlink_sync(struct nfs_context *nfs, const char *path);
+int nfs_unlink(struct nfs_context *nfs, const char *path);
 
 
 
@@ -556,7 +594,7 @@ int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_opendir_sync(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
+int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
 
 
 
@@ -608,7 +646,7 @@ int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_statvfs_sync(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
+int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
 
 
 /*
@@ -635,7 +673,7 @@ int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, voi
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_readlink_sync(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
+int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
 
 
 
@@ -661,7 +699,7 @@ int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_chmod_sync(struct nfs_context *nfs, const char *path, int mode);
+int nfs_chmod(struct nfs_context *nfs, const char *path, int mode);
 
 
 
@@ -687,7 +725,7 @@ int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_fchmod_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
+int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
 
 
 
@@ -713,7 +751,7 @@ int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid,
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_chown_sync(struct nfs_context *nfs, const char *path, int uid, int gid);
+int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid);
 
 
 
@@ -739,7 +777,7 @@ int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_fchown_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
+int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
 
 
 
@@ -766,7 +804,7 @@ int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_utimes_sync(struct nfs_context *nfs, const char *path, struct timeval *times);
+int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times);
 
 
 /*
@@ -792,7 +830,7 @@ int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *t
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_utime_sync(struct nfs_context *nfs, const char *path, struct utimbuf *times);
+int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times);
 
 
 
@@ -819,7 +857,7 @@ int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_access_sync(struct nfs_context *nfs, const char *path, int mode);
+int nfs_access(struct nfs_context *nfs, const char *path, int mode);
 
 
 
@@ -846,7 +884,7 @@ int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_symlink_sync(struct nfs_context *nfs, const char *oldpath, const char *newpath);
+int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath);
 
 
 /*
@@ -871,7 +909,7 @@ int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *n
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_rename_sync(struct nfs_context *nfs, const char *oldpath, const char *newpath);
+int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath);
 
 
 
@@ -897,9 +935,67 @@ int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *new
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_link_sync(struct nfs_context *nfs, const char *oldpath, const char *newpath);
+int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath);
 
 
+/*
+ * GETEXPORTS()
+ */
+/*
+ * Async getexports()
+ * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
+ * returned structures.
+ *
+ * This function will return the list of exports from an NFS server.
+ *
+ * Function returns
+ *  0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
+ * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
+ *
+ * When the callback is invoked, status indicates the result:
+ *      0 : Success.
+ *          data is a pointer to an exports pointer:
+ *          exports export = *(exports *)data;
+ * -errno : An error occured.
+ *          data is the error string.
+ */
+int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data);
+/*
+ * Sync getexports(<server>)
+ * Function returns
+ *            NULL : something failed
+ *  exports export : a linked list of exported directories
+ * 
+ * returned data must be freed by calling mount_free_export_list(exportnode);
+ */
+struct exportnode *mount_getexports(const char *server);
+
+void mount_free_export_list(struct exportnode *exports);
+
 
 //qqq replace later with lseek(cur, 0)
 off_t nfs_get_current_offset(struct nfsfh *nfsfh);
+
+
+
+
+
+struct nfs_server_list {
+       struct nfs_server_list *next;
+       char *addr;
+};
+
+/*
+ * Sync find_local_servers(<server>)
+ * This function will probe all local networks for NFS server. This function will
+ * block for one second while awaiting for all nfs servers to respond.
+ *
+ * Function returns
+ * NULL : something failed
+ *
+ * struct nfs_server_list : a linked list of all discovered servers
+ * 
+ * returned data must be freed by nfs_free_srvr_list(srv);
+ */
+struct nfs_server_list *nfs_find_local_servers(void);
+void free_nfs_srvr_list(struct nfs_server_list *srv);