snapshot_write_next(9)
πΎ snapshot_write_next(9) πΎ
okay so this is a page from the Kernel API Manual and honestly it's giving "hibernation internals bestie" energy β let's get into it π«Ά
β¨ NAME β¨
snapshot_write_next β get the address to store the next image page. that's the whole gig, no cap.
πΈ SYNOPSIS πΈ
int snapshot_write_next (struct snapshot_handle *handle );
π ARGUMENTS π
handleβ the snapshot handle structure that guides the writing. think of it as the little tour guide for your image pages β¨
π DESCRIPTION π
ok so on the first call, handle should point to a zeroed snapshot_handle structure. it gets populated right then and there, and after that you should pass a pointer to it to this function every next time. like, don't lose track of it, bestie π
On success, the function returns a positive number. and then? the caller is allowed to write up to the returned number of bytes to the memory location computed by the data_of macro. that's your green light, go off π
The function returns 0 to indicate the "end of file" condition. iconic, we love a clean ending π
Negative numbers are returned on errors β and in those cases the structure pointed to by handle is not updated and should not be used any more. like, seriously, don't touch it after that. it's done. periodt π«
π¦ SEE ALSO π¦
Kernel file ./kernel/power/snapshot.c β and the whole friend group:
get_image_page(9)free_image_page(9)alloc_rtree_node(9)free_mem_extents(9)create_mem_extents(9)memory_bm_next_pfn(9)mark_nosave_pages(9)create_basic_memory_bitmaps(9)free_basic_memory_bitmaps(9)snapshot_additional_pages(9)count_free_highmem_pages(9)count_highmem_pages(9)count_data_pages(9)swsusp_free(9)preallocate_image_pages(9)free_unnecessary_pages(9)minimum_image_size(9)hibernate_preallocate_memory(9)pack_pfns(9)snapshot_read_next(9)unpack_orig_pfns(9)count_highmem_image_pages(9)prepare_highmem_image(9)copy_last_highmem_page(9)prepare_image(9)restore_highmem(9)
okay that's the whole thing, mwah π this one lives in ./kernel/power, and the version vibes are October 2026, page snapshot_write_next(9) β go read it again if you need to, i'll wait π§ββοΈβ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms