diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-10 18:59:42 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-10 18:59:42 +0200 |
commit | 31c1f537450e96f8ddd6a0fad2adaefe57996f03 (patch) | |
tree | 816bab62c1215cd2886dd0d238ff30dbfd032ff0 /udev | |
parent | ecc9ec579feb4b7cc86bcf7caed3cb841faf3c9e (diff) |
get rid of udev_sysdeps.c
Diffstat (limited to 'udev')
-rw-r--r-- | udev/Makefile.am | 1 | ||||
-rw-r--r-- | udev/lib/list.h | 286 | ||||
-rw-r--r-- | udev/test-udev.c | 2 | ||||
-rw-r--r-- | udev/udev_db.c | 36 | ||||
-rw-r--r-- | udev/udev_device_event.c | 28 | ||||
-rw-r--r-- | udev/udev_node.c | 48 | ||||
-rw-r--r-- | udev/udev_rules.c | 160 | ||||
-rw-r--r-- | udev/udev_rules_parse.c | 14 | ||||
-rw-r--r-- | udev/udev_sysdeps.c | 68 | ||||
-rw-r--r-- | udev/udev_sysdeps.h | 8 | ||||
-rw-r--r-- | udev/udev_sysfs.c | 132 | ||||
-rw-r--r-- | udev/udev_utils.c | 2 | ||||
-rw-r--r-- | udev/udev_utils_file.c | 2 | ||||
-rw-r--r-- | udev/udevadm-info.c | 36 | ||||
-rw-r--r-- | udev/udevadm-settle.c | 12 | ||||
-rw-r--r-- | udev/udevadm-test.c | 12 | ||||
-rw-r--r-- | udev/udevadm-trigger.c | 124 | ||||
-rw-r--r-- | udev/udevd.c | 34 |
18 files changed, 609 insertions, 396 deletions
diff --git a/udev/Makefile.am b/udev/Makefile.am index 66edd341fd..62739c05d9 100644 --- a/udev/Makefile.am +++ b/udev/Makefile.am @@ -25,7 +25,6 @@ common_files = \ udev_node.c \ udev_rules.c \ udev_rules_parse.c \ - udev_sysdeps.c \ udev_sysfs.c \ udev_utils.c \ udev_utils_file.c \ diff --git a/udev/lib/list.h b/udev/lib/list.h new file mode 100644 index 0000000000..3266e1b124 --- /dev/null +++ b/udev/lib/list.h @@ -0,0 +1,286 @@ +/* + * Based on list.h in the Linux kernel source tree. + */ + +#ifndef _LIST_H +#define _LIST_H + +/** + * container_of - cast a member of a structure out to the containing structure + * + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + +/* + * These are non-NULL pointers that will result in page faults + * under normal circumstances, used to verify that nobody uses + * non-initialized list entries. + */ +#define LIST_POISON1 ((void *) 0x00100100) +#define LIST_POISON2 ((void *) 0x00200200) + +/* + * Simple doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ + +struct list_head { + struct list_head *next, *prev; +}; + +#define LIST_HEAD_INIT(name) { &(name), &(name) } + +#define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + +#define INIT_LIST_HEAD(ptr) do { \ + (ptr)->next = (ptr); (ptr)->prev = (ptr); \ +} while (0) + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + +/** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ +static inline void list_add_tail(struct list_head *new, struct list_head *head) +{ + __list_add(new, head->prev, head); +} + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty on entry does not return true after this, the entry is + * in an undefined state. + */ +static inline void list_del(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + entry->next = LIST_POISON1; + entry->prev = LIST_POISON2; +} + +/** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ +static inline void list_del_init(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); +} + +/** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ +static inline void list_move(struct list_head *list, struct list_head *head) +{ + __list_del(list->prev, list->next); + list_add(list, head); +} + +/** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ +static inline void list_move_tail(struct list_head *list, + struct list_head *head) +{ + __list_del(list->prev, list->next); + list_add_tail(list, head); +} + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static inline int list_empty(struct list_head *head) +{ + return head->next == head; +} + +static inline void __list_splice(struct list_head *list, + struct list_head *head) +{ + struct list_head *first = list->next; + struct list_head *last = list->prev; + struct list_head *at = head->next; + + first->prev = head; + head->next = first; + + last->next = at; + at->prev = last; +} + +/** + * list_splice - join two lists + * @list: the new list to add. + * @head: the place to add it in the first list. + */ +static inline void list_splice(struct list_head *list, struct list_head *head) +{ + if (!list_empty(list)) + __list_splice(list, head); +} + +/** + * list_splice_init - join two lists and reinitialise the emptied list. + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * The list at @list is reinitialised + */ +static inline void list_splice_init(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) { + __list_splice(list, head); + INIT_LIST_HEAD(list); + } +} + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + +/** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ +#define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); \ + pos = pos->next) + +/** + * __list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + * + * This variant differs from list_for_each() in that it's the + * simplest possible list iteration code. + * Use this for code that knows the list to be very short (empty + * or 1 entry) most of the time. + */ +#define __list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +/** + * list_for_each_prev - iterate over a list backwards + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ +#define list_for_each_prev(pos, head) \ + for (pos = (head)->prev; pos != (head); pos = pos->prev) + +/** + * list_for_each_safe - iterate over a list safe against removal of list entry + * @pos: the &struct list_head to use as a loop counter. + * @n: another &struct list_head to use as temporary storage + * @head: the head for your list. + */ +#define list_for_each_safe(pos, n, head) \ + for (pos = (head)->next, n = pos->next; pos != (head); \ + pos = n, n = pos->next) + +/** + * list_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + +/** + * list_for_each_entry_reverse - iterate backwards over list of given type. + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define list_for_each_entry_reverse(pos, head, member) \ + for (pos = list_entry((head)->prev, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.prev, typeof(*pos), member)) + +/** + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry + * @pos: the type * to use as a loop counter. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(*n), member)) + +#endif /* _LIST_H */ diff --git a/udev/test-udev.c b/udev/test-udev.c index d33fcf566d..dae7aaa634 100644 --- a/udev/test-udev.c +++ b/udev/test-udev.c @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) /* override built-in sysfs device */ udevice->dev = dev; - strlcpy(udevice->action, action, sizeof(udevice->action)); + util_strlcpy(udevice->action, action, sizeof(udevice->action)); /* get dev_t from environment, which is needed for "remove" to work, "add" works also from sysfs */ maj = getenv("MAJOR"); diff --git a/udev/udev_db.c b/udev/udev_db.c index 2c3a24939e..763178d50c 100644 --- a/udev/udev_db.c +++ b/udev/udev_db.c @@ -35,9 +35,9 @@ static size_t devpath_to_db_path(struct udev *udev, const char *devpath, char *f size_t start; /* translate to location of db file */ - strlcpy(filename, udev_get_dev_path(udev), len); - start = strlcat(filename, "/.udev/db/", len); - strlcat(filename, devpath, len); + util_strlcpy(filename, udev_get_dev_path(udev), len); + start = util_strlcat(filename, "/.udev/db/", len); + util_strlcat(filename, devpath, len); return util_path_encode(&filename[start], len - start); } @@ -50,15 +50,15 @@ static int name_index(struct udev *udev, const char *devpath, const char *name, int fd; /* directory with device name */ - strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); - start = strlcat(filename, "/.udev/names/", sizeof(filename)); - strlcat(filename, name, sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); + start = util_strlcat(filename, "/.udev/names/", sizeof(filename)); + util_strlcat(filename, name, sizeof(filename)); util_path_encode(&filename[start], sizeof(filename) - start); /* entry with the devpath */ - strlcpy(device, devpath, sizeof(device)); + util_strlcpy(device, devpath, sizeof(device)); util_path_encode(device, sizeof(device)); - strlcat(filename, "/", sizeof(filename)); - strlcat(filename, device, sizeof(filename)); + util_strlcat(filename, "/", sizeof(filename)); + util_strlcat(filename, device, sizeof(filename)); if (add) { info(udev, "creating index: '%s'\n", filename); @@ -81,9 +81,9 @@ int udev_db_get_devices_by_name(struct udev *udev, const char *name, struct list DIR *dir; int rc = 0; - strlcpy(dirname, udev_get_dev_path(udev), sizeof(dirname)); - start = strlcat(dirname, "/.udev/names/", sizeof(dirname)); - strlcat(dirname, name, sizeof(dirname)); + util_strlcpy(dirname, udev_get_dev_path(udev), sizeof(dirname)); + start = util_strlcat(dirname, "/.udev/names/", sizeof(dirname)); + util_strlcat(dirname, name, sizeof(dirname)); util_path_encode(&dirname[start], sizeof(dirname) - start); dir = opendir(dirname); @@ -104,7 +104,7 @@ int udev_db_get_devices_by_name(struct udev *udev, const char *name, struct list if (ent->d_name[0] == '.') continue; - strlcpy(device, ent->d_name, sizeof(device)); + util_strlcpy(device, ent->d_name, sizeof(device)); util_path_decode(device); name_list_add(udev, name_list, device, 0); rc++; @@ -219,7 +219,7 @@ int udev_db_get_device(struct udevice *udevice, const char *devpath) return -1; } dbg(udevice->udev, "db link points to '%s'\n", target); - strlcpy(udevice->name, target, sizeof(udevice->name)); + util_strlcpy(udevice->name, target, sizeof(udevice->name)); return 0; } @@ -241,7 +241,7 @@ int udev_db_get_device(struct udevice *udevice, const char *devpath) switch(bufline[0]) { case 'N': - strlcpy(udevice->name, line, sizeof(udevice->name)); + util_strlcpy(udevice->name, line, sizeof(udevice->name)); break; case 'M': sscanf(line, "%u:%u", &maj, &min); @@ -298,8 +298,8 @@ int udev_db_get_all_entries(struct udev *udev, struct list_head *name_list) char dbpath[PATH_MAX]; DIR *dir; - strlcpy(dbpath, udev_get_dev_path(udev), sizeof(dbpath)); - strlcat(dbpath, "/.udev/db", sizeof(dbpath)); + util_strlcpy(dbpath, udev_get_dev_path(udev), sizeof(dbpath)); + util_strlcat(dbpath, "/.udev/db", sizeof(dbpath)); dir = opendir(dbpath); if (dir == NULL) { info(udev, "no udev_db available '%s': %s\n", dbpath, strerror(errno)); @@ -316,7 +316,7 @@ int udev_db_get_all_entries(struct udev *udev, struct list_head *name_list) if (ent->d_name[0] == '.') continue; - strlcpy(device, ent->d_name, sizeof(device)); + util_strlcpy(device, ent->d_name, sizeof(device)); util_path_decode(device); name_list_add(udev, name_list, device, 1); dbg(udev, "added '%s'\n", device); diff --git a/udev/udev_device_event.c b/udev/udev_device_event.c index 102ea87a48..aacd1d2bc1 100644 --- a/udev/udev_device_event.c +++ b/udev/udev_device_event.c @@ -31,7 +31,6 @@ #include "udev.h" #include "udev_rules.h" - static void kernel_log(struct ifreq ifr) { int klog; @@ -69,8 +68,8 @@ static int rename_netif(struct udevice *udevice) } memset(&ifr, 0x00, sizeof(struct ifreq)); - strlcpy(ifr.ifr_name, udevice->dev->kernel, IFNAMSIZ); - strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ); + util_strlcpy(ifr.ifr_name, udevice->dev->kernel, IFNAMSIZ); + util_strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ); retval = ioctl(sk, SIOCSIFNAME, &ifr); if (retval == 0) kernel_log(ifr); @@ -79,22 +78,24 @@ static int rename_netif(struct udevice *udevice) /* see if the destination interface name already exists */ if (errno != EEXIST) { - err(udevice->udev, "error changing netif name %s to %s: %s\n", ifr.ifr_name, ifr.ifr_newname, strerror(errno)); + err(udevice->udev, "error changing netif name %s to %s: %s\n", + ifr.ifr_name, ifr.ifr_newname, strerror(errno)); goto exit; } /* free our own name, another process may wait for us */ - strlcpy(ifr.ifr_newname, udevice->dev->kernel, IFNAMSIZ); - strlcat(ifr.ifr_newname, "_rename", IFNAMSIZ); + util_strlcpy(ifr.ifr_newname, udevice->dev->kernel, IFNAMSIZ); + util_strlcat(ifr.ifr_newname, "_rename", IFNAMSIZ); retval = ioctl(sk, SIOCSIFNAME, &ifr); if (retval != 0) { - err(udevice->udev, "error changing netif name %s to %s: %s\n", ifr.ifr_name, ifr.ifr_newname, strerror(errno)); + err(udevice->udev, "error changing netif name %s to %s: %s\n", + ifr.ifr_name, ifr.ifr_newname, strerror(errno)); goto exit; } /* wait 30 seconds for our target to become available */ - strlcpy(ifr.ifr_name, ifr.ifr_newname, IFNAMSIZ); - strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ); + util_strlcpy(ifr.ifr_name, ifr.ifr_newname, IFNAMSIZ); + util_strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ); loop = 30 * 20; while (loop--) { retval = ioctl(sk, SIOCSIFNAME, &ifr); @@ -108,7 +109,8 @@ static int rename_netif(struct udevice *udevice) ifr.ifr_name, ifr.ifr_newname, strerror(errno)); break; } - dbg(udevice->udev, "wait for netif '%s' to become free, loop=%i\n", udevice->name, (30 * 20) - loop); + dbg(udevice->udev, "wait for netif '%s' to become free, loop=%i\n", + udevice->name, (30 * 20) - loop); usleep(1000 * 1000 / 20); } } @@ -199,11 +201,11 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udevice) setenv("INTERFACE_OLD", udevice->dev->kernel, 1); /* now change the devpath, because the kernel device name has changed */ - strlcpy(devpath, udevice->dev->devpath, sizeof(devpath)); + util_strlcpy(devpath, udevice->dev->devpath, sizeof(devpath)); pos = strrchr(devpath, '/'); if (pos != NULL) { pos[1] = '\0'; - strlcat(devpath, udevice->name, sizeof(devpath)); + util_strlcat(devpath, udevice->name, sizeof(devpath)); sysfs_device_set_values(udevice->udev, udevice->dev, devpath, NULL, NULL); setenv("DEVPATH", udevice->dev->devpath, 1); setenv("INTERFACE", udevice->name, 1); @@ -226,7 +228,7 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udevice) } else { dbg(udevice->udev, "'%s' not found in database, using kernel name '%s'\n", udevice->dev->devpath, udevice->dev->kernel); - strlcpy(udevice->name, udevice->dev->kernel, sizeof(udevice->name)); + util_strlcpy(udevice->name, udevice->dev->kernel, sizeof(udevice->name)); } udev_rules_get_run(rules, udevice); diff --git a/udev/udev_node.c b/udev/udev_node.c index 80c4f0a5f3..0319b2f875 100644 --- a/udev/udev_node.c +++ b/udev/udev_node.c @@ -51,8 +51,8 @@ int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_ udev_selinux_lsetfilecon(udevice->udev, file, mode); } else { info(udevice->udev, "atomically replace existing file '%s'\n", file); - strlcpy(file_tmp, file, sizeof(file_tmp)); - strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp)); + util_strlcpy(file_tmp, file, sizeof(file_tmp)); + util_strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp)); unlink(file_tmp); udev_selinux_setfscreatecon(udevice->udev, file_tmp, mode); err = mknod(file_tmp, mode, devt); @@ -119,10 +119,10 @@ static int node_symlink(struct udevice *udevice, const char *node, const char *s } while (slink[i] != '\0') { if (slink[i] == '/') - strlcat(target, "../", sizeof(target)); + util_strlcat(target, "../", sizeof(target)); i++; } - strlcat(target, &node[tail], sizeof(target)); + util_strlcat(target, &node[tail], sizeof(target)); /* preserve link with correct target, do not replace node of other device */ if (lstat(slink, &stats) == 0) { @@ -163,8 +163,8 @@ static int node_symlink(struct udevice *udevice, const char *node, const char *s } info(udevice->udev, "atomically replace '%s'\n", slink); - strlcpy(slink_tmp, slink, sizeof(slink_tmp)); - strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp)); + util_strlcpy(slink_tmp, slink, sizeof(slink_tmp)); + util_strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp)); unlink(slink_tmp); udev_selinux_setfscreatecon(udevice->udev, slink, S_IFLNK); retval = symlink(target, slink_tmp); @@ -195,9 +195,9 @@ static int update_link(struct udevice *udevice, const char *name) int priority = 0; int rc = 0; - strlcpy(slink, udev_get_dev_path(udevice->udev), sizeof(slink)); - strlcat(slink, "/", sizeof(slink)); - strlcat(slink, name, sizeof(slink)); + util_strlcpy(slink, udev_get_dev_path(udevice->udev), sizeof(slink)); + util_strlcat(slink, "/", sizeof(slink)); + util_strlcat(slink, name, sizeof(slink)); count = udev_db_get_devices_by_name(udevice->udev, name, &name_list); info(udevice->udev, "found %i devices with name '%s'\n", count, name); @@ -224,7 +224,7 @@ static int update_link(struct udevice *udevice, const char *name) info(udevice->udev, "'%s' is our device node, database inconsistent, skip link update\n", udevice->name); } else if (target[0] == '\0' || udevice->link_priority >= priority) { priority = udevice->link_priority; - strlcpy(target, udevice->name, sizeof(target)); + util_strlcpy(target, udevice->name, sizeof(target)); } continue; } @@ -241,7 +241,7 @@ static int update_link(struct udevice *udevice, const char *name) udevice_db->dev->devpath, udevice_db->link_priority, priority); if (target[0] == '\0' || udevice_db->link_priority > priority) { priority = udevice_db->link_priority; - strlcpy(target, udevice_db->name, sizeof(target)); + util_strlcpy(target, udevice_db->name, sizeof(target)); } } } @@ -256,9 +256,9 @@ static int update_link(struct udevice *udevice, const char *name) } /* create symlink to the target with the highest priority */ - strlcpy(node, udev_get_dev_path(udevice->udev), sizeof(node)); - strlcat(node, "/", sizeof(node)); - strlcat(node, target, sizeof(node)); + util_strlcpy(node, udev_get_dev_path(udevice->udev), sizeof(node)); + util_strlcat(node, "/", sizeof(node)); + util_strlcat(node, target, sizeof(node)); info(udevice->udev, "'%s' with target '%s' has the highest priority %i, create it\n", name, target, priority); if (!udevice->test_run) { create_path(udevice->udev, slink); @@ -276,10 +276,10 @@ void udev_node_update_symlinks(struct udevice *udevice, struct udevice *udevice_ list_for_each_entry(name_loop, &udevice->symlink_list, node) { info(udevice->udev, "update symlink '%s' of '%s'\n", name_loop->name, udevice->dev->devpath); update_link(udevice, name_loop->name); - strlcat(symlinks, udev_get_dev_path(udevice->udev), sizeof(symlinks)); - strlcat(symlinks, "/", sizeof(symlinks)); - strlcat(symlinks, name_loop->name, sizeof(symlinks)); - strlcat(symlinks, " ", sizeof(symlinks)); + util_strlcat(symlinks, udev_get_dev_path(udevice->udev), sizeof(symlinks)); + util_strlcat(symlinks, "/", sizeof(symlinks)); + util_strlcat(symlinks, name_loop->name, sizeof(symlinks)); + util_strlcat(symlinks, " ", sizeof(symlinks)); } /* export symlinks to environment */ @@ -327,9 +327,9 @@ int udev_node_add(struct udevice *udevice) int i; int retval = 0; - strlcpy(filename, udev_get_dev_path(udevice->udev), sizeof(filename)); - strlcat(filename, "/", sizeof(filename)); - strlcat(filename, udevice->name, sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udevice->udev), sizeof(filename)); + util_strlcat(filename, "/", sizeof(filename)); + util_strlcat(filename, udevice->name, sizeof(filename)); create_path(udevice->udev, filename); if (strcmp(udevice->owner, "root") == 0) @@ -406,9 +406,9 @@ int udev_node_remove(struct udevice *udevice) int retval = 0; int num; - strlcpy(filename, udev_get_dev_path(udevice->udev), sizeof(filename)); - strlcat(filename, "/", sizeof(filename)); - strlcat(filename, udevice->name, sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udevice->udev), sizeof(filename)); + util_strlcat(filename, "/", sizeof(filename)); + util_strlcat(filename, udevice->name, sizeof(filename)); if (stat(filename, &stats) != 0) { info(udevice->udev, "device node '%s' not found\n", filename); return 0; diff --git a/udev/udev_rules.c b/udev/udev_rules.c index a56ed4e176..72c859348e 100644 --- a/udev/udev_rules.c +++ b/udev/udev_rules.c @@ -131,7 +131,7 @@ static int run_program(struct udev *udev, const char *command, const char *subsy int retval = 0; /* build argv from comand */ - strlcpy(arg, command, sizeof(arg)); + util_strlcpy(arg, command, sizeof(arg)); i = 0; if (strchr(arg, ' ') != NULL) { char *pos = arg; @@ -172,8 +172,8 @@ static int run_program(struct udev *udev, const char *command, const char *subsy /* allow programs in /lib/udev called without the path */ if (strchr(argv[0], '/') == NULL) { - strlcpy(program, UDEV_PREFIX "/lib/udev/", sizeof(program)); - strlcat(program, argv[0], sizeof(program)); + util_strlcpy(program, UDEV_PREFIX "/lib/udev/", sizeof(program)); + util_strlcat(program, argv[0], sizeof(program)); argv[0] = program; } @@ -432,7 +432,7 @@ static int import_parent_into_env(struct udevice *udevice, const char *filter) char name[NAME_SIZE]; char *pos; - strlcpy(name, name_loop->name, sizeof(name)); + util_strlcpy(name, name_loop->name, sizeof(name)); pos = strchr(name, '='); if (pos) { pos[0] = '\0'; @@ -472,22 +472,22 @@ static int pass_env_to_socket(struct udev *udev, const char *sockpath, const cha saddr.sun_family = AF_LOCAL; if (sockpath[0] == '@') { /* abstract namespace socket requested */ - strlcpy(&saddr.sun_path[1], &sockpath[1], sizeof(saddr.sun_path)-1); + util_strlcpy(&saddr.sun_path[1], &sockpath[1], sizeof(saddr.sun_path)-1); saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]); } else if (stat(sockpath, &stats) == 0 && S_ISSOCK(stats.st_mode)) { /* existing socket file */ - strlcpy(saddr.sun_path, sockpath, sizeof(saddr.sun_path)); + util_strlcpy(saddr.sun_path, sockpath, sizeof(saddr.sun_path)); saddrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path); } else { /* no socket file, assume abstract namespace socket */ - strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1); + util_strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1); saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]); } bufpos = snprintf(buf, sizeof(buf), "%s@%s", action, devpath); bufpos++; for (i = 0; environ[i] != NULL && bufpos < (sizeof(buf)); i++) { - bufpos += strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos); + bufpos += util_strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos); bufpos++; } if (bufpos > sizeof(buf)) @@ -514,7 +514,7 @@ int udev_rules_run(struct udevice *udevice) } else { char program[PATH_SIZE]; - strlcpy(program, name_loop->name, sizeof(program)); + util_strlcpy(program, name_loop->name, sizeof(program)); udev_rules_apply_format(udevice, program, sizeof(program)); if (run_program(udevice->udev, program, udevice->dev->subsystem, NULL, 0, NULL) != 0) if (!name_loop->ignore_error) @@ -535,12 +535,12 @@ static int wait_for_file(struct udevice *udevice, const char *file, int timeout) /* a relative path is a device attribute */ if (file[0] != '/') { - strlcpy(devicepath, udev_get_sys_path(udevice->udev), sizeof(devicepath)); - strlcat(devicepath, udevice->dev->devpath, sizeof(devicepath)); + util_strlcpy(devicepath, udev_get_sys_path(udevice->udev), sizeof(devicepath)); + util_strlcat(devicepath, udevice->dev->devpath, sizeof(devicepath)); - strlcpy(filepath, devicepath, sizeof(filepath)); - strlcat(filepath, "/", sizeof(filepath)); - strlcat(filepath, file, sizeof(filepath)); + util_strlcpy(filepath, devicepath, sizeof(filepath)); + util_strlcat(filepath, "/", sizeof(filepath)); + util_strlcat(filepath, file, sizeof(filepath)); file = filepath; } @@ -580,7 +580,7 @@ static int attr_get_by_subsys_id(struct udev *udev, const char *attrstr, char *d goto out; attrib = &attrib[1]; - strlcpy(subsys, &attrstr[1], sizeof(subsys)); + util_strlcpy(subsys, &attrstr[1], sizeof(subsys)); pos = strchr(subsys, ']'); if (pos == NULL) goto out; @@ -614,7 +614,7 @@ static int attr_subst_subdir(char *attr, size_t len) DIR *dir; pos[1] = '\0'; - strlcpy(str, &pos[2], sizeof(str)); + util_strlcpy(str, &pos[2], sizeof(str)); dir = opendir(attr); if (dir != NULL) { struct dirent *dent; @@ -624,8 +624,8 @@ static int attr_subst_subdir(char *attr, size_t len) if (dent->d_name[0] == '.') continue; - strlcat(attr, dent->d_name, len); - strlcat(attr, str, len); + util_strlcat(attr, dent->d_name, len); + util_strlcat(attr, str, len); if (stat(attr, &stats) == 0) { found = 1; break; @@ -635,7 +635,7 @@ static int attr_subst_subdir(char *attr, size_t len) closedir(dir); } if (!found) - strlcat(attr, str, len); + util_strlcat(attr, str, len); } return found; @@ -704,8 +704,8 @@ void udev_rules_apply_format(struct udevice *udevice, char *string, size_t maxsi if (head[1] == '\0') break; if (head[1] == '$') { - strlcpy(temp, head+2, sizeof(temp)); - strlcpy(head+1, temp, maxsize); + util_strlcpy(temp, head+2, sizeof(temp)); + util_strlcpy(head+1, temp, maxsize); head++; continue; } @@ -725,8 +725,8 @@ void udev_rules_apply_format(struct udevice *udevice, char *string, size_t maxsi if (head[1] == '\0') break; if (head[1] == '%') { - strlcpy(temp, head+2, sizeof(temp)); - strlcpy(head+1, temp, maxsize); + util_strlcpy(temp, head+2, sizeof(temp)); + util_strlcpy(head+1, temp, maxsize); head++; continue; } @@ -749,42 +749,42 @@ void udev_rules_apply_format(struct udevice *udevice, char *string, size_t maxsi break; found: attr = get_format_attribute(udevice->udev, &tail); - strlcpy(temp, tail, sizeof(temp)); + util_strlcpy(temp, tail, sizeof(temp)); dbg(udevice->udev, "format=%i, string='%s', tail='%s'\n", type ,string, tail); switch (type) { case SUBST_DEVPATH: - strlcat(string, udevice->dev->devpath, maxsize); + util_strlcat(string, udevice->dev->devpath, maxsize); dbg(udevice->udev, "substitute devpath '%s'\n", udevice->dev->devpath); break; case SUBST_KERNEL: - strlcat(string, udevice->dev->kernel, maxsize); + util_strlcat(string, udevice->dev->kernel, maxsize); dbg(udevice->udev, "substitute kernel name '%s'\n", udevice->dev->kernel); break; case SUBST_KERNEL_NUMBER: - strlcat(string, udevice->dev->kernel_number, maxsize); + util_strlcat(string, udevice->dev->kernel_number, maxsize); dbg(udevice->udev, "substitute kernel number '%s'\n", udevice->dev->kernel_number); break; case SUBST_ID: if (udevice->dev_parent != NULL) { - strlcat(string, udevice->dev_parent->kernel, maxsize); + util_strlcat(string, udevice->dev_parent->kernel, maxsize); dbg(udevice->udev, "substitute id '%s'\n", udevice->dev_parent->kernel); } break; case SUBST_DRIVER: if (udevice->dev_parent != NULL) { - strlcat(string, udevice->dev_parent->driver, maxsize); + util_strlcat(string, udevice->dev_parent->driver, maxsize); dbg(udevice->udev, "substitute driver '%s'\n", udevice->dev_parent->driver); } break; case SUBST_MAJOR: sprintf(temp2, "%d", major(udevice->devt)); - strlcat(string, temp2, maxsize); + util_strlcat(string, temp2, maxsize); dbg(udevice->udev, "substitute major number '%s'\n", temp2); break; case SUBST_MINOR: sprintf(temp2, "%d", minor(udevice->devt)); - strlcat(string, temp2, maxsize); + util_strlcat(string, temp2, maxsize); dbg(udevice->udev, "substitute minor number '%s'\n", temp2); break; case SUBST_RESULT: @@ -807,17 +807,17 @@ found: err(udevice->udev, "requested part of result string not found\n"); break; } - strlcpy(temp2, cpos, sizeof(temp2)); + util_strlcpy(temp2, cpos, sizeof(temp2)); /* %{2+}c copies the whole string from the second part on */ if (rest[0] != '+') { cpos = strchr(temp2, ' '); if (cpos) cpos[0] = '\0'; } - strlcat(string, temp2, maxsize); + util_strlcat(string, temp2, maxsize); dbg(udevice->udev, "substitute part of result string '%s'\n", temp2); } else { - strlcat(string, udevice->program_result, maxsize); + util_strlcat(string, udevice->program_result, maxsize); dbg(udevice->udev, "substitute result string '%s'\n", udevice->program_result); } break; @@ -858,7 +858,7 @@ found: break; /* strip trailing whitespace, and replace unwanted characters */ - size = strlcpy(temp2, value, sizeof(temp2)); + size = util_strlcpy(temp2, value, sizeof(temp2)); if (size >= sizeof(temp2)) size = sizeof(temp2)-1; while (size > 0 && isspace(temp2[size-1])) @@ -866,7 +866,7 @@ found: count = util_replace_chars(temp2, ALLOWED_CHARS_INPUT); if (count > 0) info(udevice->udev, "%i character(s) replaced\n" , count); - strlcat(string, temp2, maxsize); + util_strlcat(string, temp2, maxsize); dbg(udevice->udev, "substitute sysfs value '%s'\n", temp2); } break; @@ -883,7 +883,7 @@ found: if (udev_parent != NULL) { /* lookup the name in the udev_db with the DEVPATH of the parent */ if (udev_db_get_device(udev_parent, dev_parent->devpath) == 0) { - strlcat(string, udev_parent->name, maxsize); + util_strlcat(string, udev_parent->name, maxsize); dbg(udevice->udev, "substitute parent node name'%s'\n", udev_parent->name); } else dbg(udevice->udev, "parent not found in database\n"); @@ -900,15 +900,15 @@ found: udevice->tmp_node[sizeof(udevice->tmp_node)-1] = '\0'; udev_node_mknod(udevice, udevice->tmp_node, udevice->devt, 0600, 0, 0); } - strlcat(string, udevice->tmp_node, maxsize); + util_strlcat(string, udevice->tmp_node, maxsize); dbg(udevice->udev, "substitute temporary device node name '%s'\n", udevice->tmp_node); break; case SUBST_NAME: if (udevice->name[0] == '\0') { - strlcat(string, udevice->dev->kernel, maxsize); + util_strlcat(string, udevice->dev->kernel, maxsize); dbg(udevice->udev, "substitute udevice->kernel '%s'\n", udevice->name); } else { - strlcat(string, udevice->name, maxsize); + util_strlcat(string, udevice->name, maxsize); dbg(udevice->udev, "substitute udevice->name '%s'\n", udevice->name); } break; @@ -918,19 +918,19 @@ found: char symlinks[PATH_SIZE] = ""; list_for_each_entry(name_loop, &udevice->symlink_list, node) { - strlcat(symlinks, name_loop->name, sizeof(symlinks)); - strlcat(symlinks, " ", sizeof(symlinks)); + util_strlcat(symlinks, name_loop->name, sizeof(symlinks)); + util_strlcat(symlinks, " ", sizeof(symlinks)); } util_remove_trailing_chars(symlinks, ' '); - strlcat(string, symlinks, maxsize); + util_strlcat(string, symlinks, maxsize); } break; case SUBST_ROOT: - strlcat(string, udev_get_dev_path(udevice->udev), maxsize); + util_strlcat(string, udev_get_dev_path(udevice->udev), maxsize); dbg(udevice->udev, "substitute udev_root '%s'\n", udev_get_dev_path(udevice->udev)); break; case SUBST_SYS: - strlcat(string, udev_get_sys_path(udevice->udev), maxsize); + util_strlcat(string, udev_get_sys_path(udevice->udev), maxsize); dbg(udevice->udev, "substitute sys_path '%s'\n", udev_get_sys_path(udevice->udev)); break; case SUBST_ENV: @@ -944,7 +944,7 @@ found: break; } dbg(udevice->udev, "substitute env '%s=%s'\n", attr, pos); - strlcat(string, pos, maxsize); + util_strlcat(string, pos, maxsize); break; default: err(udevice->udev, "unknown substitution type=%i\n", type); @@ -955,7 +955,7 @@ found: head[len] = '\0'; dbg(udevice->udev, "truncate to %i chars, subtitution string becomes '%s'\n", len, head); } - strlcat(string, temp, maxsize); + util_strlcat(string, temp, maxsize); } } @@ -981,7 +981,7 @@ static int match_key(struct udev *udev, const char *key_name, struct udev_rule * return 0; /* look for a matching string, parts are separated by '|' */ - strlcpy(value, rule->buf + key->val_off, sizeof(value)); + util_strlcpy(value, rule->buf + key->val_off, sizeof(value)); key_value = value; dbg(udev, "key %s value='%s'\n", key_name, key_value); while (key_value) { @@ -1076,24 +1076,24 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule) struct stat statbuf; int match; - strlcpy(filename, key_val(rule, &rule->test), sizeof(filename)); + util_strlcpy(filename, key_val(rule, &rule->test), sizeof(filename)); udev_rules_apply_format(udevice, filename, sizeof(filename)); if (attr_get_by_subsys_id(udevice->udev, filename, devpath, sizeof(devpath), &attr)) { - strlcpy(filename, udev_get_sys_path(udevice->udev), sizeof(filename)); - strlcat(filename, devpath, sizeof(filename)); + util_strlcpy(filename, udev_get_sys_path(udevice->udev), sizeof(filename)); + util_strlcat(filename, devpath, sizeof(filename)); if (attr != NULL) { - strlcat(filename, "/", sizeof(filename)); - strlcat(filename, attr, sizeof(filename)); + util_strlcat(filename, "/", sizeof(filename)); + util_strlcat(filename, attr, sizeof(filename)); } } else if (filename[0] != '/') { char tmp[PATH_SIZE]; - strlcpy(tmp, udev_get_sys_path(udevice->udev), sizeof(tmp)); - strlcat(tmp, udevice->dev->devpath, sizeof(tmp)); - strlcat(tmp, "/", sizeof(tmp)); - strlcat(tmp, filename, sizeof(tmp)); - strlcpy(filename, tmp, sizeof(filename)); + util_strlcpy(tmp, udev_get_sys_path(udevice->udev), sizeof(tmp)); + util_strlcat(tmp, udevice->dev->devpath, sizeof(tmp)); + util_strlcat(tmp, "/", sizeof(tmp)); + util_strlcat(tmp, filename, sizeof(tmp)); + util_strlcpy(filename, tmp, sizeof(filename)); } attr_subst_subdir(filename, sizeof(filename)); @@ -1117,7 +1117,7 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule) char filename[PATH_SIZE]; int found; - strlcpy(filename, key_val(rule, &rule->wait_for), sizeof(filename)); + util_strlcpy(filename, key_val(rule, &rule->wait_for), sizeof(filename)); udev_rules_apply_format(udevice, filename, sizeof(filename)); found = (wait_for_file(udevice, filename, 10) == 0); if (!found && (rule->wait_for.operation != KEY_OP_NOMATCH)) @@ -1148,7 +1148,7 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule) value = sysfs_attr_get_value(udevice->udev, udevice->dev->devpath, key_name); if (value == NULL) goto nomatch; - strlcpy(val, value, sizeof(val)); + util_strlcpy(val, value, sizeof(val)); /* strip trailing whitespace of value, if not asked to match for it */ len = strlen(key_value); @@ -1196,7 +1196,7 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule) value = sysfs_attr_get_value(udevice->udev, udevice->dev->devpath, key_name); if (value == NULL) goto try_parent; - strlcpy(val, value, sizeof(val)); + util_strlcpy(val, value, sizeof(val)); /* strip trailing whitespace of value, if not asked to match for it */ len = strlen(key_value); @@ -1229,7 +1229,7 @@ try_parent: char program[PATH_SIZE]; char result[PATH_SIZE]; - strlcpy(program, key_val(rule, &rule->program), sizeof(program)); + util_strlcpy(program, key_val(rule, &rule->program), sizeof(program)); udev_rules_apply_format(udevice, program, sizeof(program)); if (run_program(udevice->udev, program, udevice->dev->subsystem, result, sizeof(result), NULL) != 0) { dbg(udevice->udev, "PROGRAM is false\n"); @@ -1248,7 +1248,7 @@ try_parent: info(udevice->udev, "%i character(s) replaced\n" , count); } dbg(udevice->udev, "result is '%s'\n", result); - strlcpy(udevice->program_result, result, sizeof(udevice->program_result)); + util_strlcpy(udevice->program_result, result, sizeof(udevice->program_result)); dbg(udevice->udev, "PROGRAM returned successful\n"); if (rule->program.operation == KEY_OP_NOMATCH) goto nomatch; @@ -1265,7 +1265,7 @@ try_parent: char import[PATH_SIZE]; int rc = -1; - strlcpy(import, key_val(rule, &rule->import), sizeof(import)); + util_strlcpy(import, key_val(rule, &rule->import), sizeof(import)); udev_rules_apply_format(udevice, import, sizeof(import)); dbg(udevice->udev, "check for IMPORT import='%s'\n", import); if (rule->import_type == IMPORT_PROGRAM) { @@ -1296,7 +1296,7 @@ try_parent: const char *value = key_val(rule, &pair->key); /* make sure we don't write to the same string we possibly read from */ - strlcpy(temp_value, value, sizeof(temp_value)); + util_strlcpy(temp_value, value, sizeof(temp_value)); udev_rules_apply_format(udevice, temp_value, NAME_SIZE); if (temp_value[0] == '\0') { @@ -1329,23 +1329,23 @@ try_parent: if (attr_get_by_subsys_id(udevice->udev, key_name, devpath, sizeof(devpath), &attrib)) { if (attrib != NULL) { - strlcpy(attr, udev_get_sys_path(udevice->udev), sizeof(attr)); - strlcat(attr, devpath, sizeof(attr)); - strlcat(attr, "/", sizeof(attr)); - strlcat(attr, attrib, sizeof(attr)); + util_strlcpy(attr, udev_get_sys_path(udevice->udev), sizeof(attr)); + util_strlcat(attr, devpath, sizeof(attr)); + util_strlcat(attr, "/", sizeof(attr)); + util_strlcat(attr, attrib, sizeof(attr)); } } if (attr[0] == '\0') { - strlcpy(attr, udev_get_sys_path(udevice->udev), sizeof(attr)); - strlcat(attr, udevice->dev->devpath, sizeof(attr)); - strlcat(attr, "/", sizeof(attr)); - strlcat(attr, key_name, sizeof(attr)); + util_strlcpy(attr, udev_get_sys_path(udevice->udev), sizeof(attr)); + util_strlcat(attr, udevice->dev->devpath, sizeof(attr)); + util_strlcat(attr, "/", sizeof(attr)); + util_strlcat(attr, key_name, sizeof(attr)); } attr_subst_subdir(attr, sizeof(attr)); - strlcpy(value, key_val(rule, &pair->key), sizeof(value)); + util_strlcpy(value, key_val(rule, &pair->key), sizeof(value)); udev_rules_apply_format(udevice, value, sizeof(value)); info(udevice->udev, "writing '%s' to sysfs file '%s'\n", value, attr); f = fopen(attr, "w"); @@ -1420,7 +1420,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice) if (rule->mode.operation == KEY_OP_ASSIGN_FINAL) udevice->mode_final = 1; char buf[20]; - strlcpy(buf, key_val(rule, &rule->mode), sizeof(buf)); + util_strlcpy(buf, key_val(rule, &rule->mode), sizeof(buf)); udev_rules_apply_format(udevice, buf, sizeof(buf)); udevice->mode = strtol(buf, NULL, 8); dbg(udevice->udev, "applied mode=%#o to '%s'\n", udevice->mode, udevice->dev->kernel); @@ -1428,14 +1428,14 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice) if (!udevice->owner_final && rule->owner.operation != KEY_OP_UNSET) { if (rule->owner.operation == KEY_OP_ASSIGN_FINAL) udevice->owner_final = 1; - strlcpy(udevice->owner, key_val(rule, &rule->owner), sizeof(udevice->owner)); + util_strlcpy(udevice->owner, key_val(rule, &rule->owner), sizeof(udevice->owner)); udev_rules_apply_format(udevice, udevice->owner, sizeof(udevice->owner)); dbg(udevice->udev, "applied owner='%s' to '%s'\n", udevice->owner, udevice->dev->kernel); } if (!udevice->group_final && rule->group.operation != KEY_OP_UNSET) { if (rule->group.operation == KEY_OP_ASSIGN_FINAL) udevice->group_final = 1; - strlcpy(udevice->group, key_val(rule, &rule->group), sizeof(udevice->group)); + util_strlcpy(udevice->group, key_val(rule, &rule->group), sizeof(udevice->group)); udev_rules_apply_format(udevice, udevice->group, sizeof(udevice->group)); dbg(udevice->udev, "applied group='%s' to '%s'\n", udevice->group, udevice->dev->kernel); } @@ -1457,7 +1457,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice) name_list_cleanup(udevice->udev, &udevice->symlink_list); } /* allow multiple symlinks separated by spaces */ - strlcpy(temp, key_val(rule, &rule->symlink), sizeof(temp)); + util_strlcpy(temp, key_val(rule, &rule->symlink), sizeof(temp)); udev_rules_apply_format(udevice, temp, sizeof(temp)); if (rule->string_escape == ESCAPE_UNSET || rule->string_escape == ESCAPE_REPLACE) { @@ -1492,7 +1492,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice) int count; name_set = 1; - strlcpy(udevice->name, key_val(rule, &rule->name), sizeof(udevice->name)); + util_strlcpy(udevice->name, key_val(rule, &rule->name), sizeof(udevice->name)); udev_rules_apply_format(udevice, udevice->name, sizeof(udevice->name)); if (rule->string_escape == ESCAPE_UNSET || rule->string_escape == ESCAPE_REPLACE) { @@ -1536,7 +1536,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice) if (!name_set) { info(udevice->udev, "no node name set, will use kernel name '%s'\n", udevice->dev->kernel); - strlcpy(udevice->name, udevice->dev->kernel, sizeof(udevice->name)); + util_strlcpy(udevice->name, udevice->dev->kernel, sizeof(udevice->name)); } if (udevice->tmp_node[0] != '\0') { diff --git a/udev/udev_rules_parse.c b/udev/udev_rules_parse.c index 685260f12c..1c5f36d491 100644 --- a/udev/udev_rules_parse.c +++ b/udev/udev_rules_parse.c @@ -209,7 +209,7 @@ static int add_rule_key(struct udev_rule *rule, struct key *key, key->operation = operation; key->val_off = rule->bufsize; - strlcpy(rule->buf + rule->bufsize, value, val_len+1); + util_strlcpy(rule->buf + rule->bufsize, value, val_len+1); rule->bufsize += val_len+1; return 0; @@ -229,7 +229,7 @@ static int add_rule_key_pair(struct udev_rules *rules, struct udev_rule *rule, s /* add the key-name of the pair */ pairs->keys[pairs->count].key_name_off = rule->bufsize; - strlcpy(rule->buf + rule->bufsize, key, key_len+1); + util_strlcpy(rule->buf + rule->bufsize, key, key_len+1); rule->bufsize += key_len+1; pairs->count++; @@ -448,15 +448,15 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena char *pos; struct stat statbuf; - strlcpy(file, value, sizeof(file)); + util_strlcpy(file, value, sizeof(file)); pos = strchr(file, ' '); if (pos) pos[0] = '\0'; /* allow programs in /lib/udev called without the path */ if (strchr(file, '/') == NULL) { - strlcpy(file, UDEV_PREFIX "/lib/udev/", sizeof(file)); - strlcat(file, value, sizeof(file)); + util_strlcpy(file, UDEV_PREFIX "/lib/udev/", sizeof(file)); + util_strlcat(file, value, sizeof(file)); pos = strchr(file, ' '); if (pos) pos[0] = '\0'; @@ -750,8 +750,8 @@ int udev_rules_init(struct udev *udev, struct udev_rules *rules, int resolve_nam add_matching_files(udev, &name_list, SYSCONFDIR "/udev/rules.d", ".rules"); /* read dynamic/temporary rules */ - strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); - strlcat(filename, "/.udev/rules.d", sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); + util_strlcat(filename, "/.udev/rules.d", sizeof(filename)); if (stat(filename, &statbuf) != 0) { create_path(udev, filename); udev_selinux_setfscreatecon(udev, filename, S_IFDIR|0755); diff --git a/udev/udev_sysdeps.c b/udev/udev_sysdeps.c deleted file mode 100644 index 73065f7674..0000000000 --- a/udev/udev_sysdeps.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2005-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 <string.h> -#include <sys/types.h> - -#include "udev_sysdeps.h" - -#ifndef HAVE_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t size) -{ - size_t bytes = 0; - char *q = dst; - const char *p = src; - char ch; - - while ((ch = *p++)) { - if (bytes+1 < size) - *q++ = ch; - bytes++; - } - - /* If size == 0 there is no space for a final null... */ - if (size) - *q = '\0'; - return bytes; -} - -size_t strlcat(char *dst, const char *src, size_t size) -{ - size_t bytes = 0; - char *q = dst; - const char *p = src; - char ch; - - while (bytes < size && *q) { - q++; - bytes++; - } - if (bytes == size) - return (bytes + strlen(src)); - - while ((ch = *p++)) { - if (bytes+1 < size) - *q++ = ch; - bytes++; - } - - *q = '\0'; - return bytes; -} -#endif /* HAVE_STRLCPY */ diff --git a/udev/udev_sysdeps.h b/udev/udev_sysdeps.h index 15387dcebd..eaeab86f6b 100644 --- a/udev/udev_sysdeps.h +++ b/udev/udev_sysdeps.h @@ -46,11 +46,5 @@ static inline int inotify_add_watch(int fd, const char *name, uint32_t mask) #define IN_MOVE 0 #define IN_CLOSE_WRITE 0 -#endif - -#ifndef HAVE_STRLCPY -extern size_t strlcpy(char *dst, const char *src, size_t size); -extern size_t strlcat(char *dst, const char *src, size_t size); -#endif - +#endif /* HAVE_INOTIFY */ #endif diff --git a/udev/udev_sysfs.c b/udev/udev_sysfs.c index 6b9f9dac3a..0d4a971188 100644 --- a/udev/udev_sysfs.c +++ b/udev/udev_sysfs.c @@ -71,17 +71,17 @@ void sysfs_device_set_values(struct udev *udev, { char *pos; - strlcpy(dev->devpath, devpath, sizeof(dev->devpath)); + util_strlcpy(dev->devpath, devpath, sizeof(dev->devpath)); if (subsystem != NULL) - strlcpy(dev->subsystem, subsystem, sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, subsystem, sizeof(dev->subsystem)); if (driver != NULL) - strlcpy(dev->driver, driver, sizeof(dev->driver)); + util_strlcpy(dev->driver, driver, sizeof(dev->driver)); /* set kernel name */ pos = strrchr(dev->devpath, '/'); if (pos == NULL) return; - strlcpy(dev->kernel, &pos[1], sizeof(dev->kernel)); + util_strlcpy(dev->kernel, &pos[1], sizeof(dev->kernel)); dbg(udev, "kernel='%s'\n", dev->kernel); /* some devices have '!' in their name, change that to '/' */ @@ -96,7 +96,7 @@ void sysfs_device_set_values(struct udev *udev, pos = &dev->kernel[strlen(dev->kernel)]; while (isdigit(pos[-1])) pos--; - strlcpy(dev->kernel_number, pos, sizeof(dev->kernel_number)); + util_strlcpy(dev->kernel_number, pos, sizeof(dev->kernel_number)); dbg(udev, "kernel_number='%s'\n", dev->kernel_number); } @@ -108,8 +108,8 @@ int sysfs_resolve_link(struct udev *udev, char *devpath, size_t size) int i; int back; - strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path)); - strlcat(link_path, devpath, sizeof(link_path)); + util_strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path)); + util_strlcat(link_path, devpath, sizeof(link_path)); len = readlink(link_path, link_target, sizeof(link_target)); if (len <= 0) return -1; @@ -127,8 +127,8 @@ int sysfs_resolve_link(struct udev *udev, char *devpath, size_t size) pos[0] = '\0'; } dbg(udev, "after moving back '%s'\n", devpath); - strlcat(devpath, "/", size); - strlcat(devpath, &link_target[back * 3], size); + util_strlcat(devpath, "/", size); + util_strlcat(devpath, &link_target[back * 3], size); return 0; } @@ -155,7 +155,7 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath) return NULL; dbg(udev, "open '%s'\n", devpath); - strlcpy(devpath_real, devpath, sizeof(devpath_real)); + util_strlcpy(devpath_real, devpath, sizeof(devpath_real)); util_remove_trailing_chars(devpath_real, '/'); if (devpath[0] == '\0' ) return NULL; @@ -169,8 +169,8 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath) } /* if we got a link, resolve it to the real device */ - strlcpy(path, udev_get_sys_path(udev), sizeof(path)); - strlcat(path, devpath_real, sizeof(path)); + util_strlcpy(path, udev_get_sys_path(udev), sizeof(path)); + util_strlcat(path, devpath_real, sizeof(path)); if (lstat(path, &statbuf) != 0) { dbg(udev, "stat '%s' failed: %s\n", path, strerror(errno)); return NULL; @@ -198,9 +198,9 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath) sysfs_device_set_values(udev, dev, devpath_real, NULL, NULL); /* get subsystem name */ - strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path)); - strlcat(link_path, dev->devpath, sizeof(link_path)); - strlcat(link_path, "/subsystem", sizeof(link_path)); + util_strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path)); + util_strlcat(link_path, dev->devpath, sizeof(link_path)); + util_strlcat(link_path, "/subsystem", sizeof(link_path)); len = readlink(link_path, link_target, sizeof(link_target)); if (len > 0) { /* get subsystem from "subsystem" link */ @@ -208,36 +208,36 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath) dbg(udev, "subsystem link '%s' points to '%s'\n", link_path, link_target); pos = strrchr(link_target, '/'); if (pos != NULL) - strlcpy(dev->subsystem, &pos[1], sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, &pos[1], sizeof(dev->subsystem)); } else if (strstr(dev->devpath, "/drivers/") != NULL) { - strlcpy(dev->subsystem, "drivers", sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, "drivers", sizeof(dev->subsystem)); } else if (strncmp(dev->devpath, "/module/", 8) == 0) { - strlcpy(dev->subsystem, "module", sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, "module", sizeof(dev->subsystem)); } else if (strncmp(dev->devpath, "/subsystem/", 11) == 0) { pos = strrchr(dev->devpath, '/'); if (pos == &dev->devpath[10]) - strlcpy(dev->subsystem, "subsystem", sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, "subsystem", sizeof(dev->subsystem)); } else if (strncmp(dev->devpath, "/class/", 7) == 0) { pos = strrchr(dev->devpath, '/'); if (pos == &dev->devpath[6]) - strlcpy(dev->subsystem, "subsystem", sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, "subsystem", sizeof(dev->subsystem)); } else if (strncmp(dev->devpath, "/bus/", 5) == 0) { pos = strrchr(dev->devpath, '/'); if (pos == &dev->devpath[4]) - strlcpy(dev->subsystem, "subsystem", sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, "subsystem", sizeof(dev->subsystem)); } /* get driver name */ - strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path)); - strlcat(link_path, dev->devpath, sizeof(link_path)); - strlcat(link_path, "/driver", sizeof(link_path)); + util_strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path)); + util_strlcat(link_path, dev->devpath, sizeof(link_path)); + util_strlcat(link_path, "/driver", sizeof(link_path)); len = readlink(link_path, link_target, sizeof(link_target)); if (len > 0) { link_target[len] = '\0'; dbg(udev, "driver link '%s' points to '%s'\n", link_path, link_target); pos = strrchr(link_target, '/'); if (pos != NULL) - strlcpy(dev->driver, &pos[1], sizeof(dev->driver)); + util_strlcpy(dev->driver, &pos[1], sizeof(dev->driver)); } dbg(udev, "add to cache 'devpath=%s', subsystem='%s', driver='%s'\n", dev->devpath, dev->subsystem, dev->driver); @@ -257,7 +257,7 @@ struct sysfs_device *sysfs_device_get_parent(struct udev *udev, struct sysfs_dev if (dev->parent != NULL) return dev->parent; - strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath)); + util_strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath)); dbg(udev, "'%s'\n", parent_devpath); /* strip last element */ @@ -288,8 +288,8 @@ struct sysfs_device *sysfs_device_get_parent(struct udev *udev, struct sysfs_dev return dev->parent; device_link: - strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath)); - strlcat(parent_devpath, "/device", sizeof(parent_devpath)); + util_strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath)); + util_strlcat(parent_devpath, "/device", sizeof(parent_devpath)); if (sysfs_resolve_link(udev, parent_devpath, sizeof(parent_devpath)) != 0) return NULL; @@ -324,13 +324,13 @@ char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *a size_t sysfs_len; dbg(udev, "open '%s'/'%s'\n", devpath, attr_name); - sysfs_len = strlcpy(path_full, udev_get_sys_path(udev), sizeof(path_full)); + sysfs_len = util_strlcpy(path_full, udev_get_sys_path(udev), sizeof(path_full)); if(sysfs_len >= sizeof(path_full)) sysfs_len = sizeof(path_full) - 1; path = &path_full[sysfs_len]; - strlcat(path_full, devpath, sizeof(path_full)); - strlcat(path_full, "/", sizeof(path_full)); - strlcat(path_full, attr_name, sizeof(path_full)); + util_strlcat(path_full, devpath, sizeof(path_full)); + util_strlcat(path_full, "/", sizeof(path_full)); + util_strlcat(path_full, attr_name, sizeof(path_full)); /* look for attribute in cache */ list_for_each_entry(attr_loop, &attr_list, node) { @@ -346,7 +346,7 @@ char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *a if (attr == NULL) return NULL; memset(attr, 0x00, sizeof(struct sysfs_attr)); - strlcpy(attr->path, path, sizeof(attr->path)); + util_strlcpy(attr->path, path, sizeof(attr->path)); dbg(udev, "add to cache '%s'\n", path_full); list_add(&attr->node, &attr_list); @@ -367,7 +367,7 @@ char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *a pos = strrchr(link_target, '/'); if (pos != NULL) { dbg(udev, "cache '%s' with link value '%s'\n", path_full, value); - strlcpy(attr->value_local, &pos[1], sizeof(attr->value_local)); + util_strlcpy(attr->value_local, &pos[1], sizeof(attr->value_local)); attr->value = attr->value_local; } } @@ -399,7 +399,7 @@ char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *a value[size] = '\0'; 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)); + util_strlcpy(attr->value_local, value, sizeof(attr->value_local)); attr->value = attr->value_local; out: @@ -413,30 +413,30 @@ int sysfs_lookup_devpath_by_subsys_id(struct udev *udev, char *devpath_full, siz char *path; struct stat statbuf; - sysfs_len = strlcpy(path_full, udev_get_sys_path(udev), sizeof(path_full)); + sysfs_len = util_strlcpy(path_full, udev_get_sys_path(udev), sizeof(path_full)); path = &path_full[sysfs_len]; if (strcmp(subsystem, "subsystem") == 0) { - strlcpy(path, "/subsystem/", sizeof(path_full) - sysfs_len); - strlcat(path, id, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/subsystem/", sizeof(path_full) - sysfs_len); + util_strlcat(path, id, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; - strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len); - strlcat(path, id, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len); + util_strlcat(path, id, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; goto out; - strlcpy(path, "/class/", sizeof(path_full) - sysfs_len); - strlcat(path, id, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/class/", sizeof(path_full) - sysfs_len); + util_strlcat(path, id, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; } if (strcmp(subsystem, "module") == 0) { - strlcpy(path, "/module/", sizeof(path_full) - sysfs_len); - strlcat(path, id, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/module/", sizeof(path_full) - sysfs_len); + util_strlcat(path, id, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; goto out; @@ -446,46 +446,46 @@ int sysfs_lookup_devpath_by_subsys_id(struct udev *udev, char *devpath_full, siz char subsys[NAME_SIZE]; char *driver; - strlcpy(subsys, id, sizeof(subsys)); + util_strlcpy(subsys, id, sizeof(subsys)); driver = strchr(subsys, ':'); if (driver != NULL) { driver[0] = '\0'; driver = &driver[1]; - strlcpy(path, "/subsystem/", sizeof(path_full) - sysfs_len); - strlcat(path, subsys, sizeof(path_full) - sysfs_len); - strlcat(path, "/drivers/", sizeof(path_full) - sysfs_len); - strlcat(path, driver, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/subsystem/", sizeof(path_full) - sysfs_len); + util_strlcat(path, subsys, sizeof(path_full) - sysfs_len); + util_strlcat(path, "/drivers/", sizeof(path_full) - sysfs_len); + util_strlcat(path, driver, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; - strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len); - strlcat(path, subsys, sizeof(path_full) - sysfs_len); - strlcat(path, "/drivers/", sizeof(path_full) - sysfs_len); - strlcat(path, driver, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len); + util_strlcat(path, subsys, sizeof(path_full) - sysfs_len); + util_strlcat(path, "/drivers/", sizeof(path_full) - sysfs_len); + util_strlcat(path, driver, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; } goto out; } - strlcpy(path, "/subsystem/", sizeof(path_full) - sysfs_len); - strlcat(path, subsystem, sizeof(path_full) - sysfs_len); - strlcat(path, "/devices/", sizeof(path_full) - sysfs_len); - strlcat(path, id, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/subsystem/", sizeof(path_full) - sysfs_len); + util_strlcat(path, subsystem, sizeof(path_full) - sysfs_len); + util_strlcat(path, "/devices/", sizeof(path_full) - sysfs_len); + util_strlcat(path, id, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; - strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len); - strlcat(path, subsystem, sizeof(path_full) - sysfs_len); - strlcat(path, "/devices/", sizeof(path_full) - sysfs_len); - strlcat(path, id, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len); + util_strlcat(path, subsystem, sizeof(path_full) - sysfs_len); + util_strlcat(path, "/devices/", sizeof(path_full) - sysfs_len); + util_strlcat(path, id, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; - strlcpy(path, "/class/", sizeof(path_full) - sysfs_len); - strlcat(path, subsystem, sizeof(path_full) - sysfs_len); - strlcat(path, "/", sizeof(path_full) - sysfs_len); - strlcat(path, id, sizeof(path_full) - sysfs_len); + util_strlcpy(path, "/class/", sizeof(path_full) - sysfs_len); + util_strlcat(path, subsystem, sizeof(path_full) - sysfs_len); + util_strlcat(path, "/", sizeof(path_full) - sysfs_len); + util_strlcat(path, id, sizeof(path_full) - sysfs_len); if (stat(path_full, &statbuf) == 0) goto found; out: @@ -493,6 +493,6 @@ out: found: if (S_ISLNK(statbuf.st_mode)) sysfs_resolve_link(udev, path, sizeof(path_full) - sysfs_len); - strlcpy(devpath_full, path, len); + util_strlcpy(devpath_full, path, len); return 1; } diff --git a/udev/udev_utils.c b/udev/udev_utils.c index 669e4f3419..c051b20abd 100644 --- a/udev/udev_utils.c +++ b/udev/udev_utils.c @@ -55,7 +55,7 @@ struct name_entry *name_list_add(struct udev *udev, struct list_head *name_list, if (name_new == NULL) return NULL; memset(name_new, 0x00, sizeof(struct name_entry)); - strlcpy(name_new->name, name, sizeof(name_new->name)); + util_strlcpy(name_new->name, name, sizeof(name_new->name)); dbg(udev, "adding '%s'\n", name_new->name); list_add_tail(&name_new->node, &name_loop->node); diff --git a/udev/udev_utils_file.c b/udev/udev_utils_file.c index 19b0f22ba8..abe17eb300 100644 --- a/udev/udev_utils_file.c +++ b/udev/udev_utils_file.c @@ -36,7 +36,7 @@ int create_path(struct udev *udev, const char *path) struct stat stats; int ret; - strlcpy(p, path, sizeof(p)); + util_strlcpy(p, path, sizeof(p)); pos = strrchr(p, '/'); if (pos == p || pos == NULL) return 0; diff --git a/udev/udevadm-info.c b/udev/udevadm-info.c index 402fa76e8d..172d5638c6 100644 --- a/udev/udevadm-info.c +++ b/udev/udevadm-info.c @@ -38,8 +38,8 @@ static void print_all_attributes(struct udev *udev, const char *devpath, const c DIR *dir; struct dirent *dent; - strlcpy(path, udev_get_sys_path(udev), sizeof(path)); - strlcat(path, devpath, sizeof(path)); + util_strlcpy(path, udev_get_sys_path(udev), sizeof(path)); + util_strlcat(path, devpath, sizeof(path)); dir = opendir(path); if (dir != NULL) { @@ -58,9 +58,9 @@ static void print_all_attributes(struct udev *udev, const char *devpath, const c if (strcmp(dent->d_name, "dev") == 0) continue; - strlcpy(filename, path, sizeof(filename)); - strlcat(filename, "/", sizeof(filename)); - strlcat(filename, dent->d_name, sizeof(filename)); + util_strlcpy(filename, path, sizeof(filename)); + util_strlcat(filename, "/", sizeof(filename)); + util_strlcat(filename, dent->d_name, sizeof(filename)); if (lstat(filename, &statbuf) != 0) continue; if (S_ISLNK(statbuf.st_mode)) @@ -69,7 +69,7 @@ static void print_all_attributes(struct udev *udev, const char *devpath, const c attr_value = sysfs_attr_get_value(udev, devpath, dent->d_name); if (attr_value == NULL) continue; - len = strlcpy(value, attr_value, sizeof(value)); + len = util_strlcpy(value, attr_value, sizeof(value)); if(len >= sizeof(value)) len = sizeof(value) - 1; dbg(udev, "attr '%s'='%s'(%zi)\n", dent->d_name, value, len); @@ -191,9 +191,9 @@ static int lookup_device_by_name(struct udev *udev, struct udevice **udevice, co info(udev, "found db entry '%s'\n", device->name); /* make sure, we don't get a link of a different device */ - strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); - strlcat(filename, "/", sizeof(filename)); - strlcat(filename, name, sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); + util_strlcat(filename, "/", sizeof(filename)); + util_strlcat(filename, name, sizeof(filename)); if (stat(filename, &statbuf) != 0) goto next; if (major(udevice_loop->devt) > 0 && udevice_loop->devt != statbuf.st_rdev) { @@ -286,18 +286,18 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) case 'n': /* remove /dev if given */ if (strncmp(optarg, udev_get_dev_path(udev), strlen(udev_get_dev_path(udev))) == 0) - strlcpy(name, &optarg[strlen(udev_get_dev_path(udev))+1], sizeof(name)); + util_strlcpy(name, &optarg[strlen(udev_get_dev_path(udev))+1], sizeof(name)); else - strlcpy(name, optarg, sizeof(name)); + util_strlcpy(name, optarg, sizeof(name)); util_remove_trailing_chars(name, '/'); dbg(udev, "name: %s\n", name); break; case 'p': /* remove /sys if given */ if (strncmp(optarg, udev_get_sys_path(udev), strlen(udev_get_sys_path(udev))) == 0) - strlcpy(path, &optarg[strlen(udev_get_sys_path(udev))], sizeof(path)); + util_strlcpy(path, &optarg[strlen(udev_get_sys_path(udev))], sizeof(path)); else - strlcpy(path, optarg, sizeof(path)); + util_strlcpy(path, optarg, sizeof(path)); util_remove_trailing_chars(path, '/'); /* possibly resolve to real devpath */ @@ -306,16 +306,16 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) char *pos; /* also check if the parent is a link */ - strlcpy(temp, path, sizeof(temp)); + util_strlcpy(temp, path, sizeof(temp)); pos = strrchr(temp, '/'); if (pos != 0) { char tail[PATH_SIZE]; - strlcpy(tail, pos, sizeof(tail)); + util_strlcpy(tail, pos, sizeof(tail)); pos[0] = '\0'; if (sysfs_resolve_link(udev, temp, sizeof(temp)) == 0) { - strlcpy(path, temp, sizeof(path)); - strlcat(path, tail, sizeof(path)); + util_strlcpy(path, temp, sizeof(path)); + util_strlcat(path, tail, sizeof(path)); } } } @@ -353,7 +353,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) break; case 'd': action = ACTION_DEVICE_ID_FILE; - strlcpy(name, optarg, sizeof(name)); + util_strlcpy(name, optarg, sizeof(name)); break; case 'a': action = ACTION_ATTRIBUTE_WALK; diff --git a/udev/udevadm-settle.c b/udev/udevadm-settle.c index c6c95a1ddc..ed67bbbdfb 100644 --- a/udev/udevadm-settle.c +++ b/udev/udevadm-settle.c @@ -107,8 +107,8 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) } } - strlcpy(queuename, udev_get_dev_path(udev), sizeof(queuename)); - strlcat(queuename, "/.udev/queue", sizeof(queuename)); + util_strlcpy(queuename, udev_get_dev_path(udev), sizeof(queuename)); + util_strlcat(queuename, "/.udev/queue", sizeof(queuename)); loop = timeout * LOOP_PER_SECOND; while (loop--) { @@ -129,8 +129,8 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) } /* read current udev seqnum */ - strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); - strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); + util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); fd = open(filename, O_RDONLY); if (fd < 0) goto exit; @@ -143,8 +143,8 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) info(udev, "udev seqnum = %llu\n", seq_udev); /* read current kernel seqnum */ - strlcpy(filename, udev_get_sys_path(udev), sizeof(filename)); - strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename)); + util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename)); + util_strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename)); fd = open(filename, O_RDONLY); if (fd < 0) goto exit; diff --git a/udev/udevadm-test.c b/udev/udevadm-test.c index 994a354960..b6fccf34e7 100644 --- a/udev/udevadm-test.c +++ b/udev/udevadm-test.c @@ -42,9 +42,9 @@ static int import_uevent_var(struct udev *udev, const char *devpath) int rc = -1; /* read uevent file */ - strlcpy(path, udev_get_sys_path(udev), sizeof(path)); - strlcat(path, devpath, sizeof(path)); - strlcat(path, "/uevent", sizeof(path)); + util_strlcpy(path, udev_get_sys_path(udev), sizeof(path)); + util_strlcat(path, devpath, sizeof(path)); + util_strlcat(path, "/uevent", sizeof(path)); fd = open(path, O_RDONLY); if (fd < 0) goto out; @@ -163,11 +163,11 @@ int udevadm_test(struct udev *udev, int argc, char *argv[]) } if (subsystem != NULL) - strlcpy(dev->subsystem, subsystem, sizeof(dev->subsystem)); + util_strlcpy(dev->subsystem, subsystem, sizeof(dev->subsystem)); /* override built-in sysfs device */ udevice->dev = dev; - strlcpy(udevice->action, action, sizeof(udevice->action)); + util_strlcpy(udevice->action, action, sizeof(udevice->action)); udevice->devt = udev_device_get_devt(udevice); /* simulate node creation with test flag */ @@ -191,7 +191,7 @@ int udevadm_test(struct udev *udev, int argc, char *argv[]) list_for_each_entry(name_loop, &udevice->run_list, node) { char program[PATH_SIZE]; - strlcpy(program, name_loop->name, sizeof(program)); + util_strlcpy(program, name_loop->name, sizeof(program)); udev_rules_apply_format(udevice, program, sizeof(program)); info(udev, "run: '%s'\n", program); } diff --git a/udev/udevadm-trigger.c b/udev/udevadm-trigger.c index 6d01040e01..04fb9bcbcc 100644 --- a/udev/udevadm-trigger.c +++ b/udev/udevadm-trigger.c @@ -71,14 +71,14 @@ static int device_list_insert(struct udev *udev, const char *path) dbg(udev, "add '%s'\n" , path); /* we only have a device, if we have an uevent file */ - strlcpy(filename, path, sizeof(filename)); - strlcat(filename, "/uevent", sizeof(filename)); + util_strlcpy(filename, path, sizeof(filename)); + util_strlcat(filename, "/uevent", sizeof(filename)); if (stat(filename, &statbuf) < 0) return -1; if (!(statbuf.st_mode & S_IWUSR)) return -1; - strlcpy(devpath, &path[strlen(udev_get_sys_path(udev))], sizeof(devpath)); + util_strlcpy(devpath, &path[strlen(udev_get_sys_path(udev))], sizeof(devpath)); /* resolve possible link to real target */ if (lstat(path, &statbuf) < 0) @@ -96,9 +96,9 @@ static void trigger_uevent(struct udev *udev, const char *devpath, const char *a char filename[PATH_SIZE]; int fd; - strlcpy(filename, udev_get_sys_path(udev), sizeof(filename)); - strlcat(filename, devpath, sizeof(filename)); - strlcat(filename, "/uevent", sizeof(filename)); + util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename)); + util_strlcat(filename, devpath, sizeof(filename)); + util_strlcat(filename, "/uevent", sizeof(filename)); if (verbose) printf("%s\n", devpath); @@ -156,9 +156,9 @@ static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac bufpos++; /* add subsystem */ - strlcpy(path, udev_get_sys_path(udev), sizeof(path)); - strlcat(path, devpath, sizeof(path)); - strlcat(path, "/subsystem", sizeof(path)); + util_strlcpy(path, udev_get_sys_path(udev), sizeof(path)); + util_strlcat(path, devpath, sizeof(path)); + util_strlcat(path, "/subsystem", sizeof(path)); len = readlink(path, link_target, sizeof(link_target)); if (len > 0) { char *pos; @@ -174,10 +174,10 @@ static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac /* add symlinks and node name */ path[0] = '\0'; list_for_each_entry(name_loop, &udevice->symlink_list, node) { - strlcat(path, udev_get_dev_path(udev), sizeof(path)); - strlcat(path, "/", sizeof(path)); - strlcat(path, name_loop->name, sizeof(path)); - strlcat(path, " ", sizeof(path)); + util_strlcat(path, udev_get_dev_path(udev), sizeof(path)); + util_strlcat(path, "/", sizeof(path)); + util_strlcat(path, name_loop->name, sizeof(path)); + util_strlcat(path, " ", sizeof(path)); } util_remove_trailing_chars(path, ' '); if (path[0] != '\0') { @@ -185,17 +185,17 @@ static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac bufpos++; } if (udevice->name[0] != '\0') { - strlcpy(path, udev_get_dev_path(udev), sizeof(path)); - strlcat(path, "/", sizeof(path)); - strlcat(path, udevice->name, sizeof(path)); + util_strlcpy(path, udev_get_dev_path(udev), sizeof(path)); + util_strlcat(path, "/", sizeof(path)); + util_strlcat(path, udevice->name, sizeof(path)); bufpos += snprintf(&buf[bufpos], sizeof(buf)-1, "DEVNAME=%s", path); bufpos++; } /* add keys from device "uevent" file */ - strlcpy(path, udev_get_sys_path(udev), sizeof(path)); - strlcat(path, devpath, sizeof(path)); - strlcat(path, "/uevent", sizeof(path)); + util_strlcpy(path, udev_get_sys_path(udev), sizeof(path)); + util_strlcat(path, devpath, sizeof(path)); + util_strlcat(path, "/uevent", sizeof(path)); fd = open(path, O_RDONLY); if (fd >= 0) { char value[4096]; @@ -214,7 +214,7 @@ static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac if (next == NULL) break; next[0] = '\0'; - bufpos += strlcpy(&buf[bufpos], key, sizeof(buf) - bufpos-1); + bufpos += util_strlcpy(&buf[bufpos], key, sizeof(buf) - bufpos-1); bufpos++; key = &next[1]; } @@ -223,7 +223,7 @@ static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac /* add keys from database */ list_for_each_entry(name_loop, &udevice->env_list, node) { - bufpos += strlcpy(&buf[bufpos], name_loop->name, sizeof(buf) - bufpos-1); + bufpos += util_strlcpy(&buf[bufpos], name_loop->name, sizeof(buf) - bufpos-1); bufpos++; } if (bufpos > sizeof(buf)) @@ -289,7 +289,7 @@ static int attr_match(const char *path, const char *attr_value) char file[PATH_SIZE]; char *match_value; - strlcpy(attr, attr_value, sizeof(attr)); + util_strlcpy(attr, attr_value, sizeof(attr)); /* separate attr and match value */ match_value = strchr(attr, '='); @@ -298,9 +298,9 @@ static int attr_match(const char *path, const char *attr_value) match_value = &match_value[1]; } - strlcpy(file, path, sizeof(file)); - strlcat(file, "/", sizeof(file)); - strlcat(file, attr, sizeof(file)); + util_strlcpy(file, path, sizeof(file)); + util_strlcat(file, "/", sizeof(file)); + util_strlcat(file, attr, sizeof(file)); if (match_value != NULL) { /* match file content */ @@ -369,9 +369,9 @@ static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type else return; - strlcpy(base, udev_get_sys_path(udev), sizeof(base)); - strlcat(base, "/", sizeof(base)); - strlcat(base, subsys, sizeof(base)); + util_strlcpy(base, udev_get_sys_path(udev), sizeof(base)); + util_strlcat(base, "/", sizeof(base)); + util_strlcat(base, subsys, sizeof(base)); dir = opendir(base); if (dir != NULL) { @@ -387,9 +387,9 @@ static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type if (subsystem_filtered(dent->d_name)) continue; - strlcpy(dirname, base, sizeof(dirname)); - strlcat(dirname, "/", sizeof(dirname)); - strlcat(dirname, dent->d_name, sizeof(dirname)); + util_strlcpy(dirname, base, sizeof(dirname)); + util_strlcat(dirname, "/", sizeof(dirname)); + util_strlcat(dirname, dent->d_name, sizeof(dirname)); if (scan == SCAN_SUBSYSTEM) { if (attr_filtered(dirname)) @@ -400,7 +400,7 @@ static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type continue; } - strlcat(dirname, subdir, sizeof(dirname)); + util_strlcat(dirname, subdir, sizeof(dirname)); /* look for devices/drivers */ dir2 = opendir(dirname); @@ -411,9 +411,9 @@ static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type if (dent2->d_name[0] == '.') continue; - strlcpy(dirname2, dirname, sizeof(dirname2)); - strlcat(dirname2, "/", sizeof(dirname2)); - strlcat(dirname2, dent2->d_name, sizeof(dirname2)); + util_strlcpy(dirname2, dirname, sizeof(dirname2)); + util_strlcat(dirname2, "/", sizeof(dirname2)); + util_strlcat(dirname2, dent2->d_name, sizeof(dirname2)); if (attr_filtered(dirname2)) continue; device_list_insert(udev, dirname2); @@ -434,8 +434,8 @@ static void scan_block(struct udev *udev) if (subsystem_filtered("block")) return; - strlcpy(base, udev_get_sys_path(udev), sizeof(base)); - strlcat(base, "/block", sizeof(base)); + util_strlcpy(base, udev_get_sys_path(udev), sizeof(base)); + util_strlcat(base, "/block", sizeof(base)); dir = opendir(base); if (dir != NULL) { @@ -447,9 +447,9 @@ static void scan_block(struct udev *udev) if (dent->d_name[0] == '.') continue; - strlcpy(dirname, base, sizeof(dirname)); - strlcat(dirname, "/", sizeof(dirname)); - strlcat(dirname, dent->d_name, sizeof(dirname)); + util_strlcpy(dirname, base, sizeof(dirname)); + util_strlcat(dirname, "/", sizeof(dirname)); + util_strlcat(dirname, dent->d_name, sizeof(dirname)); if (attr_filtered(dirname)) continue; if (device_list_insert(udev, dirname) != 0) @@ -467,9 +467,9 @@ static void scan_block(struct udev *udev) if (!strcmp(dent2->d_name,"device")) continue; - strlcpy(dirname2, dirname, sizeof(dirname2)); - strlcat(dirname2, "/", sizeof(dirname2)); - strlcat(dirname2, dent2->d_name, sizeof(dirname2)); + util_strlcpy(dirname2, dirname, sizeof(dirname2)); + util_strlcat(dirname2, "/", sizeof(dirname2)); + util_strlcat(dirname2, dent2->d_name, sizeof(dirname2)); if (attr_filtered(dirname2)) continue; device_list_insert(udev, dirname2); @@ -487,8 +487,8 @@ static void scan_class(struct udev *udev) DIR *dir; struct dirent *dent; - strlcpy(base, udev_get_sys_path(udev), sizeof(base)); - strlcat(base, "/class", sizeof(base)); + util_strlcpy(base, udev_get_sys_path(udev), sizeof(base)); + util_strlcat(base, "/class", sizeof(base)); dir = opendir(base); if (dir != NULL) { @@ -503,9 +503,9 @@ static void scan_class(struct udev *udev) if (subsystem_filtered(dent->d_name)) continue; - strlcpy(dirname, base, sizeof(dirname)); - strlcat(dirname, "/", sizeof(dirname)); - strlcat(dirname, dent->d_name, sizeof(dirname)); + util_strlcpy(dirname, base, sizeof(dirname)); + util_strlcat(dirname, "/", sizeof(dirname)); + util_strlcat(dirname, dent->d_name, sizeof(dirname)); dir2 = opendir(dirname); if (dir2 != NULL) { for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) { @@ -517,9 +517,9 @@ static void scan_class(struct udev *udev) if (!strcmp(dent2->d_name, "device")) continue; - strlcpy(dirname2, dirname, sizeof(dirname2)); - strlcat(dirname2, "/", sizeof(dirname2)); - strlcat(dirname2, dent2->d_name, sizeof(dirname2)); + util_strlcpy(dirname2, dirname, sizeof(dirname2)); + util_strlcat(dirname2, "/", sizeof(dirname2)); + util_strlcat(dirname2, dent2->d_name, sizeof(dirname2)); if (attr_filtered(dirname2)) continue; device_list_insert(udev, dirname2); @@ -537,8 +537,8 @@ static void scan_failed(struct udev *udev) DIR *dir; struct dirent *dent; - strlcpy(base, udev_get_dev_path(udev), sizeof(base)); - strlcat(base, "/.udev/failed", sizeof(base)); + util_strlcpy(base, udev_get_dev_path(udev), sizeof(base)); + util_strlcat(base, "/.udev/failed", sizeof(base)); dir = opendir(base); if (dir != NULL) { @@ -549,10 +549,10 @@ static void scan_failed(struct udev *udev) if (dent->d_name[0] == '.') continue; - start = strlcpy(device, udev_get_sys_path(udev), sizeof(device)); + start = util_strlcpy(device, udev_get_sys_path(udev), sizeof(device)); if(start >= sizeof(device)) start = sizeof(device) - 1; - strlcat(device, dent->d_name, sizeof(device)); + util_strlcat(device, dent->d_name, sizeof(device)); util_path_decode(&device[start]); device_list_insert(udev, device); } @@ -651,15 +651,15 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) saddr.sun_family = AF_LOCAL; if (sockpath[0] == '@') { /* abstract namespace socket requested */ - strlcpy(&saddr.sun_path[1], &sockpath[1], sizeof(saddr.sun_path)-1); + util_strlcpy(&saddr.sun_path[1], &sockpath[1], sizeof(saddr.sun_path)-1); saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]); } else if (stat(sockpath, &stats) == 0 && S_ISSOCK(stats.st_mode)) { /* existing socket file */ - strlcpy(saddr.sun_path, sockpath, sizeof(saddr.sun_path)); + util_strlcpy(saddr.sun_path, sockpath, sizeof(saddr.sun_path)); saddrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path); } else { /* no socket file, assume abstract namespace socket */ - strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1); + util_strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1); saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]); } } else if (env != NULL) { @@ -675,8 +675,8 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) struct stat statbuf; /* if we have /sys/subsystem, forget all the old stuff */ - strlcpy(base, udev_get_sys_path(udev), sizeof(base)); - strlcat(base, "/subsystem", sizeof(base)); + util_strlcpy(base, udev_get_sys_path(udev), sizeof(base)); + util_strlcat(base, "/subsystem", sizeof(base)); if (stat(base, &statbuf) == 0) { scan_subsystem(udev, "subsystem", SCAN_SUBSYSTEM); exec_list(udev, action, env); @@ -689,8 +689,8 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) scan_class(udev); /* scan "block" if it isn't a "class" */ - strlcpy(base, udev_get_sys_path(udev), sizeof(base)); - strlcat(base, "/class/block", sizeof(base)); + util_strlcpy(base, udev_get_sys_path(udev), sizeof(base)); + util_strlcat(base, "/class/block", sizeof(base)); if (stat(base, &statbuf) != 0) scan_block(udev); exec_list(udev, action, env); diff --git a/udev/udevd.c b/udev/udevd.c index 06bfbd953e..59866afdee 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -141,7 +141,7 @@ static int udev_event_process(struct udevd_uevent_msg *msg) udevice = udev_device_init(msg->udev); if (udevice == NULL) return -1; - strlcpy(udevice->action, msg->action, sizeof(udevice->action)); + util_strlcpy(udevice->action, msg->action, sizeof(udevice->action)); sysfs_device_set_values(udevice->udev, udevice->dev, msg->devpath, msg->subsystem, msg->driver); udevice->devpath_old = msg->devpath_old; udevice->devt = msg->devt; @@ -176,10 +176,10 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st snprintf(filename, sizeof(filename), "%s/.udev/queue/%llu", udev_get_dev_path(msg->udev), msg->seqnum); /* location of failed file */ - strlcpy(filename_failed, udev_get_dev_path(msg->udev), 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)); + util_strlcpy(filename_failed, udev_get_dev_path(msg->udev), sizeof(filename_failed)); + util_strlcat(filename_failed, "/", sizeof(filename_failed)); + start = util_strlcat(filename_failed, ".udev/failed/", sizeof(filename_failed)); + util_strlcat(filename_failed, msg->devpath, sizeof(filename_failed)); util_path_encode(&filename_failed[start], sizeof(filename_failed) - start); switch (state) { @@ -196,10 +196,10 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st /* "move" event - rename failed file to current name, do not delete failed */ char filename_failed_old[PATH_SIZE]; - strlcpy(filename_failed_old, udev_get_dev_path(msg->udev), 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)); + util_strlcpy(filename_failed_old, udev_get_dev_path(msg->udev), sizeof(filename_failed_old)); + util_strlcat(filename_failed_old, "/", sizeof(filename_failed_old)); + start = util_strlcat(filename_failed_old, ".udev/failed/", sizeof(filename_failed_old)); + util_strlcat(filename_failed_old, msg->devpath_old, sizeof(filename_failed_old)); util_path_encode(&filename_failed_old[start], sizeof(filename) - start); if (rename(filename_failed_old, filename_failed) == 0) @@ -287,8 +287,8 @@ static void msg_queue_insert(struct udevd_uevent_msg *msg) export_event_state(msg, EVENT_QUEUED); info(msg->udev, "seq %llu queued, '%s' '%s'\n", msg->seqnum, msg->action, msg->subsystem); - strlcpy(filename, udev_get_dev_path(msg->udev), sizeof(filename)); - strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(msg->udev), sizeof(filename)); + util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd >= 0) { char str[32]; @@ -755,8 +755,8 @@ static void export_initial_seqnum(struct udev *udev) char seqnum[32]; ssize_t len = 0; - strlcpy(filename, udev_get_sys_path(udev), sizeof(filename)); - strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename)); + util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename)); + util_strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename)); fd = open(filename, O_RDONLY); if (fd >= 0) { len = read(fd, seqnum, sizeof(seqnum)-1); @@ -766,8 +766,8 @@ static void export_initial_seqnum(struct udev *udev) strcpy(seqnum, "0\n"); len = 3; } - strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); - strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); + util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); create_path(udev, filename); fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd >= 0) { @@ -986,8 +986,8 @@ int main(int argc, char *argv[]) IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); /* watch dynamic rules directory */ - strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); - strlcat(filename, "/.udev/rules.d", sizeof(filename)); + util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); + util_strlcat(filename, "/.udev/rules.d", sizeof(filename)); inotify_add_watch(inotify_fd, filename, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); } |