yaffs: Add python test for O_EXCL
[yaffs2.git] / direct / python / yaffsfs.py
1 from ctypes import *
2 cdll.LoadLibrary("./libyaffsfs.so")
3 ylib = CDLL("./libyaffsfs.so")
4
5 #int yaffs_open(const YCHAR *path, int oflag, int mode) ;
6 yaffs_open = ylib.yaffs_open
7 yaffs_open.argtypes = [ c_char_p, c_int, c_int]
8 yaffs_open.restype = c_int
9
10 #int yaffs_close(int fd) ;
11 yaffs_close = ylib.yaffs_close
12 yaffs_close.argtypes = [ c_int]
13 yaffs_close.restype = c_int
14
15 #int yaffs_fsync(int fd) ;
16 yaffs_fsync = ylib.yaffs_fsync
17 yaffs_fsync.argtypes = [c_int]
18 yaffs_fsync.restype = c_int
19
20 #int yaffs_fdatasync(int fd) ;
21 yaffs_fdatasync = ylib.yaffs_fdatasync
22 yaffs_fdatasync.argtypes = [c_int]
23 yaffs_fdatasync.restype = c_int
24
25 #int yaffs_flush(int fd) ; /* same as yaffs_fsync() */
26 yaffs_flush = ylib.yaffs_flush
27 yaffs_flush.argtypes = [c_int]
28 yaffs_flush.restype = c_int
29
30 #int yaffs_access(const YCHAR *path, int amode);
31 yaffs_access=ylib.yaffs_access
32 yaffs_access.argtypes= [c_char_p,c_int]
33 yaffs_access.restype = c_int
34
35 #int yaffs_dup(int fd);
36 yaffs_dup = ylib.yaffs_dup
37 yaffs_dup.argtypes = [c_int]
38 yaffs_dup.restype = c_int
39
40 #int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
41 yaffs_read=ylib.yaffs_read
42 yaffs_read.argtypes=[c_int,c_char_p,c_int]
43 yaffs_read.restype = c_int
44
45 #int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
46 yaffs_write=ylib.yaffs_write
47 yaffs_write.argtypes=[c_int,c_char_p,c_int]
48 yaffs_write.restype = c_int
49
50 #int yaffs_pread(int fd, void *buf, unsigned int nbyte, unsigned int offset);
51 yaffs_pread=ylib.yaffs_pread
52 yaffs_pread.argtypes=[c_int,c_char_p,c_int,c_int]
53 yaffs_pread.restype = c_int
54
55 #int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, unsigned int offset);
56 yaffs_pwrite=ylib.yaffs_pwrite
57 yaffs_pwrite.argtypes=[c_int,c_char_p,c_int,c_int]
58 yaffs_pwrite.restype = c_int
59
60 # off_t = 4 byte int
61 #off_t yaffs_lseek(int fd, off_t offset, int whence) ;
62 yaffs_lseek=ylib.yaffs_lseek
63 yaffs_lseek.argtypes= [c_int, c_int, c_int]
64 yaffs_lseek.restype= c_int
65
66 #int yaffs_truncate(const YCHAR *path, off_t newSize);
67 yaffs_truncate=ylib.yaffs_truncate
68 yaffs_truncate.argtypes = [c_char_p,c_int]
69 yaffs_truncate.restype = c_int
70
71 #int yaffs_ftruncate(int fd, off_t newSize);
72 yaffs_ftruncate = ylib.yaffs_ftruncate
73 yaffs_truncate.argtypes = [c_int,c_int]
74 yaffs_truncate.restype = c_int
75
76 #int yaffs_unlink(const YCHAR *path) ;
77 yaffs_unlink=ylib.yaffs_unlink
78 yaffs_unlink.argtypes = [c_char_p]
79 yaffs_unlink.restype = c_int
80
81 #int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath) ;
82 yaffs_rename= ylib.yaffs_rename
83 yaffs_rename.argtypes=[c_char_p, c_char_p]
84 yaffs_rename.restype = c_int
85
86 class yaffs_stat_struct(Structure):
87     _fields_ = [
88         ("st_dev", c_int),
89         ("st_ino", c_int),
90         ("st_mode", c_int),
91         ("st_nlink", c_int),
92         ("st_uid", c_int),
93         ("st_gid", c_int),
94         ("st_rdev", c_int),
95         ("st_size", c_int),
96         ("st_blksize", c_int),
97         ("st_blocks", c_int),
98         ("yst_atime", c_int),
99         ("yst_mtime", c_int),
100         ("yst_ctime", c_int)]
101
102 #int yaffs_stat(const YCHAR *path, struct yaffs_stat *buf) ;
103 yaffs_stat = ylib.yaffs_stat
104 yaffs_stat.argtypes=[c_char_p,POINTER(yaffs_stat_struct)]
105 yaffs_stat.restype=c_int
106
107 #int yaffs_lstat(const YCHAR *path, struct yaffs_stat *buf) ;
108 yaffs_lstat = ylib.yaffs_lstat
109 yaffs_lstat.argtypes=[c_char_p,POINTER(yaffs_stat_struct)]
110 yaffs_lstat.restype=c_int
111
112 #int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
113 yaffs_fstat = ylib.yaffs_fstat
114 yaffs_fstat.argtypes=[c_int,POINTER(yaffs_stat_struct)]
115 yaffs_fstat.restype=c_int
116
117
118 #int yaffs_chmod(const YCHAR *path, mode_t mode);
119 yaffs_chmod = ylib.yaffs_chmod
120 yaffs_chmod.argtypes = [c_char_p, c_int]
121 yaffs_chmod.restype = c_int
122
123 #int yaffs_fchmod(int fd, mode_t mode); 
124 yaffs_fchmod = ylib.yaffs_fchmod
125 yaffs_fchmod.argtypes = [c_int, c_int]
126 yaffs_fchmod.restype = c_int
127
128 #int yaffs_mkdir(const YCHAR *path, mode_t mode) ;
129 yaffs_mkdir = ylib.yaffs_mkdir
130 yaffs_mkdir.argtypes = [c_char_p, c_int]
131 yaffs_mkdir.restype = c_int
132
133 #int yaffs_rmdir(const YCHAR *path) ;
134 yaffs_rmdir = ylib.yaffs_rmdir
135 yaffs_rmdir.argtypes = [c_char_p]
136 yaffs_rmdir.restype = c_int
137
138 class yaffs_dirent_struct(Structure):
139     _fields_ = [
140         ("d_ino", c_int),
141         ("d_off", c_int),
142         ("d_reclen", c_short),
143         ("d_type", c_char),
144         ("d_name", c_char * 257),
145         ("d_dont_use", c_int)]
146
147 #yaffs_DIR *yaffs_opendir(const YCHAR *dirname) ;
148 yaffs_opendir = ylib.yaffs_opendir
149 yaffs_opendir.argtypes = [c_char_p]
150 yaffs_opendir.restype = c_int
151
152 #struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;
153 yaffs_readdir= ylib.yaffs_readdir
154 yaffs_readdir.argtypes=[c_int]
155 yaffs_readdir.restype=POINTER(yaffs_dirent_struct)
156
157 #void yaffs_rewinddir(yaffs_DIR *dirp) ;
158 yaffs_rewinddir = ylib.yaffs_rewinddir
159 yaffs_rewinddir.argtypes = [c_int]
160 yaffs_rewinddir.restype = c_int ###### Should be void
161
162 #int yaffs_closedir(yaffs_DIR *dirp) ;
163 yaffs_closedir = ylib.yaffs_closedir
164 yaffs_closedir.argtypes = [c_int]
165 yaffs_closedir.restype = c_int
166
167
168 #int yaffs_mount(const YCHAR *path) ;
169 yaffs_mount = ylib.yaffs_mount
170 yaffs_mount.argtypes = [c_char_p]
171 yaffs_mount.restype = c_int
172
173 #int yaffs_mount2(const YCHAR *path,int readOnly) ;
174 yaffs_mount2 = ylib.yaffs_mount2
175 yaffs_mount2.argtypes = [c_char_p, c_int]
176 yaffs_mount2.restype = c_int
177
178 #int yaffs_unmount(const YCHAR *path) ;
179 yaffs_unmount = ylib.yaffs_unmount
180 yaffs_unmount.argtypes = [c_char_p]
181 yaffs_unmount.restype = c_int
182
183 #int yaffs_unmount(const YCHAR *path, int force) ;
184 yaffs_unmount2 = ylib.yaffs_unmount2
185 yaffs_unmount2.argtypes = [c_char_p, c_int]
186 yaffs_unmount2.restype = c_int
187
188 #int yaffs_remount(const YCHAR *path, int force, int readOnly) ;
189 yaffs_remount = ylib.yaffs_remount
190 yaffs_remount.argtypes = [c_char_p, c_int, c_int]
191 yaffs_remount.restype = c_int
192
193 #int yaffs_sync(const YCHAR *path) ;
194 yaffs_sync = ylib.yaffs_sync
195 yaffs_sync.argtypes = [c_char_p]
196 yaffs_sync.restype = c_int
197
198 #int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath);
199 yaffs_symlink= ylib.yaffs_symlink
200 yaffs_symlink.argtypes= [c_char_p, c_char_p]
201 yaffs_symlink.restype = c_int
202
203 #int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz); 
204 yaffs_readlink = ylib.yaffs_readlink
205 yaffs_readlink.argtypes = [c_char_p, c_char_p, c_int]
206 yaffs_readlink.restype = c_int
207
208 #int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath); 
209 yaffs_link = ylib.yaffs_link
210 yaffs_link.argtypes = [c_char_p, c_char_p]
211 yaffs_link.restype = c_int
212
213 #int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev);
214 yaffs_mknod = ylib.yaffs_mknod
215 yaffs_mknod.argtypes = [c_char_p, c_int, c_int]
216 yaffs_mknod.restype = c_int
217
218 #loff_t yaffs_freespace(const YCHAR *path);
219 yaffs_freespace = ylib.yaffs_freespace
220 yaffs_freespace.argtypes = [c_char_p]
221 yaffs_freespace.restype = c_longlong
222
223 #loff_t yaffs_totalspace(const YCHAR *path);
224 yaffs_totalspace = ylib.yaffs_totalspace
225 yaffs_totalspace.argtypes = [c_char_p]
226 yaffs_totalspace.restype = c_longlong
227
228 #int yaffs_inodecount(const YCHAR *path);
229 yaffs_inodecount = ylib.yaffs_inodecount
230 yaffs_inodecount.argtypes = [c_char_p]
231 yaffs_inodecount.restype = c_int
232
233 #int yaffs_StartUp(void)
234 yaffs_StartUp = ylib.yaffs_StartUp
235 yaffs_StartUp.argtypes = []
236 yaffs_StartUp.restype = c_int
237