summaryrefslogtreecommitdiffstats
path: root/src/basic/mkdir.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* repart: respect `SOURCE_DATE_EPOCH` on `mkdir_p_root`Moritz Sanft2024-05-071-1/+6
| | | | | | | | | | | | | | | | This let's systemd-repart respect the `SOURCE_DATE_EPOCH` environment variable when creating directories in the local tree through `CopyFiles` or `MakeDirectories`. To do this, we pass a timestamp `ts` to `mkdir_p_root`, which it will use to fix up `mtime` and `atime` of the directory it creates as well as the `mtime` of the directory it creates the other directory *in*, as the `mtime` of the latter is modified when creating a directory in it. For the same reason, it also needs to fixup the `mtime` of the upper directory when copying a file into it through `CopyFiles`. If `SOURCE_DATE_EPOCH`, times are left as is. (`UTIME_OMIT`)
* mkdir: Add support for creating subvolumes to mkdir_p_root()Daan De Meyer2023-08-141-1/+1
| | | | | We pass in the paths which should be subvolumes and try to create those as subvolumes if we can.
* mkdir: Add mkdirat_parents()Daan De Meyer2022-11-091-1/+5
|
* mkdir: Add mkdirat_safe()Daan De Meyer2022-11-091-2/+9
|
* basic: do not warn in mkdir_p() when parent directory existsZbigniew Jędrzejewski-Szmek2022-02-111-2/+3
| | | | | | | | | | | | | | | | | | | | | This effectively disables warnings about type/mode/ownership of existing directories when recursively creating parent directories. (Or files. If there's a file in a place we expect a directory, the code will later try to create a file and fail. This follows the general pattern where we do (void)mkdir() if the mkdir() is immediately followed by opening of a file.) I was recently debugging an issue with the fstab-generator [1], and it says: 'Directory "/tmp" already exists, but has mode 0777 that is too permissive (0644 was requested), refusing.' which is very specific but totally wrong in this context. This output was added in 37c1d5e97dbc869edd8fc178427714e2d9428d2b, and I still think it is worth to do it, because if you actually *do* want the directory, if there's something wrong, the precise error message will make it much easier to diagnose. And we can't easily pass the information what failed up the call chain because there are multiple things we check (ownership, permission mask, type)… So passing a param whether to warn or not down into the library code seems like the best solution, despite not being very elegant. [1] https://bugzilla.redhat.com/show_bug.cgi?id=2051285
* shared: clean up mkdir.h/label.h situationLennart Poettering2021-11-161-8/+3
| | | | | | | | | | Previously the mkdir_label() family of calls was implemented in src/shared/mkdir-label.c but its functions partly declared ins src/shared/label.h and partly in src/basic/mkdir.h (!!). That's weird (and wrong). Let's clean this up, and add a proper mkdir-label.h matching the .c file.
* mkdir: drop mkdir_errno_wrapper(), use mkdirat_errno_wrapper() insteadLennart Poettering2021-11-161-5/+4
| | | | | | | Let's reduce our code duplication, and let's focus on using xyzat() style APIs more, hence drop mkdir_errno_wrapper() and stick to mkdirar_errno_wrapper() wherever we can, it's a true superset of functionality after all.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* mkdir: add new mkdir_p_root() helperLennart Poettering2020-08-241-0/+2
|
* basic/mkdir: introduce safe recursive variantsLuca Boccassi2020-06-231-3/+5
| | | | Add mkdir_p_safe and mkdir_parents_safe. Will be used by nspawn.
* basic/label: introduce mkdirat_label()/mkdirat_errno_wrapper() helpersFranck Bui2018-07-301-0/+1
|
* tree-wide: drop double newlineYu Watanabe2018-06-291-1/+0
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: warn when a directory path already exists but has bad mode/owner/typeZbigniew Jędrzejewski-Szmek2018-03-231-0/+1
| | | | | | | | | | | | | | | | | | | | | When we are attempting to create directory somewhere in the bowels of /var/lib and get an error that it already exists, it can be quite hard to diagnose what is wrong (especially for a user who is not aware that the directory must have the specified owner, and permissions not looser than what was requested). Let's print a warning in most cases. A warning is appropriate, because such state is usually a sign of borked installation and needs to be resolved by the adminstrator. $ build/test-fs-util Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing. Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting. No functional change except for the new log lines.
* basic/mkdir: convert bool flag to enumZbigniew Jędrzejewski-Szmek2018-03-221-3/+7
| | | | In preparation for subsequent changes...
* Add mkdir_errno_wrapper() and use instead of mkdir() in various placesZbigniew Jędrzejewski-Szmek2017-12-161-0/+1
| | | | | We'd pass pointers to mkdir and mkdir_label to call in various places. mkdir returns the error in errno while mkdir_label returns the error directly.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* mkdir: introduce follow_symlink flag to mkdir_safe{,_label}()Yu Watanabe2017-10-061-3/+3
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* build-sys: split internal basic/ library from shared/Kay Sievers2015-06-111-0/+40
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/