1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1992-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
20 ***********************************************************************/
28 static const char usage
[] =
29 "[-?\n@(#)$Id: sync (AT&T Research) 2006-10-04 $\n]"
31 "[+NAME?sync - schedule file system updates]"
32 "[+DESCRIPTION?\bsync\b calls \bsync\b(2), which causes all information "
33 "in memory that updates file systems to be scheduled for writing out to "
34 "all file systems. The writing, although scheduled, is not necessarily "
35 "complete upon return from \bsync\b.]"
36 "[+?Since \bsync\b(2) has no failure indication, \bsync\b only fails for "
37 "option/operand syntax errors, or when \bsync\b(2) does not return, in "
38 "which case \bsync\b also does not return.]"
39 "[+?At minimum \bsync\b should be called before halting the system. Most "
40 "systems provide graceful shutdown procedures that include \bsync\b -- "
41 "use them if possible.]"
44 "[+0?\bsync\b(2) returned.]"
45 "[+>0?Option/operand syntax error.]"
47 "[+SEE ALSO?\bsync\b(2), \bshutdown\b(8)]"
54 b_sync(int argc
, char** argv
, void* context
)
56 cmdinit(argc
, argv
, context
, ERROR_CATALOG
, 0);
59 switch (optget(argv
, usage
))
62 error(2, "%s", opt_info
.arg
);
65 error(ERROR_usage(2), "%s", opt_info
.arg
);
70 argv
+= opt_info
.index
;
71 if (error_info
.errors
|| *argv
)
72 error(ERROR_usage(2), "%s", optusage(NiL
));
76 error(ERROR_usage(2), "failed -- the native system does not provide a sync(2) call");