vfs_ops.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _VFS_OPS_H_
  13. #define _VFS_OPS_H_
  14. #include <sys/stat.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define VFS_PREFIX_MAX (15)
  19. #define VFS_NEED_REAL_PATH (0x0001)
  20. typedef struct
  21. {
  22. int flags;
  23. int (*umount)(void *fs);
  24. int (*remount)(void *fs, unsigned flags);
  25. int (*open)(void *fs, const char *path, int flags, int /*mode_t*/ mode);
  26. int (*close)(void *fs, int fd);
  27. ssize_t (*read)(void *fs, int fd, void *dst, size_t size);
  28. ssize_t (*write)(void *fs, int fd, const void *data, size_t size);
  29. long /*off_t*/ (*lseek)(void *fs, int fd, long /*off_t*/ offset, int mode);
  30. int (*fstat)(void *fs, int fd, struct stat *st);
  31. int (*stat)(void *fs, const char *path, struct stat *st);
  32. int (*truncate)(void *fs, const char *path, long length);
  33. int (*ftruncate)(void *fs, int fd, long length);
  34. int (*unlink)(void *fs, const char *path);
  35. int (*rename)(void *fs, const char *src, const char *dst);
  36. DIR *(*opendir)(void *fs, const char *name);
  37. struct dirent *(*readdir)(void *fs, DIR *pdir);
  38. int (*readdir_r)(void *fs, DIR *pdir, struct dirent *entry, struct dirent **out_dirent);
  39. long (*telldir)(void *fs, DIR *pdir);
  40. void (*seekdir)(void *fs, DIR *pdir, long loc);
  41. int (*closedir)(void *fs, DIR *pdir);
  42. int (*mkdir)(void *fs, const char *name, int /*mode_t*/ mode);
  43. int (*rmdir)(void *fs, const char *name);
  44. int (*fsync)(void *fs, int fd);
  45. int (*statvfs)(void *fs, struct statvfs *buf);
  46. int (*sfile_init)(void *fs, const char *path);
  47. ssize_t (*sfile_read)(void *fs, const char *path, void *dst, size_t size);
  48. ssize_t (*sfile_write)(void *fs, const char *path, const void *data, size_t size);
  49. ssize_t (*sfile_size)(void *fs, const char *path);
  50. ssize_t (*file_write)(void *fs, const char *path, const void *data, size_t size);
  51. } vfs_ops_t;
  52. int vfs_register(const char *base_path, const vfs_ops_t *ops, void *fs);
  53. int vfs_unregister(const char *base_path);
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif // H