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.

free_ramdisk.c:

#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; }
continue;
}
ioctl(fd, BLKFLSBUF, 0);
close(fd);
++argv;
}
return eax == 0;
}

//eof


>How difficult would this be to write?


Jan Engelhardt
--
| Alphagate Systems, http://alphagate.hopto.org/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/