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