proc_create_...single_write(9)
π 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 bypde_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 π
- Kernel file
./fs/proc/proc_net.c proc_create_net_data_write(9)β its sibling, go say hi π
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
- 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