target/cramfs: cleanup
Remove the cramfs host tools building process, which is now in package/cramfs. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
4bcefe826b
commit
e01de2e7d6
@ -1,6 +1,5 @@
|
||||
config BR2_TARGET_ROOTFS_CRAMFS
|
||||
bool "cramfs root filesystem"
|
||||
select BR2_HOST_FAKEROOT
|
||||
help
|
||||
Build a cramfs root filesystem
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,284 +0,0 @@
|
||||
--- cramfs-1.1/mkcramfs.c.orig 2005-04-13 05:55:57.000000000 -0600
|
||||
+++ cramfs-1.1/mkcramfs.c 2005-04-13 16:19:57.000000000 -0600
|
||||
@@ -117,6 +117,7 @@
|
||||
static int opt_squash = 0;
|
||||
static char *opt_image = NULL;
|
||||
static char *opt_name = NULL;
|
||||
+static int swap_endian = 0;
|
||||
|
||||
static int warn_dev, warn_gid, warn_namelen, warn_skip, warn_size, warn_uid;
|
||||
static const char *const memory_exhausted = "memory exhausted";
|
||||
@@ -155,6 +156,8 @@
|
||||
" -i file insert a file image into the filesystem (requires >= 2.4.0)\n"
|
||||
" -n name set name of cramfs filesystem\n"
|
||||
" -p pad by %d bytes for boot code\n"
|
||||
+ " -l litte endian filesystem\n"
|
||||
+ " -b big endian filesystem\n"
|
||||
" -s sort directory entries (old option, ignored)\n"
|
||||
" -v be more verbose\n"
|
||||
" -z make explicit holes (requires >= 2.3.39)\n"
|
||||
@@ -504,6 +506,50 @@
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
+/* routines to swap endianness/bitfields in inode/superblock block data */
|
||||
+static void fix_inode(struct cramfs_inode *inode)
|
||||
+{
|
||||
+#define wswap(x) (((x)>>24) | (((x)>>8)&0xff00) | (((x)&0xff00)<<8) | (((x)&0xff)<<24))
|
||||
+ /* attempt #2 */
|
||||
+ inode->mode = (inode->mode >> 8) | ((inode->mode&0xff)<<8);
|
||||
+ inode->uid = (inode->uid >> 8) | ((inode->uid&0xff)<<8);
|
||||
+ inode->size = (inode->size >> 16) | (inode->size&0xff00) |
|
||||
+ ((inode->size&0xff)<<16);
|
||||
+ ((u32*)inode)[2] = wswap(inode->offset | (inode->namelen<<26));
|
||||
+}
|
||||
+
|
||||
+static void fix_offset(struct cramfs_inode *inode, u32 offset)
|
||||
+{
|
||||
+ u32 tmp = wswap(((u32*)inode)[2]);
|
||||
+ ((u32*)inode)[2] = wswap((offset >> 2) | (tmp&0xfc000000));
|
||||
+}
|
||||
+
|
||||
+static void fix_block_pointer(u32 *p)
|
||||
+{
|
||||
+ *p = wswap(*p);
|
||||
+}
|
||||
+
|
||||
+static void fix_super(struct cramfs_super *super)
|
||||
+{
|
||||
+ u32 *p = (u32*)super;
|
||||
+
|
||||
+ /* fix superblock fields */
|
||||
+ p[0] = wswap(p[0]); /* magic */
|
||||
+ p[1] = wswap(p[1]); /* size */
|
||||
+ p[2] = wswap(p[2]); /* flags */
|
||||
+ p[3] = wswap(p[3]); /* future */
|
||||
+
|
||||
+ /* fix filesystem info fields */
|
||||
+ p = (u32*)&super->fsid;
|
||||
+ p[0] = wswap(p[0]); /* crc */
|
||||
+ p[1] = wswap(p[1]); /* edition */
|
||||
+ p[2] = wswap(p[2]); /* blocks */
|
||||
+ p[3] = wswap(p[3]); /* files */
|
||||
+
|
||||
+ fix_inode(&super->root);
|
||||
+#undef wswap
|
||||
+}
|
||||
+
|
||||
/* Returns sizeof(struct cramfs_super), which includes the root inode. */
|
||||
static unsigned int write_superblock(struct entry *root, char *base, int size)
|
||||
{
|
||||
@@ -539,6 +585,7 @@
|
||||
super->root.gid = root->gid;
|
||||
super->root.size = root->size;
|
||||
super->root.offset = offset >> 2;
|
||||
+ if (swap_endian) fix_super(super);
|
||||
|
||||
return offset;
|
||||
}
|
||||
@@ -553,7 +600,10 @@
|
||||
if (offset >= (1 << (2 + CRAMFS_OFFSET_WIDTH))) {
|
||||
error_msg_and_die("filesystem too big");
|
||||
}
|
||||
- inode->offset = (offset >> 2);
|
||||
+ if (swap_endian)
|
||||
+ fix_offset(inode, offset);
|
||||
+ else
|
||||
+ inode->offset = (offset >> 2);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -638,6 +688,7 @@
|
||||
stack_entries++;
|
||||
}
|
||||
entry = entry->next;
|
||||
+ if (swap_endian) fix_inode(inode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -734,6 +785,7 @@
|
||||
}
|
||||
|
||||
*(u32 *) (base + offset) = curr;
|
||||
+ if (swap_endian) fix_block_pointer((u32*)(base + offset));
|
||||
offset += 4;
|
||||
} while (size);
|
||||
|
||||
@@ -1146,7 +1198,7 @@
|
||||
progname = argv[0];
|
||||
|
||||
/* command line options */
|
||||
- while ((c = getopt(argc, argv, "hEe:i:n:psvzD:q")) != EOF) {
|
||||
+ while ((c = getopt(argc, argv, "hEe:i:n:psvzD:qlb")) != EOF) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(MKFS_OK);
|
||||
@@ -1174,6 +1227,18 @@
|
||||
opt_pad = PAD_SIZE;
|
||||
fslen_ub += PAD_SIZE;
|
||||
break;
|
||||
+ case 'b':
|
||||
+#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
+ swap_endian = 1;
|
||||
+ printf("Swapping filesystem endian-ness\n");
|
||||
+#endif
|
||||
+ break;
|
||||
+ case 'l':
|
||||
+#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
+ swap_endian = 1;
|
||||
+ printf("Swapping filesystem endian-ness\n");
|
||||
+#endif
|
||||
+ break;
|
||||
case 's':
|
||||
/* old option, ignored */
|
||||
break;
|
||||
--- cramfs-1.1/cramfsck.c.orig 2005-04-25 11:50:31.000000000 -0700
|
||||
+++ cramfs-1.1/cramfsck.c 2005-04-25 16:53:25.000000000 -0700
|
||||
@@ -30,6 +30,7 @@
|
||||
* 2000/07/15: Daniel Quinlan (initial support for block devices)
|
||||
* 2002/01/10: Daniel Quinlan (additional checks, test more return codes,
|
||||
* use read if mmap fails, standardize messages)
|
||||
+ * 2004/09/01: Alfonso Acosta (Add swapping support)
|
||||
*/
|
||||
|
||||
/* compile-time options */
|
||||
@@ -51,6 +52,7 @@
|
||||
#include <utime.h>
|
||||
#include <sys/ioctl.h>
|
||||
#define _LINUX_STRING_H_
|
||||
+#include <byteswap.h>
|
||||
#include "linux/cramfs_fs.h"
|
||||
#include <zlib.h>
|
||||
|
||||
@@ -74,6 +76,7 @@
|
||||
static char *filename; /* ROM image filename */
|
||||
struct cramfs_super super; /* just find the cramfs superblock once */
|
||||
static int opt_verbose = 0; /* 1 = verbose (-v), 2+ = very verbose (-vv) */
|
||||
+static int need_swapping = 0; /* fs and host dont have the same endianness */
|
||||
#ifdef INCLUDE_FS_TESTS
|
||||
static int opt_extract = 0; /* extract cramfs (-x) */
|
||||
static char *extract_dir = "/"; /* extraction directory (-x) */
|
||||
@@ -85,6 +88,9 @@
|
||||
static unsigned long start_data = ~0UL; /* start of the data (256 MB = max) */
|
||||
static unsigned long end_data = 0; /* end of the data */
|
||||
|
||||
+/* access 32 byte variables */
|
||||
+#define CRAMFS_32(x) (need_swapping ? bswap_32(x) : x)
|
||||
+
|
||||
/* Guarantee access to at least 8kB at a time */
|
||||
#define ROMBUFFER_BITS 13
|
||||
#define ROMBUFFERSIZE (1 << ROMBUFFER_BITS)
|
||||
@@ -166,20 +172,34 @@
|
||||
if (super.magic == CRAMFS_MAGIC) {
|
||||
*start = 0;
|
||||
}
|
||||
+ else if (super.magic == bswap_32(CRAMFS_MAGIC)) {
|
||||
+ *start = 0;
|
||||
+ need_swapping = 1;
|
||||
+ }
|
||||
+
|
||||
else if (*length >= (PAD_SIZE + sizeof(super))) {
|
||||
lseek(fd, PAD_SIZE, SEEK_SET);
|
||||
if (read(fd, &super, sizeof(super)) != sizeof(super)) {
|
||||
die(FSCK_ERROR, 1, "read failed: %s", filename);
|
||||
}
|
||||
- if (super.magic == CRAMFS_MAGIC) {
|
||||
+ if (super.magic == CRAMFS_32(CRAMFS_MAGIC)) {
|
||||
*start = PAD_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/* superblock tests */
|
||||
- if (super.magic != CRAMFS_MAGIC) {
|
||||
+ if (super.magic != CRAMFS_32(CRAMFS_MAGIC)) {
|
||||
die(FSCK_UNCORRECTED, 0, "superblock magic not found");
|
||||
}
|
||||
+ if (need_swapping){
|
||||
+ super.size = bswap_32(super.size);
|
||||
+ super.flags = bswap_32(super.flags);
|
||||
+ super.future = bswap_32(super.future);
|
||||
+ super.fsid.crc = bswap_32(super.fsid.crc);
|
||||
+ super.fsid.edition = bswap_32(super.fsid.edition);
|
||||
+ super.fsid.blocks = bswap_32(super.fsid.blocks);
|
||||
+ super.fsid.files = bswap_32(super.fsid.files);
|
||||
+ }
|
||||
if (super.flags & ~CRAMFS_SUPPORTED_FLAGS) {
|
||||
die(FSCK_ERROR, 0, "unsupported filesystem features");
|
||||
}
|
||||
@@ -215,7 +235,10 @@
|
||||
die(FSCK_USAGE, 0, "unable to test CRC: old cramfs format");
|
||||
#endif /* not INCLUDE_FS_TESTS */
|
||||
}
|
||||
-
|
||||
+ else if (need_swapping) {
|
||||
+ /* crc checking in this case would mean translating the whole file */
|
||||
+ return;
|
||||
+ }
|
||||
crc = crc32(0L, Z_NULL, 0);
|
||||
|
||||
buf = mmap(NULL, super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
@@ -300,12 +323,23 @@
|
||||
|
||||
static struct cramfs_inode *cramfs_iget(struct cramfs_inode * i)
|
||||
{
|
||||
+#define wswap(x) (((x)>>24) | (((x)>>8)&0xff00) | (((x)&0xff00)<<8) | (((x)&0xff)<<24))
|
||||
struct cramfs_inode *inode = malloc(sizeof(struct cramfs_inode));
|
||||
|
||||
if (!inode) {
|
||||
die(FSCK_ERROR, 1, "malloc failed");
|
||||
}
|
||||
- *inode = *i;
|
||||
+ if(!need_swapping) {
|
||||
+ *inode = *i;
|
||||
+ }
|
||||
+ else {
|
||||
+ inode->mode=bswap_16(i->mode);
|
||||
+ inode->uid=bswap_16(i->uid);
|
||||
+ inode->size=bswap_32(i->size << 8);
|
||||
+ inode->gid=i->gid;
|
||||
+ inode->namelen = bswap_32(((u32*)i)[2]) >> 26;
|
||||
+ inode->offset = bswap_32(((u32*)i)[2]) & 0x3FFFFFFF;
|
||||
+ }
|
||||
return inode;
|
||||
}
|
||||
|
||||
@@ -324,9 +358,9 @@
|
||||
*/
|
||||
static struct cramfs_inode *read_super(void)
|
||||
{
|
||||
- unsigned long offset = super.root.offset << 2;
|
||||
-
|
||||
- if (!S_ISDIR(super.root.mode))
|
||||
+ struct cramfs_inode *root = cramfs_iget(&super.root);
|
||||
+ unsigned long offset = root->offset << 2;
|
||||
+ if (!S_ISDIR(root->mode))
|
||||
die(FSCK_UNCORRECTED, 0, "root inode is not directory");
|
||||
if (!(super.flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) &&
|
||||
((offset != sizeof(struct cramfs_super)) &&
|
||||
@@ -334,7 +368,7 @@
|
||||
{
|
||||
die(FSCK_UNCORRECTED, 0, "bad root offset (%lu)", offset);
|
||||
}
|
||||
- return cramfs_iget(&super.root);
|
||||
+ return root;
|
||||
}
|
||||
|
||||
static int uncompress_block(void *src, int len)
|
||||
@@ -366,7 +400,7 @@
|
||||
|
||||
do {
|
||||
unsigned long out = PAGE_CACHE_SIZE;
|
||||
- unsigned long next = *(u32 *) romfs_read(offset);
|
||||
+ unsigned long next = CRAMFS_32(*(u32 *) romfs_read(offset));
|
||||
|
||||
if (next > end_data) {
|
||||
end_data = next;
|
||||
@@ -529,7 +563,7 @@
|
||||
{
|
||||
unsigned long offset = i->offset << 2;
|
||||
unsigned long curr = offset + 4;
|
||||
- unsigned long next = *(u32 *) romfs_read(offset);
|
||||
+ unsigned long next = CRAMFS_32(*(u32 *) romfs_read(offset));
|
||||
unsigned long size;
|
||||
|
||||
if (offset == 0) {
|
@ -1,13 +0,0 @@
|
||||
--- cramfs-1.1/cramfsck.c.orig 2006-12-22 22:16:59.328125000 +1100
|
||||
+++ cramfs-1.1/cramfsck.c 2006-12-19 01:02:05.531250000 +1100
|
||||
@@ -56,6 +56,10 @@
|
||||
#include "linux/cramfs_fs.h"
|
||||
#include <zlib.h>
|
||||
|
||||
+#ifdef __CYGWIN__
|
||||
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
|
||||
+#endif /* __CYGWIN__ */
|
||||
+
|
||||
#define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
|
||||
|
||||
/* Exit codes used by fsck-type programs */
|
@ -1,38 +1,3 @@
|
||||
#############################################################
|
||||
#
|
||||
# mkcramfs to build to target cramfs filesystems
|
||||
#
|
||||
#############################################################
|
||||
CRAMFS_DIR=$(BUILD_DIR)/cramfs-1.1
|
||||
CRAMFS_SOURCE=cramfs-1.1.tar.gz
|
||||
ifeq ($(call qstrip,$(BR2_SOURCEFORGE_MIRROR)),unc)
|
||||
# UNC does not seem to have cramfs
|
||||
CRAMFS_SITE=http://internap.dl.sourceforge.net/sourceforge/cramfs
|
||||
else
|
||||
CRAMFS_SITE=http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/cramfs
|
||||
endif
|
||||
|
||||
$(DL_DIR)/$(CRAMFS_SOURCE):
|
||||
$(call DOWNLOAD,$(CRAMFS_SITE),$(CRAMFS_SOURCE))
|
||||
|
||||
$(CRAMFS_DIR): $(DL_DIR)/$(CRAMFS_SOURCE)
|
||||
$(ZCAT) $(DL_DIR)/$(CRAMFS_SOURCE) | tar -C $(BUILD_DIR) -xvf -
|
||||
toolchain/patch-kernel.sh $(CRAMFS_DIR) target/cramfs/ cramfs\*.patch
|
||||
|
||||
$(CRAMFS_DIR)/mkcramfs: $(CRAMFS_DIR)
|
||||
$(MAKE) CFLAGS="$(HOST_CFLAGS) -Wall -O2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS="$(HOST_LDFLAGS)" -C $(CRAMFS_DIR)
|
||||
touch -c $@
|
||||
|
||||
cramfs: host-zlib $(CRAMFS_DIR)/mkcramfs
|
||||
|
||||
cramfs-source: $(DL_DIR)/$(CRAMFS_SOURCE)
|
||||
|
||||
cramfs-clean:
|
||||
-$(MAKE) -C $(CRAMFS_DIR) clean
|
||||
|
||||
cramfs-dirclean:
|
||||
rm -rf $(CRAMFS_DIR)
|
||||
|
||||
#############################################################
|
||||
#
|
||||
# Build the cramfs root filesystem image
|
||||
@ -50,7 +15,7 @@ endif
|
||||
|
||||
CRAMFS_TARGET=$(IMAGE).cramfs
|
||||
|
||||
cramfsroot: host-fakeroot makedevs cramfs
|
||||
cramfsroot: host-fakeroot host-cramfs makedevs
|
||||
# Use fakeroot to pretend all target binaries are owned by root
|
||||
rm -f $(BUILD_DIR)/_fakeroot.$(notdir $(CRAMFS_TARGET))
|
||||
touch $(BUILD_DIR)/.fakeroot.00000
|
||||
@ -62,20 +27,12 @@ ifneq ($(TARGET_DEVICE_TABLE),)
|
||||
>> $(BUILD_DIR)/_fakeroot.$(notdir $(CRAMFS_TARGET))
|
||||
endif
|
||||
# Use fakeroot so mkcramfs believes the previous fakery
|
||||
echo "$(CRAMFS_DIR)/mkcramfs -q $(CRAMFS_OPTS) " \
|
||||
echo "$(HOST_DIR)/usr/bin/mkcramfs -q $(CRAMFS_OPTS) " \
|
||||
"$(TARGET_DIR) $(CRAMFS_TARGET)" >> $(BUILD_DIR)/_fakeroot.$(notdir $(CRAMFS_TARGET))
|
||||
chmod a+x $(BUILD_DIR)/_fakeroot.$(notdir $(CRAMFS_TARGET))
|
||||
$(HOST_DIR)/usr/bin/fakeroot -- $(BUILD_DIR)/_fakeroot.$(notdir $(CRAMFS_TARGET))
|
||||
-@rm -f $(BUILD_DIR)/_fakeroot.$(notdir $(CRAMFS_TARGET))
|
||||
|
||||
cramfsroot-source: cramfs-source
|
||||
|
||||
cramfsroot-clean:
|
||||
-$(MAKE) -C $(CRAMFS_DIR) clean
|
||||
|
||||
cramfsroot-dirclean:
|
||||
rm -rf $(CRAMFS_DIR)
|
||||
|
||||
#############################################################
|
||||
#
|
||||
# Toplevel Makefile options
|
||||
|
Loading…
Reference in New Issue
Block a user