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