aboutsummaryrefslogtreecommitdiff
path: root/util-linux/freeramdisk.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-06-04 05:08:29 +0000
committerEric Andersen <andersen@codepoet.org>2000-06-04 05:08:29 +0000
commitef4268efa7474ba84dc02ffc29030ad6407fedcb (patch)
treea7e405d939dc014ccb08867eb6a26ebc28c3ad74 /util-linux/freeramdisk.c
parent832000f7f3e368bb00d02bf4b54cb531affdaf1b (diff)
downloadbusybox-w32-ef4268efa7474ba84dc02ffc29030ad6407fedcb.tar.gz
busybox-w32-ef4268efa7474ba84dc02ffc29030ad6407fedcb.tar.bz2
busybox-w32-ef4268efa7474ba84dc02ffc29030ad6407fedcb.zip
This patch
- eliminates the need to have a buffer and strcpy to it - makes freeramdisk complain if it's given more than one argument Regards, Pavel Roskin
Diffstat (limited to 'util-linux/freeramdisk.c')
-rw-r--r--util-linux/freeramdisk.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index 4106cf144..cabe5660b 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -43,21 +43,17 @@ static const char freeramdisk_usage[] =
43extern int 43extern int
44freeramdisk_main(int argc, char **argv) 44freeramdisk_main(int argc, char **argv)
45{ 45{
46 char rname[256] = "/dev/ram";
47 int f; 46 int f;
48 47
49 if (argc < 2 || ( argv[1] && *argv[1] == '-')) { 48 if (argc != 2 || *argv[1] == '-') {
50 usage(freeramdisk_usage); 49 usage(freeramdisk_usage);
51 } 50 }
52 51
53 if (argc >1) 52 if ((f = open(argv[1], O_RDWR)) == -1) {
54 strcpy(rname, argv[1]); 53 fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno));
55
56 if ((f = open(rname, O_RDWR)) == -1) {
57 fatalError( "freeramdisk: cannot open %s: %s\n", rname, strerror(errno));
58 } 54 }
59 if (ioctl(f, BLKFLSBUF) < 0) { 55 if (ioctl(f, BLKFLSBUF) < 0) {
60 fatalError( "freeramdisk: failed ioctl on %s: %s\n", rname, strerror(errno)); 56 fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno));
61 } 57 }
62 /* Don't bother closing. Exit does 58 /* Don't bother closing. Exit does
63 * that, so we can save a few bytes */ 59 * that, so we can save a few bytes */