aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-03-14 02:40:51 +0000
committerRob Landley <rob@landley.net>2006-03-14 02:40:51 +0000
commit0b22c1c962ff57e68035413d7790dd2b137a2aeb (patch)
tree19fea5141691cfadfdb2394d6d4c948609153488 /util-linux
parent2f135fc6bf5184bf782ec6cdd39c49a708670163 (diff)
downloadbusybox-w32-0b22c1c962ff57e68035413d7790dd2b137a2aeb.tar.gz
busybox-w32-0b22c1c962ff57e68035413d7790dd2b137a2aeb.tar.bz2
busybox-w32-0b22c1c962ff57e68035413d7790dd2b137a2aeb.zip
Tito unified fdflush and freeramdisk. I tweaked the result a bit.
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/Makefile.in2
-rw-r--r--util-linux/fdflush.c54
-rw-r--r--util-linux/freeramdisk.c49
3 files changed, 10 insertions, 95 deletions
diff --git a/util-linux/Makefile.in b/util-linux/Makefile.in
index f6a50b7f7..522ae2ffb 100644
--- a/util-linux/Makefile.in
+++ b/util-linux/Makefile.in
@@ -13,7 +13,7 @@ srcdir=$(top_srcdir)/util-linux
13UTILLINUX-y:= 13UTILLINUX-y:=
14UTILLINUX-$(CONFIG_DMESG) +=dmesg.o 14UTILLINUX-$(CONFIG_DMESG) +=dmesg.o
15UTILLINUX-$(CONFIG_FBSET) +=fbset.o 15UTILLINUX-$(CONFIG_FBSET) +=fbset.o
16UTILLINUX-$(CONFIG_FDFLUSH) +=fdflush.o 16UTILLINUX-$(CONFIG_FDFLUSH) +=freeramdisk.o
17UTILLINUX-$(CONFIG_FDFORMAT) +=fdformat.o 17UTILLINUX-$(CONFIG_FDFORMAT) +=fdformat.o
18UTILLINUX-$(CONFIG_FDISK) +=fdisk.o 18UTILLINUX-$(CONFIG_FDISK) +=fdisk.o
19UTILLINUX-$(CONFIG_FREERAMDISK) +=freeramdisk.o 19UTILLINUX-$(CONFIG_FREERAMDISK) +=freeramdisk.o
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
deleted file mode 100644
index 79c8f454f..000000000
--- a/util-linux/fdflush.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini fdflush implementation for busybox
4 *
5 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@perens.com>.
6 * Copyright (C) 2003 by Erik Andersen <andersen@codeoet.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <stdio.h>
25#include <sys/ioctl.h>
26#include <fcntl.h>
27#include <stdlib.h>
28#include <unistd.h>
29#include "busybox.h"
30
31/* From <linux/fd.h> */
32#define FDFLUSH _IO(2,0x4b)
33
34int fdflush_main(int argc, char **argv)
35{
36 int fd, result;
37
38 if (argc != 2)
39 bb_show_usage();
40
41 fd = bb_xopen(argv[1], 0);
42
43 result = ioctl(fd, FDFLUSH, 0);
44
45 if (ENABLE_FEATURE_CLEAN_UP) close(fd);
46
47 if (result) {
48 bb_perror_nomsg_and_die();
49 }
50
51 /* Don't bother closing. Exit does
52 * that, so we can save a few bytes */
53 return EXIT_SUCCESS;
54}
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index cfea35bea..b5449750a 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -1,24 +1,12 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * freeramdisk implementation for busybox 3 * freeramdisk and fdflush implementations for busybox
4 * 4 *
5 * Copyright (C) 2000 and written by Emanuele Caratti <wiz@iol.it> 5 * Copyright (C) 2000 and written by Emanuele Caratti <wiz@iol.it>
6 * Adjusted a bit by Erik Andersen <andersen@codepoet.org> 6 * Adjusted a bit by Erik Andersen <andersen@codepoet.org>
7 * Unified with fdflush by Tito Ragusa <farmatito@tiscali.it>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */ 10 */
23 11
24#include <stdio.h> 12#include <stdio.h>
@@ -30,40 +18,21 @@
30#include <unistd.h> 18#include <unistd.h>
31#include "busybox.h" 19#include "busybox.h"
32 20
33 21extern int freeramdisk_main(int argc, char **argv)
34/* From linux/fs.h */
35#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
36
37extern int
38freeramdisk_main(int argc, char **argv)
39{ 22{
40 int result; 23 int result;
41 int fd; 24 int fd;
42 25
43 if (argc != 2) { 26 if (argc != 2) bb_show_usage();
44 bb_show_usage();
45 }
46 27
47 fd = bb_xopen(argv[1], O_RDWR); 28 fd = bb_xopen(argv[1], O_RDWR);
48 29
49 result = ioctl(fd, BLKFLSBUF); 30 // Act like freeramdisk, fdflush, or both depending on configuration.
31 result = ioctl(fd, (bb_applet_name[1]=='r' && ENABLE_FREERAMDISK)
32 || !ENABLE_FDFLUSH ? _IO(0x12,97) : _IO(2,0x4b));
50 33
51 if (ENABLE_FEATURE_CLEAN_UP) close(fd); 34 if (ENABLE_FEATURE_CLEAN_UP) close(fd);
52 35
53 if (result < 0) { 36 if (result) bb_perror_msg_and_die("%s", argv[1]);
54 bb_perror_msg_and_die("failed ioctl on %s", argv[1]);
55 }
56
57 /* Don't bother closing. Exit does
58 * that, so we can save a few bytes */
59 return EXIT_SUCCESS; 37 return EXIT_SUCCESS;
60} 38}
61
62/*
63Local Variables:
64c-file-style: "linux"
65c-basic-offset: 4
66tab-width: 4
67End:
68*/
69