morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

freeramdisk.c (588B)


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