openmoko-session2: add RDEPENDS openmoko-panel-memory and oe-stylize
[vuplus_openembedded] / packages / klibc / files / fstype-sane-and-vfat-jffs2.patch
1 diff -r 3c9d84425ba7 utils/fstype.c
2 --- a/utils/fstype.c    Thu Feb 14 02:09:30 2008 +0200
3 +++ b/utils/fstype.c    Thu Feb 14 02:13:46 2008 +0200
4 @@ -13,11 +13,18 @@
5   */
6  
7  #include <sys/types.h>
8 +#include <linux/types.h>
9  #include <stdio.h>
10  #include <string.h>
11  #include <unistd.h>
12  #include <endian.h>
13  #include <netinet/in.h>
14 +#if __BYTE_ORDER == __BIG_ENDIAN
15 +#include <linux/byteorder/big_endian.h> 
16 +#else 
17 +#include <linux/byteorder/little_endian.h> 
18 +#endif 
19 +
20  
21  #define cpu_to_be32(x) __cpu_to_be32(x)        /* Needed by romfs_fs.h */
22  
23 @@ -105,6 +112,27 @@ static int romfs_image(const unsigned ch
24         return 0;
25  }
26  
27 +static int jffs2_image(const unsigned char *buf, unsigned long *blocks)
28 +{
29 +       // Very sloppy! ;-E
30 +       if (*buf == 0x85 && buf[1] == 0x19)
31 +               return 1;
32 +
33 +       return 0;
34 +}
35 +
36 +static int vfat_image(const unsigned char *buf, unsigned long *blocks)
37 +{
38 +        const struct romfs_super_block *sb =
39 +               (const struct romfs_super_block *)buf;
40 +       if (!strncmp(buf + 54, "FAT12   ", 8)
41 +           || !strncmp(buf + 54, "FAT16   ", 8)
42 +           || !strncmp(buf + 82, "FAT32   ", 8))
43 +               return 1;
44 +
45 +       return 0;
46 +}
47 +
48  static int minix_image(const unsigned char *buf, unsigned long *blocks)
49  {
50         const struct minix_super_block *sb =
51 @@ -167,8 +195,6 @@ static int xfs_image(const unsigned char
52                 (const struct xfs_sb *)buf;
53  
54         if (__be32_to_cpu(sb->sb_magicnum) == XFS_SB_MAGIC) {
55 -               *blocks = __be64_to_cpu(sb->sb_dblocks) *
56 -                         (__be32_to_cpu(sb->sb_blocksize) / BLOCK_SIZE);
57                 return 1;
58         }
59         return 0;
60 @@ -184,6 +210,8 @@ static struct imagetype images[] = {
61         { 0,    "gzip",         gzip_image      },
62         { 0,    "cramfs",       cramfs_image    },
63         { 0,    "romfs",        romfs_image     },
64 +       { 0,    "jffs2",        jffs2_image     },
65 +       { 0,    "vfat",         vfat_image      },
66         { 0,    "xfs",          xfs_image       },
67         { 1,    "minix",        minix_image     },
68         { 1,    "ext3",         ext3_image      },