[systemd-commits] 2 commits - Makefile.am src/libudev src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Wed Apr 23 23:12:27 PDT 2014


 Makefile.am                   |    4 ++--
 src/libudev/libudev-monitor.c |    9 ++++++---
 src/shared/path-util.c        |   25 ++++++++++++-------------
 3 files changed, 20 insertions(+), 18 deletions(-)

New commits:
commit 0d522a7a0547982eae9ab1b5971e4bed9c2fbc7c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Apr 24 08:11:39 2014 +0200

    errno: make sure to handle the 3 errnos that are aliases for others properly

diff --git a/Makefile.am b/Makefile.am
index f261c47..1d37357 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1095,7 +1095,7 @@ BUILT_SOURCES += \
 
 src/shared/errno-list.txt:
 	$(AM_V_at)$(MKDIR_P) $(dir $@)
-	$(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - < /dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+[0-9]/ { print $$2; }'  > $@
+	$(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - < /dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }'  > $@
 
 src/shared/errno-from-name.gperf: src/shared/errno-list.txt
 	$(AM_V_at)$(MKDIR_P) $(dir $@)
@@ -1107,7 +1107,7 @@ src/shared/errno-from-name.h: src/shared/errno-from-name.gperf
 
 src/shared/errno-to-name.h: src/shared/errno-list.txt
 	$(AM_V_at)$(MKDIR_P) $(dir $@)
-	$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' < $< > $@
+	$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' < $< > $@
 
 src/shared/af-list.txt:
 	$(AM_V_at)$(MKDIR_P) $(dir $@)

commit 21749924e12201d8f5210c5dc9695e18fd16bb93
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Apr 24 07:46:31 2014 +0200

    util: make sure all our name_to_handle_at() code makes use of file_handle_union

diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 0a2ab82..c05cb3e 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/shared/path-util.c b/src/shared/path-util.c
index 373dd7a..69fcb16 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -324,11 +324,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
@@ -337,12 +341,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 */
@@ -358,15 +359,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;
@@ -393,7 +393,6 @@ fallback:
 
         r = lstat(parent, &b);
         free(parent);
-
         if (r < 0)
                 return -errno;
 



More information about the systemd-commits mailing list