5 * Phillip Lougher <phillip@squashfs.org.uk>
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level squashfsory.
11 struct squashfs_page_actor
{
17 void (*release_pages
)(struct page
**, int, int);
20 extern struct squashfs_page_actor
*squashfs_page_actor_init(struct page
**,
21 int, int, void (*)(struct page
**, int, int));
22 extern void squashfs_page_actor_free(struct squashfs_page_actor
*, int);
24 extern void squashfs_actor_to_buf(struct squashfs_page_actor
*, void *, int);
25 extern void squashfs_buf_to_actor(void *, struct squashfs_page_actor
*, int);
26 extern void squashfs_bh_to_actor(struct buffer_head
**, int,
27 struct squashfs_page_actor
*, int, int, int);
28 extern void squashfs_bh_to_buf(struct buffer_head
**, int, void *, int, int,
32 * Calling code should avoid sleeping between calls to squashfs_first_page()
33 * and squashfs_finish_page().
35 static inline void *squashfs_first_page(struct squashfs_page_actor
*actor
)
38 return actor
->pageaddr
= actor
->page
[0] ? kmap_atomic(actor
->page
[0])
42 static inline void *squashfs_next_page(struct squashfs_page_actor
*actor
)
44 if (!IS_ERR_OR_NULL(actor
->pageaddr
))
45 kunmap_atomic(actor
->pageaddr
);
47 if (actor
->next_page
== actor
->pages
)
48 return actor
->pageaddr
= ERR_PTR(-ENODATA
);
50 actor
->pageaddr
= actor
->page
[actor
->next_page
] ?
51 kmap_atomic(actor
->page
[actor
->next_page
]) : NULL
;
53 return actor
->pageaddr
;
56 static inline void squashfs_finish_page(struct squashfs_page_actor
*actor
)
58 if (!IS_ERR_OR_NULL(actor
->pageaddr
))
59 kunmap_atomic(actor
->pageaddr
);
62 extern struct page
**alloc_page_array(int, int);
63 extern void free_page_array(struct page
**, int);