From 5f59a986e2d0a637dbec0a473e28b3a3574e63bf Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Wed, 30 Jan 2013 19:11:42 +0100 Subject: [PATCH] Upgrading sync Change-Id: Ied34ebd1d2dc963f5a2af8fc3bbf8e6c94df61cf --- bin/Makefile | 4 +-- bin/sync/Makefile | 7 ++++ bin/sync/sync.8 | 72 ++++++++++++++++++++++++++++++++++++++++ bin/sync/sync.c | 59 ++++++++++++++++++++++++++++++++ commands/Makefile | 2 +- commands/sync/Makefile | 5 --- commands/sync/sync.c | 14 -------- drivers/ramdisk/Makefile | 4 +-- man/man8/Makefile | 2 +- man/man8/sync.8 | 35 ------------------- releasetools/nbsd_ports | 1 + 11 files changed, 145 insertions(+), 60 deletions(-) create mode 100644 bin/sync/Makefile create mode 100644 bin/sync/sync.8 create mode 100644 bin/sync/sync.c delete mode 100644 commands/sync/Makefile delete mode 100644 commands/sync/sync.c delete mode 100644 man/man8/sync.8 diff --git a/bin/Makefile b/bin/Makefile index 0e632bdfc..cf014658b 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.22 2007/12/31 15:31:24 ad Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -SUBDIR= cat date echo ed expr kill ln \ - mkdir pax pwd rm rmdir test +SUBDIR= cat date echo ed expr kill ln ls \ + mkdir pax pwd rm rmdir sync test .include diff --git a/bin/sync/Makefile b/bin/sync/Makefile new file mode 100644 index 000000000..25ea7e849 --- /dev/null +++ b/bin/sync/Makefile @@ -0,0 +1,7 @@ +# $NetBSD: Makefile,v 1.9 1997/07/20 22:38:07 christos Exp $ +# @(#)Makefile 8.1 (Berkeley) 5/31/93 + +PROG= sync +MAN= sync.8 + +.include diff --git a/bin/sync/sync.8 b/bin/sync/sync.8 new file mode 100644 index 000000000..a0e65135d --- /dev/null +++ b/bin/sync/sync.8 @@ -0,0 +1,72 @@ +.\" $NetBSD: sync.8,v 1.15 2003/08/07 09:05:42 agc Exp $ +.\" +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)sync.8 8.1 (Berkeley) 5/31/93 +.\" +.Dd May 31, 1993 +.Dt SYNC 8 +.Os +.Sh NAME +.Nm sync +.Nd force completion of pending disk writes (flush cache) +.Sh SYNOPSIS +.Nm +.Sh DESCRIPTION +The +.Nm +program can be called to ensure that all disk writes have been +completed before the processor is halted in a way not suitably done by +.Xr reboot 8 +or +.Xr halt 8 . +Generally, it is preferable to use +.Xr reboot 8 +or +.Xr halt 8 +to shut down the system, +as they may perform additional actions +such as resynchronizing the hardware clock +and flushing internal caches before performing a final +.Nm . +.Pp +The +.Nm +program simply invokes the +.Xr sync 2 +system call. +.Sh SEE ALSO +.Xr fsync 2 , +.Xr sync 2 , +.Xr halt 8 , +.Xr reboot 8 +.Sh HISTORY +A +.Nm +command appeared in +.At v6 . diff --git a/bin/sync/sync.c b/bin/sync/sync.c new file mode 100644 index 000000000..2b9c36783 --- /dev/null +++ b/bin/sync/sync.c @@ -0,0 +1,59 @@ +/* $NetBSD: sync.c,v 1.13 2008/07/20 00:52:40 lukem Exp $ */ + +/* + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1987, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)sync.c 8.1 (Berkeley) 5/31/93"; +#else +__RCSID("$NetBSD: sync.c,v 1.13 2008/07/20 00:52:40 lukem Exp $"); +#endif +#endif /* not lint */ + +#include +#include + +int main(int, char *[]); + +/* ARGSUSED */ +int +main(int argc, char *argv[]) +{ + setprogname(argv[0]); + sync(); + exit(0); + /* NOTREACHED */ +} diff --git a/commands/Makefile b/commands/Makefile index 2a7849217..aba23a3c1 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -24,7 +24,7 @@ SUBDIR= add_route arp ash at backup banner basename btrace cal \ reboot remsync rev rget rlogin \ rotate rsh rshd service setup shar acksize \ sleep slip spell split sprofalyze sprofdiff srccrc \ - stty svclog svrctl swifi sync synctree sysenv \ + stty svclog svrctl swifi synctree sysenv \ syslogd tail tcpd tcpdp tcpstat tee telnet \ telnetd term termcap tget time touch tr \ truncate tty udpstat umount uname unexpand \ diff --git a/commands/sync/Makefile b/commands/sync/Makefile deleted file mode 100644 index 037c73196..000000000 --- a/commands/sync/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -PROG= sync -BINDIR= /bin -MAN= - -.include diff --git a/commands/sync/sync.c b/commands/sync/sync.c deleted file mode 100644 index ab98a5e6a..000000000 --- a/commands/sync/sync.c +++ /dev/null @@ -1,14 +0,0 @@ -/* sync - flush the file system buffers. Author: Andy Tanenbaum */ - -#include -#include - -int main(void); - -int main() -{ -/* First prize in shortest useful program contest. */ -/* Highest comment/code ratio */ - sync(); - return(0); -} diff --git a/drivers/ramdisk/Makefile b/drivers/ramdisk/Makefile index b3f8d382e..f9c66a024 100644 --- a/drivers/ramdisk/Makefile +++ b/drivers/ramdisk/Makefile @@ -58,8 +58,8 @@ PROG_DRIVERS+= acpi .if ${MACHINE_ARCH} == "earm" EXTRA+= rc.arm mylogin.sh ttys PROG_DRIVERS+= mmc tty gpio -PROG_COMMANDS+= cp dd getty time sync sleep stty umount -PROG_BIN+= cat ls rm +PROG_COMMANDS+= cp dd getty time sleep stty umount +PROG_BIN+= cat ls rm sync PROTO= proto.arm.small .endif # ${MACHINE_ARCH} == "earm" diff --git a/man/man8/Makefile b/man/man8/Makefile index e07795717..37cb25a3a 100644 --- a/man/man8/Makefile +++ b/man/man8/Makefile @@ -8,7 +8,7 @@ MAN= add_route.8 backup.8 boot.8 btrace.8 \ poweroff.8 printroot.8 pr_routes.8 pwdauth.8 rarpd.8 \ rdate.8 readclock.8 reboot.8 repartition.8 \ rshd.8 screendump.8 serial-ip.8 service.8 \ - setup.8 shutdown.8 slip.8 srccrc.8 sync.8 syslogd.8 tcpd.8 \ + setup.8 shutdown.8 slip.8 srccrc.8 syslogd.8 tcpd.8 \ unix.8 update.8 usage.8 vbfs.8 MLINKS += httpd.8 in.httpd.8 diff --git a/man/man8/sync.8 b/man/man8/sync.8 deleted file mode 100644 index 2e4956b61..000000000 --- a/man/man8/sync.8 +++ /dev/null @@ -1,35 +0,0 @@ -.TH SYNC 8 -.SH NAME -sync \- flush the cache to disk -.SH SYNOPSIS -\fBsync\fR -.br -.de FL -.TP -\\fB\\$1\\fR -\\$2 -.. -.de EX -.TP 20 -\\fB\\$1\\fR -# \\$2 -.. -.SH EXAMPLES -.TP 20 -.B sync -# Write out all modified cache blocks -.SH DESCRIPTION -.PP -\s-1MINIX 3\s-1 -maintains a cache of recently used disk blocks. -The -.I sync -command writes any modified cache blocks back to the disk. -This is essential before stopping the system, and should be done before -running any -.I a.out -program that might crash. -.SH "SEE ALSO" -.BR sync (2), -.BR update (8), -.BR shutdown (8). diff --git a/releasetools/nbsd_ports b/releasetools/nbsd_ports index 416d22364..79779e146 100644 --- a/releasetools/nbsd_ports +++ b/releasetools/nbsd_ports @@ -21,6 +21,7 @@ 2012/10/17 12:00:00,bin/pwd 2011/08/29 14:48:46,bin/rm 2011/08/29 14:49:38,bin/rmdir +2012/10/17 12:00:00,bin/sync 2012/10/17 12:00:00,bin/test 2012/10/17 12:00:00,build.sh 2012/10/17 12:00:00,common/dist/zlib