1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2018-2023 Oracle. All Rights Reserved.
6 #ifndef __XFS_SCRUB_XFILE_H__
7 #define __XFS_SCRUB_XFILE_H__
15 static inline bool xfile_page_cached(const struct xfile_page *xfpage)
17 return xfpage->page != NULL;
20 static inline pgoff_t xfile_page_index(const struct xfile_page *xfpage)
22 return xfpage->page->index;
29 int xfile_create(const char *description, loff_t isize, struct xfile **xfilep);
30 void xfile_destroy(struct xfile *xf);
32 ssize_t xfile_pread(struct xfile *xf, void *buf, size_t count, loff_t pos);
33 ssize_t xfile_pwrite(struct xfile *xf, const void *buf, size_t count,
37 * Load an object. Since we're treating this file as "memory", any error or
38 * short IO is treated as a failure to allocate memory.
41 xfile_obj_load(struct xfile *xf, void *buf, size_t count, loff_t pos)
43 ssize_t ret = xfile_pread(xf, buf, count, pos);
45 if (ret < 0 || ret != count)
51 * Store an object. Since we're treating this file as "memory", any error or
52 * short IO is treated as a failure to allocate memory.
55 xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos)
57 ssize_t ret = xfile_pwrite(xf, buf, count, pos);
59 if (ret < 0 || ret != count)
64 loff_t xfile_seek_data(struct xfile *xf, loff_t pos);
68 unsigned long long bytes;
71 int xfile_stat(struct xfile *xf, struct xfile_stat *statbuf);
73 int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len,
74 struct xfile_page *xbuf);
75 int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf);
77 #endif /* __XFS_SCRUB_XFILE_H__ */