yaffsfs.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
  3. *
  4. * Copyright (C) 2002-2011 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. #ifndef NAME_MAX
  24. #define NAME_MAX 256
  25. #endif
  26. #define YAFFS_MAX_FILE_SIZE (0x800000000LL - 1)
  27. struct yaffs_dirent {
  28. long d_ino; /* inode number */
  29. off_t d_off; /* offset to this dirent */
  30. unsigned short d_reclen; /* length of this dirent */
  31. YUCHAR d_type; /* type of this record */
  32. YCHAR d_name[NAME_MAX+1]; /* file name (null-terminated) */
  33. unsigned d_dont_use; /* debug: not for public consumption */
  34. };
  35. typedef struct opaque_structure yaffs_DIR;
  36. struct yaffs_stat {
  37. int st_dev; /* device */
  38. int st_ino; /* inode */
  39. unsigned st_mode; /* protection */
  40. int st_nlink; /* number of hard links */
  41. int st_uid; /* user ID of owner */
  42. int st_gid; /* group ID of owner */
  43. unsigned st_rdev; /* device type (if inode device) */
  44. loff_t st_size; /* total size, in bytes */
  45. unsigned long st_blksize; /* blocksize for filesystem I/O */
  46. unsigned long st_blocks; /* number of blocks allocated */
  47. #ifdef CONFIG_YAFFS_WINCE
  48. /* Special 64-bit times for WinCE */
  49. unsigned long yst_wince_atime[2];
  50. unsigned long yst_wince_mtime[2];
  51. unsigned long yst_wince_ctime[2];
  52. #else
  53. unsigned long yst_atime; /* time of last access */
  54. unsigned long yst_mtime; /* time of last modification */
  55. unsigned long yst_ctime; /* time of last change */
  56. #endif
  57. };
  58. struct yaffs_utimbuf {
  59. unsigned long actime;
  60. unsigned long modtime;
  61. };
  62. int yaffs_open(const YCHAR *path, int oflag, int mode) ;
  63. int yaffs_close(int fd) ;
  64. int yaffs_fsync(int fd) ;
  65. int yaffs_fdatasync(int fd) ;
  66. int yaffs_flush(int fd) ; /* same as yaffs_fsync() */
  67. int yaffs_access(const YCHAR *path, int amode);
  68. int yaffs_dup(int fd);
  69. int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
  70. int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
  71. int yaffs_pread(int fd, void *buf, unsigned int nbyte, loff_t offset);
  72. int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, loff_t offset);
  73. loff_t yaffs_lseek(int fd, loff_t offset, int whence) ;
  74. int yaffs_truncate(const YCHAR *path, loff_t new_size);
  75. int yaffs_ftruncate(int fd, loff_t new_size);
  76. int yaffs_unlink(const YCHAR *path) ;
  77. int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath) ;
  78. int yaffs_stat(const YCHAR *path, struct yaffs_stat *buf) ;
  79. int yaffs_lstat(const YCHAR *path, struct yaffs_stat *buf) ;
  80. int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
  81. int yaffs_utime(const YCHAR *path, const struct yaffs_utimbuf *buf);
  82. int yaffs_futime(int fd, const struct yaffs_utimbuf *buf);
  83. int yaffs_setxattr(const char *path, const char *name,
  84. const void *data, int size, int flags);
  85. int yaffs_lsetxattr(const char *path, const char *name,
  86. const void *data, int size, int flags);
  87. int yaffs_fsetxattr(int fd, const char *name,
  88. const void *data, int size, int flags);
  89. int yaffs_getxattr(const char *path, const char *name,
  90. void *data, int size);
  91. int yaffs_lgetxattr(const char *path, const char *name,
  92. void *data, int size);
  93. int yaffs_fgetxattr(int fd, const char *name,
  94. void *data, int size);
  95. int yaffs_removexattr(const char *path, const char *name);
  96. int yaffs_lremovexattr(const char *path, const char *name);
  97. int yaffs_fremovexattr(int fd, const char *name);
  98. int yaffs_listxattr(const char *path, char *list, int size);
  99. int yaffs_llistxattr(const char *path, char *list, int size);
  100. int yaffs_flistxattr(int fd, char *list, int size);
  101. #ifdef CONFIG_YAFFS_WINCE
  102. int yaffs_set_wince_times(int fd,
  103. const unsigned *wctime,
  104. const unsigned *watime,
  105. const unsigned *wmtime);
  106. int yaffs_get_wince_times(int fd,
  107. unsigned *wctime,
  108. unsigned *watime,
  109. unsigned *wmtime);
  110. #endif
  111. int yaffs_chmod(const YCHAR *path, mode_t mode);
  112. int yaffs_fchmod(int fd, mode_t mode);
  113. int yaffs_mkdir(const YCHAR *path, mode_t mode) ;
  114. int yaffs_rmdir(const YCHAR *path) ;
  115. yaffs_DIR *yaffs_opendir(const YCHAR *dirname) ;
  116. struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;
  117. void yaffs_rewinddir(yaffs_DIR *dirp) ;
  118. int yaffs_closedir(yaffs_DIR *dirp) ;
  119. int yaffs_mount(const YCHAR *path) ;
  120. int yaffs_mount2(const YCHAR *path, int read_only);
  121. int yaffs_mount_common(const YCHAR *path, int read_only, int skip_checkpt);
  122. int yaffs_unmount(const YCHAR *path) ;
  123. int yaffs_unmount2(const YCHAR *path, int force);
  124. int yaffs_remount(const YCHAR *path, int force, int read_only);
  125. int yaffs_sync(const YCHAR *path) ;
  126. int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath);
  127. int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz);
  128. int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath);
  129. int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev);
  130. loff_t yaffs_freespace(const YCHAR *path);
  131. loff_t yaffs_totalspace(const YCHAR *path);
  132. int yaffs_inodecount(const YCHAR *path);
  133. int yaffs_n_handles(const YCHAR *path);
  134. #define YAFFS_SHARE_READ 1
  135. #define YAFFS_SHARE_WRITE 2
  136. int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int shareMode);
  137. struct yaffs_dev;
  138. void yaffs_add_device(struct yaffs_dev *dev);
  139. int yaffs_start_up(void);
  140. int yaffsfs_GetLastError(void);
  141. /* Functions to iterate through devices. NB Use with extreme care! */
  142. void yaffs_dev_rewind(void);
  143. struct yaffs_dev *yaffs_next_dev(void);
  144. /* Function to get the last error */
  145. int yaffs_get_error(void);
  146. const char *yaffs_error_to_str(int err);
  147. /* Function only for debugging */
  148. void *yaffs_getdev(const YCHAR *path);
  149. int yaffs_dump_dev(const YCHAR *path);
  150. int yaffs_set_error(int error);
  151. /* Trace control functions */
  152. unsigned yaffs_set_trace(unsigned tm);
  153. unsigned yaffs_get_trace(void);
  154. #endif