Add readprofile applet support.
[oweals/busybox.git] / util-linux / freeramdisk.c
index dd7700c06f5b4741cd9c04bca5fe093ffc2f4058..e5061dc34bba6bff32b064ec4ff86616632285f3 100644 (file)
@@ -3,7 +3,7 @@
  * freeramdisk implementation for busybox
  *
  * Copyright (C) 2000 and written by Emanuele Caratti <wiz@iol.it>
- * Adjusted a bit by Erik Andersen <andersee@debian.org>
+ * Adjusted a bit by Erik Andersen <andersen@codepoet.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,8 +26,8 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
-#include <errno.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include "busybox.h"
 
 
@@ -38,20 +38,20 @@ extern int
 freeramdisk_main(int argc, char **argv)
 {
        int result;
-       FILE *f;
+       int fd;
 
        if (argc != 2) {
-               show_usage();
+               bb_show_usage();
        }
 
-       f = xfopen(argv[1], "r+");
-       
-       result = ioctl(fileno(f), BLKFLSBUF);
+       fd = bb_xopen(argv[1], O_RDWR);
+
+       result = ioctl(fd, BLKFLSBUF);
 #ifdef CONFIG_FEATURE_CLEAN_UP
-       fclose(f);
+       close(fd);
 #endif
        if (result < 0) {
-               perror_msg_and_die("failed ioctl on %s", argv[1]);
+               bb_perror_msg_and_die("failed ioctl on %s", argv[1]);
        }
 
        /* Don't bother closing.  Exit does