Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
external_e2fsprogs
Commits
f364093b
Commit
f364093b
authored
22 years ago
by
Theodore Ts'o
Browse files
Options
Download
Email Patches
Plain Diff
Update debugfs and e2fsck to use the blkid library.
parent
ed1b33e8
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
123 additions
and
93 deletions
+123
-93
debugfs/ChangeLog
debugfs/ChangeLog
+5
-0
debugfs/Makefile.in
debugfs/Makefile.in
+2
-2
debugfs/logdump.c
debugfs/logdump.c
+23
-15
e2fsck/ChangeLog
e2fsck/ChangeLog
+19
-0
e2fsck/Makefile.in
e2fsck/Makefile.in
+9
-6
e2fsck/e2fsck.c
e2fsck/e2fsck.c
+3
-7
e2fsck/e2fsck.h
e2fsck/e2fsck.h
+12
-3
e2fsck/journal.c
e2fsck/journal.c
+9
-7
e2fsck/pass1.c
e2fsck/pass1.c
+0
-15
e2fsck/pass2.c
e2fsck/pass2.c
+0
-15
e2fsck/unix.c
e2fsck/unix.c
+10
-23
e2fsck/util.c
e2fsck/util.c
+31
-0
No files found.
debugfs/ChangeLog
View file @
f364093b
2003-03-01 Theodore Ts'o <tytso@mit.edu>
* Makefile.in, logdump.c (do_logdump): Use the blkid functions to
find the external journal device.
2003-01-21 Theodore Ts'o <tytso@mit.edu>
* dump.c (do_dump): Open the output file with O_LARGEFILE so we
...
...
This diff is collapsed.
Click to expand it.
debugfs/Makefile.in
View file @
f364093b
...
...
@@ -24,8 +24,8 @@ SRCS= debug_cmds.c $(srcdir)/debugfs.c $(srcdir)/util.c $(srcdir)/ls.c \
$(srcdir)
/dump.c
$(srcdir)
/setsuper.c
${srcdir}
/logdump.c
\
$(srcdir)
/htree.c
LIBS
=
$(LIBEXT2FS)
$(LIBE2P)
$(LIBSS)
$(LIBCOM_ERR)
$(LIBUUID)
DEPLIBS
=
$(LIBEXT2FS)
$(LIBE2P)
$(LIBSS)
$(LIBCOM_ERR)
$(DEPLIBUUID)
LIBS
=
$(LIBEXT2FS)
$(LIBE2P)
$(LIBSS)
$(LIBCOM_ERR)
$(LIBBLKID)
$(LIBUUID)
DEPLIBS
=
$(LIBEXT2FS)
$(LIBE2P)
$(LIBSS)
$(LIBCOM_ERR)
$(LIBBLKID)
$(DEPLIBUUID)
.c.o
:
$(CC)
-c
$(ALL_CFLAGS)
$<
-o
$@
...
...
This diff is collapsed.
Click to expand it.
debugfs/logdump.c
View file @
f364093b
...
...
@@ -33,6 +33,7 @@ extern int optreset; /* defined by BSD, but not others */
#endif
#include "debugfs.h"
#include "blkid/blkid.h"
#include "jfs_user.h"
#include <uuid/uuid.h>
...
...
@@ -84,15 +85,13 @@ void do_logdump(int argc, char **argv)
ext2_ino_t
journal_inum
;
struct
ext2_inode
journal_inode
;
ext2_file_t
journal_file
;
char
*
tmp
;
const
char
*
logdump_usage
=
(
"Usage: logdump "
"[-ac] [-b<block>] [-i<inode>] "
"[-f<journal_file>] [output_file]"
);
struct
journal_source
journal_source
;
struct
ext2_super_block
*
es
=
NULL
;
optind
=
0
;
#ifdef HAVE_OPTRESET
optreset
=
1
;
/* Makes BSD getopt happy */
...
...
@@ -142,9 +141,12 @@ void do_logdump(int argc, char **argv)
return
;
}
if
(
current_fs
)
es
=
current_fs
->
super
;
if
(
inode_spec
)
{
int
inode_group
,
group_offset
,
inodes_per_block
;
if
(
check_fs_open
(
argv
[
0
]))
return
;
...
...
@@ -153,9 +155,9 @@ void do_logdump(int argc, char **argv)
return
;
inode_group
=
((
inode_to_dump
-
1
)
/
current_fs
->
super
->
s_inodes_per_group
);
/
es
->
s_inodes_per_group
);
group_offset
=
((
inode_to_dump
-
1
)
%
current_fs
->
super
->
s_inodes_per_group
);
%
es
->
s_inodes_per_group
);
inodes_per_block
=
(
current_fs
->
blocksize
/
sizeof
(
struct
ext2_inode
));
...
...
@@ -183,8 +185,8 @@ void do_logdump(int argc, char **argv)
if
(
block_to_dump
!=
-
1
&&
current_fs
!=
NULL
)
{
group_to_dump
=
((
block_to_dump
-
current_fs
->
super
->
s_first_data_block
)
/
current_fs
->
super
->
s_blocks_per_group
);
es
->
s_first_data_block
)
/
es
->
s_blocks_per_group
);
bitmap_to_dump
=
current_fs
->
group_desc
[
group_to_dump
].
bg_block_bitmap
;
}
...
...
@@ -202,7 +204,7 @@ void do_logdump(int argc, char **argv)
journal_source
.
where
=
JOURNAL_IS_EXTERNAL
;
journal_source
.
fd
=
journal_fd
;
}
else
if
((
journal_inum
=
current_fs
->
super
->
s_journal_inum
))
{
}
else
if
((
journal_inum
=
es
->
s_journal_inum
))
{
if
(
debugfs_read_inode
(
journal_inum
,
&
journal_inode
,
argv
[
0
]))
return
;
...
...
@@ -214,8 +216,17 @@ void do_logdump(int argc, char **argv)
}
journal_source
.
where
=
JOURNAL_IS_INTERNAL
;
journal_source
.
file
=
journal_file
;
}
else
if
((
journal_fn
=
ext2fs_find_block_device
(
current_fs
->
super
->
s_journal_dev
)))
{
}
else
{
char
uuid
[
37
];
uuid_unparse
(
es
->
s_journal_uuid
,
uuid
);
journal_fn
=
blkid_get_devname
(
NULL
,
"UUID"
,
uuid
);
if
(
!
journal_fn
)
journal_fn
=
blkid_devno_to_devname
(
es
->
s_journal_dev
);
if
(
!
journal_fn
)
{
com_err
(
argv
[
0
],
0
,
"filesystem has no journal"
);
return
;
}
journal_fd
=
open
(
journal_fn
,
O_RDONLY
,
0
);
if
(
journal_fd
<
0
)
{
com_err
(
argv
[
0
],
errno
,
"while opening %s for logdump"
,
...
...
@@ -228,9 +239,6 @@ void do_logdump(int argc, char **argv)
free
(
journal_fn
);
journal_source
.
where
=
JOURNAL_IS_EXTERNAL
;
journal_source
.
fd
=
journal_fd
;
}
else
{
com_err
(
argv
[
0
],
0
,
"filesystem has no journal"
);
return
;
}
dump_journal
(
argv
[
0
],
out_file
,
&
journal_source
);
...
...
This diff is collapsed.
Click to expand it.
e2fsck/ChangeLog
View file @
f364093b
2003-03-01 Theodore Ts'o <tytso@mit.edu>
* Makefile.in, journal.c, unix.c: Use blkid functions to find the
journal from the UUID, and to interpret the device
specification.
* e2fsck.c: Free the blkid_cache when releasing the e2fsck context
structure.
* e2fsck.h: If strnlen is not present, define it as a macro which
calls e2fsck_strlen(). Add prototype for string_copy().
Add blkid_cache to e2fsck context, and make
filesystem_name, device_name, and journal_name be
non-const variables.
* pass1.c, pass2.c: Remove static strnlen function
* util.c (string_copy, e2fsck_strnlen): New functions
2003-01-29 Theodore Ts'o <tytso@mit.edu>
* unix.c (usage): Make descripton -c be a bit more explicit
...
...
This diff is collapsed.
Click to expand it.
e2fsck/Makefile.in
View file @
f364093b
...
...
@@ -16,15 +16,18 @@ PROGS= e2fsck
MANPAGES
=
e2fsck.8
XTRA_CFLAGS
=
-DRESOURCE_TRACK
LIBS
=
$(LIBEXT2FS)
$(LIBCOM_ERR)
$(LIBUUID)
DEPLIBS
=
$(LIBEXT2FS)
$(LIBCOM_ERR)
$(DEPLIBUUID)
LIBS
=
$(LIBEXT2FS)
$(LIBCOM_ERR)
$(LIBBLKID)
$(LIBUUID)
DEPLIBS
=
$(LIBEXT2FS)
$(LIBCOM_ERR)
$(LIBBLKID)
$(DEPLIBUUID)
STATIC_LIBS
=
$(STATIC_LIBEXT2FS)
$(STATIC_LIBCOM_ERR)
$(STATIC_LIBUUID)
STATIC_DEPLIBS
=
$(STATIC_LIBEXT2FS)
$(STATIC_LIBCOM_ERR)
$(DEPSTATIC_LIBUUID)
STATIC_LIBS
=
$(STATIC_LIBEXT2FS)
$(STATIC_LIBCOM_ERR)
$(STATIC_LIBBLKID)
\
$(STATIC_LIBUUID)
STATIC_DEPLIBS
=
$(STATIC_LIBEXT2FS)
$(STATIC_LIBCOM_ERR)
$(STATIC_LIBBLKID)
\
$(DEPSTATIC_LIBUUID)
PROFILED_LIBS
=
$(PROFILED_LIBEXT2FS)
$(PROFILED_LIBCOM_ERR)
$(PROFILED_LIBUUID)
PROFILED_LIBS
=
$(PROFILED_LIBEXT2FS)
$(PROFILED_LIBCOM_ERR)
\
$(PROFILED_BLKID)
$(PROFILED_LIBUUID)
PROFILED_DEPLIBS
=
$(PROFILED_LIBEXT2FS)
$(PROFILED_LIBCOM_ERR)
\
$(DEPPROFILED_LIBUUID)
$(PROFILED_BLKID)
$(DEPPROFILED_LIBUUID)
.c.o
:
$(CC)
-c
$(ALL_CFLAGS)
$<
-o
$@
...
...
This diff is collapsed.
Click to expand it.
e2fsck/e2fsck.c
View file @
f364093b
...
...
@@ -157,7 +157,9 @@ void e2fsck_free_context(e2fsck_t ctx)
return
;
e2fsck_reset_context
(
ctx
);
if
(
ctx
->
blkid
)
blkid_put_cache
(
ctx
->
blkid
);
ext2fs_free_mem
((
void
**
)
&
ctx
);
}
...
...
@@ -197,9 +199,3 @@ int e2fsck_run(e2fsck_t ctx)
return
(
ctx
->
flags
&
E2F_FLAG_RUN_RETURN
);
return
0
;
}
This diff is collapsed.
Click to expand it.
e2fsck/e2fsck.h
View file @
f364093b
...
...
@@ -26,9 +26,11 @@
#if EXT2_FLAT_INCLUDES
#include "ext2_fs.h"
#include "ext2fs.h"
#include "blkid.h"
#else
#include "ext2fs/ext2_fs.h"
#include "ext2fs/ext2fs.h"
#include "blkid/blkid.h"
#endif
#ifdef ENABLE_NLS
...
...
@@ -181,8 +183,8 @@ typedef struct e2fsck_struct *e2fsck_t;
struct
e2fsck_struct
{
ext2_filsys
fs
;
const
char
*
program_name
;
const
char
*
filesystem_name
;
const
char
*
device_name
;
char
*
filesystem_name
;
char
*
device_name
;
int
flags
;
/* E2fsck internal flags */
int
options
;
blk_t
use_superblock
;
/* sb requested by user */
...
...
@@ -190,6 +192,7 @@ struct e2fsck_struct {
int
blocksize
;
/* blocksize */
blk_t
num_blocks
;
/* Total number of blocks */
int
mount_flags
;
blkid_cache
blkid
;
/* blkid cache */
#ifdef HAVE_SETJMP_H
jmp_buf
abort_loc
;
...
...
@@ -274,7 +277,7 @@ struct e2fsck_struct {
* ext3 journal support
*/
io_channel
journal_io
;
const
char
*
journal_name
;
char
*
journal_name
;
#ifdef RESOURCE_TRACK
/*
...
...
@@ -324,6 +327,11 @@ struct e2fsck_struct {
typedef
__u32
region_addr_t
;
typedef
struct
region_struct
*
region_t
;
#ifndef HAVE_STRNLEN
#define strnlen(str, x) e2fsck_strnlen((str),(x))
extern
int
e2fsck_strnlen
(
const
char
*
s
,
int
count
);
#endif
/*
* Procedure declarations
*/
...
...
@@ -428,6 +436,7 @@ extern void fatal_error(e2fsck_t ctx, const char * fmt_string);
extern
void
e2fsck_read_bitmaps
(
e2fsck_t
ctx
);
extern
void
e2fsck_write_bitmaps
(
e2fsck_t
ctx
);
extern
void
preenhalt
(
e2fsck_t
ctx
);
extern
char
*
string_copy
(
e2fsck_t
ctx
,
const
char
*
str
,
int
len
);
#ifdef RESOURCE_TRACK
extern
void
print_resource_track
(
const
char
*
desc
,
struct
resource_track
*
track
);
...
...
This diff is collapsed.
Click to expand it.
e2fsck/journal.c
View file @
f364093b
...
...
@@ -188,7 +188,6 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
errcode_t
retval
=
0
;
io_manager
io_ptr
=
0
;
unsigned
long
start
=
0
;
int
free_journal_name
=
0
;
int
ext_journal
=
0
;
clear_problem_context
(
&
pctx
);
...
...
@@ -259,11 +258,16 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
#endif
}
else
{
ext_journal
=
1
;
journal_name
=
ctx
->
journal_name
;
if
(
!
journal_name
)
{
journal_name
=
ext2fs_find_block_device
(
sb
->
s_journal_dev
);
free_journal_name
=
1
;
if
(
!
ctx
->
journal_name
)
{
char
uuid
[
37
];
uuid_unparse
(
sb
->
s_journal_uuid
,
uuid
);
ctx
->
journal_name
=
blkid_get_devname
(
ctx
->
blkid
,
"UUID"
,
uuid
);
if
(
!
ctx
->
journal_name
)
ctx
->
journal_name
=
blkid_devno_to_devname
(
sb
->
s_journal_dev
);
}
journal_name
=
ctx
->
journal_name
;
if
(
!
journal_name
)
{
fix_problem
(
ctx
,
PR_0_CANT_FIND_JOURNAL
,
&
pctx
);
...
...
@@ -283,8 +287,6 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
#endif
retval
=
io_ptr
->
open
(
journal_name
,
IO_FLAG_RW
,
&
ctx
->
journal_io
);
if
(
free_journal_name
)
free
((
void
*
)
journal_name
);
if
(
retval
)
goto
errout
;
...
...
This diff is collapsed.
Click to expand it.
e2fsck/pass1.c
View file @
f364093b
...
...
@@ -157,21 +157,6 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs, struct ext2_inode *inode)
return
1
;
}
#ifndef HAVE_STRNLEN
/*
* Incredibly, libc5 doesn't appear to have strnlen. So we have to
* provide our own.
*/
static
int
strnlen
(
const
char
*
s
,
int
count
)
{
const
char
*
cp
=
s
;
while
(
count
--
&&
*
cp
)
cp
++
;
return
cp
-
s
;
}
#endif
/*
* Check to make sure a symlink inode is real. Returns 1 if the symlink
* checks out, 0 if not.
...
...
This diff is collapsed.
Click to expand it.
e2fsck/pass2.c
View file @
f364093b
...
...
@@ -80,21 +80,6 @@ struct check_dir_struct {
e2fsck_t
ctx
;
};
#ifndef HAVE_STRNLEN
/*
* Incredibly, libc5 doesn't appear to have strnlen. So we have to
* provide our own.
*/
static
int
strnlen
(
const
char
*
s
,
int
count
)
{
const
char
*
cp
=
s
;
while
(
count
--
&&
*
cp
)
cp
++
;
return
cp
-
s
;
}
#endif
void
e2fsck_pass2
(
e2fsck_t
ctx
)
{
struct
ext2_super_block
*
sb
=
ctx
->
fs
->
super
;
...
...
This diff is collapsed.
Click to expand it.
e2fsck/unix.c
View file @
f364093b
...
...
@@ -454,17 +454,10 @@ static void signal_cancel(int sig)
static
void
parse_extended_opts
(
e2fsck_t
ctx
,
const
char
*
opts
)
{
char
*
buf
,
*
token
,
*
next
,
*
p
,
*
arg
;
int
len
,
ea_ver
;
int
ea_ver
;
int
extended_usage
=
0
;
len
=
strlen
(
opts
);
buf
=
malloc
(
len
+
1
);
if
(
!
buf
)
{
fprintf
(
stderr
,
_
(
"Couldn't allocate memory to parse "
"extended options!
\n
"
));
exit
(
1
);
}
strcpy
(
buf
,
opts
);
buf
=
string_copy
(
ctx
,
opts
,
0
);
for
(
token
=
buf
;
token
&&
*
token
;
token
=
next
)
{
p
=
strchr
(
token
,
','
);
next
=
0
;
...
...
@@ -528,6 +521,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
setbuf
(
stdout
,
NULL
);
setbuf
(
stderr
,
NULL
);
initialize_ext2_error_table
();
blkid_get_cache
(
&
ctx
->
blkid
,
NULL
);
if
(
argc
&&
*
argv
)
ctx
->
program_name
=
*
argv
;
...
...
@@ -607,7 +601,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
ctx
->
inode_buffer_blocks
=
atoi
(
optarg
);
break
;
case
'j'
:
ctx
->
journal_name
=
optarg
;
ctx
->
journal_name
=
string_copy
(
ctx
,
optarg
,
0
)
;
break
;
case
'P'
:
ctx
->
process_inode_size
=
atoi
(
optarg
);
...
...
@@ -615,11 +609,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
case
'L'
:
replace_bad_blocks
++
;
case
'l'
:
bad_blocks_file
=
(
char
*
)
malloc
(
strlen
(
optarg
)
+
1
);
if
(
!
bad_blocks_file
)
fatal_error
(
ctx
,
"Couldn't malloc bad_blocks_file"
);
strcpy
(
bad_blocks_file
,
optarg
);
bad_blocks_file
=
string_copy
(
ctx
,
optarg
,
0
);
break
;
case
'd'
:
ctx
->
options
|=
E2F_OPT_DEBUG
;
...
...
@@ -668,7 +658,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
if
((
ctx
->
options
&
E2F_OPT_NO
)
&&
!
bad_blocks_file
&&
!
cflag
&&
!
swapfs
&&
!
(
ctx
->
options
&
E2F_OPT_COMPRESS_DIRS
))
ctx
->
options
|=
E2F_OPT_READONLY
;
ctx
->
filesystem_name
=
argv
[
optind
];
ctx
->
filesystem_name
=
blkid_get_devname
(
ctx
->
blkid
,
argv
[
optind
]
,
0
)
;
if
(
extended_opts
)
parse_extended_opts
(
ctx
,
extended_opts
);
...
...
@@ -900,13 +890,8 @@ restart:
*/
if
(
ctx
->
device_name
==
0
&&
(
sb
->
s_volume_name
[
0
]
!=
0
))
{
char
*
cp
=
malloc
(
sizeof
(
sb
->
s_volume_name
)
+
1
);
if
(
cp
)
{
strncpy
(
cp
,
sb
->
s_volume_name
,
sizeof
(
sb
->
s_volume_name
));
cp
[
sizeof
(
sb
->
s_volume_name
)]
=
0
;
ctx
->
device_name
=
cp
;
}
ctx
->
device_name
=
string_copy
(
ctx
,
sb
->
s_volume_name
,
sizeof
(
sb
->
s_volume_name
));
}
if
(
ctx
->
device_name
==
0
)
ctx
->
device_name
=
ctx
->
filesystem_name
;
...
...
@@ -1112,6 +1097,8 @@ restart:
ext2fs_close
(
fs
);
ctx
->
fs
=
NULL
;
free
(
ctx
->
filesystem_name
);
free
(
ctx
->
journal_name
);
e2fsck_free_context
(
ctx
);
#ifdef RESOURCE_TRACK
...
...
This diff is collapsed.
Click to expand it.
e2fsck/util.c
View file @
f364093b
...
...
@@ -70,6 +70,37 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
return
ret
;
}
char
*
string_copy
(
e2fsck_t
ctx
,
const
char
*
str
,
int
len
)
{
char
*
ret
;
if
(
!
str
)
return
NULL
;
if
(
!
len
)
len
=
strlen
(
str
);
ret
=
malloc
(
len
+
1
);
if
(
ret
)
{
strncpy
(
ret
,
str
,
len
);
ret
[
len
]
=
0
;
}
return
ret
;
}
#ifndef HAVE_STRNLEN
/*
* Incredibly, libc5 doesn't appear to have strnlen. So we have to
* provide our own.
*/
int
e2fsck_strnlen
(
const
char
*
s
,
int
count
)
{
const
char
*
cp
=
s
;
while
(
count
--
&&
*
cp
)
cp
++
;
return
cp
-
s
;
}
#endif
#ifndef HAVE_CONIO_H
static
int
read_a_char
(
void
)
{
...
...
This diff is collapsed.
Click to expand it.
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