proc_create_...single_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME πŸ’…

proc_create_net_single_write β€” bestie, this is the one that creates a writable, net_ns-specific proc file. like, a proc file that knows about network namespaces and lets you write to it. iconic behaviour tbh 🫢


✨ SYNOPSIS ✨

struct proc_dir_entry * proc_create_net_single_write (const char *name ,
umode_t mode , struct proc_dir_entry *parent , int (*show)(struct
seq_file *, void *) , proc_write_t write , void *data );

okay so this is the <9> kernel API manual, and this is the whole signature. six args. no cap, you gotta pass all of them πŸŽ€


🌸 ARGUMENTS 🌸

  • name β€” the name of the file. literally what it'll be called 🏷️
  • mode β€” the file's access mode. you know, the permissions vibe check.
  • parent β€” the parent directory you're creating this baby in. it needs a home πŸ’–
  • show β€” the seqfile show method, i.e. the thing that reads the file for you.
  • write β€” the write method, aka how you "'modify'" the file. yes the quotes are in the original, it's giving "modify" in the loose sense 😭
  • data β€” data for retrieval by pde_data. it lives there. it waits. it gets retrieved πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so what this actually does: it creates a network-namespaced proc file inside the parent directory, with the name and mode you passed. and the special sauce? it lets you read a file that displays a single element rather than a whole series β€” single, not a series, that's the whole flex β€” and it provides for the file accepting writes that have some arbitrary effect. arbitrary. do with that what you will ✨

the show function gets called to extract the readable content via the seq_file interface. that's its whole job and it ate πŸ”₯

the write function gets called with the data copied into a kernel space scratch buffer, and a NUL gets appended for convenience 🎁 (so thoughtful). the buffer may be modified by the write function, so go off. write should return 0 on success β€” that's the green flag, return the zero, periodt.

the data value is accessible from both the show and write functions by calling pde_data on the file inode. and β€” important, bestie, don't skip this β€” the network namespace must be accessed by calling seq_file_single_net on the seq_file struct πŸ‘‘

⚠️ lowkey the NUL append and the mutable scratch buffer are the whole reason this function exists separately from its siblings β€” don't go thinking the buffer is const, it fr fr isn't πŸ™ˆ

🌈 SEE ALSO 🌈


and that's the page, bestie ✨ this gem came out of ./fs/proc in the October 2026 edition of the kernel API manual β€” go forth and create your writable net_ns proc files, you absolute main character πŸ‘‘πŸ’–πŸŽ€

πŸ“¦ where this page comes from