Commit 8d1f1c05 authored by Raghuveer Pullakandam's avatar Raghuveer Pullakandam

*** empty log message ***

parent 8ac2f471
......@@ -7,27 +7,27 @@
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../../..
SUBDIR = os/imagezip/ext4fs
SUBDIR = os/imagezip/extfs
MAINDIR = $(SRCDIR)/..
include $(OBJDIR)/Makeconf
CFLAGS += $(SUBDIRCFLAGS) -I$(MAINDIR) -I$(SRCDIR)
all: libext4fs.a
all: libextfs.a
include $(TESTBED_SRCDIR)/GNUmakerules
OBJS = ext4fs.o reloc_lilo.o
OBJS = extfs.o reloc_lilo.o
ext4fs.o: $(MAINDIR)/sliceinfo.h $(MAINDIR)/global.h
extfs.o: $(MAINDIR)/sliceinfo.h $(MAINDIR)/global.h
reloc_lilo.o: $(MAINDIR)/sliceinfo.h $(MAINDIR)/global.h $(MAINDIR)/imagehdr.h
libext4fs.a: $(OBJS)
libextfs.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $?
$(RANLIB) $@
install:
clean:
rm -f libext4fs.a $(OBJS)
rm -f libextfs.a $(OBJS)
......@@ -8,13 +8,13 @@
#include <err.h>
#include <assert.h>
#include <sys/param.h>
#include <ext4_fs.h>
#include <ext2_fs.h>
#include "sliceinfo.h"
#include "global.h"
static int read_ext4group(struct ext4_super_block *super,
struct ext4_group_desc *group, int index,
static int read_linuxgroup(struct ext2_super_block *super,
struct ext2_group_desc *group, int index,
u_int32_t sliceoffset, int infd);
extern int fixup_lilo(int slice, int stype, u_int32_t start, u_int32_t size,
......@@ -32,17 +32,17 @@ extern int fixup_lilo(int slice, int stype, u_int32_t start, u_int32_t size,
* slice, so we have to add the starting sector to everything.
*/
int
read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
read_linuxslice(int slice, int stype, u_int32_t start, u_int32_t size,
char *sname, int infd)
{
#define LINUX_SUPERBLOCK_OFFSET 1024
#define LINUX_SUPERBLOCK_SIZE 1024
#define LINUX_MAXGRPSPERBLK \
(EXT4_MAX_BLOCK_SIZE/sizeof(struct ext4_group_desc))
(EXT2_MAX_BLOCK_SIZE/sizeof(struct ext2_group_desc))
int cc, i, numgroups, rval = 0;
struct ext4_super_block fs;
struct ext4_group_desc groups[LINUX_MAXGRPSPERBLK];
struct ext2_super_block fs;
struct ext2_group_desc groups[LINUX_MAXGRPSPERBLK];
int dosslice = slice + 1; /* DOS Numbering */
off_t soff;
......@@ -55,7 +55,7 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
return 1;
assert((sizeof(fs) & ~LINUX_SUPERBLOCK_SIZE) == 0);
assert((sizeof(groups) & ~EXT4_MAX_BLOCK_SIZE) == 0);
assert((sizeof(groups) & ~EXT2_MAX_BLOCK_SIZE) == 0);
if (debug)
fprintf(stderr, " P%d %s Linux Slice)\n",
......@@ -79,15 +79,15 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
warnx("Linux Slice %d: Truncated superblock", dosslice);
return 1;
}
if (fs.s_magic != EXT4_SUPER_MAGIC) {
if (fs.s_magic != EXT2_SUPER_MAGIC) {
warnx("Linux Slice %d: Bad magic number in superblock",
dosslice);
return (1);
}
if (EXT4_BLOCK_SIZE(&fs) < EXT4_MIN_BLOCK_SIZE ||
EXT4_BLOCK_SIZE(&fs) > EXT4_MAX_BLOCK_SIZE) {
if (EXT2_BLOCK_SIZE(&fs) < EXT2_MIN_BLOCK_SIZE ||
EXT2_BLOCK_SIZE(&fs) > EXT2_MAX_BLOCK_SIZE) {
warnx("Linux Slice %d: Block size not what I expect it to be: %d!",
dosslice, EXT4_BLOCK_SIZE(&fs));
dosslice, EXT2_BLOCK_SIZE(&fs));
return 1;
}
......@@ -98,7 +98,7 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
fprintf(stderr, " %s\n",
(fs.s_feature_compat & 4) ? "EXT3" : "EXT2");
fprintf(stderr, " count %9u, size %9d, pergroup %9d\n",
fs.s_blocks_count, EXT4_BLOCK_SIZE(&fs),
fs.s_blocks_count, EXT2_BLOCK_SIZE(&fs),
fs.s_blocks_per_group);
fprintf(stderr, " bfree %9u, first %9u, groups %9d\n",
fs.s_free_blocks_count, fs.s_first_data_block,
......@@ -114,11 +114,11 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
*
* Group descriptors are in the blocks right after the superblock.
*/
assert(LINUX_SUPERBLOCK_SIZE <= EXT4_BLOCK_SIZE(&fs));
assert(EXT4_DESC_PER_BLOCK(&fs) * sizeof(struct ext4_group_desc)
== EXT4_BLOCK_SIZE(&fs));
assert(LINUX_SUPERBLOCK_SIZE <= EXT2_BLOCK_SIZE(&fs));
assert(EXT2_DESC_PER_BLOCK(&fs) * sizeof(struct ext2_group_desc)
== EXT2_BLOCK_SIZE(&fs));
soff = sectobytes(start) +
(fs.s_first_data_block + 1) * EXT4_BLOCK_SIZE(&fs);
(fs.s_first_data_block + 1) * EXT2_BLOCK_SIZE(&fs);
rval = 0;
for (i = 0; i < numgroups; i++) {
int gix;
......@@ -128,7 +128,7 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
* smaller than a sector size, packed into EXT2_BLOCK_SIZE
* blocks right after the superblock.
*/
gix = (i % EXT4_DESC_PER_BLOCK(&fs));
gix = (i % EXT2_DESC_PER_BLOCK(&fs));
if (gix == 0) {
if (devlseek(infd, soff, SEEK_SET) < 0) {
warnx("Linux Slice %d: "
......@@ -148,7 +148,7 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
"Truncated Group %d", dosslice, i);
return 1;
}
soff += EXT4_BLOCK_SIZE(&fs);
soff += EXT2_BLOCK_SIZE(&fs);
}
if (debug) {
......@@ -158,7 +158,7 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
groups[gix].bg_free_blocks_count);
}
if ((rval = read_ext4group(&fs, &groups[gix], i, start, infd)))
if ((rval = read_linuxgroup(&fs, &groups[gix], i, start, infd)))
return rval;
}
......@@ -172,13 +172,13 @@ read_ext4slice(int slice, int stype, u_int32_t start, u_int32_t size,
* of the slice, need to adjust the numbers using the slice offset.
*/
static int
read_ext4group(struct ext4_super_block *super,
struct ext4_group_desc *group,
read_linuxgroup(struct ext2_super_block *super,
struct ext2_group_desc *group,
int index,
u_int32_t sliceoffset /* Sector offset of slice */,
int infd)
{
char *p, bitmap[EXT4_MAX_BLOCK_SIZE];
char *p, bitmap[EXT2_MAX_BLOCK_SIZE];
int i, cc, max;
int count, j, freecount;
off_t offset;
......@@ -200,7 +200,7 @@ read_ext4group(struct ext4_super_block *super,
}
offset = sectobytes(sliceoffset);
offset += (off_t)EXT4_BLOCK_SIZE(super) * group->bg_block_bitmap;
offset += (off_t)EXT2_BLOCK_SIZE(super) * group->bg_block_bitmap;
if (devlseek(infd, offset, SEEK_SET) < 0) {
warn("Linux Group %d: "
"Could not seek to Group bitmap block %d",
......@@ -212,19 +212,19 @@ read_ext4group(struct ext4_super_block *super,
* Sanity check this number since it the number of blocks in
* the group (bitmap size) is dependent on the block size.
*/
if (super->s_blocks_per_group > (EXT4_BLOCK_SIZE(super) * 8)) {
if (super->s_blocks_per_group > (EXT2_BLOCK_SIZE(super) * 8)) {
warnx("Linux Group %d: "
"Block count not what I expect it to be: %d!",
index, super->s_blocks_per_group);
return 1;
}
if ((cc = devread(infd, bitmap, EXT4_BLOCK_SIZE(super))) < 0) {
if ((cc = devread(infd, bitmap, EXT2_BLOCK_SIZE(super))) < 0) {
warn("Linux Group %d: "
"Could not read Group bitmap", index);
return 1;
}
if (cc != EXT4_BLOCK_SIZE(super)) {
if (cc != EXT2_BLOCK_SIZE(super)) {
warnx("Linux Group %d: Truncated Group bitmap", index);
return 1;
}
......@@ -247,7 +247,7 @@ read_ext4group(struct ext4_super_block *super,
* The bitmap is an "inuse" map, not a free map.
*/
#define LINUX_FSBTODB(count) \
((EXT4_BLOCK_SIZE(super) / secsize) * (count))
((EXT2_BLOCK_SIZE(super) / secsize) * (count))
if (debug > 2)
fprintf(stderr, " ");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment