On Thu, Nov 05, 2026 at 11:07:32AM +0100, Geert Uytterhoeven wrote:
> > + ssize_t (*proc_write_buf)(struct file *, char *, size_t, loff_t *);
>
> "const char *"?
I prototyped this to have a detailed reply. It's not worth it.
* The buffer is the entry's private copy.
procfs creates the copy for this specific call and frees it
afterwards.
A bunch of handlers modify the buffer in place and it's documented as
allowed:
- afs_proc_cells_write()
- afs_proc_sysname_write
- a chunk of the sunrpc cache channel ->cache_parse() implementations
- thinkpad_acpi's ->write() methods
- SCSI devinfo file
- dyndbg
- cio_ignore
- the pseries ofdt parsers
- two more hand the buffer to a char * interface:
- the SCSI host ->write_info()
- simple_strtoul() in proc_scsi_write()
- four strip a trailing newline in place
All ways to make that work suck.
(1) Copy in the handler. That means eight kmemdup_nul()s and a
kvmemdup() for every nfs downcall.
IOW the copy this series just removed comes back as a copy of a
copy which is not acceptable.
(2) Make the parsers work on spans which also sucks and doesn't solve
all of them.
(3) Leave the buffer writable. Costs nothing, nobody else can see it.
So (3) I think char * stays.
> While at it, I think it would be good to use this conversion as an
> opportunity to replace "char *" by "void *", which will probably let
> you drop several casts from users.
So I tried that too. The thing is it drops exactly one u8 * cast in
ntfs3's label write. And to get this done we need to introduce a whole
range of local char *foo = arg assignments. So I decided against this.
It just doesn't add value.
Thanks for taking a look!