mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: akihana@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: Reclaim space from unused ramdisk?
Date: Tue, 26 Jul 2005 23:56:24 -0700	[thread overview]
Message-ID: <20050726235624.4f3ca2a8.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0507270823490.10780@yvahk01.tjqt.qr>

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.

  reply	other threads:[~2005-07-27  6:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-26 22:16 Mike Mohr
2005-07-26 23:21 ` Marc Ballarin
2005-07-27  6:25 ` Jan Engelhardt
2005-07-27  6:56   ` Andrew Morton [this message]
2005-07-27  7:52     ` Jan Engelhardt
2005-07-27  7:55       ` Andrew Morton
2005-07-27  8:28         ` Jan Engelhardt
2005-07-27  9:04           ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050726235624.4f3ca2a8.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=akihana@gmail.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®