summaryrefslogtreecommitdiff
path: root/src/shared/path-util.h
AgeCommit message (Collapse)Author
2015-06-11build-sys: split internal basic/ library from shared/Kay Sievers
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/
2015-05-29path-util: Change path_is_mount_point() symlink arg from bool to flagsMartin Pitt
This makes path_is_mount_point() consistent with fd_is_mount_point() wrt. flags.
2015-05-29path-util: Fix path_is_mount_point for filesMartin Pitt
Commits 27cc6f166 and f25afeb broke path_is_mount_point() for files (such as /etc/machine-id → /run/machine-id bind mounts) as with the factorization of fd_is_mount_point() we lost the parent directory. We cannot determine that from an fd only as openat(fd, "..") only works for directory fds. Change fd_is_mount_point() to behave like openat(): It now takes a file descriptor of the containing directory, a file name in it, and flags (which can be 0 or AT_SYMLINK_FOLLOW). Unlike name_to_handle_at() or openat(), fstatat() only accepts the inverse flag AT_SYMLINK_NOFOLLOW and complains with EINVAL about AT_SYMLINK_FOLLOW; so we need to transform the flags for that fallback. Adjust rm_rf_children() accordingly (only other caller of fd_is_mount_point() aside from path_is_mount_point()). Add test cases for files, links, and file bind mounts (the latter will only work when running as root). Split out a new test_path_is_mount_point() test case function as it got significantly larger now.
2015-05-13util: add generic calls for prefixing a root directory to a pathLennart Poettering
So far a number of utilities implemented their own calls for this, unify them in prefix_root() and prefix_roota(). The former uses heap memory, the latter allocates from the stack via alloca(). Port over most users of a --root= logic.
2015-04-06rm-rf: never cross mount pointsLennart Poettering
2015-03-16shared: add path_compare(), an ordering path comparisonMichal Schmidt
... and make path_equal() a simple wrapper around it.
2015-02-20core, shared: in deserializing, match same files reached via different pathsMichal Schmidt
When dbus.socket is updated like this: -ListenStream=/var/run/dbus/system_bus_socket +ListenStream=/run/dbus/system_bus_socket ... and daemon-reload is performed, bad things happen. During deserialization systemd does not recognize that the two paths refer to the same named socket and replaces the socket file with a new one. As a result, applications hang when they try talking to dbus. Fix this by finding a match not only when the path names are equal, but also when they point to the same inode. In socket_address_equal() it is necessary to move the address size comparison into the abstract sockets branch. For path name sockets the comparison must not be done and for other families it is redundant (their sizes are constant and checked by socket_address_verify()). FIFOs and special files can also have multiple pathnames, so compare the inodes for them as well. Note that previously the pathname checks used streq_ptr(), but the paths cannot be NULL. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1186018
2014-11-22Do not check for existence of remote binariesZbigniew Jędrzejewski-Szmek
systemd-run would fail when run with -M or -H and an absolute path, if this path did not exists locally. Allow it to continue, since we don't have a nice way of checking if the binary exists remotely. The case where -M or -H is used and a local path is unchanged, and we still iterate over $PATH to find the binary. We need to convert to an absolute path, and we don't have a nice mechanism to check remotely, so we assume that the binary will be located in the same place locally and remotely. http://lists.freedesktop.org/archives/systemd-devel/2014-November/025418.html
2014-09-25shared: path-util - try to make PATH_FORECH_PREFIX look less wrongTom Gundersen
We replace the idiom "X && !(*foo = 0)" with "X && ((*foo = 0), true)". This is not a functional change, but should hopefully make it less likely that people and static analyzers believe there is a typo here (i.e., to make it clear that the intention was not "X && *foo != 0"). Thanks to David Herrmann for the suggestion.
2014-07-26Add utility function to append root to pathZbigniew Jędrzejewski-Szmek
2014-06-20shared: rename path_strv_canonicalize_absolute functionsMichael Marineau
Since 12ed81d9 path_strv_canonicalize_absolute leaves the search list relative to the given root directory instead of resolving paths to their true location as the name implies. To better reflect this behavior rename to the less strongly worded path_strv_resolve.
2014-05-16path-util: add path_make_relative()Tanu Kaskinen
In user_dirs() in path-lookup.c, I want to replace this: symlink("../../../.config/systemd/user", data_home); with symlink(config_home, data_home); to avoid hardcoding .config when XDG_CONFIG_HOME is set. The problem is that config_home is an absolute path, and it's better to make the symlink relative. path_make_relative() is an utility function that converts an absolute path into a relative one.
2014-04-12fsck: Search for fsck.type in PATHMike Gilbert
Modifies find_binary() to accept NULL in the second argument. fsck.type lookup logic moved to new fsck_exists() function, with a test.
2014-02-14shared: include root when canonicalizing conf pathsMichael Marineau
The conf_files_list family accepts an alternate root path to prefix all directories in the list but path_strv_canonicalize_uniq doesn't use it. This results in the suspicious behavior of resolving directory symlinks based on the contents of / instead of the alternate root. This adds a prefix argument to path_strv_canonicalize which will now prepend the prefix, if given, to every path in the list. To avoid answering what a relative path means when called with a root prefix path_strv_canonicalize is now path_strv_canonicalize_absolute and only considers absolute paths. Fortunately all users of already call path_strv_canonicalize with a list of absolute paths.
2014-01-08No need to canonicalize fixed pathsZbigniew Jędrzejewski-Szmek
2013-12-20DEFAULT_PATH_SPLIT_USR macroShawn Landden
2013-12-06Get rid of our reimplementation of basenameZbigniew Jędrzejewski-Szmek
The only problem is that libgen.h #defines basename to point to it's own broken implementation instead of the GNU one. This can be fixed by #undefining basename.
2013-10-26udev: move udev_rules_check_timestamp to sharedTom Gundersen
I want to use this from a bulitin in a subsequent patch.
2013-09-26util: properly handle the root dir in PATH_FOREACH_PREFIXLennart Poettering
Also add PATH_FOREACH_PREFIX_MORE which includes the specified dir itself in the iteration
2013-09-25util: add macro for iterating through all prefixes of a pathLennart Poettering
Syntactic sugar in a macro PATH_FOREACH_PREFIX.
2013-09-09run: allow non-absolute paths as commandZbigniew Jędrzejewski-Szmek
2013-05-02Add __attribute__((const, pure, format)) in various placesZbigniew Jędrzejewski-Szmek
I'm assuming that it's fine if a _const_ or _pure_ function calls assert. It is assumed that the assert won't trigger, and even if it does, it can only trigger on the first call with a given set of parameters, and we don't care if the compiler moves the order of calls.
2013-04-16path-util: unify code for detecting OS treesLennart Poettering
This also makes sure we always detect an OS tree the same way, by checking for /etc/os-release.
2013-03-28tests: add some silly tests for path-util.cZbigniew Jędrzejewski-Szmek
2013-02-11binfmt,tmpfiles,modules-load,sysctl: rework the various early-boot services ↵Lennart Poettering
that work on .d/ directories This unifies much of the logic behind them: - All four will now ofllow the rule that the earlier file and earlier assignment in the .d/ directories wins. Before, sysctl was the only outlier, where the later setting always won. - All four now support getopt() and --help on the command line. - All four can now handle specification of configuration file names on the command line to apply. The tools will automatically find them, and apply them. Previously only tmpfiles could do that. This is useful for %post scripts in RPMs and suchlike. - This fixes various error path issues in conf_files_list()
2013-02-06shared: remove now unused functionZbigniew Jędrzejewski-Szmek
2012-09-14timedate: assorted improvementsLennart Poettering
- Make writing/reading of /etc/timezone dependendent of HAVE_SYSV_COMPAT - Introduce symlink_atomic() after all, and use it - Use relative symlink for /etc/localtime
2012-05-08path-util: there is no function path_parent()Lennart Poettering
2012-05-08util: split-out path-util.[ch]Kay Sievers