RE: [Yaffs] Make YAFFS2 work as a root FS, patch

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Sergey Kubushyn
Date:  
To: Martin Fouts
CC: yaffs-list
Subject: RE: [Yaffs] Make YAFFS2 work as a root FS, patch
On Thu, 27 Oct 2005, Martin Fouts wrote:

> Sergey,
>
> Your patch is broken. Somehow returns are being dropped.


I don't know how it happened.

> Fortunately, it was a simple enough patch that I was able to apply it
> by
> hand.
>
> You were, by the way, mistaken. Linux kernel will mount YAFFS2
> filesystem without it. However, when the read of the mtd super struct
> fails, the error returned (EPERM) will be confusing to the end user.


No, it will not.

All the filesystems known to the kernel at bootup are tried in turn. YAFFS
comes before YAFFS2 so before YAFFS2 is tried kernel gets an error from
YAFFS that is -1 i.e. -EPERM now. That breaks the loop and make the kernel
panic.

The code for this is in init/do_mounts.c (kernel tree), function name is
mount_block_root() (line 285, 2.6.12 kernel.) If you look in "switch (err)"
statement in that function you will clearly see that there are only 3
possible errors it handles - 0 for successful mount, -EACCESS that makes it
retry the mount readonly and -EINVAL that makes it try the next FS in the
list. Any other error returned by an FS makes the kernel panic in line 313.
This is done _inside_ the loop. If all the system tried failed to mount with
a proper code, i.e. loop is exhausted, it will panic outside the loop in
line 315, right before out: label. BTW, that -EACCESS case is another weak
spot because it causes an infinite loop if the same error is returned when
mounting an FS readonly.

> EINVAL isn't really the right thing to return -- there are other
> possible errors than invalid argument that might cause the read to fail
> -- but it is probably as good as any as a catchall.


It IS the right thing to do. That's how the root FS mount works and _EVERY_
other FS returns -EINVAL. It might look wrong, it might even BE wrong but
that is how kernel works and what the rules are. If one plays the game he
_MUST_ obey the rules no matter how wrong or stupid they might look
especially when _ALL_ other players do obey.

One should really read the source...

>
> I'll test the new version tomorrow and push a patch later in the day.
>
> Marty
>
> > -----Original Message-----
> > From:
> > [mailto:yaffs-bounces@stoneboat.aleph1.co.uk] On Behalf Of
> > Sergey Kubushyn
> > Sent: Wednesday, October 12, 2005 10:21 AM
> > To: yaffs-list
> > Subject: [Yaffs] Make YAFFS2 work as a root FS, patch
> >
> > This one is also tiny but critical. Linux kernel will NOT
> > mount YAFFS2 filesystem without it. I will not be explaining
> > why leaving it as an exercize for a reader.
> >
> > === Cut ===
> > diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_fs.c
> > linux-2.6.12/fs/yaffs2/yaffs_fs.c
> > --- linux-2.6.12.orig/fs/yaffs2/yaffs_fs.c    2005-10-11
> > 18:01:36.000000000 -0700
> > +++ linux-2.6.12/fs/yaffs2/yaffs_fs.c    2005-10-11
> > 18:15:57.000000000 -0700
> > @@ -1492,7 +1492,7 @@
> >  static int yaffs_internal_read_super_mtd(struct super_block
> > *sb, void *data,
> >                       int silent)
> >  {
> > -    return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -1;
> > +    return yaffs_internal_read_super(1, sb, data, silent) ?
> > 0 : -EINVAL;
> >  }

> >
> >  static struct super_block *yaffs_read_super(struct
> > file_system_type *fs, @@ -1529,7 +1529,7 @@  static int
> > yaffs2_internal_read_super_mtd(struct super_block *sb, void *data,
> >                        int silent)
> >  {
> > -    return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -1;
> > +    return yaffs_internal_read_super(2, sb, data, silent) ?
> > 0 : -EINVAL;
> >  }

> >
> > static struct super_block *yaffs2_read_super(struct
> > file_system_type *fs, === Cut ===
> >
> > ---
> > ******************************************************************
> > *  KSI@home    KOI8 Net  < >  The impossible we do immediately.  *
> > *  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
> > ******************************************************************

> >
> >
> > _______________________________________________
> > yaffs mailing list
> >
> > http://stoneboat.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs
> >
>


---
******************************************************************
*  KSI@home    KOI8 Net  < >  The impossible we do immediately.  *
*  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
******************************************************************