163499Sps/*- 263499Sps * Copyright (c) 2000 Paul Saab <ps@FreeBSD.org> 363499Sps * All rights reserved. 463499Sps * 563499Sps * Redistribution and use in source and binary forms, with or without 663499Sps * modification, are permitted provided that the following conditions 763499Sps * are met: 863499Sps * 1. Redistributions of source code must retain the above copyright 963499Sps * notice, this list of conditions and the following disclaimer. 1063499Sps * 2. Redistributions in binary form must reproduce the above copyright 1163499Sps * notice, this list of conditions and the following disclaimer in the 1263499Sps * documentation and/or other materials provided with the distribution. 1363499Sps * 1463499Sps * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1563499Sps * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1663499Sps * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1763499Sps * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1863499Sps * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1963499Sps * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2063499Sps * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2163499Sps * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2263499Sps * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2363499Sps * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2463499Sps * SUCH DAMAGE. 2563499Sps */ 2663499Sps 2763812Sps#ifndef lint 2863812Sps#endif /* not lint */ 2999112Sobrien#include <sys/cdefs.h> 3099112Sobrien__FBSDID("$FreeBSD$"); 3163812Sps 3263499Sps#include <err.h> 3363499Sps#include <fcntl.h> 3463499Sps#include <stdio.h> 3578717Sdd#include <stdlib.h> 3663499Sps#include <sysexits.h> 3763499Sps#include <unistd.h> 3863499Sps 39140811Sssouhlalstatic void usage(void); 4063499Sps 4163499Spsint 4263499Spsmain(int argc, char *argv[]) 4363499Sps{ 4463499Sps int fd; 4563499Sps int i; 46140811Sssouhlal int rval; 4763499Sps 48140865Sdelphij if (argc < 2) { 4963499Sps usage(); 50140865Sdelphij /* NOTREACHED */ 51140865Sdelphij } 5263499Sps 53140865Sdelphij rval = EX_OK; 5463499Sps for (i = 1; i < argc; ++i) { 55140865Sdelphij if ((fd = open(argv[i], O_RDONLY)) == -1) { 56140811Sssouhlal warn("open %s", argv[i]); 57140865Sdelphij if (rval == EX_OK) 58140865Sdelphij rval = EX_NOINPUT; 59140811Sssouhlal continue; 60140811Sssouhlal } 6163499Sps 62140865Sdelphij if (fsync(fd) == -1) { 63140811Sssouhlal warn("fsync %s", argv[i]); 64140865Sdelphij if (rval == EX_OK) 65140865Sdelphij rval = EX_OSERR; 66140811Sssouhlal } 6763499Sps close(fd); 6863499Sps } 69140865Sdelphij exit(rval); 70140865Sdelphij /* NOTREACHED */ 7163499Sps} 7263499Sps 73140811Sssouhlalstatic void 74140865Sdelphijusage(void) 7563499Sps{ 76140865Sdelphij 7763812Sps fprintf(stderr, "usage: fsync file ...\n"); 7863499Sps exit(EX_USAGE); 79140865Sdelphij /* NOTREACHED */ 8063499Sps} 81