[klibc] why mtd root device number is __makedev(0,254)

maximilian attems max at stro.at
Wed Mar 24 15:16:14 PDT 2010


On Wed, 24 Mar 2010, Andrea Adami wrote:

> In OpenEmbedded we added vfat and jffs2 detection to klibc fstypes.
> Jffs2 one is awfully slow so perhaps we would need better examples to

so to be fair let's have a look at this patch that you haven't posted
yet to klibc mailinglist, please don't be shy to do so in future.
we like to pick up patches and review :)

patch, picked up from
http://cgit.openembedded.org/cgit.cgi/openembedded/tree/recipes/klibc/files/fstype-sane-vfat-and-jffs2-for-1.5.patch
if you have newer version please holler and submit.


> Index: klibc-1.5/usr/kinit/fstype/fstype.c
> ===================================================================
> --- klibc-1.5.orig/usr/kinit/fstype/fstype.c	2008-02-28 00:48:35.319254938 +0100
> +++ klibc-1.5/usr/kinit/fstype/fstype.c	2008-02-28 00:52:20.583257793 +0100
> @@ -20,7 +20,7 @@
>  #include <netinet/in.h>
>  #include <sys/utsname.h>
>  #include <sys/vfs.h>
> -
> +#include <linux/types.h>

hmm why?

>  #define cpu_to_be32(x) __cpu_to_be32(x)	/* Needed by romfs_fs.h */
> 
>  #include "romfs_fs.h"
> @@ -37,6 +37,12 @@
>  #include "ocfs2_fs.h"
>  #include "nilfs_fs.h"
> 
> +#if __BYTE_ORDER == __BIG_ENDIAN
> +#include <linux/byteorder/big_endian.h>
> +#else
> +#include <linux/byteorder/little_endian.h>
> +#endif
> +

this looks wrong.

>  /*
>   * Slightly cleaned up version of jfs_superblock to
>   * avoid pulling in other kernel header files.
> @@ -59,6 +65,27 @@
>  /* Swap needs the definition of block size */
>  #include "swap_fs.h"
> 
> +static int jffs2_image(const unsigned char *buf, unsigned long *blocks)
> +{
> +       // Very sloppy! ;-E
> +       if (*buf == 0x85 && buf[1] == 0x19)
> +               return 1;
> +
> +       return 0;
> +}

the comment says it all, please.

> +
> +static int vfat_image(const unsigned char *buf, unsigned long *blocks)
> +{
> +        const struct romfs_super_block *sb =
> +               (const struct romfs_super_block *)buf;

hmm using *romfs* sb to check against vfat.

> +       if (!strncmp(buf + 54, "FAT12   ", 8)
> +           || !strncmp(buf + 54, "FAT16   ", 8)
> +           || !strncmp(buf + 82, "FAT32   ", 8))
> +               return 1;
> +
> +       return 0;
> +}
> +
>  static int gzip_image(const void *buf, unsigned long long *bytes)
>  {277 304
> 	const unsigned char *p = buf;
> @@ -490,6 +517,8 @@
> 	{1, "ext3", ext3_image},
> 	{1, "ext2", ext2_image},
> 	{1, "minix", minix_image},
> +	{0, "jffs2", jffs2_image},
> +	{0, "vfat", vfat_image},
> 	{1, "nilfs2", nilfs2_image},
> 	{2, "ocfs2", ocfs2_image},
> 	{8, "reiserfs", reiserfs_image},

so please revert that thing.

to add fstype detection look it up and see examples
git log -p usr/kinit/fstype

each submission adds a corresponding sb header file
definition and then corresponding probe.

also there are fs known to have vfat signature on their sb like jfs,
so aboves is certainly not safe enough.
beside the questionable value of a vfat root?
 



More information about the klibc mailing list