dfs_tmpfs.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-10-24 flybreak the first version
  9. * 2023-02-01 xqyjlj fix cannot open the same file repeatedly in 'w' mode
  10. */
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include <dfs.h>
  14. #include <dfs_fs.h>
  15. #include <dfs_dentry.h>
  16. #include <dfs_file.h>
  17. #include <dfs_mnt.h>
  18. #ifdef RT_USING_SMART
  19. #include <lwp.h>
  20. #include <lwp_user_mm.h>
  21. #endif
  22. #include "dfs_tmpfs.h"
  23. #define DBG_TAG "tmpfs"
  24. #define DBG_LVL DBG_INFO
  25. #include <rtdbg.h>
  26. static int _path_separate(const char *path, char *parent_path, char *file_name)
  27. {
  28. const char *path_p, *path_q;
  29. RT_ASSERT(path[0] == '/');
  30. file_name[0] = '\0';
  31. path_p = path_q = &path[1];
  32. __next_dir:
  33. while (*path_q != '/' && *path_q != '\0')
  34. {
  35. path_q++;
  36. }
  37. if (path_q != path_p) /*sub dir*/
  38. {
  39. if (*path_q != '\0')
  40. {
  41. path_q++;
  42. path_p = path_q;
  43. goto __next_dir;
  44. }
  45. else /* Last level dir */
  46. {
  47. rt_memcpy(parent_path, path, path_p - path - 1);
  48. parent_path[path_p - path - 1] = '\0';
  49. rt_memcpy(file_name, path_p, path_q - path_p);
  50. file_name[path_q - path_p] = '\0';
  51. }
  52. }
  53. if (parent_path[0] == 0)
  54. {
  55. parent_path[0] = '/';
  56. parent_path[1] = '\0';
  57. }
  58. LOG_D("parent_path: %s", parent_path);
  59. LOG_D("file_name: %s", file_name);
  60. return 0;
  61. }
  62. static int _get_subdir(const char *path, char *name)
  63. {
  64. const char *subpath = path;
  65. while (*subpath == '/' && *subpath)
  66. subpath ++;
  67. while (*subpath != '/' && *subpath)
  68. {
  69. *name = *subpath;
  70. name ++;
  71. subpath ++;
  72. }
  73. return 0;
  74. }
  75. static int _free_subdir(struct tmpfs_file *dfile)
  76. {
  77. struct tmpfs_file *file;
  78. rt_list_t *list, *temp_list;
  79. struct tmpfs_sb *superblock;
  80. RT_ASSERT(dfile->type == TMPFS_TYPE_DIR);
  81. rt_list_for_each_safe(list, temp_list, &dfile->subdirs)
  82. {
  83. file = rt_list_entry(list, struct tmpfs_file, sibling);
  84. if (file->type == TMPFS_TYPE_DIR)
  85. {
  86. _free_subdir(file);
  87. }
  88. if (file->data != NULL)
  89. {
  90. /* TODO: fix for rt-smart */
  91. rt_free(file->data);
  92. }
  93. superblock = file->sb;
  94. RT_ASSERT(superblock != NULL);
  95. rt_spin_lock(&superblock->lock);
  96. rt_list_remove(&(file->sibling));
  97. rt_spin_unlock(&superblock->lock);
  98. rt_free(file);
  99. }
  100. return 0;
  101. }
  102. static int dfs_tmpfs_mount(struct dfs_mnt *mnt,
  103. unsigned long rwflag,
  104. const void *data)
  105. {
  106. struct tmpfs_sb *superblock;
  107. superblock = rt_calloc(1, sizeof(struct tmpfs_sb));
  108. if (superblock)
  109. {
  110. superblock->df_size = sizeof(struct tmpfs_sb);
  111. superblock->magic = TMPFS_MAGIC;
  112. rt_list_init(&superblock->sibling);
  113. superblock->root.name[0] = '/';
  114. superblock->root.sb = superblock;
  115. superblock->root.type = TMPFS_TYPE_DIR;
  116. rt_list_init(&superblock->root.sibling);
  117. rt_list_init(&superblock->root.subdirs);
  118. rt_spin_lock_init(&superblock->lock);
  119. mnt->data = superblock;
  120. }
  121. else
  122. {
  123. return -1;
  124. }
  125. return RT_EOK;
  126. }
  127. static int dfs_tmpfs_unmount(struct dfs_mnt *mnt)
  128. {
  129. struct tmpfs_sb *superblock;
  130. /* FIXME: don't unmount on busy. */
  131. superblock = (struct tmpfs_sb *)mnt->data;
  132. RT_ASSERT(superblock != NULL);
  133. mnt->data = NULL;
  134. _free_subdir(&(superblock->root));
  135. rt_free(superblock);
  136. return RT_EOK;
  137. }
  138. int dfs_tmpfs_statfs(struct dfs_mnt *mnt, struct statfs *buf)
  139. {
  140. struct tmpfs_sb *superblock;
  141. superblock = (struct tmpfs_sb *)mnt->data;
  142. RT_ASSERT(superblock != NULL);
  143. RT_ASSERT(buf != NULL);
  144. buf->f_bsize = 512;
  145. buf->f_blocks = (superblock->df_size + 511) / 512;
  146. buf->f_bfree = 1;
  147. buf->f_bavail = buf->f_bfree;
  148. return RT_EOK;
  149. }
  150. int dfs_tmpfs_ioctl(struct dfs_file *file, int cmd, void *args)
  151. {
  152. struct tmpfs_file *d_file;
  153. struct tmpfs_sb *superblock;
  154. d_file = (struct tmpfs_file *)file->vnode->data;
  155. RT_ASSERT(d_file != NULL);
  156. superblock = d_file->sb;
  157. RT_ASSERT(superblock != NULL);
  158. switch (cmd)
  159. {
  160. #ifdef RT_USING_SMART
  161. case RT_FIOMMAP2:
  162. {
  163. struct dfs_mmap2_args *mmap2 = (struct dfs_mmap2_args *)args;
  164. if (mmap2)
  165. {
  166. if (mmap2->length > file->vnode->size)
  167. {
  168. return -RT_ENOMEM;
  169. }
  170. LOG_D("tmpfile mmap ptr:%x , size:%d\n", d_file->data, mmap2->length);
  171. mmap2->ret = lwp_map_user_phy(lwp_self(), RT_NULL, d_file->data, mmap2->length, 0);
  172. }
  173. return RT_EOK;
  174. break;
  175. }
  176. #endif
  177. default:
  178. break;
  179. }
  180. return -EIO;
  181. }
  182. struct tmpfs_file *dfs_tmpfs_lookup(struct tmpfs_sb *superblock,
  183. const char *path,
  184. rt_size_t *size)
  185. {
  186. const char *subpath, *curpath, *filename = RT_NULL;
  187. char subdir_name[TMPFS_NAME_MAX];
  188. struct tmpfs_file *file, *curfile;
  189. rt_list_t *list;
  190. subpath = path;
  191. while (*subpath == '/' && *subpath)
  192. subpath ++;
  193. if (! *subpath) /* is root directory */
  194. {
  195. *size = 0;
  196. return &(superblock->root);
  197. }
  198. curpath = subpath;
  199. curfile = &superblock->root;
  200. find_subpath:
  201. while (*subpath != '/' && *subpath)
  202. subpath ++;
  203. if (! *subpath) /* is last directory */
  204. filename = curpath;
  205. else
  206. subpath ++; /* skip '/' */
  207. memset(subdir_name, 0, TMPFS_NAME_MAX);
  208. _get_subdir(curpath, subdir_name);
  209. rt_spin_lock(&superblock->lock);
  210. rt_list_for_each(list, &curfile->subdirs)
  211. {
  212. file = rt_list_entry(list, struct tmpfs_file, sibling);
  213. if (filename) /* find file */
  214. {
  215. if (rt_strcmp(file->name, filename) == 0)
  216. {
  217. *size = file->size;
  218. rt_spin_unlock(&superblock->lock);
  219. return file;
  220. }
  221. }
  222. else if (rt_strcmp(file->name, subdir_name) == 0)
  223. {
  224. *size = file->size;
  225. curpath = subpath;
  226. curfile = file;
  227. rt_spin_unlock(&superblock->lock);
  228. goto find_subpath;
  229. }
  230. }
  231. rt_spin_unlock(&superblock->lock);
  232. /* not found */
  233. return NULL;
  234. }
  235. static ssize_t dfs_tmpfs_read(struct dfs_file *file, void *buf, size_t count, off_t *pos)
  236. {
  237. rt_size_t length;
  238. struct tmpfs_file *d_file;
  239. d_file = (struct tmpfs_file *)file->vnode->data;
  240. RT_ASSERT(d_file != NULL);
  241. if (count < file->vnode->size - *pos)
  242. length = count;
  243. else
  244. length = file->vnode->size - *pos;
  245. if (length > 0)
  246. memcpy(buf, &(d_file->data[*pos]), length);
  247. /* update file current position */
  248. *pos += length;
  249. return length;
  250. }
  251. static ssize_t dfs_tmpfs_write(struct dfs_file *file, const void *buf, size_t count, off_t *pos)
  252. {
  253. struct tmpfs_file *d_file;
  254. struct tmpfs_sb *superblock;
  255. d_file = (struct tmpfs_file *)file->vnode->data;
  256. RT_ASSERT(d_file != NULL);
  257. superblock = d_file->sb;
  258. RT_ASSERT(superblock != NULL);
  259. if (count + *pos > file->vnode->size)
  260. {
  261. rt_uint8_t *ptr;
  262. ptr = rt_realloc(d_file->data, *pos + count);
  263. if (ptr == NULL)
  264. {
  265. rt_set_errno(-ENOMEM);
  266. return 0;
  267. }
  268. rt_spin_lock(&superblock->lock);
  269. superblock->df_size += (*pos - d_file->size + count);
  270. rt_spin_unlock(&superblock->lock);
  271. /* update d_file and file size */
  272. d_file->data = ptr;
  273. d_file->size = *pos + count;
  274. file->vnode->size = d_file->size;
  275. LOG_D("tmpfile ptr:%x, size:%d", ptr, d_file->size);
  276. }
  277. if (count > 0)
  278. memcpy(d_file->data + *pos, buf, count);
  279. /* update file current position */
  280. *pos += count;
  281. return count;
  282. }
  283. static off_t dfs_tmpfs_lseek(struct dfs_file *file, off_t offset, int wherece)
  284. {
  285. switch (wherece)
  286. {
  287. case SEEK_SET:
  288. break;
  289. case SEEK_CUR:
  290. offset += file->fpos;
  291. break;
  292. case SEEK_END:
  293. offset += file->vnode->size;
  294. break;
  295. default:
  296. return -EINVAL;
  297. }
  298. if (offset <= (off_t)file->vnode->size)
  299. {
  300. return offset;
  301. }
  302. return -EIO;
  303. }
  304. static int dfs_tmpfs_close(struct dfs_file *file)
  305. {
  306. RT_ASSERT(file->vnode->ref_count > 0);
  307. return RT_EOK;
  308. }
  309. static int dfs_tmpfs_open(struct dfs_file *file)
  310. {
  311. struct tmpfs_file *d_file;
  312. d_file = (struct tmpfs_file *)file->vnode->data;
  313. RT_ASSERT(d_file != RT_NULL);
  314. /* Creates a new file.
  315. * If the file is existing, it is truncated and overwritten.
  316. */
  317. if (file->flags & O_TRUNC)
  318. {
  319. d_file->size = 0;
  320. file->vnode->size = d_file->size;
  321. file->fpos = file->vnode->size;
  322. if (d_file->data != NULL)
  323. {
  324. /* ToDo: fix for rt-smart. */
  325. rt_free(d_file->data);
  326. d_file->data = NULL;
  327. }
  328. }
  329. if (file->flags & O_APPEND)
  330. {
  331. file->fpos = file->vnode->size;
  332. }
  333. else
  334. {
  335. file->fpos = 0;
  336. }
  337. return 0;
  338. }
  339. static int dfs_tmpfs_stat(struct dfs_dentry *dentry, struct stat *st)
  340. {
  341. rt_size_t size;
  342. struct tmpfs_file *d_file;
  343. struct tmpfs_sb *superblock;
  344. superblock = (struct tmpfs_sb *)dentry->mnt->data;
  345. d_file = dfs_tmpfs_lookup(superblock, dentry->pathname, &size);
  346. if (d_file == NULL)
  347. return -ENOENT;
  348. st->st_dev = (dev_t)(size_t)(dentry->mnt->dev_id);
  349. st->st_ino = (ino_t)dfs_dentry_full_path_crc32(dentry);
  350. st->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH |
  351. S_IWUSR | S_IWGRP | S_IWOTH;
  352. if (d_file->type == TMPFS_TYPE_DIR)
  353. {
  354. st->st_mode &= ~S_IFREG;
  355. st->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
  356. }
  357. st->st_size = d_file->size;
  358. st->st_mtime = 0;
  359. return RT_EOK;
  360. }
  361. static int dfs_tmpfs_getdents(struct dfs_file *file,
  362. struct dirent *dirp,
  363. uint32_t count)
  364. {
  365. rt_size_t index, end;
  366. struct dirent *d;
  367. struct tmpfs_file *d_file, *n_file;
  368. rt_list_t *list;
  369. struct tmpfs_sb *superblock;
  370. d_file = (struct tmpfs_file *)file->vnode->data;
  371. superblock = d_file->sb;
  372. RT_ASSERT(superblock != RT_NULL);
  373. /* make integer count */
  374. count = (count / sizeof(struct dirent));
  375. if (count == 0)
  376. return -EINVAL;
  377. end = file->fpos + count;
  378. index = 0;
  379. count = 0;
  380. rt_list_for_each(list, &d_file->subdirs)
  381. {
  382. n_file = rt_list_entry(list, struct tmpfs_file, sibling);
  383. if (index >= (rt_size_t)file->fpos)
  384. {
  385. d = dirp + count;
  386. if (d_file->type == TMPFS_TYPE_FILE)
  387. {
  388. d->d_type = DT_REG;
  389. }
  390. if (d_file->type == TMPFS_TYPE_DIR)
  391. {
  392. d->d_type = DT_DIR;
  393. }
  394. d->d_namlen = RT_NAME_MAX;
  395. d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
  396. rt_strncpy(d->d_name, n_file->name, TMPFS_NAME_MAX);
  397. count += 1;
  398. file->fpos += 1;
  399. }
  400. index += 1;
  401. if (index >= end)
  402. {
  403. break;
  404. }
  405. }
  406. return count * sizeof(struct dirent);
  407. }
  408. static int dfs_tmpfs_unlink(struct dfs_dentry *dentry)
  409. {
  410. rt_size_t size;
  411. struct tmpfs_sb *superblock;
  412. struct tmpfs_file *d_file;
  413. superblock = (struct tmpfs_sb *)dentry->mnt->data;
  414. RT_ASSERT(superblock != NULL);
  415. d_file = dfs_tmpfs_lookup(superblock, dentry->pathname, &size);
  416. if (d_file == NULL)
  417. return -ENOENT;
  418. rt_spin_lock(&superblock->lock);
  419. rt_list_remove(&(d_file->sibling));
  420. rt_spin_unlock(&superblock->lock);
  421. if (d_file->data != NULL)
  422. rt_free(d_file->data);
  423. rt_free(d_file);
  424. return RT_EOK;
  425. }
  426. static int dfs_tmpfs_rename(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentry)
  427. {
  428. struct tmpfs_file *d_file, *p_file;
  429. struct tmpfs_sb *superblock;
  430. rt_size_t size;
  431. char parent_path[DFS_PATH_MAX], file_name[TMPFS_NAME_MAX];
  432. superblock = (struct tmpfs_sb *)old_dentry->mnt->data;
  433. RT_ASSERT(superblock != NULL);
  434. d_file = dfs_tmpfs_lookup(superblock, new_dentry->pathname, &size);
  435. if (d_file != NULL)
  436. return -EEXIST;
  437. d_file = dfs_tmpfs_lookup(superblock, old_dentry->pathname, &size);
  438. if (d_file == NULL)
  439. return -ENOENT;
  440. /* find parent file */
  441. _path_separate(new_dentry->pathname, parent_path, file_name);
  442. if (file_name[0] == '\0') /* it's root dir */
  443. return -ENOENT;
  444. /* open parent directory */
  445. p_file = dfs_tmpfs_lookup(superblock, parent_path, &size);
  446. RT_ASSERT(p_file != NULL);
  447. rt_spin_lock(&superblock->lock);
  448. rt_list_remove(&(d_file->sibling));
  449. rt_spin_unlock(&superblock->lock);
  450. strncpy(d_file->name, file_name, TMPFS_NAME_MAX);
  451. rt_spin_lock(&superblock->lock);
  452. rt_list_insert_after(&(p_file->subdirs), &(d_file->sibling));
  453. rt_spin_unlock(&superblock->lock);
  454. return RT_EOK;
  455. }
  456. static struct dfs_vnode *_dfs_tmpfs_lookup(struct dfs_dentry *dentry)
  457. {
  458. struct dfs_vnode *vnode = RT_NULL;
  459. rt_size_t size;
  460. struct tmpfs_sb *superblock;
  461. struct tmpfs_file *d_file;
  462. if (dentry == NULL || dentry->mnt == NULL || dentry->mnt->data == NULL)
  463. {
  464. return NULL;
  465. }
  466. superblock = (struct tmpfs_sb *)dentry->mnt->data;
  467. d_file = dfs_tmpfs_lookup(superblock, dentry->pathname, &size);
  468. if (d_file)
  469. {
  470. vnode = dfs_vnode_create();
  471. if (vnode)
  472. {
  473. if (d_file->type == TMPFS_TYPE_DIR)
  474. {
  475. vnode->mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;
  476. vnode->type = FT_DIRECTORY;
  477. }
  478. else
  479. {
  480. vnode->mode = S_IFREG | S_IRUSR | S_IWUSR | S_IXUSR;
  481. vnode->type = FT_REGULAR;
  482. }
  483. vnode->mnt = dentry->mnt;
  484. vnode->data = d_file;
  485. vnode->size = d_file->size;
  486. }
  487. }
  488. return vnode;
  489. }
  490. static struct dfs_vnode *dfs_tmpfs_create_vnode(struct dfs_dentry *dentry, int type, mode_t mode)
  491. {
  492. struct dfs_vnode *vnode = RT_NULL;
  493. rt_size_t size;
  494. struct tmpfs_sb *superblock;
  495. struct tmpfs_file *d_file, *p_file;
  496. char parent_path[DFS_PATH_MAX], file_name[TMPFS_NAME_MAX];
  497. if (dentry == NULL || dentry->mnt == NULL || dentry->mnt->data == NULL)
  498. {
  499. return NULL;
  500. }
  501. superblock = (struct tmpfs_sb *)dentry->mnt->data;
  502. RT_ASSERT(superblock != NULL);
  503. vnode = dfs_vnode_create();
  504. if (vnode)
  505. {
  506. /* find parent file */
  507. _path_separate(dentry->pathname, parent_path, file_name);
  508. if (file_name[0] == '\0') /* it's root dir */
  509. {
  510. dfs_vnode_destroy(vnode);
  511. return NULL;
  512. }
  513. /* open parent directory */
  514. p_file = dfs_tmpfs_lookup(superblock, parent_path, &size);
  515. if (p_file == NULL)
  516. {
  517. dfs_vnode_destroy(vnode);
  518. return NULL;
  519. }
  520. /* create a file entry */
  521. d_file = (struct tmpfs_file *)rt_calloc(1, sizeof(struct tmpfs_file));
  522. if (d_file == NULL)
  523. {
  524. dfs_vnode_destroy(vnode);
  525. return NULL;
  526. }
  527. superblock->df_size += sizeof(struct tmpfs_file);
  528. strncpy(d_file->name, file_name, TMPFS_NAME_MAX);
  529. rt_list_init(&(d_file->subdirs));
  530. rt_list_init(&(d_file->sibling));
  531. d_file->data = NULL;
  532. d_file->size = 0;
  533. d_file->sb = superblock;
  534. if (type == FT_DIRECTORY)
  535. {
  536. d_file->type = TMPFS_TYPE_DIR;
  537. vnode->mode = S_IFDIR | mode;
  538. vnode->type = FT_DIRECTORY;
  539. }
  540. else
  541. {
  542. d_file->type = TMPFS_TYPE_FILE;
  543. vnode->mode = S_IFREG | mode;
  544. vnode->type = FT_REGULAR;
  545. }
  546. rt_spin_lock(&superblock->lock);
  547. rt_list_insert_after(&(p_file->subdirs), &(d_file->sibling));
  548. rt_spin_unlock(&superblock->lock);
  549. vnode->mnt = dentry->mnt;
  550. vnode->data = d_file;
  551. vnode->size = d_file->size;
  552. }
  553. return vnode;
  554. }
  555. static int dfs_tmpfs_free_vnode(struct dfs_vnode *vnode)
  556. {
  557. /* nothing to be freed */
  558. if (vnode && vnode->ref_count <= 1)
  559. {
  560. vnode->data = NULL;
  561. }
  562. return 0;
  563. }
  564. static const struct dfs_file_ops _tmp_fops =
  565. {
  566. .open = dfs_tmpfs_open,
  567. .close = dfs_tmpfs_close,
  568. .ioctl = dfs_tmpfs_ioctl,
  569. .read = dfs_tmpfs_read,
  570. .write = dfs_tmpfs_write,
  571. .lseek = dfs_tmpfs_lseek,
  572. .getdents = dfs_tmpfs_getdents,
  573. };
  574. static const struct dfs_filesystem_ops _tmpfs_ops =
  575. {
  576. .name = "tmp",
  577. .flags = DFS_FS_FLAG_DEFAULT,
  578. .default_fops = &_tmp_fops,
  579. .mount = dfs_tmpfs_mount,
  580. .umount = dfs_tmpfs_unmount,
  581. .statfs = dfs_tmpfs_statfs,
  582. .unlink = dfs_tmpfs_unlink,
  583. .stat = dfs_tmpfs_stat,
  584. .rename = dfs_tmpfs_rename,
  585. .lookup = _dfs_tmpfs_lookup,
  586. .create_vnode = dfs_tmpfs_create_vnode,
  587. .free_vnode = dfs_tmpfs_free_vnode
  588. };
  589. static struct dfs_filesystem_type _tmpfs =
  590. {
  591. .fs_ops = &_tmpfs_ops,
  592. };
  593. int dfs_tmpfs_init(void)
  594. {
  595. /* register tmp file system */
  596. dfs_register(&_tmpfs);
  597. return 0;
  598. }
  599. INIT_COMPONENT_EXPORT(dfs_tmpfs_init);