chiark / gitweb /
shared: add formats-util.h
[elogind.git] / src / shared / clean-ipc.c
index cb17226..48b1086 100644 (file)
 #include <sys/sem.h>
 #include <sys/msg.h>
 #include <sys/stat.h>
-#include <sys/mman.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <mqueue.h>
 
 #include "util.h"
+#include "formats-util.h"
 #include "strv.h"
 #include "clean-ipc.h"
 
@@ -44,7 +44,7 @@ static int clean_sysvipc_shm(uid_t delete_uid) {
                 if (errno == ENOENT)
                         return 0;
 
-                log_warning("Failed to open /proc/sysvipc/shm: %m");
+                log_warning_errno(errno, "Failed to open /proc/sysvipc/shm: %m");
                 return -errno;
         }
 
@@ -78,7 +78,7 @@ static int clean_sysvipc_shm(uid_t delete_uid) {
                         if (errno == EIDRM || errno == EINVAL)
                                 continue;
 
-                        log_warning("Failed to remove SysV shared memory segment %i: %m", shmid);
+                        log_warning_errno(errno, "Failed to remove SysV shared memory segment %i: %m", shmid);
                         ret = -errno;
                 }
         }
@@ -86,7 +86,7 @@ static int clean_sysvipc_shm(uid_t delete_uid) {
         return ret;
 
 fail:
-        log_warning("Failed to read /proc/sysvipc/shm: %m");
+        log_warning_errno(errno, "Failed to read /proc/sysvipc/shm: %m");
         return -errno;
 }
 
@@ -101,7 +101,7 @@ static int clean_sysvipc_sem(uid_t delete_uid) {
                 if (errno == ENOENT)
                         return 0;
 
-                log_warning("Failed to open /proc/sysvipc/sem: %m");
+                log_warning_errno(errno, "Failed to open /proc/sysvipc/sem: %m");
                 return -errno;
         }
 
@@ -130,7 +130,7 @@ static int clean_sysvipc_sem(uid_t delete_uid) {
                         if (errno == EIDRM || errno == EINVAL)
                                 continue;
 
-                        log_warning("Failed to remove SysV semaphores object %i: %m", semid);
+                        log_warning_errno(errno, "Failed to remove SysV semaphores object %i: %m", semid);
                         ret = -errno;
                 }
         }
@@ -138,7 +138,7 @@ static int clean_sysvipc_sem(uid_t delete_uid) {
         return ret;
 
 fail:
-        log_warning("Failed to read /proc/sysvipc/sem: %m");
+        log_warning_errno(errno, "Failed to read /proc/sysvipc/sem: %m");
         return -errno;
 }
 
@@ -153,7 +153,7 @@ static int clean_sysvipc_msg(uid_t delete_uid) {
                 if (errno == ENOENT)
                         return 0;
 
-                log_warning("Failed to open /proc/sysvipc/msg: %m");
+                log_warning_errno(errno, "Failed to open /proc/sysvipc/msg: %m");
                 return -errno;
         }
 
@@ -183,7 +183,7 @@ static int clean_sysvipc_msg(uid_t delete_uid) {
                         if (errno == EIDRM || errno == EINVAL)
                                 continue;
 
-                        log_warning("Failed to remove SysV message queue %i: %m", msgid);
+                        log_warning_errno(errno, "Failed to remove SysV message queue %i: %m", msgid);
                         ret = -errno;
                 }
         }
@@ -191,7 +191,7 @@ static int clean_sysvipc_msg(uid_t delete_uid) {
         return ret;
 
 fail:
-        log_warning("Failed to read /proc/sysvipc/msg: %m");
+        log_warning_errno(errno, "Failed to read /proc/sysvipc/msg: %m");
         return -errno;
 }
 
@@ -211,7 +211,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
                         if (errno == ENOENT)
                                 continue;
 
-                        log_warning("Failed to stat() POSIX shared memory segment %s: %m", de->d_name);
+                        log_warning_errno(errno, "Failed to stat() POSIX shared memory segment %s: %m", de->d_name);
                         ret = -errno;
                         continue;
                 }
@@ -225,7 +225,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
                         kid = xopendirat(dirfd(dir), de->d_name, O_NOFOLLOW|O_NOATIME);
                         if (!kid) {
                                 if (errno != ENOENT) {
-                                        log_warning("Failed to enter shared memory directory %s: %m", de->d_name);
+                                        log_warning_errno(errno, "Failed to enter shared memory directory %s: %m", de->d_name);
                                         ret = -errno;
                                 }
                         } else {
@@ -239,7 +239,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
                                 if (errno == ENOENT)
                                         continue;
 
-                                log_warning("Failed to remove POSIX shared memory directory %s: %m", de->d_name);
+                                log_warning_errno(errno, "Failed to remove POSIX shared memory directory %s: %m", de->d_name);
                                 ret = -errno;
                         }
                 } else {
@@ -249,7 +249,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
                                 if (errno == ENOENT)
                                         continue;
 
-                                log_warning("Failed to remove POSIX shared memory segment %s: %m", de->d_name);
+                                log_warning_errno(errno, "Failed to remove POSIX shared memory segment %s: %m", de->d_name);
                                 ret = -errno;
                         }
                 }
@@ -258,7 +258,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
         return ret;
 
 fail:
-        log_warning("Failed to read /dev/shm: %m");
+        log_warning_errno(errno, "Failed to read /dev/shm: %m");
         return -errno;
 }
 
@@ -270,7 +270,7 @@ static int clean_posix_shm(uid_t uid) {
                 if (errno == ENOENT)
                         return 0;
 
-                log_warning("Failed to open /dev/shm: %m");
+                log_warning_errno(errno, "Failed to open /dev/shm: %m");
                 return -errno;
         }
 
@@ -287,7 +287,7 @@ static int clean_posix_mq(uid_t uid) {
                 if (errno == ENOENT)
                         return 0;
 
-                log_warning("Failed to open /dev/mqueue: %m");
+                log_warning_errno(errno, "Failed to open /dev/mqueue: %m");
                 return -errno;
         }
 
@@ -302,7 +302,7 @@ static int clean_posix_mq(uid_t uid) {
                         if (errno == ENOENT)
                                 continue;
 
-                        log_warning("Failed to stat() MQ segment %s: %m", de->d_name);
+                        log_warning_errno(errno, "Failed to stat() MQ segment %s: %m", de->d_name);
                         ret = -errno;
                         continue;
                 }
@@ -317,7 +317,7 @@ static int clean_posix_mq(uid_t uid) {
                         if (errno == ENOENT)
                                 continue;
 
-                        log_warning("Failed to unlink POSIX message queue %s: %m", fn);
+                        log_warning_errno(errno, "Failed to unlink POSIX message queue %s: %m", fn);
                         ret = -errno;
                 }
         }
@@ -325,7 +325,7 @@ static int clean_posix_mq(uid_t uid) {
         return ret;
 
 fail:
-        log_warning("Failed to read /dev/mqueue: %m");
+        log_warning_errno(errno, "Failed to read /dev/mqueue: %m");
         return -errno;
 }