summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-04-24 07:46:31 +0200
committerAnthony G. Basile <blueness@gentoo.org>2014-04-26 14:09:19 -0400
commit56127c00c37485fc2c66c9e442701726139e3438 (patch)
treeae6d15ba6055244d561d31513fc6e775f1c235ac /src
parentc59a37701bf49dbcba2297e7507d62ee05d9c916 (diff)
util: make sure all our name_to_handle_at() code makes use of file_handle_union
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/libudev/libudev-monitor.c9
-rw-r--r--src/libudev/path-util.c25
2 files changed, 18 insertions, 16 deletions
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index ec3f6da91e..4319ee01c2 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -108,17 +108,20 @@ static struct udev_monitor *udev_monitor_new(struct udev *udev)
/* we consider udev running when /dev is on devtmpfs */
static bool udev_has_devtmpfs(struct udev *udev) {
- union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ, };
- int mount_id;
+
+ union file_handle_union h = {
+ .handle.handle_bytes = MAX_HANDLE_SZ
+ };
+
_cleanup_fclose_ FILE *f = NULL;
char line[LINE_MAX], *e;
+ int mount_id;
int r;
r = name_to_handle_at(AT_FDCWD, "/dev", &h.handle, &mount_id, 0);
if (r < 0)
return false;
-
f = fopen("/proc/self/mountinfo", "re");
if (!f)
return false;
diff --git a/src/libudev/path-util.c b/src/libudev/path-util.c
index 67863a8757..3512002cfa 100644
--- a/src/libudev/path-util.c
+++ b/src/libudev/path-util.c
@@ -253,11 +253,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
@@ -266,12 +270,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 */
@@ -287,15 +288,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;
@@ -322,7 +322,6 @@ fallback:
r = lstat(parent, &b);
free(parent);
-
if (r < 0)
return -errno;