yaffsfs.h 4.6 KB

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