diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-13 21:09:28 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-13 21:09:28 +0200 |
commit | 93b0f384589fce818edb9678571a30e71930d14c (patch) | |
tree | 0a66d2d7749b97e8d5919fdf2971db43a52240c2 /udev/lib/libudev-util.c | |
parent | b2d9e4f20075d355cd4fe091929bc336642aa50d (diff) |
libudev: udev_device - add attribute cache
Diffstat (limited to 'udev/lib/libudev-util.c')
-rw-r--r-- | udev/lib/libudev-util.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/udev/lib/libudev-util.c b/udev/lib/libudev-util.c index 7aea8c67fb..50eacdd37d 100644 --- a/udev/lib/libudev-util.c +++ b/udev/lib/libudev-util.c @@ -27,6 +27,7 @@ #include <string.h> #include <dirent.h> #include <ctype.h> +#include <fcntl.h> #include <sys/stat.h> #include "libudev.h" @@ -97,7 +98,7 @@ int util_resolve_sys_link(struct udev *udev, char *devpath, size_t size) } struct util_name_entry *util_name_list_add(struct udev *udev, struct list_head *name_list, - const char *name, int sort) + const char *name, const char *value, int sort) { struct util_name_entry *name_loop; struct util_name_entry *name_new; @@ -126,7 +127,14 @@ struct util_name_entry *util_name_list_add(struct udev *udev, struct list_head * free(name_new); return NULL; } - dbg(udev, "adding '%s'\n", name_new->name); + if (value != NULL) { + name_new->value = strdup(value); + if (name_new->value == NULL) { + free(name_new); + return NULL; + } + } + dbg(udev, "adding '%s=%s'\n", name_new->name, name_new->value); list_add_tail(&name_new->node, &name_loop->node); return name_new; } @@ -139,6 +147,7 @@ void util_name_list_cleanup(struct udev *udev, struct list_head *name_list) list_for_each_entry_safe(name_loop, name_tmp, name_list, node) { list_del(&name_loop->node); free(name_loop->name); + free(name_loop->value); free(name_loop); } } |