mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs
       [not found] <8GGkX-2Xv-5@gated-at.bofh.it>
@ 2007-07-14 18:49 ` Bodo Eggert
  2007-07-15  5:24   ` Al Boldi
  2007-07-15  5:24   ` [PATCH 0/3][try 1] init: enable system-on-initramfs Al Boldi
  0 siblings, 2 replies; 6+ messages in thread
From: Bodo Eggert @ 2007-07-14 18:49 UTC (permalink / raw)
  To: Al Boldi, linux-kernel, 7eggert

Al Boldi <a1426z@gawab.com> wrote:
> Bodo Eggert wrote:

Please reply-to-all, I'm not subscribed, but reading through a news gateway.

>> This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to use
>> tmpfs instead of ramfs". All the fame belongs to him, the bugs belong to
>> me.
> 
> Actually, my patch was a rework of John Zielinski's
> http://marc.info/?l=linux-kernel&m=107013630212011&w=4 patch, so the credit
> really goes to him.

>> Signed-Off-By: Bodo Eggert <7eggert@gmx.de>
>>
>>
>> diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig
>> linux-2.6.22.tmpfsroot/fs/Kconfig --- linux-2.6.22.base/fs/Kconfig
>> 2007-07-12 14:05:16.000000000 +0200 +++ linux-2.6.22.tmpfsroot/fs/Kconfig
>>  2007-07-12 15:10:09.000000000 +0200 @@ -989,6 +989,22 @@ config
>> TMPFS_POSIX_ACL
> 
> Setting this in fs/Kconfig is way to deep, and too far away from the
> initramfs Kconfig, which makes it obscure.

If it were under general setup, you'd have to enter fs to select tmpfs,
enter general setup to replace ramfs, and re-enter fs to disable ramfs.
I consider making people do that to be an evil deed.

The current position is very convenient, ramfs is below tmpfs, and while you
go from top to the bottom, you can enable tmpfs, tmpfs-replaces-ramfs and
ramfs=n.

>>           If you don't know what Access Control Lists are, say N.
>>
>> +config TMPFS_ROOT
>> +       bool "Use tmpfs instrad of ramfs for initramfs"
> 
> Check typo.
> 
>> +       depends on TMPFS
> 
> Should probably depend on SHMEM too.

Sounds reasonable.

>> @@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
>>         def_bool HUGETLBFS
>>
>>  config RAMFS
>> -       bool
>> +       bool "Ramfs file system support" if TMPFS_ROOT
> 
> What's wrong with the original Kconfig of making this tristate?

I tested =m, found it not to compile because of a nonexported __symbol
and decided it wasn't worth the effort of adding another export while
other people struggle to reduce their number.

>> diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c
>> linux-2.6.22.tmpfsroot/mm/shmem.c --- linux-2.6.22.base/mm/shmem.c
>> 2007-07-12 14:05:25.000000000 +0200 +++ linux-2.6.22.tmpfsroot/mm/shmem.c
>>  2007-07-12 15:01:32.000000000 +0200 @@ -2369,6 +2369,8 @@ static void
>> init_once(void *foo, struct
>>
>>  static int init_inodecache(void)
>>  {
>> +       if (shmem_inode_cachep)
>> +               return 0;
>>         shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
>>                                 sizeof(struct shmem_inode_info),
>>                                 0, 0, init_once, NULL);
>> @@ -2582,6 +2584,34 @@ put_memory:
>>         return ERR_PTR(error);
>>  }
>>
>> +#ifdef CONFIG_TMPFS_ROOT
>> +static int rootfs_get_sb(struct file_system_type *fs_type,
>> +       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
>> +{
>> +       return get_sb_nodev(fs_type, flags|MS_NOUSER, data,
>> shmem_fill_super, +                           mnt);
> 
> Setting the MS_NOUSER flag will make this invisible to df (diskfree).

Which is obviously a bad thing for my cause, but good if you'd boot a
normal system. Is there any way out?

>> +}
>> +
>> +/*static struct super_block *rootfs_get_sb(struct file_system_type
>> *fs_type, +       int flags, const char *dev_name, void *data)
>> +{
>> +       return get_sb_single(fs_type, flags, data, shmem_fill_super);
>> +}*/
> 
> You commented this out, probably asking for clarification:  IIRC, it's
> get_sb_single instead of get_sb_nodev, because tmpfs can be mounted more
> than once and thus needs to be reference counted.

No, I had left it there accidentially. Your comment tells me it was ment to
happen.
-- 
If at first you don't succeed call in an air-strike. 

Friß, Spammer: zbyUv@7nKzeel.7eggert.dyndns.org J@op16.7eggert.dyndns.org
 NS6uqbvhd9@d.7eggert.dyndns.org QcPun@SgLk.7eggert.dyndns.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs
  2007-07-14 18:49 ` [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs Bodo Eggert
@ 2007-07-15  5:24   ` Al Boldi
  2007-07-26 20:34     ` Al Boldi
  2007-07-15  5:24   ` [PATCH 0/3][try 1] init: enable system-on-initramfs Al Boldi
  1 sibling, 1 reply; 6+ messages in thread
From: Al Boldi @ 2007-07-15  5:24 UTC (permalink / raw)
  To: Bodo Eggert; +Cc: linux-kernel

Bodo Eggert wrote:
> Al Boldi <a1426z@gawab.com> wrote:
> > Bodo Eggert wrote:
>
> Please reply-to-all, I'm not subscribed, but reading through a news
> gateway.

Same here.  The problem is, I have no idea who's on the cc, and expected you 
to be on the list.  Sorry.

> >> This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to use
> >> tmpfs instead of ramfs". All the fame belongs to him, the bugs belong
> >> to me.
> >
> > Actually, my patch was a rework of John Zielinski's
> > http://marc.info/?l=linux-kernel&m=107013630212011&w=4 patch, so the
> > credit really goes to him.
> >
> >> Signed-Off-By: Bodo Eggert <7eggert@gmx.de>
> >>
> >>
> >> diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig
> >> linux-2.6.22.tmpfsroot/fs/Kconfig --- linux-2.6.22.base/fs/Kconfig
> >> 2007-07-12 14:05:16.000000000 +0200 +++
> >> linux-2.6.22.tmpfsroot/fs/Kconfig 2007-07-12 15:10:09.000000000 +0200
> >> @@ -989,6 +989,22 @@ config TMPFS_POSIX_ACL
> >
> > Setting this in fs/Kconfig is way to deep, and too far away from the
> > initramfs Kconfig, which makes it obscure.
>
> If it were under general setup, you'd have to enter fs to select tmpfs,
> enter general setup to replace ramfs, and re-enter fs to disable ramfs.
> I consider making people do that to be an evil deed.

That's easy to fix, just change "depends on" to "select" in Kconfig.

> The current position is very convenient, ramfs is below tmpfs, and while
> you go from top to the bottom, you can enable tmpfs, tmpfs-replaces-ramfs
> and ramfs=n.
>
> >>           If you don't know what Access Control Lists are, say N.
> >>
> >> +config TMPFS_ROOT
> >> +       bool "Use tmpfs instrad of ramfs for initramfs"
> >
> > Check typo.
> >
> >> +       depends on TMPFS
> >
> > Should probably depend on SHMEM too.
>
> Sounds reasonable.
>
> >> @@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
> >>         def_bool HUGETLBFS
> >>
> >>  config RAMFS
> >> -       bool
> >> +       bool "Ramfs file system support" if TMPFS_ROOT
> >
> > What's wrong with the original Kconfig of making this tristate?
>
> I tested =m, found it not to compile because of a nonexported __symbol
> and decided it wasn't worth the effort of adding another export while
> other people struggle to reduce their number.

Ok.

> >> diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c
> >> linux-2.6.22.tmpfsroot/mm/shmem.c --- linux-2.6.22.base/mm/shmem.c
> >> 2007-07-12 14:05:25.000000000 +0200 +++
> >> linux-2.6.22.tmpfsroot/mm/shmem.c 2007-07-12 15:01:32.000000000 +0200
> >> @@ -2369,6 +2369,8 @@ static void init_once(void *foo, struct
> >>
> >>  static int init_inodecache(void)
> >>  {
> >> +       if (shmem_inode_cachep)
> >> +               return 0;
> >>         shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
> >>                                 sizeof(struct shmem_inode_info),
> >>                                 0, 0, init_once, NULL);
> >> @@ -2582,6 +2584,34 @@ put_memory:
> >>         return ERR_PTR(error);
> >>  }
> >>
> >> +#ifdef CONFIG_TMPFS_ROOT
> >> +static int rootfs_get_sb(struct file_system_type *fs_type,
> >> +       int flags, const char *dev_name, void *data, struct vfsmount
> >> *mnt) +{
> >> +       return get_sb_nodev(fs_type, flags|MS_NOUSER, data,
> >> shmem_fill_super, +                           mnt);
> >
> > Setting the MS_NOUSER flag will make this invisible to df (diskfree).
>
> Which is obviously a bad thing for my cause, but good if you'd boot a
> normal system. Is there any way out?

Just remove the MS_NOUSER flag.  Normal systems would want to umount it after 
pivoting, so it won't be visible then.

> >> +}
> >> +
> >> +/*static struct super_block *rootfs_get_sb(struct file_system_type
> >> *fs_type, +       int flags, const char *dev_name, void *data)
> >> +{
> >> +       return get_sb_single(fs_type, flags, data, shmem_fill_super);
> >> +}*/
> >
> > You commented this out, probably asking for clarification:  IIRC, it's
> > get_sb_single instead of get_sb_nodev, because tmpfs can be mounted more
> > than once and thus needs to be reference counted.
>
> No, I had left it there accidentially. Your comment tells me it was ment
> to happen.


Thanks!

--
Al


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3][try 1] init: enable system-on-initramfs
  2007-07-14 18:49 ` [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs Bodo Eggert
  2007-07-15  5:24   ` Al Boldi
@ 2007-07-15  5:24   ` Al Boldi
  1 sibling, 0 replies; 6+ messages in thread
From: Al Boldi @ 2007-07-15  5:24 UTC (permalink / raw)
  To: Bodo Eggert; +Cc: linux-kernel

Bodo Eggert wrote:
> On Sat, 14 Jul 2007, H. Peter Anvin wrote:
> > Bodo Eggert wrote:
> > > On Sat, 14 Jul 2007, H. Peter Anvin wrote:
> > >> Bodo Eggert wrote:
> > >>> Setting the name of the rdinit process to the name of the init
> > >>> process in order to select the root device should not be the right
> > >>> knob.
> > >>
> > >> What's wrong with it?
> > >
> > > rdinit is supposed to be the program that mounts, root is supposed to
> > > be whatever is mounted and init is supposed to run the system. Three
> > > different things. Now if you want to change the third, just set the
> > > first to the second ...
> >
> > That only applies to a model that you explicitly doesn't want to use.
>
> I don't want to use rdinit, because there is no task for rdinit(3), and I
> don't want to mount a filesystem(3). But I do want to use init(2).
>
> I have to lie to the kernel saying (2) is (1) in order to trick it into
> beleaving I'd do (3) myself, which I don't, just in order to not do (3).
> If the bug of not calling the security hook would be fixed, this trick
> would use the path where rdinit is expected to trigger the callback, but
> since that rdinit would be no rdinit, that callback would still be wrongly
> skipped. That would not be a bad thing for my setup, but it clearly shows
> this setup to be wrong.
>
> The correct solution is tell the kernel not to do (3) if you don't want
> it to do (3). The rest will work as intended.

Sounds rather confusing.

This is how I see it:

  initrd=initrd.img.gz implies root=rootfs
  rdinit=/bin/sh is the special init=/bin/sh for initrd.

Both initrd/root and rdinit/init must be separate for pivoting to succeed.  
If you want to drop into the initrd (i.e. rootfs), then instruct your 
initrd.img.gz not to pivot (i.e. not over-mount another filesystem).


Thanks!

--
Al


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs
  2007-07-15  5:24   ` Al Boldi
@ 2007-07-26 20:34     ` Al Boldi
  0 siblings, 0 replies; 6+ messages in thread
From: Al Boldi @ 2007-07-26 20:34 UTC (permalink / raw)
  To: Bodo Eggert; +Cc: linux-kernel, H. Peter Anvin, akpm

 
What happened to this one?  Is it in -mm?


Thanks!

--
Al

Al Boldi wrote:
> Bodo Eggert wrote:
> > Al Boldi <a1426z@gawab.com> wrote:
> > > Bodo Eggert wrote:
> > >> This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to
> > >> use tmpfs instead of ramfs". All the fame belongs to him, the bugs
> > >> belong to me.
> > >
> > > Actually, my patch was a rework of John Zielinski's
> > > http://marc.info/?l=linux-kernel&m=107013630212011&w=4 patch, so the
> > > credit really goes to him.
> > >
> > >> Signed-Off-By: Bodo Eggert <7eggert@gmx.de>
> > >>
> > >>
> > >> diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig
> > >> linux-2.6.22.tmpfsroot/fs/Kconfig --- linux-2.6.22.base/fs/Kconfig
> > >> 2007-07-12 14:05:16.000000000 +0200 +++
> > >> linux-2.6.22.tmpfsroot/fs/Kconfig 2007-07-12 15:10:09.000000000 +0200
> > >> @@ -989,6 +989,22 @@ config TMPFS_POSIX_ACL
> > >
> > > Setting this in fs/Kconfig is way to deep, and too far away from the
> > > initramfs Kconfig, which makes it obscure.
> >
> > If it were under general setup, you'd have to enter fs to select tmpfs,
> > enter general setup to replace ramfs, and re-enter fs to disable ramfs.
> > I consider making people do that to be an evil deed.
>
> That's easy to fix, just change "depends on" to "select" in Kconfig.
>
> > The current position is very convenient, ramfs is below tmpfs, and while
> > you go from top to the bottom, you can enable tmpfs,
> > tmpfs-replaces-ramfs and ramfs=n.
> >
> > >>           If you don't know what Access Control Lists are, say N.
> > >>
> > >> +config TMPFS_ROOT
> > >> +       bool "Use tmpfs instrad of ramfs for initramfs"
> > >
> > > Check typo.
> > >
> > >> +       depends on TMPFS
> > >
> > > Should probably depend on SHMEM too.
> >
> > Sounds reasonable.
> >
> > >> @@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
> > >>         def_bool HUGETLBFS
> > >>
> > >>  config RAMFS
> > >> -       bool
> > >> +       bool "Ramfs file system support" if TMPFS_ROOT
> > >
> > > What's wrong with the original Kconfig of making this tristate?
> >
> > I tested =m, found it not to compile because of a nonexported __symbol
> > and decided it wasn't worth the effort of adding another export while
> > other people struggle to reduce their number.
>
> Ok.
>
> > >> diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c
> > >> linux-2.6.22.tmpfsroot/mm/shmem.c --- linux-2.6.22.base/mm/shmem.c
> > >> 2007-07-12 14:05:25.000000000 +0200 +++
> > >> linux-2.6.22.tmpfsroot/mm/shmem.c 2007-07-12 15:01:32.000000000 +0200
> > >> @@ -2369,6 +2369,8 @@ static void init_once(void *foo, struct
> > >>
> > >>  static int init_inodecache(void)
> > >>  {
> > >> +       if (shmem_inode_cachep)
> > >> +               return 0;
> > >>         shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
> > >>                                 sizeof(struct shmem_inode_info),
> > >>                                 0, 0, init_once, NULL);
> > >> @@ -2582,6 +2584,34 @@ put_memory:
> > >>         return ERR_PTR(error);
> > >>  }
> > >>
> > >> +#ifdef CONFIG_TMPFS_ROOT
> > >> +static int rootfs_get_sb(struct file_system_type *fs_type,
> > >> +       int flags, const char *dev_name, void *data, struct vfsmount
> > >> *mnt) +{
> > >> +       return get_sb_nodev(fs_type, flags|MS_NOUSER, data,
> > >> shmem_fill_super, +                           mnt);
> > >
> > > Setting the MS_NOUSER flag will make this invisible to df (diskfree).
> >
> > Which is obviously a bad thing for my cause, but good if you'd boot a
> > normal system. Is there any way out?
>
> Just remove the MS_NOUSER flag.  Normal systems would want to umount it
> after pivoting, so it won't be visible then.
>
> > >> +}
> > >> +
> > >> +/*static struct super_block *rootfs_get_sb(struct file_system_type
> > >> *fs_type, +       int flags, const char *dev_name, void *data)
> > >> +{
> > >> +       return get_sb_single(fs_type, flags, data, shmem_fill_super);
> > >> +}*/
> > >
> > > You commented this out, probably asking for clarification:  IIRC, it's
> > > get_sb_single instead of get_sb_nodev, because tmpfs can be mounted
> > > more than once and thus needs to be reference counted.
> >
> > No, I had left it there accidentially. Your comment tells me it was ment
> > to happen.
>
> Thanks!
>
> --
> Al


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs
@ 2007-07-14  3:18 Al Boldi
  0 siblings, 0 replies; 6+ messages in thread
From: Al Boldi @ 2007-07-14  3:18 UTC (permalink / raw)
  To: linux-kernel

Bodo Eggert wrote:
> Change the root filesystem to tmpfs. Doing this makes having a system on
> tmpfs much easier, while allowing to discard the now unnecessary ramfs.

Thanks a lot!

> Having the rootfs on tmpfs allows to safely run e.g. a rescue system
> without using tricks. You might even include the rescue system into the
> kernel.
>
> This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to use
> tmpfs instead of ramfs". All the fame belongs to him, the bugs belong to
> me.

Actually, my patch was a rework of John Zielinski's 
http://marc.info/?l=linux-kernel&m=107013630212011&w=4 patch, so the credit 
really goes to him.

> Signed-Off-By: Bodo Eggert <7eggert@gmx.de>
>
>
> diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig
> linux-2.6.22.tmpfsroot/fs/Kconfig --- linux-2.6.22.base/fs/Kconfig       
> 2007-07-12 14:05:16.000000000 +0200 +++ linux-2.6.22.tmpfsroot/fs/Kconfig 
>  2007-07-12 15:10:09.000000000 +0200 @@ -989,6 +989,22 @@ config
> TMPFS_POSIX_ACL

Setting this in fs/Kconfig is way to deep, and too far away from the 
initramfs Kconfig, which makes it obscure.

>
>           If you don't know what Access Control Lists are, say N.
>
> +config TMPFS_ROOT
> +       bool "Use tmpfs instrad of ramfs for initramfs"

Check typo.                    

> +       depends on TMPFS

Should probably depend on SHMEM too.

> +       default n
> +       help
> +         This replaces the ramfs used for unpacking the cpio images
> +         with tmpfs, thereby allowing swapping these contents to disk and
> +         adding size limit support.
> +
> +         Side effect:
> +         This is useful only if you don't plan on mounting a different
> +         root filesystem. Therefore it will change the default of the
> +         root= parameter to "rootfs".
> +
> +         If unsure, say N
> +
>  config HUGETLBFS
>         bool "HugeTLB file system support"
>         depends on X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN
> @@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
>         def_bool HUGETLBFS
>
>  config RAMFS
> -       bool
> +       bool "Ramfs file system support" if TMPFS_ROOT

What's wrong with the original Kconfig of making this tristate?

>         default y
>         ---help---
>           Ramfs is a file system which keeps all files in RAM. It allows

:
:

> diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c
> linux-2.6.22.tmpfsroot/mm/shmem.c --- linux-2.6.22.base/mm/shmem.c       
> 2007-07-12 14:05:25.000000000 +0200 +++ linux-2.6.22.tmpfsroot/mm/shmem.c 
>  2007-07-12 15:01:32.000000000 +0200 @@ -2369,6 +2369,8 @@ static void
> init_once(void *foo, struct
>
>  static int init_inodecache(void)
>  {
> +       if (shmem_inode_cachep)
> +               return 0;
>         shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
>                                 sizeof(struct shmem_inode_info),
>                                 0, 0, init_once, NULL);
> @@ -2582,6 +2584,34 @@ put_memory:
>         return ERR_PTR(error);
>  }
>
> +#ifdef CONFIG_TMPFS_ROOT
> +static int rootfs_get_sb(struct file_system_type *fs_type,
> +       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
> +{
> +       return get_sb_nodev(fs_type, flags|MS_NOUSER, data,
> shmem_fill_super, +                           mnt);

Setting the MS_NOUSER flag will make this invisible to df (diskfree).

> +}
> +
> +/*static struct super_block *rootfs_get_sb(struct file_system_type
> *fs_type, +       int flags, const char *dev_name, void *data)
> +{
> +       return get_sb_single(fs_type, flags, data, shmem_fill_super);
> +}*/

You commented this out, probably asking for clarification:  IIRC, it's 
get_sb_single instead of get_sb_nodev, because tmpfs can be mounted more 
than once and thus needs to be reference counted.

> +
> +static struct file_system_type rootfs_fs_type = {
> +       .name           = "rootfs",
> +       .get_sb         = rootfs_get_sb,
> +       .kill_sb        = kill_litter_super,
> +};
> +
> +int __init init_rootfs(void)
> +{
> +       if (init_inodecache())
> +               panic("Can't initialize shm inode cache");
> +       return register_filesystem(&rootfs_fs_type);
> +}
> +#endif
> +
>  /*
>   * shmem_zero_setup - setup a shared anonymous mapping
>   *


Thanks!

--
Al


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs
  2007-07-13 18:56 [PATCH 0/3][try 1] init: enable system-on-initramfs Bodo Eggert
@ 2007-07-13 19:00 ` Bodo Eggert
  0 siblings, 0 replies; 6+ messages in thread
From: Bodo Eggert @ 2007-07-13 19:00 UTC (permalink / raw)
  To: Bodo Eggert; +Cc: linux-kernel

Change the root filesystem to tmpfs. Doing this makes having a system on
tmpfs much easier, while allowing to discard the now unnecessary ramfs.

Having the rootfs on tmpfs allows to safely run e.g. a rescue system without
using tricks. You might even include the rescue system into the kernel.

This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to use
tmpfs instead of ramfs". All the fame belongs to him, the bugs belong to me.

Signed-Off-By: Bodo Eggert <7eggert@gmx.de>


diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig linux-2.6.22.tmpfsroot/fs/Kconfig
--- linux-2.6.22.base/fs/Kconfig	2007-07-12 14:05:16.000000000 +0200
+++ linux-2.6.22.tmpfsroot/fs/Kconfig	2007-07-12 15:10:09.000000000 +0200
@@ -989,6 +989,22 @@ config TMPFS_POSIX_ACL
 
 	  If you don't know what Access Control Lists are, say N.
 
+config TMPFS_ROOT
+	bool "Use tmpfs instrad of ramfs for initramfs"
+	depends on TMPFS
+	default n
+	help
+	  This replaces the ramfs used for unpacking the cpio images
+	  with tmpfs, thereby allowing swapping these contents to disk and
+	  adding size limit support.
+	  
+	  Side effect:
+	  This is useful only if you don't plan on mounting a different
+	  root filesystem. Therefore it will change the default of the
+	  root= parameter to "rootfs".
+
+	  If unsure, say N
+
 config HUGETLBFS
 	bool "HugeTLB file system support"
 	depends on X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN
@@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
 	def_bool HUGETLBFS
 
 config RAMFS
-	bool
+	bool "Ramfs file system support" if TMPFS_ROOT
 	default y
 	---help---
 	  Ramfs is a file system which keeps all files in RAM. It allows
diff -Xdontdiff -pruN linux-2.6.22.base/fs/ramfs/inode.c linux-2.6.22.tmpfsroot/fs/ramfs/inode.c
--- linux-2.6.22.base/fs/ramfs/inode.c	2007-07-12 14:05:17.000000000 +0200
+++ linux-2.6.22.tmpfsroot/fs/ramfs/inode.c	2007-07-12 15:01:32.000000000 +0200
@@ -189,6 +189,13 @@ int ramfs_get_sb(struct file_system_type
 	return get_sb_nodev(fs_type, flags, data, ramfs_fill_super, mnt);
 }
 
+static struct file_system_type ramfs_fs_type = {
+	.name		= "ramfs",
+	.get_sb		= ramfs_get_sb,
+	.kill_sb	= kill_litter_super,
+};
+
+#ifdef CONFIG_RAMFS_ROOTFS
 static int rootfs_get_sb(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data, struct vfsmount *mnt)
 {
@@ -196,17 +203,18 @@ static int rootfs_get_sb(struct file_sys
 			    mnt);
 }
 
-static struct file_system_type ramfs_fs_type = {
-	.name		= "ramfs",
-	.get_sb		= ramfs_get_sb,
-	.kill_sb	= kill_litter_super,
-};
 static struct file_system_type rootfs_fs_type = {
 	.name		= "rootfs",
 	.get_sb		= rootfs_get_sb,
 	.kill_sb	= kill_litter_super,
 };
 
+int __init init_rootfs(void)
+{
+	return register_filesystem(&rootfs_fs_type);
+}
+#endif
+
 static int __init init_ramfs_fs(void)
 {
 	return register_filesystem(&ramfs_fs_type);
@@ -220,9 +228,4 @@ static void __exit exit_ramfs_fs(void)
 module_init(init_ramfs_fs)
 module_exit(exit_ramfs_fs)
 
-int __init init_rootfs(void)
-{
-	return register_filesystem(&rootfs_fs_type);
-}
-
 MODULE_LICENSE("GPL");
diff -Xdontdiff -pruN linux-2.6.22.base/init/do_mounts.c linux-2.6.22.tmpfsroot/init/do_mounts.c
--- linux-2.6.22.base/init/do_mounts.c	2007-07-12 15:04:48.000000000 +0200
+++ linux-2.6.22.tmpfsroot/init/do_mounts.c	2007-07-12 14:53:07.000000000 +0200
@@ -24,7 +24,11 @@ int __initdata rd_doload;	/* 1 = load RA
 
 int root_mountflags = MS_RDONLY | MS_SILENT;
 char * __initdata root_device_name;
+#ifdef CONFIG_TMPFS_ROOT
+static char __initdata saved_root_name[64] = "rootfs";
+#else
 static char __initdata saved_root_name[64];
+#endif
 
 dev_t ROOT_DEV;
 
diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c linux-2.6.22.tmpfsroot/mm/shmem.c
--- linux-2.6.22.base/mm/shmem.c	2007-07-12 14:05:25.000000000 +0200
+++ linux-2.6.22.tmpfsroot/mm/shmem.c	2007-07-12 15:01:32.000000000 +0200
@@ -2369,6 +2369,8 @@ static void init_once(void *foo, struct 
 
 static int init_inodecache(void)
 {
+	if (shmem_inode_cachep)
+		return 0;
 	shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
 				sizeof(struct shmem_inode_info),
 				0, 0, init_once, NULL);
@@ -2582,6 +2584,34 @@ put_memory:
 	return ERR_PTR(error);
 }
 
+#ifdef CONFIG_TMPFS_ROOT
+static int rootfs_get_sb(struct file_system_type *fs_type,
+	int flags, const char *dev_name, void *data, struct vfsmount *mnt)
+{
+	return get_sb_nodev(fs_type, flags|MS_NOUSER, data, shmem_fill_super,
+	                    mnt);
+}
+
+/*static struct super_block *rootfs_get_sb(struct file_system_type *fs_type,
+	int flags, const char *dev_name, void *data)
+{
+	return get_sb_single(fs_type, flags, data, shmem_fill_super);
+}*/
+
+static struct file_system_type rootfs_fs_type = {
+	.name		= "rootfs",
+	.get_sb		= rootfs_get_sb,
+	.kill_sb	= kill_litter_super,
+};
+
+int __init init_rootfs(void)
+{
+	if (init_inodecache())
+		panic("Can't initialize shm inode cache");
+	return register_filesystem(&rootfs_fs_type);
+}
+#endif
+
 /*
  * shmem_zero_setup - setup a shared anonymous mapping
  *

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-07-26 20:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <8GGkX-2Xv-5@gated-at.bofh.it>
2007-07-14 18:49 ` [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs Bodo Eggert
2007-07-15  5:24   ` Al Boldi
2007-07-26 20:34     ` Al Boldi
2007-07-15  5:24   ` [PATCH 0/3][try 1] init: enable system-on-initramfs Al Boldi
2007-07-14  3:18 [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs Al Boldi
  -- strict thread matches above, loose matches on Subject: below --
2007-07-13 18:56 [PATCH 0/3][try 1] init: enable system-on-initramfs Bodo Eggert
2007-07-13 19:00 ` [PATCH 2/3][try 1] init: enable system-on-initramfs: root-on-tmpfs Bodo Eggert

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®