From: Manuel Estrada Sainz <ranty@debian.org>
To: Hannes Reinecke <hare@suse.de>
Cc: viro@parcelfarce.linux.theplanet.co.uk,
Andrey Borzenkov <arvidjaar@mail.ru>,
Chris Friesen <cfriesen@nortelnetworks.com>,
"Kevin P. Fleming" <kpfleming@backtobasicsmgmt.com>,
Jeff Garzik <jgarzik@pobox.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Is initramfs freed after kernel is booted?
Date: Tue, 25 Nov 2003 19:26:47 +0100 [thread overview]
Message-ID: <20031125182647.GA8068@ranty.pantax.net> (raw)
In-Reply-To: <3FBB8748.8020503@suse.de>
On Wed, Nov 19, 2003 at 04:07:52PM +0100, Hannes Reinecke wrote:
> viro@parcelfarce.linux.theplanet.co.uk wrote:
> >On Mon, Nov 17, 2003 at 09:33:59PM +0300, Andrey Borzenkov wrote:
> >
> >>On Monday 17 November 2003 21:03, viro@parcelfarce.linux.theplanet.co.uk
> >>wrote:
> >>
> >>>On Mon, Nov 17, 2003 at 12:50:34PM -0500, Chris Friesen wrote:
> >>>
> >>>>viro@parcelfarce.linux.theplanet.co.uk wrote:
[snip]
> >You do, but you can trivially call unlink() on the executable itself. It
> >will be freed after it does exec() of final /sbin/init...
> >
> >Alternatively, you could
> >mkdir /root
> >mount final root on /root
> >
> >chdir("/root");
> >mount("/", "initramfs", NULL, MS_BIND, NULL);
> >mount(".", "/", NULL, MS_MOVE, NULL);
> >chroot(".");
> >execve("/sbin/init", ...)
> >
> Nope. initramfs shares the superblock with 'rootfs', which has the
> MS_NOUSER flags set. Hence graft_tree() (which is the worker function
> for MS_BIND) refuses to work.
> Can't we just remove the MS_NOUSER flags if initramfs is active?
> Probably not the correct way, but certainly the quickest :-)
> The correct way would probably be to clone the superblock of initramfs,
> set the filesystem-type of initramfs to 'ramfs' so that initramfs
> appears to be a chroot()ed filesystem like initrd. Then we could do a
> pivot_root and we have the contents of initramfs still available.
> But needs someone with deeper fs-knowledge than myself to do it.
How about this one liner?
--- fs/ramfs/inode.c 22 Oct 2003 15:19:58 -0000 1.39
+++ fs/ramfs/inode.c 25 Nov 2003 18:10:00 -0000
@@ -207,7 +207,7 @@
static struct super_block *rootfs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
- return get_sb_nodev(fs_type, flags|MS_NOUSER, data, ramfs_fill_super);
+ return get_sb_single(fs_type, flags, data, ramfs_fill_super);
}
static struct file_system_type ramfs_fs_type = {
Since rootfs is supposed to be mounted just once, it shouldn't be a
problem using get_sb_single().
This way, you can mount rootfs anytime, and get in there to remove
files.
Am I missing something obvious here?
Have a nice day
Manuel
--
--- Manuel Estrada Sainz <ranty@debian.org>
<ranty@bigfoot.com>
<ranty@users.sourceforge.net>
------------------------ <manuel.estrada@hispalinux.es> -------------------
Let us have the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.
prev parent reply other threads:[~2003-11-25 18:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-16 17:09 Andrey Borzenkov
2003-11-16 19:51 ` Jeff Garzik
2003-11-17 14:39 ` Chris Friesen
2003-11-17 15:36 ` "Andrey Borzenkov"
2003-11-17 15:39 ` Chris Friesen
2003-11-17 15:46 ` Jeff Garzik
2003-11-17 18:32 ` Bryan O'Sullivan
2003-11-17 15:47 ` Kevin P. Fleming
2003-11-17 16:06 ` Chris Friesen
2003-11-17 16:25 ` Erik Mouw
2003-11-17 17:25 ` viro
2003-11-17 17:47 ` viro
2003-11-17 17:50 ` Chris Friesen
2003-11-17 18:03 ` viro
2003-11-17 18:33 ` Andrey Borzenkov
2003-11-17 19:15 ` viro
2003-11-19 14:19 ` Olaf Hering
2003-11-19 15:07 ` Hannes Reinecke
2003-11-25 18:26 ` Manuel Estrada Sainz [this message]
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=20031125182647.GA8068@ranty.pantax.net \
--to=ranty@debian.org \
--cc=arvidjaar@mail.ru \
--cc=cfriesen@nortelnetworks.com \
--cc=hare@suse.de \
--cc=jgarzik@pobox.com \
--cc=kpfleming@backtobasicsmgmt.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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®