diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/Makefile | 6 | ||||
-rw-r--r-- | utils/syncfs.c | 80 |
2 files changed, 83 insertions, 3 deletions
diff --git a/utils/Makefile b/utils/Makefile index 08763cb6..0e4adae1 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -18,12 +18,12 @@ dir := utils makemode := utilities -targets = shd ps settrans showtrans sync su mount fsysopts \ +targets = shd ps settrans showtrans syncfs su mount fsysopts \ storeinfo login w uptime ids loginpr sush vmstat portinfo \ devprobe vminfo addauth rmauth unsu setauth ftpcp ftpdir storecat \ storeread ping msgport special-targets = mount loginpr sush uptime -SRCS = shd.c ps.c su.c settrans.c sync.c showtrans.c addauth.c rmauth.c \ +SRCS = shd.c ps.c su.c settrans.c syncfs.c showtrans.c addauth.c rmauth.c \ mount.sh fsysopts.c storeinfo.c login.c loginpr.sh sush.sh w.c \ uptime.sh psout.c ids.c vmstat.c portinfo.c devprobe.c vminfo.c \ parse.c frobauth.c frobauth-mod.c setauth.c pids.c nonsugid.c \ @@ -66,7 +66,7 @@ ping: ../libthreads/libthreads.a # We must include libthreads because of a bug in the way shared libraries # work: all libraries that *any* routine in libfshelp uses must be defined. settrans: ../libfshelp/libfshelp.a ../libports/libports.a ../libthreads/libthreads.a -ps w ids settrans sync showtrans fsysopts storeinfo login vmstat portinfo \ +ps w ids settrans syncfs showtrans fsysopts storeinfo login vmstat portinfo \ devprobe vminfo addauth rmauth setauth su unsu ftpcp ftpdir storeread \ storecat msgport: \ ../libshouldbeinlibc/libshouldbeinlibc.a diff --git a/utils/syncfs.c b/utils/syncfs.c new file mode 100644 index 00000000..984af3da --- /dev/null +++ b/utils/syncfs.c @@ -0,0 +1,80 @@ +/* syncfs -- User interface to file_syncfs, synchronize filesystems. + Copyright (C) 1994, 95, 96, 97, 98 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <hurd.h> +#include <argp.h> +#include <error.h> +#include <version.h> + +const char *argp_program_version = STANDARD_HURD_VERSION (sync); + +static int synchronous = 1, do_children = 1; + +static void +sync_one (const char *name, file_t port) +{ + error_t err = (port == MACH_PORT_NULL ? errno + : file_syncfs (port, synchronous, do_children)); + if (err) + error (1, err, "%s", name); +} + +static error_t +parser (int key, char *arg, struct argp_state *state) +{ + switch (key) + { + case 'a': synchronous = 0; break; + case 'c': do_children = 0; break; + + case ARGP_KEY_NO_ARGS: + sync_one ("/", getcrdir ()); + break; + + case ARGP_KEY_ARG: + sync_one (arg, file_name_lookup (arg, 0, 0)); + break; + + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + + +int +main (int argc, char *argv[]) +{ + static struct argp_option options[] = + { + {"asynchronous", 'a', 0, 0, "Do not wait for completion"}, + {"no-children", 'c', 0, 0, "Do not synchronize child filesystems"}, + {0} + }; + struct argp argp = + {options, parser, + "[FILE...]", "Force all pending disk writes to be done immediately" + "\vThe filesystem containing each FILE is synchronized, and its child" + " filesystems unless --no-children is specified. With no FILE argument" + " synchronizes the root filesystem."}; + + argp_parse (&argp, argc, argv, 0, 0, 0); + + return 0; +} |