[systemd-devel] [PATCH V3] path-util.c: fix path_is_mount_point() for symlinks

Lennart Poettering lennart at poettering.net
Tue Mar 10 09:26:17 PDT 2015


On Fri, 20.02.15 13:25, harald at redhat.com (harald at redhat.com) wrote:

Sorry for the late review!

> --- a/src/shared/path-util.c
> +++ b/src/shared/path-util.c
> @@ -456,9 +456,9 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
>  
>          union file_handle_union h = FILE_HANDLE_INIT;
>          int mount_id = -1, mount_id_parent = -1;
> -        _cleanup_free_ char *parent = NULL;
>          struct stat a, b;
>          int r;
> +        _cleanup_close_ int fd = -1;
>          bool nosupp = false;
>  
>          /* We are not actually interested in the file handles, but
> @@ -468,7 +468,15 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
>          if (path_equal(t, "/"))
>                  return 1;
>  
> -        r = name_to_handle_at(AT_FDCWD, t, &h.handle, &mount_id, allow_symlink ? AT_SYMLINK_FOLLOW : 0);
> +        fd = openat(AT_FDCWD, t, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|(allow_symlink ? 0 : O_PATH));
> +        if (fd < 0) {
> +                if (errno == ENOENT)
> +                        return 0;

We eat up this error? Why not pass the -ENOENT up?

Otherwise I like this!

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list