dfs_jffs2.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * File : rtthread.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2012, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE.
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2012-1-7 prife the first version
  13. */
  14. #include <rtthread.h>
  15. #include "cyg/infra/cyg_type.h"
  16. #include "cyg/fileio/fileio.h"
  17. #include "codes.h"
  18. #undef mode_t
  19. #include <dfs_fs.h>
  20. #include <dfs_def.h>
  21. #include <dfs_jffs2.h>
  22. #include "porting.h"
  23. #define FILE_PATH_MAX 256 /* the longest file path */
  24. #define DEVICE_PART_MAX 1 /* the max partions on a nand deivce*/
  25. #if DEVICE_PART_MAX > 1
  26. #error "support only one jffs2 partition on a flash device!"
  27. #endif
  28. extern cyg_fileops jffs2_fileops;
  29. extern cyg_fileops jffs2_dirops;
  30. extern struct cyg_fstab_entry jffs2_fste;
  31. /* make sure the following struct var had been initilased to 0! */ //fixme
  32. struct device_part
  33. {
  34. rt_device_t dev;
  35. struct cyg_mtab_entry * mte;
  36. };
  37. static struct device_part device_partition[DEVICE_PART_MAX] = {0};
  38. #define jffs2_mount jffs2_fste.mount
  39. #define jffs2_umount jffs2_fste.umount
  40. #define jffs2_open jffs2_fste.open
  41. #define jffs2_unlink jffs2_fste.unlink
  42. #define jffs2_mkdir jffs2_fste.mkdir
  43. #define jffs2_rmdir jffs2_fste.rmdir
  44. #define jffs2_rename jffs2_fste.rename
  45. #define jffs2_link jffs2_fste.link
  46. #define jffs2_opendir jffs2_fste.opendir
  47. #define jffs2_chdir jffs2_fste.chdir
  48. #define jffs2_ops_stat jffs2_fste.stat
  49. #define jffs2_getinfo jffs2_fste.getinfo
  50. #define jffs2_setinfo jffs2_fste.setinfo
  51. #define jffs2_file_read jffs2_fileops.fo_read
  52. #define jffs2_file_write jffs2_fileops.fo_write
  53. #define jffs2_file_lseek jffs2_fileops.fo_lseek
  54. #define jffs2_file_ioctl jffs2_fileops.fo_ioctl
  55. #define jffs2_file_select jffs2_fileops.fo_select
  56. #define jffs2_file_fsync jffs2_fileops.fo_fsync
  57. #define jffs2_file_colse jffs2_fileops.fo_close
  58. #define jffs2_file_fstat jffs2_fileops.fo_fstat
  59. #define jffs2_file_getinfo jffs2_fileops.fo_getinfo
  60. #define jffs2_file_setinfo jffs2_fileops.fo_setinfo
  61. #define jffs2_dir_read jffs2_dirops.fo_read
  62. //#define jffs2_dir_write jffs2_dirops.fo_write
  63. #define jffs2_dir_lseek jffs2_dirops.fo_lseek
  64. //#define jffs2_dir_ioctl jffs2_dirops.fo_ioctl
  65. #define jffs2_dir_select jffs2_dirops.fo_select
  66. //#define jffs2_dir_fsync jffs2_dirops.fo_fsync
  67. #define jffs2_dir_colse jffs2_dirops.fo_close
  68. //#define jffs2_dir_fstat jffs2_dirops.fo_fstat
  69. //#define jffs2_dir_getinfo jffs2_dirops.fo_getinfo
  70. //#define jffs2_dir_setinfo jffs2_dirops.fo_setinfo
  71. /*
  72. * RT-Thread Device Interface for jffs2
  73. */
  74. /* these code is in src/flashio.c */
  75. static int jffs2_result_to_dfs(int result)
  76. {
  77. int status = -1;
  78. switch (result)
  79. {
  80. case ENOERR:/** no error */
  81. break;
  82. case EACCES:/** Tried to open read-only file for writing, or files sharing mode
  83. does not allow specified operations, or given path is directory */
  84. status = -DFS_STATUS_EINVAL;
  85. break;/* no suitable */
  86. case EEXIST: /** _O_CREAT and _O_EXCL flags specified, but filename already exists */
  87. status = -DFS_STATUS_EEXIST;
  88. break;
  89. case EINVAL: /** Invalid oflag or pmode argument */
  90. status = -DFS_STATUS_EINVAL;
  91. break;
  92. case EMFILE: /** No more file handles available(too many open files) */
  93. status = -1;
  94. break;//fixme
  95. case ENOENT: /** file or path not found */
  96. status = -DFS_STATUS_ENOENT;
  97. break;
  98. case EBADF: /** invalid file handle */
  99. status = -DFS_STATUS_EBADF;
  100. break;
  101. case ENOMEM:/** no enough memory */
  102. status = -DFS_STATUS_ENOMEM;
  103. break;
  104. case EIO: /** I/O error from lower level flash operation */
  105. status = -DFS_STATUS_EIO;
  106. break;
  107. case ENOTDIR: /** Not a directory */
  108. status = -DFS_STATUS_ENOTDIR;
  109. break;
  110. case EISDIR: /** Is a directory */
  111. status = -DFS_STATUS_EISDIR;
  112. break;
  113. default:
  114. status = -1;
  115. break; /* unknown error! */
  116. }
  117. return status;
  118. }
  119. /*
  120. * RT-Thread DFS Interface for jffs2
  121. */
  122. static int dfs_jffs2_mount(struct dfs_filesystem* fs,
  123. unsigned long rwflag,
  124. const void* data)
  125. {
  126. unsigned index;
  127. struct cyg_mtab_entry * mte;
  128. int result;
  129. /* find a empty entry in partition table */
  130. for (index = 0; index < DEVICE_PART_MAX; index ++)
  131. {
  132. if (device_partition[index].dev == RT_NULL)
  133. break;
  134. }
  135. if (index == DEVICE_PART_MAX)
  136. return -DFS_STATUS_ENOSPC;
  137. mte = rt_malloc(sizeof(struct cyg_mtab_entry));
  138. if (mte == RT_NULL)
  139. return -DFS_STATUS_ENOMEM;
  140. mte->name = fs->path;
  141. mte->fsname = "jffs2";
  142. mte->devname = NULL;
  143. /* note that, i use mte->data to store rtt's device
  144. * while, in jffs2_mount, mte->data will be copy into
  145. * s_dev in struct super_block, and mte->data will be
  146. * filled with jffs2_sb(see the source of jffs2_mount.
  147. */
  148. mte->data = fs->dev_id;
  149. device_partition[index].dev = fs->dev_id;
  150. /* after jffs2_mount, mte->data will not be dev_id any more */
  151. result = jffs2_mount(NULL, mte);
  152. if (result != 0)
  153. {
  154. return jffs2_result_to_dfs(result);
  155. }
  156. /* save this pointer */
  157. device_partition[index].mte = mte;
  158. return 0;
  159. }
  160. static int _find_fs(struct cyg_mtab_entry ** mte, rt_device_t dev_id)
  161. {
  162. unsigned index;
  163. /* find device index */
  164. for (index = 0; index < DEVICE_PART_MAX; index++)
  165. {
  166. if (device_partition[index].dev == dev_id)
  167. {
  168. *mte = device_partition[index].mte;
  169. return 0;
  170. }
  171. }
  172. rt_kprintf("error, could not found the fs!");
  173. return -1;
  174. }
  175. static int dfs_jffs2_unmount(struct dfs_filesystem* fs)
  176. {
  177. int result;
  178. unsigned index;
  179. /* find device index, then umount it */
  180. for (index = 0; index < DEVICE_PART_MAX; index++)
  181. {
  182. if (device_partition[index].dev == fs->dev_id)
  183. {
  184. struct cyg_mtab_entry * mte;
  185. result = jffs2_umount(device_partition[index].mte);
  186. if (result)
  187. return jffs2_result_to_dfs(result);
  188. rt_free(device_partition[index].mte);
  189. device_partition[index].dev = NULL;
  190. device_partition[index].mte = NULL;
  191. return DFS_STATUS_OK;
  192. }
  193. }
  194. return -DFS_STATUS_ENOENT;
  195. }
  196. static int dfs_jffs2_mkfs(const char* device_name)
  197. {
  198. /* just erase all blocks on this nand partition */
  199. return -DFS_STATUS_ENOSYS;
  200. }
  201. static int dfs_jffs2_statfs(struct dfs_filesystem* fs,
  202. struct statfs *buf)
  203. {
  204. /* since the limit of unsigned long, so the max size of flash device is 4G */
  205. struct cyg_mtab_entry * mte;
  206. struct jffs2_fs_info info;
  207. int result;
  208. result = _find_fs(&mte, fs->dev_id);
  209. if (result)
  210. return -DFS_STATUS_ENOENT;
  211. RT_ASSERT(mte->data != NULL);
  212. jffs2_get_info_from_sb(mte->data, &info);
  213. buf->f_bsize = info.sector_size;
  214. buf->f_blocks = info.nr_blocks;
  215. buf->f_bfree = info.free_size; //fixme need test!
  216. // jffs2_sb = (struct super_block)(mte->data);
  217. // c = JFFS2_SB_INFO(jffs2_sb);
  218. //
  219. // buf->f_bsize = c->sector_size;
  220. // buf->f_blocks = c->nr_blocks;
  221. // buf->f_bfree = c->free_size; //fixme need test!
  222. return 0;
  223. }
  224. static const char jffs2_root_path[] = ".";
  225. static int dfs_jffs2_open(struct dfs_fd* file)
  226. {
  227. int oflag, mode;
  228. int result;
  229. cyg_file * jffs2_file;
  230. struct cyg_mtab_entry * mte;
  231. const char * name;
  232. oflag = file->flags;
  233. jffs2_file = rt_malloc(sizeof(cyg_file));
  234. if (jffs2_file == RT_NULL)
  235. return -DFS_STATUS_ENOMEM;
  236. /* just escape '/' provided by dfs code */
  237. name = file->path;
  238. if ((name[0] == '/') && (name[1] == 0))
  239. name = jffs2_root_path;
  240. else /* name[0] still will be '/' */
  241. name ++;
  242. result = _find_fs(&mte, file->fs->dev_id);
  243. if (result)
  244. {
  245. rt_free(jffs2_file);
  246. return -DFS_STATUS_ENOENT;
  247. }
  248. if (oflag & DFS_O_DIRECTORY) /* operations about dir */
  249. {
  250. if (oflag & DFS_O_CREAT) /* create a dir*/
  251. {
  252. /* fixme, should test file->path can end with '/' */
  253. result = jffs2_mkdir(mte, mte->root, name);
  254. if (result)
  255. return jffs2_result_to_dfs(result);
  256. }
  257. /* open dir */
  258. result = jffs2_opendir(mte, mte->root, name, jffs2_file);
  259. if (result)
  260. return jffs2_result_to_dfs(result);
  261. /* save this pointer, it will be used by dfs_jffs2_getdents*/
  262. file->data = jffs2_file;
  263. return 0;
  264. }
  265. /* regular file operations */
  266. mode = 0;
  267. if (oflag & DFS_O_RDONLY) mode |= JFFS2_O_RDONLY;
  268. if (oflag & DFS_O_WRONLY) mode |= JFFS2_O_WRONLY;
  269. if (oflag & DFS_O_RDWR) mode |= JFFS2_O_RDWR;
  270. /* Opens the file, if it is existing. If not, a new file is created. */
  271. if (oflag & DFS_O_CREAT) mode |= JFFS2_O_CREAT;
  272. /* Creates a new file. If the file is existing, it is truncated and overwritten. */
  273. if (oflag & DFS_O_TRUNC) mode |= JFFS2_O_TRUNC;
  274. /* Creates a new file. The function fails if the file is already existing. */
  275. if (oflag & DFS_O_EXCL) mode |= JFFS2_O_EXCL;
  276. // if (oflag & DFS_O_APPEND) mode |= JFFS2_O_APPEND;
  277. result = jffs2_open(mte, 0, name, mode, jffs2_file);
  278. if (result != 0)
  279. {
  280. rt_free(jffs2_file);
  281. return jffs2_result_to_dfs(result);
  282. }
  283. /* save this pointer, it will be used when calling read()£¬write(),
  284. flush(), lessk(), and will be rt_free when calling close()*/
  285. file->data = jffs2_file;
  286. file->pos = jffs2_file->f_offset;
  287. file->size = 0;
  288. jffs2_file_lseek(jffs2_file, &(file->size), SEEK_END);
  289. jffs2_file->f_offset = file->pos;
  290. if (oflag & DFS_O_APPEND)
  291. {
  292. file->pos = file->size;
  293. jffs2_file->f_offset = file->size;
  294. }
  295. return 0;
  296. }
  297. static int dfs_jffs2_close(struct dfs_fd* file)
  298. {
  299. int result;
  300. cyg_file * jffs2_file;
  301. RT_ASSERT(file->data != NULL);
  302. jffs2_file = (cyg_file *)(file->data);
  303. if (file->flags & DFS_O_DIRECTORY) /* operations about dir */
  304. {
  305. result = jffs2_dir_colse(jffs2_file);
  306. if (result)
  307. return jffs2_result_to_dfs(result);
  308. return 0;
  309. }
  310. /* regular file operations */
  311. result = jffs2_file_colse(jffs2_file);
  312. if (result)
  313. return jffs2_result_to_dfs(result);
  314. /* release memory */
  315. rt_free(jffs2_file);
  316. return 0;
  317. }
  318. static int dfs_jffs2_ioctl(struct dfs_fd* file, int cmd, void* args)
  319. {
  320. return -DFS_STATUS_ENOSYS;
  321. }
  322. static int dfs_jffs2_read(struct dfs_fd* file, void* buf, rt_size_t len)
  323. {
  324. cyg_file * jffs2_file;
  325. struct CYG_UIO_TAG uio_s;
  326. struct CYG_IOVEC_TAG iovec;
  327. int char_read;
  328. int result;
  329. RT_ASSERT(file->data != NULL);
  330. jffs2_file = (cyg_file *)(file->data);
  331. uio_s.uio_iov = &iovec;
  332. uio_s.uio_iov->iov_base = buf;
  333. uio_s.uio_iov->iov_len = len;
  334. uio_s.uio_iovcnt = 1; //must be 1
  335. //uio_s.uio_offset //not used...
  336. uio_s.uio_resid = uio_s.uio_iov->iov_len; //seem no use in jffs2;
  337. char_read = jffs2_file->f_offset; /* the current offset */
  338. result = jffs2_file_read(jffs2_file, &uio_s);
  339. if (result)
  340. return jffs2_result_to_dfs(result);
  341. /* update position */
  342. file->pos = jffs2_file->f_offset;
  343. char_read = jffs2_file->f_offset - char_read;
  344. return char_read;
  345. }
  346. static int dfs_jffs2_write(struct dfs_fd* file,
  347. const void* buf,
  348. rt_size_t len)
  349. {
  350. cyg_file * jffs2_file;
  351. struct CYG_UIO_TAG uio_s;
  352. struct CYG_IOVEC_TAG iovec;
  353. int char_write;
  354. int result;
  355. RT_ASSERT(file->data != NULL);
  356. jffs2_file = (cyg_file *)(file->data);
  357. uio_s.uio_iov = &iovec;
  358. uio_s.uio_iov->iov_base = buf;
  359. uio_s.uio_iov->iov_len = len;
  360. uio_s.uio_iovcnt = 1; //must be 1
  361. //uio_s.uio_offset //not used...
  362. uio_s.uio_resid = uio_s.uio_iov->iov_len; //seem no use in jffs2;
  363. char_write = jffs2_file->f_offset;
  364. result = jffs2_file_write(jffs2_file, &uio_s);
  365. if (result)
  366. return jffs2_result_to_dfs(result);
  367. /* update position */
  368. file->pos = jffs2_file->f_offset;
  369. char_write = jffs2_file->f_offset - char_write;
  370. return char_write;
  371. }
  372. static int dfs_jffs2_flush(struct dfs_fd* file)
  373. {
  374. /* infact, jffs2 not support, jffs2_fo_sync just return ok */
  375. return -DFS_STATUS_ENOSYS;
  376. }
  377. /* fixme warning: the offset is rt_off_t, so maybe the size of a file is must <= 2G*/
  378. static int dfs_jffs2_lseek(struct dfs_fd* file,
  379. rt_off_t offset)
  380. {
  381. cyg_file * jffs2_file;
  382. int result;
  383. RT_ASSERT(file->data != NULL);
  384. jffs2_file = (cyg_file *)(file->data);
  385. /* set offset as current offset */
  386. jffs2_file_lseek(jffs2_file, &offset, SEEK_SET);
  387. if (result)
  388. return jffs2_result_to_dfs(result);
  389. return 0;
  390. }
  391. /* return the size of struct dirent*/
  392. static int dfs_jffs2_getdents(struct dfs_fd* file,
  393. struct dirent* dirp,
  394. rt_uint32_t count)
  395. {
  396. cyg_file * jffs2_file;
  397. struct CYG_UIO_TAG uio_s;
  398. struct CYG_IOVEC_TAG iovec;
  399. struct jffs2_dirent jffs2_d;
  400. struct dirent * d;
  401. rt_uint32_t index;
  402. int result;
  403. RT_ASSERT(file->data != RT_NULL);
  404. jffs2_file = (cyg_file*)(file->data);
  405. //set jffs2_d
  406. memset(&jffs2_d, 0, sizeof(struct jffs2_dirent));
  407. //set CYG_UIO_TAG uio_s
  408. uio_s.uio_iov = &iovec;
  409. uio_s.uio_iov->iov_base = &jffs2_d;
  410. uio_s.uio_iov->iov_len = sizeof(struct jffs2_dirent);;
  411. uio_s.uio_iovcnt = 1; //must be 1
  412. uio_s.uio_offset = 0;//not used...
  413. uio_s.uio_resid = uio_s.uio_iov->iov_len; //seem no use in jffs2;
  414. /* make integer count, usually count is 1 */
  415. count = (count / sizeof(struct dirent)) * sizeof(struct dirent);
  416. if (count == 0)
  417. return -DFS_STATUS_EINVAL;
  418. index = 0;
  419. /* usually, the while loop should only be looped only once! */
  420. while (1)
  421. {
  422. d = dirp + index;
  423. result = jffs2_dir_read(jffs2_file, &uio_s);
  424. /* if met a error or all entry are read over, break while*/
  425. if (result || jffs2_d.d_name[0] == 0)
  426. break;
  427. switch(jffs2_d.d_type & JFFS2_S_IFMT)
  428. {
  429. case JFFS2_S_IFREG: d->d_type = DFS_DT_REG; break;
  430. case JFFS2_S_IFDIR: d->d_type = DFS_DT_DIR; break;
  431. default: d->d_type = DFS_DT_UNKNOWN; break;
  432. }
  433. /* write the rest feilds of struct dirent* dirp */
  434. d->d_namlen = rt_strlen(jffs2_d.d_name);
  435. d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
  436. rt_strncpy(d->d_name, jffs2_d.d_name, d->d_namlen + 1);
  437. index ++;
  438. if (index * sizeof(struct dirent) >= count)
  439. break;
  440. }
  441. if (result)
  442. return jffs2_result_to_dfs(result);
  443. return index * sizeof(struct dirent);
  444. }
  445. static int dfs_jffs2_unlink(struct dfs_filesystem* fs, const char* path)
  446. {
  447. int result;
  448. struct jffs2_stat s;
  449. cyg_mtab_entry * mte;
  450. result = _find_fs(&mte, fs->dev_id);
  451. if (result)
  452. return -DFS_STATUS_ENOENT;
  453. /* deal path */
  454. if (path[0] == '/')
  455. path++;
  456. /* judge file type, dir is to be delete by rmdir, others by unlink */
  457. result = jffs2_ops_stat(mte, mte->root, path, &s);
  458. if (result)
  459. return jffs2_result_to_dfs(result);
  460. switch(s.st_mode & JFFS2_S_IFMT)
  461. {
  462. case JFFS2_S_IFREG:
  463. result = jffs2_unlink(mte, mte->root, path);
  464. break;
  465. case JFFS2_S_IFDIR:
  466. result = jffs2_rmdir(mte, mte->root, path);
  467. break;
  468. default:
  469. /* unknown file type */
  470. return -1;
  471. }
  472. if (result)
  473. return jffs2_result_to_dfs(result);
  474. return 0;
  475. }
  476. static int dfs_jffs2_rename(struct dfs_filesystem* fs,
  477. const char* oldpath,
  478. const char* newpath)
  479. {
  480. int result;
  481. cyg_mtab_entry * mte;
  482. result = _find_fs(&mte, fs->dev_id);
  483. if (result)
  484. return -DFS_STATUS_ENOENT;
  485. if (*oldpath == '/')
  486. oldpath += 1;
  487. if (*newpath == '/')
  488. newpath += 1;
  489. result = jffs2_rename(mte, mte->root, oldpath, mte->root, newpath);
  490. if (result)
  491. return jffs2_result_to_dfs(result);
  492. return 0;
  493. }
  494. static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct stat *st)
  495. {
  496. int result;
  497. struct jffs2_stat s;
  498. cyg_mtab_entry * mte;
  499. /* deal the path for jffs2 */
  500. RT_ASSERT(!((path[0] == '/') && (path[1] == 0)));
  501. if (path[0] == '/')
  502. path++;
  503. result = _find_fs(&mte, fs->dev_id);
  504. if (result)
  505. return -DFS_STATUS_ENOENT;
  506. result = jffs2_ops_stat(mte, mte->root, path, &s);
  507. if (result)
  508. return jffs2_result_to_dfs(result);
  509. /* convert to dfs stat structure */
  510. switch(s.st_mode & JFFS2_S_IFMT)
  511. {
  512. case JFFS2_S_IFREG:
  513. st->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH |
  514. DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH;
  515. break;
  516. case JFFS2_S_IFDIR:
  517. st->st_mode = DFS_S_IFDIR | DFS_S_IXUSR | DFS_S_IXGRP | DFS_S_IXOTH;
  518. break;
  519. default:
  520. st->st_mode = DFS_DT_UNKNOWN; //fixme
  521. break;
  522. }
  523. st->st_dev = 0;
  524. st->st_size = s.st_size;
  525. st->st_mtime = s.st_mtime;
  526. /*st->st_blksize = ;*/ //fixme: what's this field?
  527. return 0;
  528. }
  529. static const struct dfs_filesystem_operation dfs_jffs2_ops =
  530. {
  531. "jffs2", /* file system type: jffs2 */
  532. DFS_FS_FLAG_DEFAULT, /* use Relative Path */
  533. dfs_jffs2_mount,
  534. dfs_jffs2_unmount,
  535. dfs_jffs2_mkfs,
  536. dfs_jffs2_statfs,
  537. dfs_jffs2_open,
  538. dfs_jffs2_close,
  539. dfs_jffs2_ioctl,
  540. dfs_jffs2_read,
  541. dfs_jffs2_write,
  542. dfs_jffs2_flush,
  543. dfs_jffs2_lseek,
  544. dfs_jffs2_getdents,
  545. dfs_jffs2_unlink,
  546. dfs_jffs2_stat,
  547. dfs_jffs2_rename,
  548. };
  549. int dfs_jffs2_init(void)
  550. {
  551. /* register fatfs file system */
  552. dfs_register(&dfs_jffs2_ops);
  553. return 0;
  554. }