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>