]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #8708 from poettering/namespace-repeat
authorLennart Poettering <lennart@poettering.net>
Wed, 18 Apr 2018 16:46:44 +0000 (18:46 +0200)
committerGitHub <noreply@github.com>
Wed, 18 Apr 2018 16:46:44 +0000 (18:46 +0200)
pid1 namespacing fixes

1  2 
src/basic/fs-util.c
src/basic/fs-util.h

index c6708a4c58ceb3c2149f38f141972ed7b38cac80,3dc194ca6e7c6b7b98702bf86c66ebaf1f8fb0e6..61aeb1fc8a22060b0ea4666485851442de899b01
@@@ -611,13 -618,34 +614,34 @@@ int chase_symlinks(const char *path, co
           * Suggested usage: whenever you want to canonicalize a path, use this function. Pass the absolute path you got
           * as-is: fully qualified and relative to your host's root. Optionally, specify the root parameter to tell this
           * function what to do when encountering a symlink with an absolute path as directory: prefix it by the
-          * specified path. */
+          * specified path.
+          *
+          * There are three ways to invoke this function:
+          *
+          * 1. Without CHASE_STEP or CHASE_OPEN: in this case the path is resolved and the normalized path is returned
+          *    in `ret`. The return value is < 0 on error. If CHASE_NONEXISTENT is also set 0 is returned if the file
+          *    doesn't exist, > 0 otherwise. If CHASE_NONEXISTENT is not set >= 0 is returned if the destination was
+          *    found, -ENOENT if it doesn't.
+          *
+          * 2. With CHASE_OPEN: in this case the destination is opened after chasing it as O_PATH and this file
+          *    descriptor is returned as return value. This is useful to open files relative to some root
+          *    directory. Note that the returned O_PATH file descriptors must be converted into a regular one (using
+          *    fd_reopen() or such) before it can be used for reading/writing. CHASE_OPEN may not be combined with
+          *    CHASE_NONEXISTENT.
+          *
+          * 3. With CHASE_STEP: in this case only a single step of the normalization is executed, i.e. only the first
+          *    symlink or ".." component of the path is resolved, and the resulting path is returned. This is useful if
+          *    a caller wants to trace the a path through the file system verbosely. Returns < 0 on error, > 0 if the
+          *    path is fully normalized, and == 0 for each normalization step. This may be combined with
+          *    CHASE_NONEXISTENT, in which case 1 is returned when a component is not found.
+          *
+          * */
  
          /* A root directory of "/" or "" is identical to none */
 -        if (noop_root(original_root))
 +        if (empty_or_root(original_root))
                  original_root = NULL;
  
-         if (!original_root && !ret && (flags & (CHASE_NONEXISTENT|CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_OPEN)) == CHASE_OPEN) {
+         if (!original_root && !ret && (flags & (CHASE_NONEXISTENT|CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_OPEN|CHASE_STEP)) == CHASE_OPEN) {
                  /* Shortcut the CHASE_OPEN case if the caller isn't interested in the actual path and has no root set
                   * and doesn't care about any of the other special features we provide either. */
                  r = open(path, O_PATH|O_CLOEXEC);
Simple merge