]> git.ipfire.org Git - thirdparty/kmod.git/commit
shared: rework fd_lookup_path() helper
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 7 May 2025 11:31:45 +0000 (12:31 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 9 May 2025 18:52:46 +0000 (13:52 -0500)
commit9ad9a8d6b2f55ce400e77856e0429703df916ca2
tree79520ef2bebd7f84432a6b6cc8c7f6153ae32756
parent9615035e7b8b05b6033883f87a4fd6912040ccd7
shared: rework fd_lookup_path() helper

Reduce the stack and heap memory usage of the helper by using a caller
provided buffer. This allows us to avoid copying the path, yet again,
within the caller.

Aside: readlink(3) returns -1 on all errors, it won't return the
prospective size if the output buffer is too small.

v2:
 - swap fd_lookup_path() path/pathlen argument order

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/345
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
shared/tmpfile-util.c
shared/util.c
shared/util.h