]> git.ipfire.org Git - thirdparty/systemd.git/commit
chase: allow using chase() as mkdir_p() replacement
authorLennart Poettering <lennart@poettering.net>
Mon, 13 Jan 2025 11:53:54 +0000 (12:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 20 Jan 2025 10:31:55 +0000 (11:31 +0100)
commite49e76d64df09bea3c54385f0cf0161b61466ec6
tree13d08a790ea592cab04a711a0fbd56307ae54d5f
parentb97936807556203d899ba6225acf96b0557b52b8
chase: allow using chase() as mkdir_p() replacement

This allows using CHASE_MKDIR_0755 without CHASE_NONEXISTENT or
CHASE_PARENT, so that it will create the final component of the path
too should it be missing.

This is really useful as a mkdir_p() replacement that returns an fd to
the final component, and knows how to operate relative to a root fs.

Kinda reverts 4ea0bcb9229fe12e0c428659d76934351b821872 (which only
refused the flags combination which didn't work, instead of making it
work, which is what this commit does.)

This also corrects behaviour if CHASE_MKDIR_0755 is used in one more
way: we'll now always open the dir as O_PATH. This is generally the
better idea, but matters in particular once with allow using
CHASE_MKDIR_0755 to create the final component: we should uniformly
return an O_PATH dir that must be converted to a proper fd first before
using it.
src/basic/chase.c
src/basic/chase.h
src/test/test-chase.c