Closed GoogleCodeExporter closed 9 years ago
If the vendor distributed the GPL sources for the firmware in question, check
their
tools to see which version of cramfs is being used, and if its been modified or
not.
It may be a different version or utilize a different compression algorithm.
Original comment by jeremy.collake@gmail.com
on 19 Aug 2008 at 4:00
Hi, I find all file referd to cramfs from sdk kit.
I' attached it.
At the first look the compression looks like gzip but ther's also lzma option.
I compare the default cramfs super-block and the openrg-version.
I found some differences:
1]default cramfs :
#ifndef _CRAMFS_FS_SB
#define _CRAMFS_FS_SB
/*
* cramfs super-block data in memory
*/
struct cramfs_sb_info {
unsigned long magic;
unsigned long size;
unsigned long blocks;
unsigned long files;
unsigned long flags;
};
static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb)
{
return sb->s_fs_info;
}
#endif
struct cramfs_info {
__u32 crc;
__u32 edition;
__u32 blocks;
__u32 files;
};
/*
* Superblock information at the beginning of the FS.
*/
struct cramfs_super {
__u32 magic; /* 0x28cd3d45 - random number */
__u32 size; /* length in bytes */
__u32 flags; /* feature flags */
__u32 future; /* reserved for future use */
__u8 signature[16]; /* "Compressed ROMFS" */
struct cramfs_info fsid; /* unique filesystem info */
__u8 name[16]; /* user-defined name */
struct cramfs_inode root; /* root inode data */
};
/*
* Feature flags
*
* 0x00000000 - 0x000000ff: features that work for all past kernels
* 0x00000100 - 0xffffffff: features that don't work for past kernels
*/
#define CRAMFS_FLAG_FSID_VERSION_2 0x00000001 /* fsid version #2 */
#define CRAMFS_FLAG_SORTED_DIRS 0x00000002 /* sorted dirs */
#define CRAMFS_FLAG_HOLES 0x00000100 /* support for holes */
#define CRAMFS_FLAG_WRONG_SIGNATURE 0x00000200 /* reserved */
#define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET 0x00000400 /* shifted root fs */
/*
/*
* Valid values in super.flags. Currently we refuse to mount
* if (flags & ~CRAMFS_SUPPORTED_FLAGS). Maybe that should be
* changed to test super.future instead.
*/
#define CRAMFS_SUPPORTED_FLAGS ( 0x000000ff \
| CRAMFS_FLAG_HOLES \
| CRAMFS_FLAG_WRONG_SIGNATURE \
| CRAMFS_FLAG_SHIFTED_ROOT_OFFSET )
2]openrg-cramfs super-block
/*
* cramfs super-block data in memory
*/
struct cramfs_sb_info {
unsigned long magic;
unsigned long size;
unsigned long blocks;
unsigned long files;
unsigned long flags;
unsigned long sub_type;
void *uncomp_buffer;
int uncomp_blk_offset;
int uncomp_blk_data_size;
};
static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb)
{
return sb->s_fs_info;
}
#endif
struct cramfs_info {
u32 crc;
u32 edition;
u32 blocks;
u32 files;
};
/*
* Superblock information at the beginning of the FS.
*/
struct cramfs_super {
u32 magic; /* 0x28cd3d45 - random number */
u32 size; /* length in bytes */
u32 flags; /* feature flags */
u32 future; /* reserved for future use */
u8 signature[16]; /* "Compressed ROMFS" */
struct cramfs_info fsid; /* unique filesystem info */
u8 name[16]; /* user-defined name */
struct cramfs_inode root; /* root inode data */
};
/*
* Feature flags
*
* 0x00000000 - 0x000000ff: features that work for all past kernels
* 0x00000100 - 0xffffffff: features that don't work for past kernels
*/
#define CRAMFS_FLAG_FSID_VERSION_2 0x00000001 /* fsid version #2 */
#define CRAMFS_FLAG_SORTED_DIRS 0x00000002 /* sorted dirs */
#define CRAMFS_FLAG_HOLES 0x00000100 /* support for holes */
#define CRAMFS_FLAG_WRONG_SIGNATURE 0x00000200 /* reserved */
#define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET 0x00000400 /* shifted root fs */
#define CRAMFS_FLAG_BLKSZ_MASK 0x00003800 /* Block size mask */
#define CRAMFS_FLAG_COMP_METHOD_MASK 0x0000C000 /* Compression method
* mask */
#define CRAMFS_FLAG_BLKSZ_SHIFT 11
#define CRAMFS_FLAG_COMP_METHOD_SHIFT 14
#define CRAMFS_FLAG_COMP_METHOD_NONE 0
#define CRAMFS_FLAG_COMP_METHOD_GZIP 1
#define CRAMFS_FLAG_COMP_METHOD_LZMA 2
/*
* Valid values in super.flags. Currently we refuse to mount
* if (flags & ~CRAMFS_SUPPORTED_FLAGS). Maybe that should be
* changed to test super.future instead.
*/
#define CRAMFS_SUPPORTED_FLAGS ( 0x000000ff \
| CRAMFS_FLAG_HOLES \
| CRAMFS_FLAG_WRONG_SIGNATURE \
| CRAMFS_FLAG_SHIFTED_ROOT_OFFSET \
| CRAMFS_FLAG_BLKSZ_MASK \
| CRAMFS_FLAG_COMP_METHOD_MASK)
It seams that differ for the following flags:
#define CRAMFS_FLAG_BLKSZ_MASK 0x00003800 /* Block size mask */
#define CRAMFS_FLAG_COMP_METHOD_MASK 0x0000C000 /* Compression method *
mask */
Original comment by drpepppp...@gmail.com
on 19 Aug 2008 at 4:50
The sdk files.
Original comment by drpepppp...@gmail.com
on 19 Aug 2008 at 4:51
Attachments:
Thanks for the update. I'm sorry it has taken me so long to notice your
changes. If
and when I get a chance, I'll work on adding support for these type of cramfs
images.
From what you've provided, it should be easy to add in the support. If anyone
gets to
it before I do, feel free to submit patches and I'll get them added on in.
Original comment by jeremy.collake@gmail.com
on 11 Sep 2008 at 5:43
Hello, I get the same problem on another openrg firmware. Did you make an
update to
your tool yet ?
Original comment by vincent....@gmail.com
on 15 Feb 2009 at 10:04
Same problem here.
Original comment by zibree
on 1 May 2009 at 12:12
[deleted comment]
I am able to extract files from an openrg LZA-cramfs with the latest SVN code,
but
all these files contain are zeros. It seems that the LZMA decompression does
not work.
Original comment by zot...@gmx.net
on 28 Jun 2009 at 12:18
I downloaded the GPL part of an openRG router
(http://broadband.adbglobal.com/web/support-area/gpl-code/default.page) and
found that the compression algorithm is based on an old lzma sdk, modified by
Jungo/OpenRG team.
I created an lzma-uncramfs program, based on cramfs, implementing this
compression algorithnm and able to extract files from the openrg cramfs image;
I attach this program with the modified lzma sdk needed to compile it.
Original comment by digiampi...@gmail.com
on 23 Feb 2011 at 2:59
Attachments:
Thanks digiampietro, added this to FMK!
Original comment by heffne...@gmail.com
on 5 Sep 2011 at 3:45
Original issue reported on code.google.com by
drpepppp...@gmail.com
on 19 Aug 2008 at 3:29Attachments: