50b5cbcd8eac356c859043a48bf76e45007e76d2
[yaffs2.git] / direct / yaffsfs.h
1 /*
2  * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
3  *
4  * Copyright (C) 2002-2010 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Charles Manning <charles@aleph1.co.uk>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License version 2.1 as
11  * published by the Free Software Foundation.
12  *
13  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
14  */
15
16 /*
17  * Header file for using yaffs in an application via
18  * a direct interface.
19  */
20
21
22 #ifndef __YAFFSFS_H__
23 #define __YAFFSFS_H__
24
25 #include "yaffscfg.h"
26 #include "yportenv.h"
27
28
29 //typedef long off_t;
30 //typedef long dev_t;
31 //typedef unsigned long mode_t;
32
33
34 #ifndef NAME_MAX
35 #define NAME_MAX        256
36 #endif
37
38
39 struct yaffs_dirent{
40     long d_ino;                 /* inode number */
41     off_t d_off;                /* offset to this dirent */
42     unsigned short d_reclen;    /* length of this d_name */
43     YUCHAR  d_type;     /* type of this record */
44     YCHAR d_name [NAME_MAX+1];   /* file name (null-terminated) */
45     unsigned d_dont_use;        /* debug pointer, not for public consumption */
46 };
47
48 typedef struct yaffs_dirent yaffs_dirent;
49
50
51 typedef struct __opaque yaffs_DIR;
52
53
54
55 struct yaffs_stat{
56     int               st_dev;      /* device */
57     int           st_ino;      /* inode */
58     unsigned      st_mode;     /* protection */
59     int           st_nlink;    /* number of hard links */
60     int           st_uid;      /* user ID of owner */
61     int           st_gid;      /* group ID of owner */
62     unsigned      st_rdev;     /* device type (if inode device) */
63     off_t         st_size;     /* total size, in bytes */
64     unsigned long st_blksize;  /* blocksize for filesystem I/O */
65     unsigned long st_blocks;   /* number of blocks allocated */
66 #ifdef CONFIG_YAFFS_WINCE
67         /* Special 64-bit times for WinCE */
68         unsigned long yst_wince_atime[2];
69         unsigned long yst_wince_mtime[2];
70         unsigned long yst_wince_ctime[2];
71 #else
72         unsigned long yst_atime;    /* time of last access */
73     unsigned long yst_mtime;    /* time of last modification */
74     unsigned long yst_ctime;    /* time of last change */
75 #endif
76 };
77
78 int yaffs_open(const YCHAR *path, int oflag, int mode) ;
79
80 int yaffs_close(int fd) ;
81 int yaffs_fsync(int fd) ;
82 int yaffs_fdatasync(int fd) ;
83 int yaffs_flush(int fd) ; /* same as yaffs_fsync() */
84
85 int yaffs_access(const YCHAR *path, int amode);
86
87 int yaffs_dup(int fd);
88
89 int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
90 int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
91
92 int yaffs_pread(int fd, void *buf, unsigned int nbyte, unsigned int offset);
93 int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, unsigned int offset);
94
95 off_t yaffs_lseek(int fd, off_t offset, int whence) ;
96
97 int yaffs_truncate(const YCHAR *path, off_t new_size);
98 int yaffs_ftruncate(int fd, off_t new_size);
99
100 int yaffs_unlink(const YCHAR *path) ;
101 int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath) ;
102
103 int yaffs_stat(const YCHAR *path, struct yaffs_stat *buf) ;
104 int yaffs_lstat(const YCHAR *path, struct yaffs_stat *buf) ;
105 int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
106
107 int yaffs_setxattr(const char *path, const char *name, const void *data, int size, int flags);
108 int yaffs_lsetxattr(const char *path, const char *name, const void *data, int size, int flags);
109 int yaffs_fsetxattr(int fd, const char *name, const void *data, int size, int flags);
110
111 int yaffs_getxattr(const char *path, const char *name, void *data, int size);
112 int yaffs_lgetxattr(const char *path, const char *name, void *data, int size);
113 int yaffs_fgetxattr(int fd, const char *name, void *data, int size);
114
115 int yaffs_removexattr(const char *path, const char *name);
116 int yaffs_lremovexattr(const char *path, const char *name);
117 int yaffs_fremovexattr(int fd, const char *name);
118
119 int yaffs_listxattr(const char *path, char *list, int size);
120 int yaffs_llistxattr(const char *path, char *list, int size);
121 int yaffs_flistxattr(int fd, char *list, int size);
122
123
124 #ifdef CONFIG_YAFFS_WINCE
125
126 int yaffs_set_wince_times(int fd, const unsigned *wctime, const unsigned *watime, const unsigned *wmtime);
127 int yaffs_get_wince_times(int fd, unsigned *wctime, unsigned *watime, unsigned *wmtime);
128
129 #endif
130
131 int yaffs_chmod(const YCHAR *path, mode_t mode); 
132 int yaffs_fchmod(int fd, mode_t mode); 
133
134 int yaffs_mkdir(const YCHAR *path, mode_t mode) ;
135 int yaffs_rmdir(const YCHAR *path) ;
136
137 yaffs_DIR *yaffs_opendir(const YCHAR *dirname) ;
138 struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;
139 void yaffs_rewinddir(yaffs_DIR *dirp) ;
140 int yaffs_closedir(yaffs_DIR *dirp) ;
141
142 int yaffs_mount(const YCHAR *path) ;
143 int yaffs_mount2(const YCHAR *path, int read_only);
144 int yaffs_unmount(const YCHAR *path) ;
145 int yaffs_unmount2(const YCHAR *path, int force);
146 int yaffs_remount(const YCHAR *path, int force, int read_only);
147
148
149 int yaffs_sync(const YCHAR *path) ;
150
151 int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath); 
152 int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz); 
153
154 int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath); 
155 int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev);
156
157 loff_t yaffs_freespace(const YCHAR *path);
158 loff_t yaffs_totalspace(const YCHAR *path);
159
160 int yaffs_inodecount(const YCHAR *path);
161
162 int yaffs_n_handles(const YCHAR *path);
163
164 #define YAFFS_SHARE_READ  1
165 #define YAFFS_SHARE_WRITE 2
166 int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int shareMode) ;
167
168
169 struct yaffs_dev;
170 void yaffs_add_device(struct yaffs_dev *dev);
171
172 int yaffs_start_up(void);
173 int yaffsfs_GetLastError(void);
174 /* Function to get the last error */
175 int yaffs_get_error(void);
176
177 /* Function only for debugging */
178 void * yaffs_getdev(const YCHAR *path);
179 int yaffs_dump_dev(const YCHAR *path);
180
181 /* Trace control functions */
182 int yaffs_set_trace(unsigned int tm);
183 unsigned int yaffs_get_trace(void);
184 #endif
185
186