1/* See LICENSE file for copyright and license details. */
2
3
4#include <sys/ioctl.h>
5#include <sys/mount.h>
6#include <sys/types.h>
7
8#include <fcntl.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <unistd.h>
12
13#include "util.h"
14
15static void
16usage(void)
17{
18 eprintf("usage: %s\n", argv0);
19}
20
21// ?man freeramdisk: free ramdisk memory
22// ?man free memory associated with a ramdisk device
23int
24main(int argc, char *argv[])
25{
26 char *dev = "/dev/ram";
27 int fd;
28
29 ARGBEGIN {
30 default:
31 usage();
32 } ARGEND;
33
34 if (argc != 0)
35 usage();
36
37 if ((fd = open(dev, O_RDWR)) < 0)
38 eprintf("open: %s:", dev);
39 if (ioctl(fd, BLKFLSBUF, dev) < 0)
40 eprintf("BLKFLSBUF %s:", dev);
41 close(fd);
42 return 0;
43}