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.

80 lines
2.4 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 <dirent.h>
  23. #include <stdint.h>
  24. #include <stdio.h>
  25. #include <sys/stat.h>
  26. #include <sys/types.h>
  27. #include <unistd.h>
  28. enum fuse_dirents_type_e
  29. {
  30. UNSET = 0,
  31. NORMAL,
  32. PLUS
  33. };
  34. typedef enum fuse_dirents_type_e fuse_dirents_type_t;
  35. typedef struct fuse_dirents_s fuse_dirents_t;
  36. struct fuse_dirents_s
  37. {
  38. char *buf;
  39. uint64_t buf_len;
  40. uint64_t data_len;
  41. fuse_dirents_type_t type;
  42. };
  43. int fuse_dirents_init(fuse_dirents_t *d);
  44. void fuse_dirents_free(fuse_dirents_t *d);
  45. void fuse_dirents_reset(fuse_dirents_t *d);
  46. int fuse_dirents_add(fuse_dirents_t *d,
  47. const struct dirent *de);
  48. int fuse_dirents_add_plus(fuse_dirents_t *d,
  49. const struct dirent *de,
  50. const fuse_entry_t *entry,
  51. const struct stat *st);
  52. #ifdef __linux__
  53. struct linux_dirent64;
  54. int fuse_dirents_add_linux(fuse_dirents_t *d,
  55. const struct linux_dirent64 *de);
  56. int fuse_dirents_add_linux_plus(fuse_dirents_t *d,
  57. const struct linux_dirent64 *de,
  58. const fuse_entry_t *entry,
  59. const struct stat *st);
  60. #endif
  61. void *fuse_dirents_find(fuse_dirents_t *d,
  62. const uint64_t ino);
  63. int fuse_dirents_convert_plus2normal(fuse_dirents_t *d);
  64. #ifdef __cplusplus
  65. }
  66. #endif