diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-23 02:57:08 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-23 02:57:08 +0200 |
commit | b99028c96307e729303be8f6750418979a7488b9 (patch) | |
tree | 692f8b651631ed42ee87d4f1b565efd01b12dc1f | |
parent | 40fd3bc837e04538df305b512157e55a2a5e0789 (diff) |
shrink struct udev_event
-rw-r--r-- | udev/lib/libudev-device.c | 28 | ||||
-rw-r--r-- | udev/udev-event.c | 13 | ||||
-rw-r--r-- | udev/udev-rules.c | 13 | ||||
-rw-r--r-- | udev/udev.h | 22 |
4 files changed, 38 insertions, 38 deletions
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c index f56db7ff15..8812f1fc84 100644 --- a/udev/lib/libudev-device.c +++ b/udev/lib/libudev-device.c @@ -34,36 +34,36 @@ #define ENVP_SIZE 128 struct udev_device { - int refcount; struct udev *udev; struct udev_device *parent_device; - int parent_set; char *syspath; const char *devpath; char *sysname; const char *sysnum; char *devnode; char *subsystem; - int subsystem_set; - struct udev_list_node devlinks_list; - int devlinks_uptodate; - struct udev_list_node properties_list; char **envp; - int envp_uptodate; char *driver; - int driver_set; - dev_t devnum; char *action; - int event_timeout; char *devpath_old; char *physdevpath; - int timeout; + struct udev_list_node devlinks_list; + struct udev_list_node properties_list; + struct udev_list_node sysattr_list; unsigned long long int seqnum; + int event_timeout; + int timeout; int num_fake_partitions; int devlink_priority; - int ignore_remove; - struct udev_list_node sysattr_list; - int info_loaded; + int refcount; + dev_t devnum; + unsigned int parent_set:1; + unsigned int subsystem_set:1; + unsigned int devlinks_uptodate:1; + unsigned int envp_uptodate:1; + unsigned int driver_set:1; + unsigned int info_loaded:1; + unsigned int ignore_remove:1; }; static size_t devpath_to_db_path(struct udev *udev, const char *devpath, char *filename, size_t len) diff --git a/udev/udev-event.c b/udev/udev-event.c index 36d36ac643..fcb9993709 100644 --- a/udev/udev-event.c +++ b/udev/udev-event.c @@ -52,6 +52,7 @@ void udev_event_unref(struct udev_event *event) udev_list_cleanup_entries(event->udev, &event->run_list); free(event->tmp_node); free(event->program_result); + free(event->name); dbg(event->udev, "free event %p\n", event); free(event); } @@ -558,15 +559,17 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules) goto exit; } - if (event->name_ignore) { + if (event->name != NULL && event->name[0] == '\0') { info(event->udev, "device node creation supressed\n"); goto exit; } - if (event->name[0] == '\0') { + if (event->name == NULL) { info(event->udev, "no node name set, will use kernel name '%s'\n", udev_device_get_sysname(event->dev)); - util_strlcpy(event->name, udev_device_get_sysname(event->dev), sizeof(event->name)); + event->name = strdup(udev_device_get_sysname(event->dev)); + if (event->name == NULL) + goto exit; } /* set device node name */ @@ -604,10 +607,8 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules) info(event->udev, "device event will be ignored\n"); goto exit; } - if (event->name[0] == '\0') { - info(event->udev, "device renaming supressed\n"); + if (event->name == NULL) goto exit; - } /* look if we want to change the name of the netif */ if (strcmp(event->name, udev_device_get_sysname(dev)) != 0) { diff --git a/udev/udev-rules.c b/udev/udev-rules.c index 675a7f0625..19ee06d379 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -1952,6 +1952,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event case TK_A_NAME: { const char *name = &rules->buf[cur->key.value_off]; + char name_str[UTIL_PATH_SIZE]; int count; if (event->name_final) @@ -1959,17 +1960,17 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event if (cur->key.op == KEY_OP_ASSIGN_FINAL) event->name_final = 1; if (name[0] == '\0') { - event->name[0] = '\0'; - event->name_ignore = 1; + free(event->name); + event->name = NULL; break; } - event->name_ignore = 0; - util_strlcpy(event->name, name, sizeof(event->name)); - udev_event_apply_format(event, event->name, sizeof(event->name)); + util_strlcpy(name_str, name, sizeof(name_str)); + udev_event_apply_format(event, name_str, sizeof(name_str)); if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) { - count = util_replace_chars(event->name, ALLOWED_CHARS_FILE); + count = util_replace_chars(name_str, ALLOWED_CHARS_FILE); if (count > 0) info(event->udev, "%i character(s) replaced\n", count); + event->name = strdup(name_str); } break; } diff --git a/udev/udev.h b/udev/udev.h index 927ff36e01..faa1bf6851 100644 --- a/udev/udev.h +++ b/udev/udev.h @@ -57,30 +57,28 @@ static inline void logging_close(void) } struct udev_event { + struct udev_list_node node; struct udev *udev; struct udev_device *dev; struct udev_device *dev_parent; - int devlink_final; - char name[UTIL_PATH_SIZE]; - int name_final; - int name_ignore; + char *name; char *tmp_node; char *program_result; mode_t mode; - int mode_final; uid_t uid; - int owner_final; gid_t gid; - int group_final; struct udev_list_node run_list; - int run_final; - int ignore_device; - int test; - - struct udev_list_node node; pid_t pid; int exitstatus; time_t queue_time; + unsigned int group_final:1; + unsigned int owner_final:1; + unsigned int mode_final:1; + unsigned int name_final:1; + unsigned int devlink_final:1; + unsigned int run_final:1; + unsigned int ignore_device:1; + unsigned int test:1; }; /* udev-rules.c */ |