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.

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