luo_preserve_file(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 β€” the file_set bestie 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:

  1. Validates that the token isn't already in use inside the file_set. no duplicate names in this house 🚫
  2. 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 πŸ’…
  3. Iterates through the registered handlers, calling can_preserve on each to find one that's compatible with the given fd. it's giving speed dating but for handlers πŸ’˜
  4. Calls the handler's .preserve operation, which saves the file's state and hands back an opaque private data handle. mysterious. we love a little mystery 🎭
  5. 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 the file_set is 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