dfs_fs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * File : dfs_fs.h
  3. * This file is part of Device File System in RT-Thread RTOS
  4. * COPYRIGHT (C) 2004-2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2005-02-22 Bernard The first version.
  23. */
  24. #ifndef __DFS_FS_H__
  25. #define __DFS_FS_H__
  26. #include <dfs.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Pre-declaration */
  31. struct dfs_filesystem;
  32. struct dfs_fd;
  33. /* File system operations */
  34. struct dfs_filesystem_ops
  35. {
  36. char *name;
  37. uint32_t flags; /* flags for file system operations */
  38. /* operations for file */
  39. const struct dfs_file_ops *fops;
  40. /* mount and unmount file system */
  41. int (*mount) (struct dfs_filesystem *fs, unsigned long rwflag, const void *data);
  42. int (*unmount) (struct dfs_filesystem *fs);
  43. /* make a file system */
  44. int (*mkfs) (rt_device_t devid);
  45. int (*statfs) (struct dfs_filesystem *fs, struct statfs *buf);
  46. int (*unlink) (struct dfs_filesystem *fs, const char *pathname);
  47. int (*stat) (struct dfs_filesystem *fs, const char *filename, struct stat *buf);
  48. int (*rename) (struct dfs_filesystem *fs, const char *oldpath, const char *newpath);
  49. };
  50. /* Mounted file system */
  51. struct dfs_filesystem
  52. {
  53. rt_device_t dev_id; /* Attached device */
  54. char *path; /* File system mount point */
  55. const struct dfs_filesystem_ops *ops; /* Operations for file system type */
  56. void *data; /* Specific file system data */
  57. };
  58. /* file system partition table */
  59. struct dfs_partition
  60. {
  61. uint8_t type; /* file system type */
  62. off_t offset; /* partition start offset */
  63. size_t size; /* partition size */
  64. rt_sem_t lock;
  65. };
  66. /* mount table */
  67. struct dfs_mount_tbl
  68. {
  69. const char *device_name;
  70. const char *path;
  71. const char *filesystemtype;
  72. unsigned long rwflag;
  73. const void *data;
  74. };
  75. int dfs_register(const struct dfs_filesystem_ops *ops);
  76. struct dfs_filesystem *dfs_filesystem_lookup(const char *path);
  77. const char* dfs_filesystem_get_mounted_path(struct rt_device* device);
  78. int dfs_filesystem_get_partition(struct dfs_partition *part,
  79. uint8_t *buf,
  80. uint32_t pindex);
  81. int dfs_mount(const char *device_name,
  82. const char *path,
  83. const char *filesystemtype,
  84. unsigned long rwflag,
  85. const void *data);
  86. int dfs_unmount(const char *specialfile);
  87. int dfs_mkfs(const char *fs_name, const char *device_name);
  88. int dfs_statfs(const char *path, struct statfs *buffer);
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif