luo_preserve_file(9)
π luo_preserve_file(9) β the Kernel API Manual glow-up π
okay so bestie, welcome to the luo_preserve_file(9) page. yes, that's the whole manual name, it's giving very "kernel api manual" energy and honestly? iconic. let's get into it β¨
πΈ NAME πΈ
luo_preserve_file β like, the actual start of preserving a file descriptor. the opening act. the main character entrance. π«
π¦ SYNOPSIS π¦
int luo_preserve_file (struct luo_file_set *file_set , u64 token , int
fd );
yes the line break is real, that's literally how it's written, no cap π
π ARGUMENTS π
file_setβ thefile_setbestie that the preserved file is gonna get added to. it's the group chat the file joins. π«Άtokenβ a unique, user-provided identifier for the file. you make it, you own it, it's your little name tag. π·οΈfdβ the actual file descriptor being preserved. the star of the show. π
β¨ DESCRIPTION β¨
so this function orchestrates (fancy word, love that for her) the first phase of preserving a file. on entry it grabs a reference to the 'struct file' via fget, which lowkey makes LUO a co-owner of the file. and she holds that reference until the file is either unpreserved or successfully finished in the next kernel β so the file literally cannot get prematurely destroyed. protective queen behavior honestly π
and like, the whole first-phase-preserving deal goes down in these steps:
- Validates that the
tokenisn't already in use inside thefile_set. no duplicate names in this house π« - Ensures the
file_set's memory for files serialization is allocated (and allocates it if needed). if it's not there, she builds it. self-sufficient π - Iterates through the registered handlers, calling
can_preserveon each to find one that's compatible with the givenfd. it's giving speed dating but for handlers π - Calls the handler's
.preserveoperation, which saves the file's state and hands back an opaque private data handle. mysterious. we love a little mystery π - Adds the new instance to the
file_set's internal list. welcome to the club, babes π
on success, LUO takes a reference to the 'struct file' and straight up considers it under her management until it's unpreserved or finished. she's responsible for it now, that's her child π₯Ή
and if anything fails? she cleans up all the intermediate allocations (the file reference, the memory for the 'luo_file' struct, all of it, every crumb π§Ή) before returning an error. no mess left behind, periodt.
π CONTEXT π
Can be called from an ioctl handler during normal system operation. so like, just normal everyday vibes. nothing chaotic. π§
π₯ RETURN π₯
0 on success β slay! β¨
and returns a negative errno on failure:
-EEXISTβ if the token is already used. taken, bestie, sorry π-EBUSYβ if the file descriptor is already preserved by another session. she's booked and busy π«-EBADFβ if the file descriptor is invalid. not a real fd, bestie π-ENOSPCβ if thefile_setis full. no room, we're at capacity π-ENOENTβ if no compatible handler is found. nobody showed up to the function π-ENOMEMβ on memory allocation failure. the allocator said no π«- Other errors might be returned by
.preserve. anything could happen, iykyk π²
π SEE ALSO π
Kernel file ./kernel/liveupdate/luo_file.c, LUO File Descriptors(9), struct luo_file(9), luo_file_unpreserve_files(9), luo_file_freeze(9), luo_file_unfreeze(9), luo_retrieve_file(9), luo_file_finish(9), luo_file_deserialize(9), liveupdate_register_file_handler(9), liveupdate_unregister_file_handler(9) β go read those next, bestie, the whole cinematic universe is right there ππ¦
and that's the page! π source: ./kernel/liveupdate Β· date: October 2026 Β· mwah, love u, go preserve some files π
β¨π
π¦ 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