diff options
| author | Rob Landley <rob@landley.net> | 2006-01-12 06:13:50 +0000 |
|---|---|---|
| committer | Rob Landley <rob@landley.net> | 2006-01-12 06:13:50 +0000 |
| commit | 29e08ffcdf8de6eb57b280d587796642259fc66e (patch) | |
| tree | ffdf21a624a71e92c1db8e3a917f5fcf18c2f79b /util-linux | |
| parent | 1c19deed17f21792fcc485038b6173b9b4c186f1 (diff) | |
| download | busybox-w32-29e08ffcdf8de6eb57b280d587796642259fc66e.tar.gz busybox-w32-29e08ffcdf8de6eb57b280d587796642259fc66e.tar.bz2 busybox-w32-29e08ffcdf8de6eb57b280d587796642259fc66e.zip | |
Frank Sorenson added hotplug support to mdev. (I tweaked it a bit. Need
to come up with a test suite for all the stuff that requires root access.
Something involving User Mode Linux or QEMU, probably...)
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/mdev.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 10369ded3..135843581 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <sys/stat.h> | 18 | #include <sys/stat.h> |
| 19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
| 20 | #include <unistd.h> | 20 | #include <unistd.h> |
| 21 | #include <stdlib.h> | ||
| 21 | #include "busybox.h" | 22 | #include "busybox.h" |
| 22 | #include "xregex.h" | 23 | #include "xregex.h" |
| 23 | 24 | ||
| @@ -209,20 +210,34 @@ static void find_dev(char *path) | |||
| 209 | 210 | ||
| 210 | int mdev_main(int argc, char *argv[]) | 211 | int mdev_main(int argc, char *argv[]) |
| 211 | { | 212 | { |
| 212 | if (argc > 1) { | 213 | char *action; |
| 213 | if (argc == 2 && !strcmp(argv[1],"-s")) { | 214 | char *env_path; |
| 214 | RESERVE_CONFIG_BUFFER(temp,PATH_MAX); | 215 | RESERVE_CONFIG_BUFFER(temp,PATH_MAX); |
| 215 | strcpy(temp,"/sys/block"); | 216 | |
| 216 | find_dev(temp); | 217 | /* Scan */ |
| 217 | strcpy(temp,"/sys/class"); | ||
| 218 | find_dev(temp); | ||
| 219 | if(ENABLE_FEATURE_CLEAN_UP) | ||
| 220 | RELEASE_CONFIG_BUFFER(temp); | ||
| 221 | return 0; | ||
| 222 | } else bb_show_usage(); | ||
| 223 | } | ||
| 224 | |||
| 225 | /* hotplug support goes here */ | ||
| 226 | 218 | ||
| 219 | if (argc == 2 && !strcmp(argv[1],"-s")) { | ||
| 220 | strcpy(temp,"/sys/block"); | ||
| 221 | find_dev(temp); | ||
| 222 | strcpy(temp,"/sys/class"); | ||
| 223 | find_dev(temp); | ||
| 224 | |||
| 225 | /* Hotplug */ | ||
| 226 | |||
| 227 | } else { | ||
| 228 | action = getenv("ACTION"); | ||
| 229 | env_path = getenv("DEVPATH"); | ||
| 230 | if (!action || !env_path) bb_show_usage(); | ||
| 231 | |||
| 232 | if (!strcmp(action, "add")) { | ||
| 233 | sprintf(temp, "/sys%s", env_path); | ||
| 234 | make_device(temp); | ||
| 235 | } else if (!strcmp(action, "remove")) { | ||
| 236 | sprintf(temp, "%s/%s", DEV_PATH, strrchr(env_path, '/') + 1); | ||
| 237 | unlink(temp); | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | if(ENABLE_FEATURE_CLEAN_UP) RELEASE_CONFIG_BUFFER(temp); | ||
| 227 | return 0; | 242 | return 0; |
| 228 | } | 243 | } |
