chiark / gitweb /
udev: util - use log_level_from_string()
[elogind.git] / src / libudev / libudev-util.c
index 93e78d5d0798865ca03c9f9af39f4fa959343ce8..f3fdf3b5aa7843fd91789ab732ec370002f1150f 100644 (file)
  * Utilities useful when dealing with devices and device node names.
  */
 
-int util_delete_path(struct udev *udev, const char *path)
-{
-        char p[UTIL_PATH_SIZE];
-        char *pos;
-        int err = 0;
-
-        if (path[0] == '/')
-                while(path[1] == '/')
-                        path++;
-        strscpy(p, sizeof(p), path);
-        pos = strrchr(p, '/');
-        if (pos == p || pos == NULL)
-                return 0;
-
-        for (;;) {
-                *pos = '\0';
-                pos = strrchr(p, '/');
-
-                /* don't remove the last one */
-                if ((pos == p) || (pos == NULL))
-                        break;
-
-                err = rmdir(p);
-                if (err < 0) {
-                        if (errno == ENOENT)
-                                err = 0;
-                        break;
-                }
-        }
-        return err;
-}
-
 /* handle "[<SUBSYSTEM>/<KERNEL>]<attribute>" format */
 int util_resolve_subsys_kernel(struct udev *udev, const char *string,
                                char *result, size_t maxsize, int read_value)
@@ -194,13 +162,8 @@ int util_log_priority(const char *priority)
         prio = strtol(priority, &endptr, 10);
         if (endptr[0] == '\0' || isspace(endptr[0]))
                 return prio;
-        if (startswith(priority, "err"))
-                return LOG_ERR;
-        if (startswith(priority, "info"))
-                return LOG_INFO;
-        if (startswith(priority, "debug"))
-                return LOG_DEBUG;
-        return 0;
+
+        return log_level_from_string(priority);
 }
 
 size_t util_path_encode(const char *src, char *dest, size_t size)
@@ -351,28 +314,3 @@ uint64_t util_string_bloom64(const char *str)
         bits |= 1LLU << ((hash >> 18) & 63);
         return bits;
 }
-
-ssize_t print_kmsg(const char *fmt, ...)
-{
-        _cleanup_close_ int fd = -1;
-        va_list ap;
-        char text[1024];
-        ssize_t len;
-        ssize_t ret;
-
-        fd = open("/dev/kmsg", O_WRONLY|O_NOCTTY|O_CLOEXEC);
-        if (fd < 0)
-                return -errno;
-
-        len = snprintf(text, sizeof(text), "<30>systemd-udevd[%u]: ", getpid());
-
-        va_start(ap, fmt);
-        len += vsnprintf(text + len, sizeof(text) - len, fmt, ap);
-        va_end(ap);
-
-        ret = write(fd, text, len);
-        if (ret < 0)
-                return -errno;
-
-        return ret;
-}