diff options
| author | Mark Whitley <markw@lineo.com> | 2000-07-20 23:06:27 +0000 |
|---|---|---|
| committer | Mark Whitley <markw@lineo.com> | 2000-07-20 23:06:27 +0000 |
| commit | 1ac435c15e23ae1bdd87d2b77754b6f6eb159bee (patch) | |
| tree | 2640cac810cd352680265029fb21235122181780 /miscutils | |
| parent | 51154bacbe34d160f089c4ab4bbb51766030233d (diff) | |
| download | busybox-w32-1ac435c15e23ae1bdd87d2b77754b6f6eb159bee.tar.gz busybox-w32-1ac435c15e23ae1bdd87d2b77754b6f6eb159bee.tar.bz2 busybox-w32-1ac435c15e23ae1bdd87d2b77754b6f6eb159bee.zip | |
Converted option parsing to getopt(). Also added some explanatory comments.
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/update.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/miscutils/update.c b/miscutils/update.c index 0bdc90eaa..3f3d68b87 100644 --- a/miscutils/update.c +++ b/miscutils/update.c | |||
| @@ -23,16 +23,22 @@ | |||
| 23 | * | 23 | * |
| 24 | */ | 24 | */ |
| 25 | 25 | ||
| 26 | /* | ||
| 27 | * Note: This program is only necessary if you are running a 2.0.x (or | ||
| 28 | * earlier) kernel. 2.2.x and higher flush filesystem buffers automatically. | ||
| 29 | */ | ||
| 30 | |||
| 26 | #include "internal.h" | 31 | #include "internal.h" |
| 27 | #include <sys/param.h> | 32 | #include <sys/param.h> |
| 28 | #include <sys/syslog.h> | 33 | #include <sys/syslog.h> |
| 34 | #include <unistd.h> /* for getopt() */ | ||
| 29 | 35 | ||
| 30 | 36 | ||
| 31 | #if defined(__GLIBC__) | 37 | #if defined(__GLIBC__) |
| 32 | #include <sys/kdaemon.h> | 38 | #include <sys/kdaemon.h> |
| 33 | #else | 39 | #else |
| 34 | static _syscall2(int, bdflush, int, func, int, data); | 40 | static _syscall2(int, bdflush, int, func, int, data); |
| 35 | #endif /* __GLIBC__ */ | 41 | #endif /* __GLIBC__ */ |
| 36 | 42 | ||
| 37 | static unsigned int sync_duration = 30; | 43 | static unsigned int sync_duration = 30; |
| 38 | static unsigned int flush_duration = 5; | 44 | static unsigned int flush_duration = 5; |
| @@ -41,29 +47,22 @@ static int use_sync = 0; | |||
| 41 | extern int update_main(int argc, char **argv) | 47 | extern int update_main(int argc, char **argv) |
| 42 | { | 48 | { |
| 43 | int pid; | 49 | int pid; |
| 50 | int opt; | ||
| 44 | 51 | ||
| 45 | argc--; | 52 | while ((opt = getopt(argc, argv, "Ss:f:")) > 0) { |
| 46 | argv++; | 53 | switch (opt) { |
| 47 | while (argc>0 && **argv == '-') { | ||
| 48 | while (*++(*argv)) { | ||
| 49 | switch (**argv) { | ||
| 50 | case 'S': | 54 | case 'S': |
| 51 | use_sync = 1; | 55 | use_sync = 1; |
| 52 | break; | 56 | break; |
| 53 | case 's': | 57 | case 's': |
| 54 | if (--argc < 1) usage(update_usage); | 58 | sync_duration = atoi(optarg); |
| 55 | sync_duration = atoi(*(++argv)); | ||
| 56 | break; | 59 | break; |
| 57 | case 'f': | 60 | case 'f': |
| 58 | if (--argc < 1) usage(update_usage); | 61 | flush_duration = atoi(optarg); |
| 59 | flush_duration = atoi(*(++argv)); | ||
| 60 | break; | 62 | break; |
| 61 | default: | 63 | default: |
| 62 | usage(update_usage); | 64 | usage(update_usage); |
| 63 | } | ||
| 64 | } | 65 | } |
| 65 | argc--; | ||
| 66 | argv++; | ||
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | pid = fork(); | 68 | pid = fork(); |
| @@ -79,6 +78,8 @@ extern int update_main(int argc, char **argv) | |||
| 79 | * This is no longer necessary since 1.3.5x, but it will harmlessly | 78 | * This is no longer necessary since 1.3.5x, but it will harmlessly |
| 80 | * exit if that is the case. | 79 | * exit if that is the case. |
| 81 | */ | 80 | */ |
| 81 | |||
| 82 | /* set the program name that will show up in a 'ps' listing */ | ||
| 82 | argv[0] = "bdflush (update)"; | 83 | argv[0] = "bdflush (update)"; |
| 83 | argv[1] = NULL; | 84 | argv[1] = NULL; |
| 84 | argv[2] = NULL; | 85 | argv[2] = NULL; |
