and some socket ops are slightly different
#define NFSDIR "/BOOKS/Classics/"
#define _GNU_SOURCE
#define NFSDIR "/BOOKS/Classics/"
#define _GNU_SOURCE
+
+#if defined(WIN32)
+#include <winsock2.h>
+typedef int off_t;
+#pragma comment(lib, "ws2_32.lib")
+WSADATA wsaData;
+#else
+#include <sys/statvfs.h>
+#include <unistd.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <unistd.h>
#include <fcntl.h>
#include "libnfs.h"
#include <rpc/rpc.h> /* for authunix_create() */
#include <fcntl.h>
#include "libnfs.h"
#include <rpc/rpc.h> /* for authunix_create() */
{
struct nfs_context *nfs;
int i, ret;
{
struct nfs_context *nfs;
int i, ret;
struct client client;
struct stat st;
struct nfsfh *nfsfh;
struct nfsdir *nfsdir;
struct nfsdirent *nfsdirent;
struct client client;
struct stat st;
struct nfsfh *nfsfh;
struct nfsdir *nfsdir;
struct nfsdirent *nfsdirent;
- client.server = SERVER;
- client.export = EXPORT;
- client.is_finished = 0;
- off_t offset;
struct statvfs svfs;
exports export, tmp;
struct statvfs svfs;
exports export, tmp;
+#if defined(WIN32)
+ if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
+ printf("Failed to start Winsock2\n");
+ exit(10);
+ }
+#endif
+
+ client.server = SERVER;
+ client.export = EXPORT;
+ client.is_finished = 0;
export = mount_getexports(SERVER);
if (export != NULL) {
printf("exports on server %s\n", SERVER);
export = mount_getexports(SERVER);
if (export != NULL) {
printf("exports on server %s\n", SERVER);
exit(10);
}
while((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) {
exit(10);
}
while((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) {
printf("Inode:%d Name:%s ", (int)nfsdirent->inode, nfsdirent->name);
printf("Inode:%d Name:%s ", (int)nfsdirent->inode, nfsdirent->name);
- asprintf(&filename, "%s/%s", NFSDIR, nfsdirent->name);
+ sprintf(&filename, "%s/%s", NFSDIR, nfsdirent->name);
ret = nfs_open(nfs, filename, O_RDONLY, &nfsfh);
ret = nfs_open(nfs, filename, O_RDONLY, &nfsfh);
if (ret != 0) {
printf("Failed to open(%s) %s\n", filename, nfs_get_error(nfs));
exit(10);
if (ret != 0) {
printf("Failed to open(%s) %s\n", filename, nfs_get_error(nfs));
exit(10);
struct nfs_context;
struct rpc_context;
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
*/
/*
* Used for interfacing the async version of the api into an external eventsystem
*/
+
+#if defined(WIN32)
+#include <winsock2.h>
+#else
+#include <unistd.h>
+#include <strings.h>
+#endif
+
#include <stdio.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
- rpc->auth = authunix_create_default();
+#if defined(WIN32)
+ rpc->auth = authunix_create("LibNFS", 65535, 65535, 0, NULL);
+#else
+ rpc->auth = authunix_create_default();
+#endif
if (rpc->auth == NULL) {
free(rpc->encodebuf);
free(rpc);
if (rpc->auth == NULL) {
free(rpc->encodebuf);
free(rpc);
rpc->auth =NULL;
if (rpc->fd != -1) {
rpc->auth =NULL;
if (rpc->fd != -1) {
+#if defined(WIN32)
+ closesocket(rpc->fd);
+#else
+ close(rpc->fd);
+#endif
}
if (rpc->encodebuf != NULL) {
}
if (rpc->encodebuf != NULL) {
* High level api to nfs filesystems
*/
* High level api to nfs filesystems
*/
+#if defined (WIN32)
+#include <winsock2.h>
+#define DllExport
+#else
+#include <strings.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <poll.h>
+#include <sys/ioctl.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#endif
+
+#ifdef HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <fcntl.h>
#include <errno.h>
-#include <poll.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netdb.h>
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
void free_nfs_srvr_list(struct nfs_server_list *srv)
{
while (srv != NULL) {
void free_nfs_srvr_list(struct nfs_server_list *srv)
{
while (srv != NULL) {
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
#include <stdio.h>
#include <errno.h>
#include <rpc/rpc.h>
#include <stdio.h>
#include <errno.h>
#include <rpc/rpc.h>
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#if defined(WIN32)
+#include <winsock2.h>
+#define S_IRUSR 0000400
+#define S_IWUSR 0000200
+#define S_IXUSR 0000100
+#define S_IRGRP 0000040
+#define S_IWGRP 0000020
+#define S_IXGRP 0000010
+#define S_IROTH 0000004
+#define S_IWOTH 0000002
+#define S_IXOTH 0000001
+#endif
+
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
#include <stdio.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <stdio.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>