10f66f451Sopenharmony_ci/* freeramdisk.c - Free all memory allocated to ramdisk 20f66f451Sopenharmony_ci * 30f66f451Sopenharmony_ci * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com> 40f66f451Sopenharmony_ci * 50f66f451Sopenharmony_ci * No Standard 60f66f451Sopenharmony_ci 70f66f451Sopenharmony_ciUSE_FREERAMDISK(NEWTOY(freeramdisk, "<1>1", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) 80f66f451Sopenharmony_ci 90f66f451Sopenharmony_ciconfig FREERAMDISK 100f66f451Sopenharmony_ci bool "freeramdisk" 110f66f451Sopenharmony_ci default y 120f66f451Sopenharmony_ci help 130f66f451Sopenharmony_ci usage: freeramdisk [RAM device] 140f66f451Sopenharmony_ci 150f66f451Sopenharmony_ci Free all memory allocated to specified ramdisk 160f66f451Sopenharmony_ci*/ 170f66f451Sopenharmony_ci 180f66f451Sopenharmony_ci#include "toys.h" 190f66f451Sopenharmony_ci 200f66f451Sopenharmony_civoid freeramdisk_main(void) 210f66f451Sopenharmony_ci{ 220f66f451Sopenharmony_ci int fd; 230f66f451Sopenharmony_ci 240f66f451Sopenharmony_ci fd = xopen(toys.optargs[0], O_RDWR); 250f66f451Sopenharmony_ci xioctl(fd, BLKFLSBUF, toys.optargs[0]); 260f66f451Sopenharmony_ci if (CFG_TOYBOX_FREE) xclose(fd); 270f66f451Sopenharmony_ci} 28