fs-util: add calls that combine chase_symlinks() and open()/opendir() in one

This is useful when opening files within disk images, as we'll then take
the relative root directory properly into account.
This commit is contained in:
Lennart Poettering
2018-03-29 15:33:12 +02:00
parent f2324783ce
commit 21c692e9bf
2 changed files with 90 additions and 3 deletions
+4
View File
@@ -20,6 +20,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <dirent.h>
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
@@ -91,6 +92,9 @@ enum {
int chase_symlinks(const char *path_with_prefix, const char *root, unsigned flags, char **ret);
int chase_symlinks_and_open(const char *path, const char *root, unsigned chase_flags, int open_flags, char **ret_path);
int chase_symlinks_and_opendir(const char *path, const char *root, unsigned chase_flags, char **ret_path, DIR **ret_dir);
/* Useful for usage with _cleanup_(), removes a directory and frees the pointer */
static inline void rmdir_and_free(char *p) {
PROTECT_ERRNO;