aboutsummaryrefslogtreecommitdiff
path: root/util-linux/fdflush.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-10-13 21:12:06 +0000
committerEric Andersen <andersen@codepoet.org>1999-10-13 21:12:06 +0000
commitf6be944a6ae612c70ce010582d9c3cdd72f7144f (patch)
tree36ab89d86aad17d6922566cad8e49ba33c5ede81 /util-linux/fdflush.c
parent305a73f5eacd94eefe2f2a5a00034d579ef6b1e7 (diff)
downloadbusybox-w32-f6be944a6ae612c70ce010582d9c3cdd72f7144f.tar.gz
busybox-w32-f6be944a6ae612c70ce010582d9c3cdd72f7144f.tar.bz2
busybox-w32-f6be944a6ae612c70ce010582d9c3cdd72f7144f.zip
More stuff
Diffstat (limited to 'util-linux/fdflush.c')
-rw-r--r--util-linux/fdflush.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
index a15e9b3f7..ce6870cd1 100644
--- a/util-linux/fdflush.c
+++ b/util-linux/fdflush.c
@@ -1,36 +1,53 @@
1
2/*
3 * Mini fdflush implementation for busybox
4 *
5 * Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
1#include "internal.h" 23#include "internal.h"
24#include <stdio.h>
2#include <sys/ioctl.h> 25#include <sys/ioctl.h>
3#include <linux/fd.h> 26#include <linux/fd.h>
4#include <sys/types.h>
5#include <sys/stat.h>
6#include <fcntl.h> 27#include <fcntl.h>
7 28
8const char fdflush_usage[] = "fdflush device";
9 29
10int 30extern int fdflush_main(int argc, char **argv)
11fdflush(const char *filename)
12{ 31{
13 int status; 32 int value;
14 int fd = open(filename, 0); 33 int fd;
15 34 if ( **(argv+1) == '-' ) {
16 if ( fd < 0 ) { 35 fprintf(stderr, "Usage: fdflush device\n");
17 name_and_error(filename); 36 exit(FALSE);
18 return 1; 37 }
19 }
20 38
21 status = ioctl(fd, FDFLUSH, 0); 39 fd = open(*argv, 0);
22 close(fd); 40 if ( fd < 0 ) {
23 41 perror(*argv);
24 if ( status != 0 ) { 42 exit(FALSE);
25 name_and_error(filename); 43 }
26 return 1;
27 }
28 return 0;
29}
30 44
45 value = ioctl(fd, FDFLUSH, 0);
46 close(fd);
31 47
32int 48 if ( value ) {
33fdflush_fn(const struct FileInfo * i) 49 perror(*argv);
34{ 50 exit(FALSE);
35 return fdflush(i->source); 51 }
52 exit (TRUE);
36} 53}