aboutsummaryrefslogtreecommitdiff
path: root/toys/other/freeramdisk.c
blob: cb0b7f8f8a7e45d001470525625d0113362653b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* freeramdisk.c - Free all memory allocated to ramdisk
 *
 * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com>
 *
 * No Standard

USE_FREERAMDISK(NEWTOY(freeramdisk, "<1>1", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))

config FREERAMDISK
  bool "freeramdisk"
  default y
  help
    usage: freeramdisk [RAM device]

    Free all memory allocated to specified ramdisk
*/

#include "toys.h"

void freeramdisk_main(void)
{
  int fd;

  fd = xopen(toys.optargs[0], O_RDWR);
  xioctl(fd, BLKFLSBUF, toys.optargs[0]);
  if (CFG_TOYBOX_FREE) xclose(fd);
}