diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-16 21:42:12 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-16 21:42:12 +0000 |
| commit | 6dda5dec238e35d7e760091aee061e5fc51e0e30 (patch) | |
| tree | 7271cf5ed5489149e0e28d066b7b3b55e816c90e /util-linux | |
| parent | ea4f0847c3d765a782eb9afe3b0f9fb0659cd1bc (diff) | |
| download | busybox-w32-6dda5dec238e35d7e760091aee061e5fc51e0e30.tar.gz busybox-w32-6dda5dec238e35d7e760091aee061e5fc51e0e30.tar.bz2 busybox-w32-6dda5dec238e35d7e760091aee061e5fc51e0e30.zip | |
mdev: change subsystem syntax from /subsystem to subsystem/devname
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/mdev.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 2451cca05..f965b6069 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
| @@ -90,21 +90,24 @@ static void make_device(char *path, int delete) | |||
| 90 | device_name = bb_basename(path); | 90 | device_name = bb_basename(path); |
| 91 | /* http://kernel.org/doc/pending/hotplug.txt says that only | 91 | /* http://kernel.org/doc/pending/hotplug.txt says that only |
| 92 | * "/sys/block/..." is for block devices. "/sys/bus" etc is not. | 92 | * "/sys/block/..." is for block devices. "/sys/bus" etc is not. |
| 93 | * But since 2.6.25 block devices are also in /sys/class/block. | 93 | * But since 2.6.25 block devices are also in /sys/class/block, |
| 94 | * We use strstr("/block/") to forestall future surprises. */ | 94 | * we use strstr("/block/") to forestall future surprises. */ |
| 95 | type = S_IFCHR; | 95 | type = S_IFCHR; |
| 96 | if (strstr(path, "/block/")) | 96 | if (strstr(path, "/block/")) |
| 97 | type = S_IFBLK; | 97 | type = S_IFBLK; |
| 98 | 98 | ||
| 99 | /* Make path point to subsystem/device_name */ | ||
| 100 | path += sizeof("/sys/class/") - 1; | ||
| 101 | |||
| 99 | #if !ENABLE_FEATURE_MDEV_CONF | 102 | #if !ENABLE_FEATURE_MDEV_CONF |
| 100 | mode = 0660; | 103 | mode = 0660; |
| 101 | #else | 104 | #else |
| 102 | /* If we have config file, look up user settings */ | 105 | /* If we have config file, look up user settings */ |
| 103 | parser = config_open2("/etc/mdev.conf", fopen_for_read); | 106 | parser = config_open2("/etc/mdev.conf", fopen_for_read); |
| 104 | while (1) { | 107 | while (1) { |
| 105 | regmatch_t off[1 + 9*ENABLE_FEATURE_MDEV_RENAME_REGEXP]; | 108 | regmatch_t off[1 + 9 * ENABLE_FEATURE_MDEV_RENAME_REGEXP]; |
| 106 | int keep_matching; | 109 | int keep_matching; |
| 107 | char *val; | 110 | char *val, *name; |
| 108 | struct bb_uidgid_t ugid; | 111 | struct bb_uidgid_t ugid; |
| 109 | char *tokens[4]; | 112 | char *tokens[4]; |
| 110 | # if ENABLE_FEATURE_MDEV_EXEC | 113 | # if ENABLE_FEATURE_MDEV_EXEC |
| @@ -128,6 +131,10 @@ static void make_device(char *path, int delete) | |||
| 128 | keep_matching = ('-' == val[0]); | 131 | keep_matching = ('-' == val[0]); |
| 129 | val += keep_matching; /* swallow leading dash */ | 132 | val += keep_matching; /* swallow leading dash */ |
| 130 | 133 | ||
| 134 | /* Match against either subsystem/device_name | ||
| 135 | * or device_name alone */ | ||
| 136 | name = strchr(val, '/') ? path : (char *) device_name; | ||
| 137 | |||
| 131 | /* Fields: regex uid:gid mode [alias] [cmd] */ | 138 | /* Fields: regex uid:gid mode [alias] [cmd] */ |
| 132 | 139 | ||
| 133 | /* 1st field: @<numeric maj,min>... */ | 140 | /* 1st field: @<numeric maj,min>... */ |
| @@ -149,15 +156,10 @@ static void make_device(char *path, int delete) | |||
| 149 | } else { /* ... or regex to match device name */ | 156 | } else { /* ... or regex to match device name */ |
| 150 | regex_t match; | 157 | regex_t match; |
| 151 | int result; | 158 | int result; |
| 152 | const char *dev_name_or_subsystem = device_name; | ||
| 153 | if ('/' == val[0] && subsystem) { | ||
| 154 | dev_name_or_subsystem = subsystem; | ||
| 155 | val++; | ||
| 156 | } | ||
| 157 | 159 | ||
| 158 | /* Is this it? */ | 160 | /* Is this it? */ |
| 159 | xregcomp(&match, val, REG_EXTENDED); | 161 | xregcomp(&match, val, REG_EXTENDED); |
| 160 | result = regexec(&match, dev_name_or_subsystem, ARRAY_SIZE(off), off, 0); | 162 | result = regexec(&match, name, ARRAY_SIZE(off), off, 0); |
| 161 | regfree(&match); | 163 | regfree(&match); |
| 162 | 164 | ||
| 163 | //bb_error_msg("matches:"); | 165 | //bb_error_msg("matches:"); |
| @@ -171,7 +173,7 @@ static void make_device(char *path, int delete) | |||
| 171 | /* If not this device, skip rest of line */ | 173 | /* If not this device, skip rest of line */ |
| 172 | /* (regexec returns whole pattern as "range" 0) */ | 174 | /* (regexec returns whole pattern as "range" 0) */ |
| 173 | if (result || off[0].rm_so | 175 | if (result || off[0].rm_so |
| 174 | || ((int)off[0].rm_eo != (int)strlen(dev_name_or_subsystem)) | 176 | || ((int)off[0].rm_eo != (int)strlen(name)) |
| 175 | ) { | 177 | ) { |
| 176 | continue; /* this line doesn't match */ | 178 | continue; /* this line doesn't match */ |
| 177 | } | 179 | } |
| @@ -214,7 +216,7 @@ static void make_device(char *path, int delete) | |||
| 214 | if (*s++ == '%') | 216 | if (*s++ == '%') |
| 215 | n++; | 217 | n++; |
| 216 | 218 | ||
| 217 | p = alias = xzalloc(strlen(a) + n * strlen(device_name)); | 219 | p = alias = xzalloc(strlen(a) + n * strlen(name)); |
| 218 | s = a + 1; | 220 | s = a + 1; |
| 219 | while (*s) { | 221 | while (*s) { |
| 220 | *p = *s; | 222 | *p = *s; |
| @@ -222,7 +224,7 @@ static void make_device(char *path, int delete) | |||
| 222 | i = (s[1] - '0'); | 224 | i = (s[1] - '0'); |
| 223 | if (i <= 9 && off[i].rm_so >= 0) { | 225 | if (i <= 9 && off[i].rm_so >= 0) { |
| 224 | n = off[i].rm_eo - off[i].rm_so; | 226 | n = off[i].rm_eo - off[i].rm_so; |
| 225 | strncpy(p, device_name + off[i].rm_so, n); | 227 | strncpy(p, name + off[i].rm_so, n); |
| 226 | p += n - 1; | 228 | p += n - 1; |
| 227 | s++; | 229 | s++; |
| 228 | } | 230 | } |
