Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
8d1f1c05
Commit
8d1f1c05
authored
Oct 16, 2009
by
Raghuveer Pullakandam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
8ac2f471
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
34 deletions
+34
-34
os/imagezip/extfs/GNUmakefile.in
os/imagezip/extfs/GNUmakefile.in
+6
-6
os/imagezip/extfs/extfs.c
os/imagezip/extfs/extfs.c
+28
-28
No files found.
os/imagezip/extfs/GNUmakefile.in
View file @
8d1f1c05
...
...
@@ -7,27 +7,27 @@
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../../..
SUBDIR = os/imagezip/ext
4
fs
SUBDIR = os/imagezip/extfs
MAINDIR = $(SRCDIR)/..
include $(OBJDIR)/Makeconf
CFLAGS += $(SUBDIRCFLAGS) -I$(MAINDIR) -I$(SRCDIR)
all: libext
4
fs.a
all: libextfs.a
include $(TESTBED_SRCDIR)/GNUmakerules
OBJS = ext
4
fs.o reloc_lilo.o
OBJS = extfs.o reloc_lilo.o
ext
4
fs.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
libext
4
fs.a: $(OBJS)
libextfs.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $?
$(RANLIB) $@
install:
clean:
rm -f libext
4
fs.a $(OBJS)
rm -f libextfs.a $(OBJS)
os/imagezip/extfs/extfs.c
View file @
8d1f1c05
...
...
@@ -8,13 +8,13 @@
#include <err.h>
#include <assert.h>
#include <sys/param.h>
#include <ext
4
_fs.h>
#include <ext
2
_fs.h>
#include "sliceinfo.h"
#include "global.h"
static
int
read_
ext4
group
(
struct
ext
4
_super_block
*
super
,
struct
ext
4
_group_desc
*
group
,
int
index
,
static
int
read_
linux
group
(
struct
ext
2
_super_block
*
super
,
struct
ext
2
_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_
ext4
slice
(
int
slice
,
int
stype
,
u_int32_t
start
,
u_int32_t
size
,
read_
linux
slice
(
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 \
(EXT
4
_MAX_BLOCK_SIZE/sizeof(struct ext
4
_group_desc))
(EXT
2
_MAX_BLOCK_SIZE/sizeof(struct ext
2
_group_desc))
int
cc
,
i
,
numgroups
,
rval
=
0
;
struct
ext
4
_super_block
fs
;
struct
ext
4
_group_desc
groups
[
LINUX_MAXGRPSPERBLK
];
struct
ext
2
_super_block
fs
;
struct
ext
2
_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
)
&
~
EXT
4
_MAX_BLOCK_SIZE
)
==
0
);
assert
((
sizeof
(
groups
)
&
~
EXT
2
_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
!=
EXT
4
_SUPER_MAGIC
)
{
if
(
fs
.
s_magic
!=
EXT
2
_SUPER_MAGIC
)
{
warnx
(
"Linux Slice %d: Bad magic number in superblock"
,
dosslice
);
return
(
1
);
}
if
(
EXT
4
_BLOCK_SIZE
(
&
fs
)
<
EXT
4
_MIN_BLOCK_SIZE
||
EXT
4
_BLOCK_SIZE
(
&
fs
)
>
EXT
4
_MAX_BLOCK_SIZE
)
{
if
(
EXT
2
_BLOCK_SIZE
(
&
fs
)
<
EXT
2
_MIN_BLOCK_SIZE
||
EXT
2
_BLOCK_SIZE
(
&
fs
)
>
EXT
2
_MAX_BLOCK_SIZE
)
{
warnx
(
"Linux Slice %d: Block size not what I expect it to be: %d!"
,
dosslice
,
EXT
4
_BLOCK_SIZE
(
&
fs
));
dosslice
,
EXT
2
_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
,
EXT
4
_BLOCK_SIZE
(
&
fs
),
fs
.
s_blocks_count
,
EXT
2
_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
<=
EXT
4
_BLOCK_SIZE
(
&
fs
));
assert
(
EXT
4
_DESC_PER_BLOCK
(
&
fs
)
*
sizeof
(
struct
ext
4
_group_desc
)
==
EXT
4
_BLOCK_SIZE
(
&
fs
));
assert
(
LINUX_SUPERBLOCK_SIZE
<=
EXT
2
_BLOCK_SIZE
(
&
fs
));
assert
(
EXT
2
_DESC_PER_BLOCK
(
&
fs
)
*
sizeof
(
struct
ext
2
_group_desc
)
==
EXT
2
_BLOCK_SIZE
(
&
fs
));
soff
=
sectobytes
(
start
)
+
(
fs
.
s_first_data_block
+
1
)
*
EXT
4
_BLOCK_SIZE
(
&
fs
);
(
fs
.
s_first_data_block
+
1
)
*
EXT
2
_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
%
EXT
4
_DESC_PER_BLOCK
(
&
fs
));
gix
=
(
i
%
EXT
2
_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
+=
EXT
4
_BLOCK_SIZE
(
&
fs
);
soff
+=
EXT
2
_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_
ext4
group
(
&
fs
,
&
groups
[
gix
],
i
,
start
,
infd
)))
if
((
rval
=
read_
linux
group
(
&
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_
ext4
group
(
struct
ext
4
_super_block
*
super
,
struct
ext
4
_group_desc
*
group
,
read_
linux
group
(
struct
ext
2
_super_block
*
super
,
struct
ext
2
_group_desc
*
group
,
int
index
,
u_int32_t
sliceoffset
/* Sector offset of slice */
,
int
infd
)
{
char
*
p
,
bitmap
[
EXT
4
_MAX_BLOCK_SIZE
];
char
*
p
,
bitmap
[
EXT
2
_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
)
EXT
4
_BLOCK_SIZE
(
super
)
*
group
->
bg_block_bitmap
;
offset
+=
(
off_t
)
EXT
2
_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
>
(
EXT
4
_BLOCK_SIZE
(
super
)
*
8
))
{
if
(
super
->
s_blocks_per_group
>
(
EXT
2
_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
,
EXT
4
_BLOCK_SIZE
(
super
)))
<
0
)
{
if
((
cc
=
devread
(
infd
,
bitmap
,
EXT
2
_BLOCK_SIZE
(
super
)))
<
0
)
{
warn
(
"Linux Group %d: "
"Could not read Group bitmap"
,
index
);
return
1
;
}
if
(
cc
!=
EXT
4
_BLOCK_SIZE
(
super
))
{
if
(
cc
!=
EXT
2
_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) \
((EXT
4
_BLOCK_SIZE(super) / secsize) * (count))
((EXT
2
_BLOCK_SIZE(super) / secsize) * (count))
if
(
debug
>
2
)
fprintf
(
stderr
,
" "
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment