summaryrefslogtreecommitdiff
path: root/src/basic/stat-util.c
Commit message (Collapse)AuthorAgeFilesLines
* util: split out namespace related stuff into a new namespace-util.[ch] pairLennart Poettering2019-03-131-46/+0
| | | | Just some minor reorganiztion.
* Merge pull request #11345 from kirbyfan64/tmpfiles-c-emptyZbigniew Jędrzejewski-Szmek2019-01-151-3/+12
|\ | | | | tmpfiles: Make C still copy if the destination directory is empty
| * stat-util: Add dir_is_empty_atRyan Gonzalez2019-01-081-3/+12
| |
* | stat-util: remove spurious newlineLennart Poettering2019-01-071-1/+0
|/
* stat-util: add new APIs device_path_make_{major_minor|canonical}() and ↵Lennart Poettering2018-11-291-0/+98
| | | | | | | | | | | | | | | | | | | | device_path_parse_major_minor() device_path_make_{major_minor|canonical) generate device node paths given a mode_t and a dev_t. We have similar code all over the place, let's unify this in one place. The former will generate a "/dev/char/" or "/dev/block" path, and never go to disk. The latter then goes to disk and resolves that path to the actual path of the device node. device_path_parse_major_minor() reverses device_path_make_major_minor(), also withozut going to disk. We have similar code doing something like this at various places, let's unify this in a single set of functions. This also allows us to teach them special tricks, for example handling of the /run/systemd/inaccessible/{blk|chr} device nodes, which we use for masking device nodes, and which do not exist in /dev/char/* and /dev/block/*
* stat-util: add fd_verify_directory(), similar to fd_verify_regular()Lennart Poettering2018-11-261-0/+23
|
* nspawn: beef up netns checking a bit, for compat with old kernelsLennart Poettering2018-10-311-4/+36
| | | | Fixes: #10544
* util: do not assign return value if it is not used (#10552)Yu Watanabe2018-10-281-3/+1
|
* basic/stat-util: introduce is_dir_fd()Franck Bui2018-07-301-0/+11
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+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.
* os-util: add helpers for finding /etc/os-releaseLennart Poettering2018-05-241-26/+0
| | | | | Place this new helpers in a new source file os-util.[ch], and move the existing and related call path_is_os_tree() to it as well.
* 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.
* stat-util: fix fd_is_network_ns()Lennart Poettering2018-03-231-1/+2
| | | | | | This was broken in 77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0. My fault. Fixes: #8543
* stat-util: unify code that checks whether something is a regular fileLennart Poettering2018-02-201-0/+29
| | | | | | Let's add a common implementation for regular file checks, that are careful to return the right error code (EISDIR/EISLNK/EBADFD) when we are encountering a wrong file node.
* journal: move code that checks for network fs to stat-util.[ch]Lennart Poettering2018-02-121-4/+25
| | | | | We have similar code in stat-util.[ch] and managing this at a central place almost definitely is the better choice.
* log: minimize includes in log.hLennart Poettering2018-01-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | log.h really should only include the bare minimum of other headers, as it is really pulled into pretty much everything else and already in itself one of the most basic pieces of code we have. Let's hence drop inclusion of: 1. sd-id128.h because it's entirely unneeded in current log.h 2. errno.h, dito. 3. sys/signalfd.h which we can replace by a simple struct forward declaration 4. process-util.h which was needed for getpid_cached() which we now hide in a funciton log_emergency_level() instead, which nicely abstracts the details away. 5. sys/socket.h which was needed for struct iovec, but a simple struct forward declaration suffices for that too. Ultimately this actually makes our source tree larger (since users of the functionality above must now include it themselves, log.h won't do that for them), but I think it helps to untangle our web of includes a tiny bit. (Background: I'd like to isolate the generic bits of src/basic/ enough so that we can do a git submodule import into casync for it)
* nspawn: introduce an option for specifying network namespace pathDongsu Park2017-12-131-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | Add a new option `--network-namespace-path` to systemd-nspawn to allow users to specify an arbitrary network namespace, e.g. `/run/netns/foo`. Then systemd-nspawn will open the netns file, pass the fd to outer_child, and enter the namespace represented by the fd before running inner_child. ``` $ sudo ip netns add foo $ mount | grep /run/netns/foo nsfs on /run/netns/foo type nsfs (rw) ... $ sudo systemd-nspawn -D /srv/fc27 --network-namespace-path=/run/netns/foo \ /bin/readlink -f /proc/self/ns/net /proc/1/ns/net:[4026532009] ``` Note that the option `--network-namespace-path=` cannot be used together with other network-related options such as `--private-network` so that the options do not conflict with each other. Fixes https://github.com/systemd/systemd/issues/7361
* util-lib: rename path_check_fstype to path_is_fs_typeZbigniew Jędrzejewski-Szmek2017-11-301-1/+1
|
* util-lib: rename fd_check_fstype to fd_is_fs_typeZbigniew Jędrzejewski-Szmek2017-11-301-2/+2
| | | | | Let's use "is" and "fs_type" for consistency with "is_fs_type". "check" is also more ambiguous than "is".
* 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.
* basic/path-util: allow flags for path_equal_or_files_sameZbigniew Jędrzejewski-Szmek2017-06-171-3/+3
| | | | | No functional change, just a new parameters and the tests that AT_SYMLINK_NOFOLLOW works as expected.
* util-lib: rework path_check_fstype() and path_is_temporary_fs() to use O_PATHLennart Poettering2016-12-211-2/+2
| | | | Also, add tests to make sure this actually works as intended.
* util-lib: add new path_is_temporary_fs() APILennart Poettering2016-12-201-0/+10
| | | | As simple wrapper around fd_is_temporary_fs().
* util-lib: make sure fd_check_fstype() opens files with O_CLOEXECLennart Poettering2016-12-201-1/+1
| | | | Also, O_NOCTTY is a safer bet, let's add that too.
* util-lib: beef path_is_os_tree() up a bitLennart Poettering2016-12-201-10/+18
| | | | | | Let's use chase_symlinks() when looking for /etc/os-release and /usr/lib/os-release as these files might be symlinks (and actually are IRL on some distros).
* 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.
* basic: include only what we useThomas Hindoe Paaboel Andersen2015-11-301-0/+4
| | | | | This is a cleaned up result of running iwyu but without forward declarations on src/basic.
* util-lib: split stat()/statfs()/stavfs() related calls into stat-util.[ch]Lennart Poettering2015-10-271-0/+216