Version increased to unfs3_0.9.22+dfsg-1maemo3
[unfs3] / unfs3 / winsupport.h
1
2 /*
3  * unfs3 Windows compatibility
4  * Copyright 2006 Peter Åstrand <astrand@cendio.se> for Cendio AB
5  * see file LICENSE for license details
6  */
7
8 #ifdef WIN32
9 #ifndef UNFS3_WINSUPPORT_H
10 #define UNFS3_WINSUPPORT_H
11
12 #include <sys/stat.h>
13 #include <dirent.h>
14 #include <utime.h>
15 #include "nfs.h"
16
17 #define LOG_EMERG       0       /* system is unusable */
18 #define LOG_ALERT       1       /* action must be taken immediately */
19 #define LOG_CRIT        2       /* critical conditions */
20 #define LOG_ERR         3       /* error conditions */
21 #define LOG_WARNING     4       /* warning conditions */
22 #define LOG_NOTICE      5       /* normal but significant condition */
23 #define LOG_INFO        6       /* informational */
24 #define LOG_DEBUG       7       /* debug-level messages */
25 #define LOG_CONS        0
26 #define LOG_PID         0
27 #define LOG_DAEMON      0
28 #define closelog()      do { } while (0)
29
30 #define O_NONBLOCK      0
31 #define ELOOP           ENAMETOOLONG
32
33 #define S_IRWXG 0
34 #define S_IXGRP S_IRGRP
35 #define S_IRGRP 0
36 #define S_IWGRP 0
37
38 #define S_IRWXO 0
39 #define S_IXOTH S_IROTH 
40 #define S_IROTH 0
41 #define S_IWOTH 0
42
43 #define S_IFLNK 0
44 #define S_IFSOCK 0
45
46 typedef int socklen_t;
47 typedef uint32 uid_t;
48 typedef uint32 gid_t;
49
50 typedef struct _backend_statstruct
51 {
52         uint32  st_dev;  
53         uint64  st_ino;  
54         _mode_t st_mode;
55         short   st_nlink;
56         uint32  st_uid;
57         uint32  st_gid;
58         _dev_t  st_rdev;
59         _off_t  st_size;
60         short   st_blksize;
61         _off_t  st_blocks;
62         time_t  st_atime;
63         time_t  st_mtime;
64         time_t  st_ctime;
65 } backend_statstruct;
66
67 typedef struct _backend_passwdstruct
68 {
69     uid_t   pw_uid;
70     gid_t   pw_gid;
71 } backend_passwdstruct;
72
73 /* Only includes fields actually used by unfs3 */
74 typedef struct _backend_statvfsstruct
75 {
76         unsigned long  f_bsize;    /* file system block size */
77         uint64         f_blocks;   /* size of fs in f_frsize units */
78         uint64         f_bfree;    /* # free blocks */
79         uint64         f_bavail;   /* # free blocks for non-root */
80         uint64         f_files;    /* # inodes */
81         uint64         f_ffree;    /* # free inodes */
82 } backend_statvfsstruct;
83
84 typedef struct _UNFS3_WIN_DIR
85 {
86     _WDIR *stream; /* Windows DIR stream. NULL means root emulation */
87     uint32 currentdrive; /* Next drive to check/return */
88     struct dirent de;
89     DWORD logdrives;
90 } UNFS3_WIN_DIR;
91
92 int inet_aton(const char *cp, struct in_addr *addr);
93 ssize_t pread(int fd, void *buf, size_t count, off_t offset);
94 ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
95 void syslog(int priority, const char *format, ...);
96
97 int win_seteuid(uid_t euid);
98 int win_setegid(gid_t egid);
99 int win_truncate(const char *path, off_t length);
100 int win_chown(const char *path, uid_t owner, gid_t group);
101 int win_fchown(int fd, uid_t owner, gid_t group);
102 int win_fchmod(int fildes, mode_t mode);
103 int win_stat(const char *file_name, backend_statstruct *buf);
104 int win_fstat(int fd, backend_statstruct *buf);
105 int win_open(const char *pathname, int flags, ...);
106 int win_close(int fd);
107 UNFS3_WIN_DIR *win_opendir(const char *name);
108 struct dirent *win_readdir(UNFS3_WIN_DIR *dir);
109 int win_closedir(UNFS3_WIN_DIR *dir);
110 int win_init();
111 void openlog(const char *ident, int option, int facility);
112 char *win_realpath(const char *path, char *resolved_path);
113 int win_readlink(const char *path, char *buf, size_t bufsiz);
114 int win_mkdir(const char *pathname, mode_t mode);
115 int win_symlink(const char *oldpath, const char *newpath);
116 int win_mknod(const char *pathname, mode_t mode, dev_t dev);
117 int win_mkfifo(const char *pathname, mode_t mode);
118 int win_link(const char *oldpath, const char *newpath);
119 int win_statvfs(const char *path, backend_statvfsstruct *buf);
120 int win_remove(const char *pathname);
121 int win_chmod(const char *path, mode_t mode);
122 int win_utime(const char *path, const struct utimbuf *times);
123 int win_rmdir(const char *path);
124 int win_rename(const char *oldpath, const char *newpath);
125 int win_gen_nonce(char *nonce);
126 int win_utf8ncasecmp(const char *s1, const char *s2, size_t n);
127 int win_store_create_verifier(char *obj, createverf3 verf);
128 int win_check_create_verifier(backend_statstruct * buf, createverf3 verf);
129
130 #endif /* UNFS3_WINSUPPORT_H */
131 #endif /* WIN32 */