chiark / gitweb /
convert to libudev and delete udev_utils_string.c
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 10 Sep 2008 16:39:23 +0000 (18:39 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 10 Sep 2008 16:39:23 +0000 (18:39 +0200)
14 files changed:
extras/floppy/Makefile.am
extras/usb_id/Makefile.am
udev/Makefile.am
udev/udev.h
udev/udev_db.c
udev/udev_node.c
udev/udev_rules.c
udev/udev_sysfs.c
udev/udev_utils.c
udev/udev_utils_string.c [deleted file]
udev/udevadm-control.c
udev/udevadm-info.c
udev/udevadm-trigger.c
udev/udevd.c

index 92877a7778a292d2bf9c720d06cdfaf9a85b2a2a..9c5fe5011439370594eebf5fc56bf671c404a9b8 100644 (file)
@@ -13,8 +13,7 @@ create_floppy_devices_SOURCES = \
        ../../udev/lib/libudev.c \
        ../../udev/lib/libudev-util.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/lib/libudev.c \
        ../../udev/lib/libudev-util.c \
        ../../udev/udev_sysdeps.c \
-       ../../udev/udev_utils.c \
-       ../../udev/udev_utils_string.c
+       ../../udev/udev_utils.c
 
 if USE_SELINUX
 create_floppy_devices_LDADD = \
 
 if USE_SELINUX
 create_floppy_devices_LDADD = \
index ba74baad4289569b3f5f4a5c34d621bfea7e5c87..eac385c3c12272a43d182bfb5584388eddbe6ac2 100644 (file)
@@ -14,8 +14,7 @@ usb_id_SOURCES = \
        ../../udev/lib/libudev-util.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_sysfs.c \
        ../../udev/lib/libudev-util.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_sysfs.c \
-       ../../udev/udev_utils.c \
-       ../../udev/udev_utils_string.c
+       ../../udev/udev_utils.c
 
 if USE_SELINUX
 usb_id_LDADD = \
 
 if USE_SELINUX
 usb_id_LDADD = \
index df0370842101e685b8ed3698df9aeb75ace32788..66edd341fd9d4eaa1166facd41bf172708b480dd 100644 (file)
@@ -29,7 +29,6 @@ common_files = \
        udev_sysfs.c \
        udev_utils.c \
        udev_utils_file.c \
        udev_sysfs.c \
        udev_utils.c \
        udev_utils_file.c \
-       udev_utils_string.c \
        lib/list.h \
        lib/libudev.h \
        lib/libudev-private.h \
        lib/list.h \
        lib/libudev.h \
        lib/libudev-private.h \
index 7f5bd10a7c1cfaa06b3868fa540cc12b16b21162..0bf06bedbacb8e8ee48c8e83dc7e3c381847765b 100644 (file)
@@ -171,13 +171,6 @@ extern int add_matching_files(struct udev *udev, struct list_head *name_list, co
 extern uid_t lookup_user(struct udev *udev, const char *user);
 extern gid_t lookup_group(struct udev *udev, const char *group);
 
 extern uid_t lookup_user(struct udev *udev, const char *user);
 extern gid_t lookup_group(struct udev *udev, const char *group);
 
-/* udev_utils_string.c */
-extern int string_is_true(const char *str);
-extern void remove_trailing_chars(char *path, char c);
-extern size_t path_encode(char *s, size_t len);
-extern size_t path_decode(char *s);
-extern int replace_chars(char *str, const char *white);
-
 /* udev_utils_file.c */
 extern int create_path(struct udev *udev, const char *path);
 extern int delete_path(struct udev *udev, const char *path);
 /* udev_utils_file.c */
 extern int create_path(struct udev *udev, const char *path);
 extern int delete_path(struct udev *udev, const char *path);
index 8596470d4962c8694fd524d430edbcd22c02734c..2c3a24939ee04ecfa7ccdf0cdbf51545943f2f80 100644 (file)
@@ -38,7 +38,7 @@ static size_t devpath_to_db_path(struct udev *udev, const char *devpath, char *f
        strlcpy(filename, udev_get_dev_path(udev), len);
        start = strlcat(filename, "/.udev/db/", len);
        strlcat(filename, devpath, len);
        strlcpy(filename, udev_get_dev_path(udev), len);
        start = strlcat(filename, "/.udev/db/", len);
        strlcat(filename, devpath, len);
-       return path_encode(&filename[start], len - start);
+       return util_path_encode(&filename[start], len - start);
 }
 
 /* reverse mapping from the device file name to the devpath */
 }
 
 /* reverse mapping from the device file name to the devpath */
@@ -53,10 +53,10 @@ static int name_index(struct udev *udev, const char *devpath, const char *name,
        strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
        start = strlcat(filename, "/.udev/names/", sizeof(filename));
        strlcat(filename, name, sizeof(filename));
        strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
        start = strlcat(filename, "/.udev/names/", sizeof(filename));
        strlcat(filename, name, sizeof(filename));
-       path_encode(&filename[start], sizeof(filename) - start);
+       util_path_encode(&filename[start], sizeof(filename) - start);
        /* entry with the devpath */
        strlcpy(device, devpath, sizeof(device));
        /* entry with the devpath */
        strlcpy(device, devpath, sizeof(device));
-       path_encode(device, sizeof(device));
+       util_path_encode(device, sizeof(device));
        strlcat(filename, "/", sizeof(filename));
        strlcat(filename, device, sizeof(filename));
 
        strlcat(filename, "/", sizeof(filename));
        strlcat(filename, device, sizeof(filename));
 
@@ -84,7 +84,7 @@ int udev_db_get_devices_by_name(struct udev *udev, const char *name, struct list
        strlcpy(dirname, udev_get_dev_path(udev), sizeof(dirname));
        start = strlcat(dirname, "/.udev/names/", sizeof(dirname));
        strlcat(dirname, name, sizeof(dirname));
        strlcpy(dirname, udev_get_dev_path(udev), sizeof(dirname));
        start = strlcat(dirname, "/.udev/names/", sizeof(dirname));
        strlcat(dirname, name, sizeof(dirname));
-       path_encode(&dirname[start], sizeof(dirname) - start);
+       util_path_encode(&dirname[start], sizeof(dirname) - start);
 
        dir = opendir(dirname);
        if (dir == NULL) {
 
        dir = opendir(dirname);
        if (dir == NULL) {
@@ -105,7 +105,7 @@ int udev_db_get_devices_by_name(struct udev *udev, const char *name, struct list
                        continue;
 
                strlcpy(device, ent->d_name, sizeof(device));
                        continue;
 
                strlcpy(device, ent->d_name, sizeof(device));
-               path_decode(device);
+               util_path_decode(device);
                name_list_add(udev, name_list, device, 0);
                rc++;
        }
                name_list_add(udev, name_list, device, 0);
                rc++;
        }
@@ -317,7 +317,7 @@ int udev_db_get_all_entries(struct udev *udev, struct list_head *name_list)
                        continue;
 
                strlcpy(device, ent->d_name, sizeof(device));
                        continue;
 
                strlcpy(device, ent->d_name, sizeof(device));
-               path_decode(device);
+               util_path_decode(device);
                name_list_add(udev, name_list, device, 1);
                dbg(udev, "added '%s'\n", device);
        }
                name_list_add(udev, name_list, device, 1);
                dbg(udev, "added '%s'\n", device);
        }
index 5f1b5c76cdbdcf0666c22975553c637ea32cbac6..80c4f0a5f3556fb2b43ec45223e860291aec8ab4 100644 (file)
@@ -283,7 +283,7 @@ void udev_node_update_symlinks(struct udevice *udevice, struct udevice *udevice_
        }
 
        /* export symlinks to environment */
        }
 
        /* export symlinks to environment */
-       remove_trailing_chars(symlinks, ' ');
+       util_remove_trailing_chars(symlinks, ' ');
        if (symlinks[0] != '\0')
                setenv("DEVLINKS", symlinks, 1);
 
        if (symlinks[0] != '\0')
                setenv("DEVLINKS", symlinks, 1);
 
index fce73e4293fc8226b52aac327a205f4ce47b6d18..a56ed4e1769166819d798ed00d4a6f8436aa8e13 100644 (file)
@@ -863,7 +863,7 @@ found:
                                        size = sizeof(temp2)-1;
                                while (size > 0 && isspace(temp2[size-1]))
                                        temp2[--size] = '\0';
                                        size = sizeof(temp2)-1;
                                while (size > 0 && isspace(temp2[size-1]))
                                        temp2[--size] = '\0';
-                               count = replace_chars(temp2, ALLOWED_CHARS_INPUT);
+                               count = util_replace_chars(temp2, ALLOWED_CHARS_INPUT);
                                if (count > 0)
                                        info(udevice->udev, "%i character(s) replaced\n" , count);
                                strlcat(string, temp2, maxsize);
                                if (count > 0)
                                        info(udevice->udev, "%i character(s) replaced\n" , count);
                                strlcat(string, temp2, maxsize);
@@ -921,7 +921,7 @@ found:
                                        strlcat(symlinks, name_loop->name, sizeof(symlinks));
                                        strlcat(symlinks, " ", sizeof(symlinks));
                                }
                                        strlcat(symlinks, name_loop->name, sizeof(symlinks));
                                        strlcat(symlinks, " ", sizeof(symlinks));
                                }
-                               remove_trailing_chars(symlinks, ' ');
+                               util_remove_trailing_chars(symlinks, ' ');
                                strlcat(string, symlinks, maxsize);
                        }
                        break;
                                strlcat(string, symlinks, maxsize);
                        }
                        break;
@@ -1240,10 +1240,10 @@ try_parent:
                        int count;
 
                        dbg(udevice->udev, "PROGRAM matches\n");
                        int count;
 
                        dbg(udevice->udev, "PROGRAM matches\n");
-                       remove_trailing_chars(result, '\n');
+                       util_remove_trailing_chars(result, '\n');
                        if (rule->string_escape == ESCAPE_UNSET ||
                            rule->string_escape == ESCAPE_REPLACE) {
                        if (rule->string_escape == ESCAPE_UNSET ||
                            rule->string_escape == ESCAPE_REPLACE) {
-                               count = replace_chars(result, ALLOWED_CHARS_INPUT);
+                               count = util_replace_chars(result, ALLOWED_CHARS_INPUT);
                                if (count > 0)
                                        info(udevice->udev, "%i character(s) replaced\n" , count);
                        }
                                if (count > 0)
                                        info(udevice->udev, "%i character(s) replaced\n" , count);
                        }
@@ -1461,7 +1461,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice)
                                udev_rules_apply_format(udevice, temp, sizeof(temp));
                                if (rule->string_escape == ESCAPE_UNSET ||
                                    rule->string_escape == ESCAPE_REPLACE) {
                                udev_rules_apply_format(udevice, temp, sizeof(temp));
                                if (rule->string_escape == ESCAPE_UNSET ||
                                    rule->string_escape == ESCAPE_REPLACE) {
-                                       count = replace_chars(temp, ALLOWED_CHARS_FILE " ");
+                                       count = util_replace_chars(temp, ALLOWED_CHARS_FILE " ");
                                        if (count > 0)
                                                info(udevice->udev, "%i character(s) replaced\n" , count);
                                }
                                        if (count > 0)
                                                info(udevice->udev, "%i character(s) replaced\n" , count);
                                }
@@ -1496,7 +1496,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice)
                                udev_rules_apply_format(udevice, udevice->name, sizeof(udevice->name));
                                if (rule->string_escape == ESCAPE_UNSET ||
                                    rule->string_escape == ESCAPE_REPLACE) {
                                udev_rules_apply_format(udevice, udevice->name, sizeof(udevice->name));
                                if (rule->string_escape == ESCAPE_UNSET ||
                                    rule->string_escape == ESCAPE_REPLACE) {
-                                       count = replace_chars(udevice->name, ALLOWED_CHARS_FILE);
+                                       count = util_replace_chars(udevice->name, ALLOWED_CHARS_FILE);
                                        if (count > 0)
                                                info(udevice->udev, "%i character(s) replaced\n", count);
                                }
                                        if (count > 0)
                                                info(udevice->udev, "%i character(s) replaced\n", count);
                                }
index 311bc6f24e602aa307e5dbaedd7b634f1c579259..6b9f9dac3a435e575cd5ba417f585509b9f5b342 100644 (file)
@@ -156,7 +156,7 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath)
 
        dbg(udev, "open '%s'\n", devpath);
        strlcpy(devpath_real, devpath, sizeof(devpath_real));
 
        dbg(udev, "open '%s'\n", devpath);
        strlcpy(devpath_real, devpath, sizeof(devpath_real));
-       remove_trailing_chars(devpath_real, '/');
+       util_remove_trailing_chars(devpath_real, '/');
        if (devpath[0] == '\0' )
                return NULL;
 
        if (devpath[0] == '\0' )
                return NULL;
 
@@ -397,7 +397,7 @@ char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *a
 
        /* got a valid value, store and return it */
        value[size] = '\0';
 
        /* got a valid value, store and return it */
        value[size] = '\0';
-       remove_trailing_chars(value, '\n');
+       util_remove_trailing_chars(value, '\n');
        dbg(udev, "cache '%s' with attribute value '%s'\n", path_full, value);
        strlcpy(attr->value_local, value, sizeof(attr->value_local));
        attr->value = attr->value_local;
        dbg(udev, "cache '%s' with attribute value '%s'\n", path_full, value);
        strlcpy(attr->value_local, value, sizeof(attr->value_local));
        attr->value = attr->value_local;
index 2cbb4d98ebbaa701816d391c13f844f03a9faf6d..669e4f3419fa7f78b8909ae844fe082ac3108ab9 100644 (file)
 
 #include "udev.h"
 
 
 #include "udev.h"
 
-
-int log_priority(const char *priority)
-{
-       char *endptr;
-       int prio;
-
-       prio = strtol(priority, &endptr, 10);
-       if (endptr[0] == '\0')
-               return prio;
-       if (strncasecmp(priority, "err", 3) == 0)
-               return LOG_ERR;
-       if (strcasecmp(priority, "info") == 0)
-               return LOG_INFO;
-       if (strcasecmp(priority, "debug") == 0)
-               return LOG_DEBUG;
-       if (string_is_true(priority))
-               return LOG_ERR;
-
-       return 0;
-}
-
 struct name_entry *name_list_add(struct udev *udev, struct list_head *name_list, const char *name, int sort)
 {
        struct name_entry *name_loop;
 struct name_entry *name_list_add(struct udev *udev, struct list_head *name_list, const char *name, int sort)
 {
        struct name_entry *name_loop;
diff --git a/udev/udev_utils_string.c b/udev/udev_utils_string.c
deleted file mode 100644 (file)
index 540fb5c..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <syslog.h>
-#include <sys/utsname.h>
-
-#include "udev.h"
-
-int string_is_true(const char *str)
-{
-       if (strcasecmp(str, "true") == 0)
-               return 1;
-       if (strcasecmp(str, "yes") == 0)
-               return 1;
-       if (strcasecmp(str, "1") == 0)
-               return 1;
-       return 0;
-}
-
-void remove_trailing_chars(char *path, char c)
-{
-       size_t len;
-
-       if (path == NULL)
-               return;
-       len = strlen(path);
-       while (len > 0 && path[len-1] == c)
-               path[--len] = '\0';
-}
-
-size_t path_encode(char *s, size_t len)
-{
-       char t[(len * 3)+1];
-       size_t i, j;
-
-       t[0] = '\0';
-       for (i = 0, j = 0; s[i] != '\0'; i++) {
-               if (s[i] == '/') {
-                       memcpy(&t[j], "\\x2f", 4);
-                       j += 4;
-               } else if (s[i] == '\\') {
-                       memcpy(&t[j], "\\x5c", 4);
-                       j += 4;
-               } else {
-                       t[j] = s[i];
-                       j++;
-               }
-       }
-       t[j] = '\0';
-       strncpy(s, t, len);
-       return j;
-}
-
-size_t path_decode(char *s)
-{
-       size_t i, j;
-
-       for (i = 0, j = 0; s[i] != '\0'; j++) {
-               if (memcmp(&s[i], "\\x2f", 4) == 0) {
-                       s[j] = '/';
-                       i += 4;
-               }else if (memcmp(&s[i], "\\x5c", 4) == 0) {
-                       s[j] = '\\';
-                       i += 4;
-               } else {
-                       s[j] = s[i];
-                       i++;
-               }
-       }
-       s[j] = '\0';
-       return j;
-}
-
-/* count of characters used to encode one unicode char */
-static int utf8_encoded_expected_len(const char *str)
-{
-       unsigned char c = (unsigned char)str[0];
-
-       if (c < 0x80)
-               return 1;
-       if ((c & 0xe0) == 0xc0)
-               return 2;
-       if ((c & 0xf0) == 0xe0)
-               return 3;
-       if ((c & 0xf8) == 0xf0)
-               return 4;
-       if ((c & 0xfc) == 0xf8)
-               return 5;
-       if ((c & 0xfe) == 0xfc)
-               return 6;
-       return 0;
-}
-
-/* decode one unicode char */
-static int utf8_encoded_to_unichar(const char *str)
-{
-       int unichar;
-       int len;
-       int i;
-
-       len = utf8_encoded_expected_len(str);
-       switch (len) {
-       case 1:
-               return (int)str[0];
-       case 2:
-               unichar = str[0] & 0x1f;
-               break;
-       case 3:
-               unichar = (int)str[0] & 0x0f;
-               break;
-       case 4:
-               unichar = (int)str[0] & 0x07;
-               break;
-       case 5:
-               unichar = (int)str[0] & 0x03;
-               break;
-       case 6:
-               unichar = (int)str[0] & 0x01;
-               break;
-       default:
-               return -1;
-       }
-
-       for (i = 1; i < len; i++) {
-               if (((int)str[i] & 0xc0) != 0x80)
-                       return -1;
-               unichar <<= 6;
-               unichar |= (int)str[i] & 0x3f;
-       }
-
-       return unichar;
-}
-
-/* expected size used to encode one unicode char */
-static int utf8_unichar_to_encoded_len(int unichar)
-{
-       if (unichar < 0x80)
-               return 1;
-       if (unichar < 0x800)
-               return 2;
-       if (unichar < 0x10000)
-               return 3;
-       if (unichar < 0x200000)
-               return 4;
-       if (unichar < 0x4000000)
-               return 5;
-       return 6;
-}
-
-/* check if unicode char has a valid numeric range */
-static int utf8_unichar_valid_range(int unichar)
-{
-       if (unichar > 0x10ffff)
-               return 0;
-       if ((unichar & 0xfffff800) == 0xd800)
-               return 0;
-       if ((unichar > 0xfdcf) && (unichar < 0xfdf0))
-               return 0;
-       if ((unichar & 0xffff) == 0xffff)
-               return 0;
-       return 1;
-}
-
-/* validate one encoded unicode char and return its length */
-static int utf8_encoded_valid_unichar(const char *str)
-{
-       int len;
-       int unichar;
-       int i;
-
-       len = utf8_encoded_expected_len(str);
-       if (len == 0)
-               return -1;
-
-       /* ascii is valid */
-       if (len == 1)
-               return 1;
-
-       /* check if expected encoded chars are available */
-       for (i = 0; i < len; i++)
-               if ((str[i] & 0x80) != 0x80)
-                       return -1;
-
-       unichar = utf8_encoded_to_unichar(str);
-
-       /* check if encoded length matches encoded value */
-       if (utf8_unichar_to_encoded_len(unichar) != len)
-               return -1;
-
-       /* check if value has valid range */
-       if (!utf8_unichar_valid_range(unichar))
-               return -1;
-
-       return len;
-}
-
-/* allow chars in whitelist, plain ascii, hex-escaping and valid utf8 */
-int replace_chars(char *str, const char *white)
-{
-       size_t i = 0;
-       int replaced = 0;
-
-       while (str[i] != '\0') {
-               int len;
-
-               /* accept whitelist */
-               if (white != NULL && strchr(white, str[i]) != NULL) {
-                       i++;
-                       continue;
-               }
-
-               /* accept plain ascii char */
-               if ((str[i] >= '0' && str[i] <= '9') ||
-                   (str[i] >= 'A' && str[i] <= 'Z') ||
-                   (str[i] >= 'a' && str[i] <= 'z')) {
-                       i++;
-                       continue;
-               }
-
-               /* accept hex encoding */
-               if (str[i] == '\\' && str[i+1] == 'x') {
-                       i += 2;
-                       continue;
-               }
-
-               /* accept valid utf8 */
-               len = utf8_encoded_valid_unichar(&str[i]);
-               if (len > 1) {
-                       i += len;
-                       continue;
-               }
-
-               /* if space is allowed, replace whitespace with ordinary space */
-               if (isspace(str[i]) && strchr(white, ' ') != NULL) {
-                       str[i] = ' ';
-                       i++;
-                       replaced++;
-                       continue;
-               }
-
-               /* everything else is replaced with '_' */
-               str[i] = '_';
-               i++;
-               replaced++;
-       }
-
-       return replaced;
-}
index 12b1e45f236ef8728996879a5404f688eebb85d5..e3a91fc9a40f6688ff0c7dfa1973dafff90394f3 100644 (file)
@@ -91,12 +91,12 @@ int udevadm_control(struct udev *udev, int argc, char *argv[])
                switch (option) {
                case 'l':
                case 'l' + 256:
                switch (option) {
                case 'l':
                case 'l' + 256:
-                       i = log_priority(optarg);
+                       i = util_log_priority(optarg);
                        if (i < 0) {
                                fprintf(stderr, "invalid number '%s'\n", optarg);
                                goto exit;
                        }
                        if (i < 0) {
                                fprintf(stderr, "invalid number '%s'\n", optarg);
                                goto exit;
                        }
-                       udev_ctrl_send_set_log_level(uctrl, log_priority(optarg));
+                       udev_ctrl_send_set_log_level(uctrl, util_log_priority(optarg));
                        rc = 0;
                        break;
                case 's':
                        rc = 0;
                        break;
                case 's':
@@ -151,7 +151,7 @@ int udevadm_control(struct udev *udev, int argc, char *argv[])
                    "this will stop working in a future release\n");
 
                if (!strncmp(arg, "log_priority=", strlen("log_priority="))) {
                    "this will stop working in a future release\n");
 
                if (!strncmp(arg, "log_priority=", strlen("log_priority="))) {
-                       udev_ctrl_send_set_log_level(uctrl, log_priority(&arg[strlen("log_priority=")]));
+                       udev_ctrl_send_set_log_level(uctrl, util_log_priority(&arg[strlen("log_priority=")]));
                        rc = 0;
                        goto exit;
                } else if (!strcmp(arg, "stop_exec_queue")) {
                        rc = 0;
                        goto exit;
                } else if (!strcmp(arg, "stop_exec_queue")) {
index 1d18f812951722a3c0c6bdded2da4441b01237ff..402fa76e8d24476a4bfab7dff855075c2248d2d8 100644 (file)
@@ -289,7 +289,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
                                strlcpy(name, &optarg[strlen(udev_get_dev_path(udev))+1], sizeof(name));
                        else
                                strlcpy(name, optarg, sizeof(name));
                                strlcpy(name, &optarg[strlen(udev_get_dev_path(udev))+1], sizeof(name));
                        else
                                strlcpy(name, optarg, sizeof(name));
-                       remove_trailing_chars(name, '/');
+                       util_remove_trailing_chars(name, '/');
                        dbg(udev, "name: %s\n", name);
                        break;
                case 'p':
                        dbg(udev, "name: %s\n", name);
                        break;
                case 'p':
@@ -298,7 +298,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
                                strlcpy(path, &optarg[strlen(udev_get_sys_path(udev))], sizeof(path));
                        else
                                strlcpy(path, optarg, sizeof(path));
                                strlcpy(path, &optarg[strlen(udev_get_sys_path(udev))], sizeof(path));
                        else
                                strlcpy(path, optarg, sizeof(path));
-                       remove_trailing_chars(path, '/');
+                       util_remove_trailing_chars(path, '/');
 
                        /* possibly resolve to real devpath */
                        if (sysfs_resolve_link(udev, path, sizeof(path)) != 0) {
 
                        /* possibly resolve to real devpath */
                        if (sysfs_resolve_link(udev, path, sizeof(path)) != 0) {
index 137ab5fb4c4f79f24d33774e77befece8f2a2cc7..6d01040e01cbf7ddd552bfaae08adb7856f0ffde 100644 (file)
@@ -179,7 +179,7 @@ static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac
                strlcat(path, name_loop->name, sizeof(path));
                strlcat(path, " ", sizeof(path));
        }
                strlcat(path, name_loop->name, sizeof(path));
                strlcat(path, " ", sizeof(path));
        }
-       remove_trailing_chars(path, ' ');
+       util_remove_trailing_chars(path, ' ');
        if (path[0] != '\0') {
                bufpos += snprintf(&buf[bufpos], sizeof(buf)-1, "DEVLINKS=%s", path);
                bufpos++;
        if (path[0] != '\0') {
                bufpos += snprintf(&buf[bufpos], sizeof(buf)-1, "DEVLINKS=%s", path);
                bufpos++;
@@ -316,7 +316,7 @@ static int attr_match(const char *path, const char *attr_value)
                if (size < 0)
                        return 0;
                value[size] = '\0';
                if (size < 0)
                        return 0;
                value[size] = '\0';
-               remove_trailing_chars(value, '\n');
+               util_remove_trailing_chars(value, '\n');
 
                /* match if attribute value matches */
                if (fnmatch(match_value, value, 0) == 0)
 
                /* match if attribute value matches */
                if (fnmatch(match_value, value, 0) == 0)
@@ -553,7 +553,7 @@ static void scan_failed(struct udev *udev)
                        if(start >= sizeof(device))
                                start = sizeof(device) - 1;
                        strlcat(device, dent->d_name, sizeof(device));
                        if(start >= sizeof(device))
                                start = sizeof(device) - 1;
                        strlcat(device, dent->d_name, sizeof(device));
-                       path_decode(&device[start]);
+                       util_path_decode(&device[start]);
                        device_list_insert(udev, device);
                }
                closedir(dir);
                        device_list_insert(udev, device);
                }
                closedir(dir);
index e88b11daa079a5ebe8a62591911810e2c6dd2582..06bfbd953e51de79c79acb655926b51122fd6ab9 100644 (file)
@@ -180,7 +180,7 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
        strlcat(filename_failed, "/", sizeof(filename_failed));
        start = strlcat(filename_failed, ".udev/failed/", sizeof(filename_failed));
        strlcat(filename_failed, msg->devpath, sizeof(filename_failed));
        strlcat(filename_failed, "/", sizeof(filename_failed));
        start = strlcat(filename_failed, ".udev/failed/", sizeof(filename_failed));
        strlcat(filename_failed, msg->devpath, sizeof(filename_failed));
-       path_encode(&filename_failed[start], sizeof(filename_failed) - start);
+       util_path_encode(&filename_failed[start], sizeof(filename_failed) - start);
 
        switch (state) {
        case EVENT_QUEUED:
 
        switch (state) {
        case EVENT_QUEUED:
@@ -200,7 +200,7 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
                        strlcat(filename_failed_old, "/", sizeof(filename_failed_old));
                        start = strlcat(filename_failed_old, ".udev/failed/", sizeof(filename_failed_old));
                        strlcat(filename_failed_old, msg->devpath_old, sizeof(filename_failed_old));
                        strlcat(filename_failed_old, "/", sizeof(filename_failed_old));
                        start = strlcat(filename_failed_old, ".udev/failed/", sizeof(filename_failed_old));
                        strlcat(filename_failed_old, msg->devpath_old, sizeof(filename_failed_old));
-                       path_encode(&filename_failed_old[start], sizeof(filename) - start);
+                       util_path_encode(&filename_failed_old[start], sizeof(filename) - start);
 
                        if (rename(filename_failed_old, filename_failed) == 0)
                                info(msg->udev, "renamed devpath, moved failed state of '%s' to %s'\n",
 
                        if (rename(filename_failed_old, filename_failed) == 0)
                                info(msg->udev, "renamed devpath, moved failed state of '%s' to %s'\n",