mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-10-03 23:38:39 +00:00
util: make sure all our name_to_handle_at() code makes use of file_handle_union
(cherry picked from commit21749924e1) (cherry picked from commit6b494ffbcb) Conflicts: src/libudev/libudev-monitor.c
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
cf4985c752
commit
40d9f7140b
+12
-13
@@ -327,11 +327,15 @@ bool path_equal(const char *a, const char *b) {
|
||||
}
|
||||
|
||||
int path_is_mount_point(const char *t, bool allow_symlink) {
|
||||
char *parent;
|
||||
int r;
|
||||
struct file_handle *h;
|
||||
|
||||
union file_handle_union h = {
|
||||
.handle.handle_bytes = MAX_HANDLE_SZ
|
||||
};
|
||||
|
||||
int mount_id, mount_id_parent;
|
||||
char *parent;
|
||||
struct stat a, b;
|
||||
int r;
|
||||
|
||||
/* We are not actually interested in the file handles, but
|
||||
* name_to_handle_at() also passes us the mount ID, hence use
|
||||
@@ -340,12 +344,9 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
|
||||
if (path_equal(t, "/"))
|
||||
return 1;
|
||||
|
||||
h = alloca(MAX_HANDLE_SZ);
|
||||
h->handle_bytes = MAX_HANDLE_SZ;
|
||||
|
||||
r = name_to_handle_at(AT_FDCWD, t, h, &mount_id, allow_symlink ? AT_SYMLINK_FOLLOW : 0);
|
||||
r = name_to_handle_at(AT_FDCWD, t, &h.handle, &mount_id, allow_symlink ? AT_SYMLINK_FOLLOW : 0);
|
||||
if (r < 0) {
|
||||
if (errno == ENOSYS || errno == ENOTSUP)
|
||||
if (IN_SET(errno, ENOSYS, EOPNOTSUPP))
|
||||
/* This kernel or file system does not support
|
||||
* name_to_handle_at(), hence fallback to the
|
||||
* traditional stat() logic */
|
||||
@@ -361,15 +362,14 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
h->handle_bytes = MAX_HANDLE_SZ;
|
||||
r = name_to_handle_at(AT_FDCWD, parent, h, &mount_id_parent, 0);
|
||||
h.handle.handle_bytes = MAX_HANDLE_SZ;
|
||||
r = name_to_handle_at(AT_FDCWD, parent, &h.handle, &mount_id_parent, 0);
|
||||
free(parent);
|
||||
|
||||
if (r < 0) {
|
||||
/* The parent can't do name_to_handle_at() but the
|
||||
* directory we are interested in can? If so, it must
|
||||
* be a mount point */
|
||||
if (errno == ENOTSUP)
|
||||
if (errno == EOPNOTSUPP)
|
||||
return 1;
|
||||
|
||||
return -errno;
|
||||
@@ -396,7 +396,6 @@ fallback:
|
||||
|
||||
r = lstat(parent, &b);
|
||||
free(parent);
|
||||
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user