Update for Linux 2.6.19 support
[yaffs2.git] / direct / yaffsfs.h
1 /*
2 * Header file for using yaffs in an application via
3 * a direct interface.
4 */
5
6
7 #ifndef __YAFFSFS_H__
8 #define __YAFFSFS_H__
9
10 #include "yaffscfg.h"
11 #include "yportenv.h"
12
13
14 //typedef long off_t;
15 //typedef long dev_t;
16 //typedef unsigned long mode_t;
17
18
19 #ifndef NAME_MAX
20 #define NAME_MAX        256
21 #endif
22
23 #ifndef O_RDONLY
24 #define O_RDONLY        00
25 #endif
26
27 #ifndef O_WRONLY
28 #define O_WRONLY        01
29 #endif
30
31 #ifndef O_RDWR
32 #define O_RDWR          02
33 #endif
34
35 #ifndef O_CREAT         
36 #define O_CREAT         0100
37 #endif
38
39 #ifndef O_EXCL
40 #define O_EXCL          0200
41 #endif
42
43 #ifndef O_TRUNC
44 #define O_TRUNC         01000
45 #endif
46
47 #ifndef O_APPEND
48 #define O_APPEND        02000
49 #endif
50
51 #ifndef SEEK_SET
52 #define SEEK_SET        0
53 #endif
54
55 #ifndef SEEK_CUR
56 #define SEEK_CUR        1
57 #endif
58
59 #ifndef SEEK_END
60 #define SEEK_END        2
61 #endif
62
63 #ifndef EBUSY
64 #define EBUSY   16
65 #endif
66
67 #ifndef ENODEV
68 #define ENODEV  19
69 #endif
70
71 #ifndef EINVAL
72 #define EINVAL  22
73 #endif
74
75 #ifndef EBADF
76 #define EBADF   9
77 #endif
78
79 #ifndef EACCESS
80 #define EACCESS 13
81 #endif
82
83 #ifndef EXDEV   
84 #define EXDEV   18
85 #endif
86
87 #ifndef ENOENT
88 #define ENOENT  2
89 #endif
90
91 #ifndef ENOSPC
92 #define ENOSPC  28
93 #endif
94
95 #ifndef ENOTEMPTY
96 #define ENOTEMPTY 39
97 #endif
98
99 #ifndef ENOMEM
100 #define ENOMEM 12
101 #endif
102
103 #ifndef EEXIST
104 #define EEXIST 17
105 #endif
106
107 #ifndef ENOTDIR
108 #define ENOTDIR 20
109 #endif
110
111 #ifndef EISDIR
112 #define EISDIR 21
113 #endif
114
115
116 // Mode flags
117
118 #ifndef S_IFMT
119 #define S_IFMT          0170000
120 #endif
121
122 #ifndef S_IFLNK
123 #define S_IFLNK         0120000
124 #endif
125
126 #ifndef S_IFDIR
127 #define S_IFDIR         0040000
128 #endif
129
130 #ifndef S_IFREG
131 #define S_IFREG         0100000
132 #endif
133
134 #ifndef S_IREAD 
135 #define S_IREAD         0000400
136 #endif
137
138 #ifndef S_IWRITE
139 #define S_IWRITE        0000200
140 #endif
141
142
143
144
145 struct yaffs_dirent{
146     long d_ino;                 /* inode number */
147     off_t d_off;                /* offset to this dirent */
148     unsigned short d_reclen;    /* length of this d_name */
149     char d_name [NAME_MAX+1];   /* file name (null-terminated) */
150     unsigned d_dont_use;        /* debug pointer, not for public consumption */
151 };
152
153 typedef struct yaffs_dirent yaffs_dirent;
154
155
156 typedef struct __opaque yaffs_DIR;
157
158
159
160 struct yaffs_stat{
161     int               st_dev;      /* device */
162     int           st_ino;      /* inode */
163     mode_t        st_mode;     /* protection */
164     int           st_nlink;    /* number of hard links */
165     int           st_uid;      /* user ID of owner */
166     int           st_gid;      /* group ID of owner */
167     unsigned      st_rdev;     /* device type (if inode device) */
168     off_t         st_size;     /* total size, in bytes */
169     unsigned long st_blksize;  /* blocksize for filesystem I/O */
170     unsigned long st_blocks;   /* number of blocks allocated */
171     unsigned long yst_atime;    /* time of last access */
172     unsigned long yst_mtime;    /* time of last modification */
173     unsigned long yst_ctime;    /* time of last change */
174 };
175
176 int yaffs_open(const char *path, int oflag, int mode) ;
177 int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
178 int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
179 int yaffs_close(int fd) ;
180 off_t yaffs_lseek(int fd, off_t offset, int whence) ;
181 int yaffs_truncate(int fd, off_t newSize);
182
183 int yaffs_unlink(const char *path) ;
184 int yaffs_rename(const char *oldPath, const char *newPath) ;
185
186 int yaffs_stat(const char *path, struct yaffs_stat *buf) ;
187 int yaffs_lstat(const char *path, struct yaffs_stat *buf) ;
188 int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
189
190 int yaffs_chmod(const char *path, mode_t mode); 
191 int yaffs_fchmod(int fd, mode_t mode); 
192
193 int yaffs_mkdir(const char *path, mode_t mode) ;
194 int yaffs_rmdir(const char *path) ;
195
196 yaffs_DIR *yaffs_opendir(const char *dirname) ;
197 struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;
198 void yaffs_rewinddir(yaffs_DIR *dirp) ;
199 int yaffs_closedir(yaffs_DIR *dirp) ;
200
201 int yaffs_mount(const char *path) ;
202 int yaffs_unmount(const char *path) ;
203
204 int yaffs_symlink(const char *oldpath, const char *newpath); 
205 int yaffs_readlink(const char *path, char *buf, int bufsiz); 
206
207 int yaffs_link(const char *oldpath, const char *newpath); 
208 int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev);
209
210 loff_t yaffs_freespace(const char *path);
211
212 void yaffs_initialise(yaffsfs_DeviceConfiguration *configList);
213
214 int yaffs_StartUp(void);
215
216 #endif
217
218