storagedir.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_STORAGEDIR_H
  4. #define TOR_STORAGEDIR_H
  5. typedef struct storage_dir_t storage_dir_t;
  6. struct config_line_t;
  7. struct sandbox_cfg_elem;
  8. storage_dir_t * storage_dir_new(const char *dirname, int n_files);
  9. void storage_dir_free(storage_dir_t *d);
  10. int storage_dir_register_with_sandbox(storage_dir_t *d,
  11. struct sandbox_cfg_elem **cfg);
  12. const smartlist_t *storage_dir_list(storage_dir_t *d);
  13. uint64_t storage_dir_get_usage(storage_dir_t *d);
  14. tor_mmap_t *storage_dir_map(storage_dir_t *d, const char *fname);
  15. uint8_t *storage_dir_read(storage_dir_t *d, const char *fname, int bin,
  16. size_t *sz_out);
  17. int storage_dir_save_bytes_to_file(storage_dir_t *d,
  18. const uint8_t *data,
  19. size_t length,
  20. int binary,
  21. char **fname_out);
  22. int storage_dir_save_string_to_file(storage_dir_t *d,
  23. const char *data,
  24. int binary,
  25. char **fname_out);
  26. int storage_dir_save_labeled_to_file(storage_dir_t *d,
  27. const struct config_line_t *labels,
  28. const uint8_t *data,
  29. size_t length,
  30. char **fname_out);
  31. tor_mmap_t *storage_dir_map_labeled(storage_dir_t *dir,
  32. const char *fname,
  33. struct config_line_t **labels_out,
  34. const uint8_t **data_out,
  35. size_t *size_out);
  36. uint8_t *storage_dir_read_labeled(storage_dir_t *d, const char *fname,
  37. struct config_line_t **labels_out,
  38. size_t *sz_out);
  39. void storage_dir_remove_file(storage_dir_t *d,
  40. const char *fname);
  41. int storage_dir_shrink(storage_dir_t *d,
  42. uint64_t target_size,
  43. int min_to_remove);
  44. int storage_dir_remove_all(storage_dir_t *d);
  45. int storage_dir_get_max_files(storage_dir_t *d);
  46. #endif /* !defined(TOR_STORAGEDIR_H) */