xfblob.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) 2021-2024 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <djwong@kernel.org>
  5. */
  6. #ifndef __XFS_SCRUB_XFBLOB_H__
  7. #define __XFS_SCRUB_XFBLOB_H__
  8. struct xfblob {
  9. struct xfile *xfile;
  10. loff_t last_offset;
  11. };
  12. typedef loff_t xfblob_cookie;
  13. int xfblob_create(const char *descr, struct xfblob **blobp);
  14. void xfblob_destroy(struct xfblob *blob);
  15. int xfblob_load(struct xfblob *blob, xfblob_cookie cookie, void *ptr,
  16. uint32_t size);
  17. int xfblob_store(struct xfblob *blob, xfblob_cookie *cookie, const void *ptr,
  18. uint32_t size);
  19. int xfblob_free(struct xfblob *blob, xfblob_cookie cookie);
  20. unsigned long long xfblob_bytes(struct xfblob *blob);
  21. void xfblob_truncate(struct xfblob *blob);
  22. static inline int
  23. xfblob_storename(
  24. struct xfblob *blob,
  25. xfblob_cookie *cookie,
  26. const struct xfs_name *xname)
  27. {
  28. return xfblob_store(blob, cookie, xname->name, xname->len);
  29. }
  30. static inline int
  31. xfblob_loadname(
  32. struct xfblob *blob,
  33. xfblob_cookie cookie,
  34. struct xfs_name *xname,
  35. uint32_t size)
  36. {
  37. int ret = xfblob_load(blob, cookie, (void *)xname->name, size);
  38. if (ret)
  39. return ret;
  40. xname->len = size;
  41. return 0;
  42. }
  43. #endif /* __XFS_SCRUB_XFBLOB_H__ */