d_path: lift -ENAMETOOLONG handling into callers of prepend_path()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 18 May 2021 02:29:03 +0000 (22:29 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 19 May 2021 00:08:12 +0000 (20:08 -0400)
commit01a4428ee7068875995ee27e9ba5503874f23e3b
tree9838c58bfc7a38657b1965bf4f19956590ad59e4
parentd8548232ea2858d1d130f3ac835185159d367caa
d_path: lift -ENAMETOOLONG handling into callers of prepend_path()

The only negative value ever returned by prepend_path() is -ENAMETOOLONG
and callers can recognize that situation (overflow) by looking at the
sign of buflen.  Lift that into the callers; we already have the
same logics (buf if buflen is non-negative, ERR_PTR(-ENAMETOOLONG) otherwise)
in several places and that'll become a new primitive several commits down
the road.

Make prepend_path() return 0 instead of -ENAMETOOLONG.  That makes for
saner calling conventions (0/1/2/3/-ENAMETOOLONG is obnoxious) and
callers actually get simpler, especially once the aforementioned
primitive gets added.

In prepend_path() itself we switch prepending the / (in case of
empty path) to use of prepend() - no need to open-code that, compiler
will do the right thing.  It's exactly the same logics as in
__dentry_path().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/d_path.c