Changeset View
Changeset View
Standalone View
Standalone View
bin/sync/sync.c
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| __FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| int | int | ||||
| main(int argc __unused, char *argv[] __unused) | main(int argc __unused, char *argv[] __unused) | ||||
| { | { | ||||
| long sync_count; | |||||
| if (argc == 1) | |||||
| sync_count = 1; | |||||
| else { | |||||
| sync_count = strtol(argv[1], NULL, 0); | |||||
| /* | |||||
| * If argv[1] isn't a valid number -- or | |||||
| * if it's 0, or negative -- then we simply use | |||||
| * the number of arguments, including argv[0], | |||||
| * to indicate how many times to sync. | |||||
| * This allows "sync 10" and "sync sync sync" | |||||
| * (as examples) to work as expected. | |||||
| */ | |||||
| if (sync_count <= 0) | |||||
| sync_count = argc; | |||||
| } | |||||
| while (sync_count--) | |||||
| sync(); | sync(); | ||||
| exit(0); | exit(0); | ||||
| } | } | ||||