mirror of git://git.suckless.org/sbase
Add freeramdisk(8)
This commit is contained in:
parent
35a9479141
commit
c88ba3750e
2
Makefile
2
Makefile
|
@ -31,6 +31,7 @@ SRC = \
|
|||
eject.c \
|
||||
fallocate.c \
|
||||
free.c \
|
||||
freeramdisk.c \
|
||||
fsfreeze.c \
|
||||
getty.c \
|
||||
halt.c \
|
||||
|
@ -93,6 +94,7 @@ MAN1 = \
|
|||
|
||||
MAN8 = \
|
||||
ctrlaltdel.8 \
|
||||
freeramdisk.8 \
|
||||
fsfreeze.8 \
|
||||
getty.8 \
|
||||
halt.8 \
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
.TH FREERAMDISK 8 ubase-VERSION
|
||||
.SH NAME
|
||||
\fBfreeramdisk\fR - Free memory used by the loadlin ramdisk
|
||||
.SH SYNOPSIS
|
||||
\fBfreeramdisk\fR
|
||||
.SH DESCRIPTION
|
||||
\fBfreeramdisk\fR frees the memory that is used by the ramdisk.
|
||||
It uses the \fI/dev/ram\fR device node.
|
|
@ -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\n", 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;
|
||||
}
|
Loading…
Reference in New Issue