Re: Reclaim space from unused ramdisk?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jan Engelhardt <[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux