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. #include "extern_c.h"
  17. EXTERN_C_BEGIN
  18. #include "kvec.h"
  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. kvec_t(uint32_t) offs;
  43. fuse_dirents_type_t type;
  44. };
  45. int fuse_dirents_init(fuse_dirents_t *d);
  46. void fuse_dirents_free(fuse_dirents_t *d);
  47. void fuse_dirents_reset(fuse_dirents_t *d);
  48. int fuse_dirents_add(fuse_dirents_t *d,
  49. const struct dirent *de,
  50. const uint64_t namelen);
  51. int fuse_dirents_add_plus(fuse_dirents_t *d,
  52. const struct dirent *de,
  53. const uint64_t namelen,
  54. const fuse_entry_t *entry,
  55. const struct stat *st);
  56. int fuse_dirents_add_linux(fuse_dirents_t *d,
  57. const struct linux_dirent64 *de,
  58. const uint64_t namelen);
  59. int fuse_dirents_add_linux_plus(fuse_dirents_t *d,
  60. const struct linux_dirent64 *de,
  61. const uint64_t namelen,
  62. const fuse_entry_t *entry,
  63. const struct stat *st);
  64. void *fuse_dirents_find(fuse_dirents_t *d,
  65. const uint64_t ino);
  66. int fuse_dirents_convert_plus2normal(fuse_dirents_t *d);
  67. EXTERN_C_END