2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
4 * Copyright (C) 2002-2011 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Charles Manning <charles@aleph1.co.uk>
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.
13 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
17 * Header file for using yaffs in an application via
31 //typedef unsigned long mode_t;
38 #define YAFFS_MAX_FILE_SIZE (0x7FFFFFFF)
42 long d_ino; /* inode number */
43 off_t d_off; /* offset to this dirent */
44 unsigned short d_reclen; /* length of this d_name */
45 YUCHAR d_type; /* type of this record */
46 YCHAR d_name [NAME_MAX+1]; /* file name (null-terminated) */
47 unsigned d_dont_use; /* debug pointer, not for public consumption */
50 typedef struct yaffs_dirent yaffs_dirent;
53 typedef struct __opaque yaffs_DIR;
58 int st_dev; /* device */
59 int st_ino; /* inode */
60 unsigned st_mode; /* protection */
61 int st_nlink; /* number of hard links */
62 int st_uid; /* user ID of owner */
63 int st_gid; /* group ID of owner */
64 unsigned st_rdev; /* device type (if inode device) */
65 off_t st_size; /* total size, in bytes */
66 unsigned long st_blksize; /* blocksize for filesystem I/O */
67 unsigned long st_blocks; /* number of blocks allocated */
68 #ifdef CONFIG_YAFFS_WINCE
69 /* Special 64-bit times for WinCE */
70 unsigned long yst_wince_atime[2];
71 unsigned long yst_wince_mtime[2];
72 unsigned long yst_wince_ctime[2];
74 unsigned long yst_atime; /* time of last access */
75 unsigned long yst_mtime; /* time of last modification */
76 unsigned long yst_ctime; /* time of last change */
81 struct yaffs_utimbuf {
83 unsigned long modtime;
87 int yaffs_open(const YCHAR *path, int oflag, int mode) ;
89 int yaffs_close(int fd) ;
90 int yaffs_fsync(int fd) ;
91 int yaffs_fdatasync(int fd) ;
92 int yaffs_flush(int fd) ; /* same as yaffs_fsync() */
94 int yaffs_access(const YCHAR *path, int amode);
96 int yaffs_dup(int fd);
98 int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
99 int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
101 int yaffs_pread(int fd, void *buf, unsigned int nbyte, unsigned int offset);
102 int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, unsigned int offset);
104 off_t yaffs_lseek(int fd, off_t offset, int whence) ;
106 int yaffs_truncate(const YCHAR *path, off_t new_size);
107 int yaffs_ftruncate(int fd, off_t new_size);
109 int yaffs_unlink(const YCHAR *path) ;
110 int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath) ;
112 int yaffs_stat(const YCHAR *path, struct yaffs_stat *buf) ;
113 int yaffs_lstat(const YCHAR *path, struct yaffs_stat *buf) ;
114 int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
116 int yaffs_utime(const YCHAR *path, const struct yaffs_utimbuf *buf);
117 int yaffs_futime(int fd, const struct yaffs_utimbuf *buf);
120 int yaffs_setxattr(const char *path, const char *name, const void *data, int size, int flags);
121 int yaffs_lsetxattr(const char *path, const char *name, const void *data, int size, int flags);
122 int yaffs_fsetxattr(int fd, const char *name, const void *data, int size, int flags);
124 int yaffs_getxattr(const char *path, const char *name, void *data, int size);
125 int yaffs_lgetxattr(const char *path, const char *name, void *data, int size);
126 int yaffs_fgetxattr(int fd, const char *name, void *data, int size);
128 int yaffs_removexattr(const char *path, const char *name);
129 int yaffs_lremovexattr(const char *path, const char *name);
130 int yaffs_fremovexattr(int fd, const char *name);
132 int yaffs_listxattr(const char *path, char *list, int size);
133 int yaffs_llistxattr(const char *path, char *list, int size);
134 int yaffs_flistxattr(int fd, char *list, int size);
137 #ifdef CONFIG_YAFFS_WINCE
139 int yaffs_set_wince_times(int fd, const unsigned *wctime, const unsigned *watime, const unsigned *wmtime);
140 int yaffs_get_wince_times(int fd, unsigned *wctime, unsigned *watime, unsigned *wmtime);
144 int yaffs_chmod(const YCHAR *path, mode_t mode);
145 int yaffs_fchmod(int fd, mode_t mode);
147 int yaffs_mkdir(const YCHAR *path, mode_t mode) ;
148 int yaffs_rmdir(const YCHAR *path) ;
150 yaffs_DIR *yaffs_opendir(const YCHAR *dirname) ;
151 struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;
152 void yaffs_rewinddir(yaffs_DIR *dirp) ;
153 int yaffs_closedir(yaffs_DIR *dirp) ;
155 int yaffs_mount(const YCHAR *path) ;
156 int yaffs_mount2(const YCHAR *path, int read_only);
157 int yaffs_unmount(const YCHAR *path) ;
158 int yaffs_unmount2(const YCHAR *path, int force);
159 int yaffs_remount(const YCHAR *path, int force, int read_only);
162 int yaffs_sync(const YCHAR *path) ;
164 int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath);
165 int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz);
167 int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath);
168 int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev);
170 loff_t yaffs_freespace(const YCHAR *path);
171 loff_t yaffs_totalspace(const YCHAR *path);
173 int yaffs_inodecount(const YCHAR *path);
175 int yaffs_n_handles(const YCHAR *path);
177 #define YAFFS_SHARE_READ 1
178 #define YAFFS_SHARE_WRITE 2
179 int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int shareMode) ;
183 void yaffs_add_device(struct yaffs_dev *dev);
185 int yaffs_start_up(void);
186 int yaffsfs_GetLastError(void);
188 /* Function to get the last error */
189 int yaffs_get_error(void);
190 const char * yaffs_error_to_str(int err);
192 /* Function only for debugging */
193 void * yaffs_getdev(const YCHAR *path);
194 int yaffs_dump_dev(const YCHAR *path);
195 int yaffs_set_error(int error);
197 /* Trace control functions */
198 unsigned yaffs_set_trace(unsigned tm);
199 unsigned yaffs_get_trace(void);
204 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
206 * Copyright (C) 2002-2011 Aleph One Ltd.
207 * for Toby Churchill Ltd and Brightstar Engineering
209 * Created by Timothy Manning <timothy@yaffs.net>
211 * This program is free software; you can redistribute it and/or modify
212 * it under the terms of the GNU Lesser General Public License version 2.1 as
213 * published by the Free Software Foundation.
215 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
218 #ifndef __error_handler_h__
219 #define __error_handler_h__
223 #include "yportenv.h"