You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.6 KiB

  1. /*
  2. ISC License
  3. Copyright (c) 2019, Antonio SJ Musumeci <trapexit@spawn.link>
  4. Permission to use, copy, modify, and/or distribute this software for any
  5. purpose with or without fee is hereby granted, provided that the above
  6. copyright notice and this permission notice appear in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. */
  15. #pragma once
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #include "fuse_dirent.h"
  20. #include "fuse_direntplus.h"
  21. #include "fuse_entry.h"
  22. #include "linux_dirent64.h"
  23. #include <dirent.h>
  24. #include <stdint.h>
  25. #include <stdio.h>
  26. #include <sys/stat.h>
  27. #include <sys/types.h>
  28. #include <unistd.h>
  29. enum fuse_dirents_type_e
  30. {
  31. UNSET = 0,
  32. NORMAL,
  33. PLUS
  34. };
  35. typedef enum fuse_dirents_type_e fuse_dirents_type_t;
  36. typedef struct fuse_dirents_s fuse_dirents_t;
  37. struct fuse_dirents_s
  38. {
  39. char *buf;
  40. uint64_t buf_len;
  41. uint64_t data_len;
  42. fuse_dirents_type_t type;
  43. };
  44. int fuse_dirents_init(fuse_dirents_t *d);
  45. void fuse_dirents_free(fuse_dirents_t *d);
  46. void fuse_dirents_reset(fuse_dirents_t *d);
  47. int fuse_dirents_add(fuse_dirents_t *d,
  48. const struct dirent *de,
  49. const uint64_t namelen);
  50. int fuse_dirents_add_plus(fuse_dirents_t *d,
  51. const struct dirent *de,
  52. const uint64_t namelen,
  53. const fuse_entry_t *entry,
  54. const struct stat *st);
  55. int fuse_dirents_add_linux(fuse_dirents_t *d,
  56. const struct linux_dirent64 *de,
  57. const uint64_t namelen);
  58. int fuse_dirents_add_linux_plus(fuse_dirents_t *d,
  59. const struct linux_dirent64 *de,
  60. const uint64_t namelen,
  61. const fuse_entry_t *entry,
  62. const struct stat *st);
  63. void *fuse_dirents_find(fuse_dirents_t *d,
  64. const uint64_t ino);
  65. int fuse_dirents_convert_plus2normal(fuse_dirents_t *d);
  66. #ifdef __cplusplus
  67. }
  68. #endif