Re: Reclaim space from unused ramdisk?

From: Andrew Morton (akpm_at_osdl.org)
Date: 07/27/05

  • Next message: Pavel Machek: "Re: [swsusp] encrypt suspend data for easy wiping"
    Date:	Tue, 26 Jul 2005 23:56:24 -0700
    To: Jan Engelhardt <jengelh@linux01.gwdg.de>
    
    

    Jan Engelhardt <jengelh@linux01.gwdg.de> wrote:
    >
    > >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;
    > }
    >

    hmm, yes. That's a special-case in the ramdisk driver.

    The command `blockdev --flushbufs /dev/ram0' should have the same effect.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Pavel Machek: "Re: [swsusp] encrypt suspend data for easy wiping"