Re: Reclaim space from unused ramdisk?

From: Jan Engelhardt
Date: Wed Jul 27 2005 - 01:27:02 EST

>I wonder if it would be possible to somehow reclaim space that has
>been previously reserved for a ramdisk without rebooting.


#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, const char **argv) {
int eax = 0;
while(*argv != NULL) {
int fd = open(*argv, O_RDWR);
if(fd < 0) {
fprintf(stderr, "Warning: Cannot open %s: %s\n",
*argv, strerror(errno));
if(eax == 0) { eax = errno; }
ioctl(fd, BLKFLSBUF, 0);
return eax == 0;


>How difficult would this be to write?

Jan Engelhardt
| Alphagate Systems,
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at