[hackers] [ubase] Add freeramdisk(8) || sin
commit c88ba3750ec6e139034e468d5a56166268188981
Author: sin <sin_AT_2f30.org>
Date: Thu Jun 26 16:16:15 2014 +0100
Add freeramdisk(8)
diff --git a/Makefile b/Makefile
index 9a32e7a..ced0a4b 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -31,6 +31,7 @@ SRC = \
eject.c \
fallocate.c \
free.c \
+ freeramdisk.c \
fsfreeze.c \
getty.c \
halt.c \
_AT_@ -93,6 +94,7 @@ MAN1 = \
MAN8 = \
ctrlaltdel.8 \
+ freeramdisk.8 \
fsfreeze.8 \
getty.8 \
halt.8 \
diff --git a/freeramdisk.8 b/freeramdisk.8
new file mode 100644
index 0000000..1932fd9
--- /dev/null
+++ b/freeramdisk.8
_AT_@ -0,0 +1,8 @@
+.TH FREERAMDISK 8 ubase-VERSION
+.SH NAME
+BfreeramdiskR - Free memory used by the loadlin ramdisk
+.SH SYNOPSIS
+BfreeramdiskR
+.SH DESCRIPTION
+BfreeramdiskR frees the memory that is used by the ramdisk.
+It uses the I/dev/ramR device node.
diff --git a/freeramdisk.c b/freeramdisk.c
new file mode 100644
index 0000000..7b0d85a
--- /dev/null
+++ b/freeramdisk.c
_AT_@ -0,0 +1,37 @@
+/* See LICENSE file for copyright and license details. */
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "util.h"
+
+static void
+usage(void)
+{
+ eprintf("usage: %s
", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *dev = "/dev/ram";
+ int fd;
+
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc != 0)
+ usage();
+
+ if ((fd = open(dev, O_RDWR)) < 0)
+ eprintf("open: %s:", dev);
+ if (ioctl(fd, BLKFLSBUF, dev) < 0)
+ eprintf("BLKFLSBUF %s:", dev);
+ close(fd);
+ return EXIT_SUCCESS;
+}
Received on Thu Jun 26 2014 - 17:26:18 CEST
This archive was generated by hypermail 2.3.0
: Thu Jun 26 2014 - 17:36:08 CEST