mirror of https://github.com/vitalif/e2fsprogs
Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
4690e621ac
commit
efc6f628e1
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 1993 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*
|
*
|
||||||
* Modifications by Robert Sanders <gt8134b@prism.gatech.edu>
|
* Modifications by Robert Sanders <gt8134b@prism.gatech.edu>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,7 +46,7 @@ ext2_filsys current_fs = NULL;
|
||||||
ext2_ino_t root, cwd;
|
ext2_ino_t root, cwd;
|
||||||
|
|
||||||
static void open_filesystem(char *device, int open_flags, blk_t superblock,
|
static void open_filesystem(char *device, int open_flags, blk_t superblock,
|
||||||
blk_t blocksize, int catastrophic,
|
blk_t blocksize, int catastrophic,
|
||||||
char *data_filename)
|
char *data_filename)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -60,7 +60,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock,
|
||||||
|
|
||||||
if (data_filename) {
|
if (data_filename) {
|
||||||
if ((open_flags & EXT2_FLAG_IMAGE_FILE) == 0) {
|
if ((open_flags & EXT2_FLAG_IMAGE_FILE) == 0) {
|
||||||
com_err(device, 0,
|
com_err(device, 0,
|
||||||
"The -d option is only valid when reading an e2image file");
|
"The -d option is only valid when reading an e2image file");
|
||||||
current_fs = NULL;
|
current_fs = NULL;
|
||||||
return;
|
return;
|
||||||
|
@ -78,7 +78,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock,
|
||||||
"opening read-only because of catastrophic mode");
|
"opening read-only because of catastrophic mode");
|
||||||
open_flags &= ~EXT2_FLAG_RW;
|
open_flags &= ~EXT2_FLAG_RW;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = ext2fs_open(device, open_flags, superblock, blocksize,
|
retval = ext2fs_open(device, open_flags, superblock, blocksize,
|
||||||
unix_io_manager, ¤t_fs);
|
unix_io_manager, ¤t_fs);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
@ -105,7 +105,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock,
|
||||||
if (data_io) {
|
if (data_io) {
|
||||||
retval = ext2fs_set_data_io(current_fs, data_io);
|
retval = ext2fs_set_data_io(current_fs, data_io);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err(device, retval,
|
com_err(device, retval,
|
||||||
"while setting data source");
|
"while setting data source");
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ void do_open_filesys(int argc, char **argv)
|
||||||
blk_t blocksize = 0;
|
blk_t blocksize = 0;
|
||||||
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
|
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
|
||||||
char *data_filename = 0;
|
char *data_filename = 0;
|
||||||
|
|
||||||
reset_getopt();
|
reset_getopt();
|
||||||
while ((c = getopt (argc, argv, "iwfecb:s:d:")) != EOF) {
|
while ((c = getopt (argc, argv, "iwfecb:s:d:")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -173,7 +173,7 @@ void do_open_filesys(int argc, char **argv)
|
||||||
if (check_fs_not_open(argv[0]))
|
if (check_fs_not_open(argv[0]))
|
||||||
return;
|
return;
|
||||||
open_filesystem(argv[optind], open_flags,
|
open_filesystem(argv[optind], open_flags,
|
||||||
superblock, blocksize, catastrophic,
|
superblock, blocksize, catastrophic,
|
||||||
data_filename);
|
data_filename);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ void do_lcd(int argc, char **argv)
|
||||||
static void close_filesystem(NOARGS)
|
static void close_filesystem(NOARGS)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (current_fs->flags & EXT2_FLAG_IB_DIRTY) {
|
if (current_fs->flags & EXT2_FLAG_IB_DIRTY) {
|
||||||
retval = ext2fs_write_inode_bitmap(current_fs);
|
retval = ext2fs_write_inode_bitmap(current_fs);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
@ -230,7 +230,7 @@ void do_init_filesys(int argc, char **argv)
|
||||||
struct ext2_super_block param;
|
struct ext2_super_block param;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (common_args_process(argc, argv, 3, 3, "initialize",
|
if (common_args_process(argc, argv, 3, 3, "initialize",
|
||||||
"<device> <blocksize>", CHECK_FS_NOTOPEN))
|
"<device> <blocksize>", CHECK_FS_NOTOPEN))
|
||||||
return;
|
return;
|
||||||
|
@ -315,12 +315,12 @@ void do_show_super_stats(int argc, char *argv[])
|
||||||
for (i=0; i < current_fs->group_desc_count; i++)
|
for (i=0; i < current_fs->group_desc_count; i++)
|
||||||
numdirs += current_fs->group_desc[i].bg_used_dirs_count;
|
numdirs += current_fs->group_desc[i].bg_used_dirs_count;
|
||||||
fprintf(out, "Directories: %d\n", numdirs);
|
fprintf(out, "Directories: %d\n", numdirs);
|
||||||
|
|
||||||
if (header_only) {
|
if (header_only) {
|
||||||
close_pager(out);
|
close_pager(out);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdp = ¤t_fs->group_desc[0];
|
gdp = ¤t_fs->group_desc[0];
|
||||||
for (i = 0; i < current_fs->group_desc_count; i++, gdp++) {
|
for (i = 0; i < current_fs->group_desc_count; i++, gdp++) {
|
||||||
fprintf(out, " Group %2d: block bitmap at %u, "
|
fprintf(out, " Group %2d: block bitmap at %u, "
|
||||||
|
@ -361,7 +361,7 @@ print_usage:
|
||||||
fprintf(stderr, "%s: Usage: show_super [-h]\n", argv[0]);
|
fprintf(stderr, "%s: Usage: show_super [-h]\n", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_dirty_filesys(int argc EXT2FS_ATTR((unused)),
|
void do_dirty_filesys(int argc EXT2FS_ATTR((unused)),
|
||||||
char **argv EXT2FS_ATTR((unused)))
|
char **argv EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
if (check_fs_open(argv[0]))
|
if (check_fs_open(argv[0]))
|
||||||
|
@ -402,10 +402,10 @@ static void finish_range(struct list_blocks_struct *lb)
|
||||||
lb->first_block = 0;
|
lb->first_block = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
|
static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
blk_t *blocknr, e2_blkcnt_t blockcnt,
|
blk_t *blocknr, e2_blkcnt_t blockcnt,
|
||||||
blk_t ref_block EXT2FS_ATTR((unused)),
|
blk_t ref_block EXT2FS_ATTR((unused)),
|
||||||
int ref_offset EXT2FS_ATTR((unused)),
|
int ref_offset EXT2FS_ATTR((unused)),
|
||||||
void *private)
|
void *private)
|
||||||
{
|
{
|
||||||
struct list_blocks_struct *lb = (struct list_blocks_struct *) private;
|
struct list_blocks_struct *lb = (struct list_blocks_struct *) private;
|
||||||
|
@ -451,7 +451,7 @@ static void dump_xattr_string(FILE *out, const char *str, int len)
|
||||||
{
|
{
|
||||||
int printable = 0;
|
int printable = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* check: is string "printable enough?" */
|
/* check: is string "printable enough?" */
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (isprint(str[i]))
|
if (isprint(str[i]))
|
||||||
|
@ -468,9 +468,9 @@ static void dump_xattr_string(FILE *out, const char *str, int len)
|
||||||
fprintf(out, "%02x ", (unsigned char)str[i]);
|
fprintf(out, "%02x ", (unsigned char)str[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void internal_dump_inode_extra(FILE *out,
|
static void internal_dump_inode_extra(FILE *out,
|
||||||
const char *prefix EXT2FS_ATTR((unused)),
|
const char *prefix EXT2FS_ATTR((unused)),
|
||||||
ext2_ino_t inode_num EXT2FS_ATTR((unused)),
|
ext2_ino_t inode_num EXT2FS_ATTR((unused)),
|
||||||
struct ext2_inode_large *inode)
|
struct ext2_inode_large *inode)
|
||||||
{
|
{
|
||||||
struct ext2_ext_attr_entry *entry;
|
struct ext2_ext_attr_entry *entry;
|
||||||
|
@ -504,7 +504,7 @@ static void internal_dump_inode_extra(FILE *out,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(out, " ");
|
fprintf(out, " ");
|
||||||
dump_xattr_string(out, EXT2_EXT_ATTR_NAME(entry),
|
dump_xattr_string(out, EXT2_EXT_ATTR_NAME(entry),
|
||||||
entry->e_name_len);
|
entry->e_name_len);
|
||||||
fprintf(out, " = \"");
|
fprintf(out, " = \"");
|
||||||
dump_xattr_string(out, start + entry->e_value_offs,
|
dump_xattr_string(out, start + entry->e_value_offs,
|
||||||
|
@ -559,11 +559,11 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||||
fprintf(out, "%sMode: %04o Flags: 0x%x\n",
|
fprintf(out, "%sMode: %04o Flags: 0x%x\n",
|
||||||
prefix, inode->i_mode & 0777, inode->i_flags);
|
prefix, inode->i_mode & 0777, inode->i_flags);
|
||||||
if (is_large_inode && large_inode->i_extra_isize >= 24) {
|
if (is_large_inode && large_inode->i_extra_isize >= 24) {
|
||||||
fprintf(out, "%sGeneration: %u Version: 0x%08x:%08x\n",
|
fprintf(out, "%sGeneration: %u Version: 0x%08x:%08x\n",
|
||||||
prefix, inode->i_generation, large_inode->i_version_hi,
|
prefix, inode->i_generation, large_inode->i_version_hi,
|
||||||
inode->osd1.linux1.l_i_version);
|
inode->osd1.linux1.l_i_version);
|
||||||
} else {
|
} else {
|
||||||
fprintf(out, "%sGeneration: %u Version: 0x%08x\n", prefix,
|
fprintf(out, "%sGeneration: %u Version: 0x%08x\n", prefix,
|
||||||
inode->i_generation, inode->osd1.linux1.l_i_version);
|
inode->i_generation, inode->osd1.linux1.l_i_version);
|
||||||
}
|
}
|
||||||
fprintf(out, "%sUser: %5d Group: %5d Size: ",
|
fprintf(out, "%sUser: %5d Group: %5d Size: ",
|
||||||
|
@ -585,11 +585,11 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||||
fprintf(out, "%sFile ACL: %d Directory ACL: %d\n",
|
fprintf(out, "%sFile ACL: %d Directory ACL: %d\n",
|
||||||
prefix,
|
prefix,
|
||||||
inode->i_file_acl, LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0);
|
inode->i_file_acl, LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0);
|
||||||
if (os == EXT2_OS_LINUX)
|
if (os == EXT2_OS_LINUX)
|
||||||
fprintf(out, "%sLinks: %d Blockcount: %llu\n",
|
fprintf(out, "%sLinks: %d Blockcount: %llu\n",
|
||||||
prefix, inode->i_links_count,
|
prefix, inode->i_links_count,
|
||||||
(((unsigned long long)
|
(((unsigned long long)
|
||||||
inode->osd2.linux2.l_i_blocks_hi << 32)) +
|
inode->osd2.linux2.l_i_blocks_hi << 32)) +
|
||||||
inode->i_blocks);
|
inode->i_blocks);
|
||||||
else
|
else
|
||||||
fprintf(out, "%sLinks: %d Blockcount: %u\n",
|
fprintf(out, "%sLinks: %d Blockcount: %u\n",
|
||||||
|
@ -605,10 +605,10 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||||
fprintf(out, "%sFragment: Address: %d Number: %d Size: %d\n",
|
fprintf(out, "%sFragment: Address: %d Number: %d Size: %d\n",
|
||||||
prefix, inode->i_faddr, frag, fsize);
|
prefix, inode->i_faddr, frag, fsize);
|
||||||
if (is_large_inode && large_inode->i_extra_isize >= 24) {
|
if (is_large_inode && large_inode->i_extra_isize >= 24) {
|
||||||
fprintf(out, "%s ctime: 0x%08x:%08x -- %s", prefix,
|
fprintf(out, "%s ctime: 0x%08x:%08x -- %s", prefix,
|
||||||
inode->i_ctime, large_inode->i_ctime_extra,
|
inode->i_ctime, large_inode->i_ctime_extra,
|
||||||
time_to_string(inode->i_ctime));
|
time_to_string(inode->i_ctime));
|
||||||
fprintf(out, "%s atime: 0x%08x:%08x -- %s", prefix,
|
fprintf(out, "%s atime: 0x%08x:%08x -- %s", prefix,
|
||||||
inode->i_atime, large_inode->i_atime_extra,
|
inode->i_atime, large_inode->i_atime_extra,
|
||||||
time_to_string(inode->i_atime));
|
time_to_string(inode->i_atime));
|
||||||
fprintf(out, "%s mtime: 0x%08x:%08x -- %s", prefix,
|
fprintf(out, "%s mtime: 0x%08x:%08x -- %s", prefix,
|
||||||
|
@ -625,7 +625,7 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||||
fprintf(out, "%smtime: 0x%08x -- %s", prefix, inode->i_mtime,
|
fprintf(out, "%smtime: 0x%08x -- %s", prefix, inode->i_mtime,
|
||||||
time_to_string(inode->i_mtime));
|
time_to_string(inode->i_mtime));
|
||||||
}
|
}
|
||||||
if (inode->i_dtime)
|
if (inode->i_dtime)
|
||||||
fprintf(out, "%sdtime: 0x%08x -- %s", prefix, inode->i_dtime,
|
fprintf(out, "%sdtime: 0x%08x -- %s", prefix, inode->i_dtime,
|
||||||
time_to_string(inode->i_dtime));
|
time_to_string(inode->i_dtime));
|
||||||
if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
|
if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
|
||||||
|
@ -644,11 +644,11 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||||
devnote = "";
|
devnote = "";
|
||||||
} else {
|
} else {
|
||||||
major = (inode->i_block[1] & 0xfff00) >> 8;
|
major = (inode->i_block[1] & 0xfff00) >> 8;
|
||||||
minor = ((inode->i_block[1] & 0xff) |
|
minor = ((inode->i_block[1] & 0xff) |
|
||||||
((inode->i_block[1] >> 12) & 0xfff00));
|
((inode->i_block[1] >> 12) & 0xfff00));
|
||||||
devnote = "(New-style) ";
|
devnote = "(New-style) ";
|
||||||
}
|
}
|
||||||
fprintf(out, "%sDevice major/minor number: %02d:%02d (hex %02x:%02x)\n",
|
fprintf(out, "%sDevice major/minor number: %02d:%02d (hex %02x:%02x)\n",
|
||||||
devnote, major, minor, major, minor);
|
devnote, major, minor, major, minor);
|
||||||
}
|
}
|
||||||
else if (do_dump_blocks)
|
else if (do_dump_blocks)
|
||||||
|
@ -658,7 +658,7 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||||
static void dump_inode(ext2_ino_t inode_num, struct ext2_inode *inode)
|
static void dump_inode(ext2_ino_t inode_num, struct ext2_inode *inode)
|
||||||
{
|
{
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
||||||
out = open_pager();
|
out = open_pager();
|
||||||
internal_dump_inode(out, "", inode_num, inode, 1);
|
internal_dump_inode(out, "", inode_num, inode, 1);
|
||||||
close_pager(out);
|
close_pager(out);
|
||||||
|
@ -900,7 +900,7 @@ void do_modify_inode(int argc, char *argv[])
|
||||||
const char *octal_format = "0%o";
|
const char *octal_format = "0%o";
|
||||||
const char *decimal_format = "%d";
|
const char *decimal_format = "%d";
|
||||||
const char *unsignedlong_format = "%lu";
|
const char *unsignedlong_format = "%lu";
|
||||||
|
|
||||||
if (common_inode_args_process(argc, argv, &inode_num, CHECK_FS_RW))
|
if (common_inode_args_process(argc, argv, &inode_num, CHECK_FS_RW))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -908,7 +908,7 @@ void do_modify_inode(int argc, char *argv[])
|
||||||
|
|
||||||
if (debugfs_read_inode(inode_num, &inode, argv[1]))
|
if (debugfs_read_inode(inode_num, &inode, argv[1]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
modify_u16(argv[0], "Mode", octal_format, &inode.i_mode);
|
modify_u16(argv[0], "Mode", octal_format, &inode.i_mode);
|
||||||
modify_u16(argv[0], "User ID", decimal_format, &inode.i_uid);
|
modify_u16(argv[0], "User ID", decimal_format, &inode.i_uid);
|
||||||
modify_u16(argv[0], "Group ID", decimal_format, &inode.i_gid);
|
modify_u16(argv[0], "Group ID", decimal_format, &inode.i_gid);
|
||||||
|
@ -919,7 +919,7 @@ void do_modify_inode(int argc, char *argv[])
|
||||||
modify_u32(argv[0], "Deletion time", decimal_format, &inode.i_dtime);
|
modify_u32(argv[0], "Deletion time", decimal_format, &inode.i_dtime);
|
||||||
modify_u16(argv[0], "Link count", decimal_format, &inode.i_links_count);
|
modify_u16(argv[0], "Link count", decimal_format, &inode.i_links_count);
|
||||||
if (os == EXT2_OS_LINUX)
|
if (os == EXT2_OS_LINUX)
|
||||||
modify_u16(argv[0], "Block count high", unsignedlong_format,
|
modify_u16(argv[0], "Block count high", unsignedlong_format,
|
||||||
&inode.osd2.linux2.l_i_blocks_hi);
|
&inode.osd2.linux2.l_i_blocks_hi);
|
||||||
modify_u32(argv[0], "Block count", unsignedlong_format, &inode.i_blocks);
|
modify_u32(argv[0], "Block count", unsignedlong_format, &inode.i_blocks);
|
||||||
modify_u32(argv[0], "File flags", hex_format, &inode.i_flags);
|
modify_u32(argv[0], "File flags", hex_format, &inode.i_flags);
|
||||||
|
@ -936,7 +936,7 @@ void do_modify_inode(int argc, char *argv[])
|
||||||
if (os == EXT2_OS_HURD)
|
if (os == EXT2_OS_HURD)
|
||||||
modify_u32(argv[0], "Translator Block",
|
modify_u32(argv[0], "Translator Block",
|
||||||
decimal_format, &inode.osd1.hurd1.h_i_translator);
|
decimal_format, &inode.osd1.hurd1.h_i_translator);
|
||||||
|
|
||||||
modify_u32(argv[0], "Fragment address", decimal_format, &inode.i_faddr);
|
modify_u32(argv[0], "Fragment address", decimal_format, &inode.i_faddr);
|
||||||
switch (os) {
|
switch (os) {
|
||||||
case EXT2_OS_HURD:
|
case EXT2_OS_HURD:
|
||||||
|
@ -956,7 +956,7 @@ void do_modify_inode(int argc, char *argv[])
|
||||||
modify_u32(argv[0], buf, decimal_format, &inode.i_block[i]);
|
modify_u32(argv[0], buf, decimal_format, &inode.i_block[i]);
|
||||||
}
|
}
|
||||||
modify_u32(argv[0], "Indirect Block", decimal_format,
|
modify_u32(argv[0], "Indirect Block", decimal_format,
|
||||||
&inode.i_block[EXT2_IND_BLOCK]);
|
&inode.i_block[EXT2_IND_BLOCK]);
|
||||||
modify_u32(argv[0], "Double Indirect Block", decimal_format,
|
modify_u32(argv[0], "Double Indirect Block", decimal_format,
|
||||||
&inode.i_block[EXT2_DIND_BLOCK]);
|
&inode.i_block[EXT2_DIND_BLOCK]);
|
||||||
modify_u32(argv[0], "Triple Indirect Block", decimal_format,
|
modify_u32(argv[0], "Triple Indirect Block", decimal_format,
|
||||||
|
@ -969,7 +969,7 @@ void do_change_working_dir(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ext2_ino_t inode;
|
ext2_ino_t inode;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (common_inode_args_process(argc, argv, &inode, 0))
|
if (common_inode_args_process(argc, argv, &inode, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -986,7 +986,7 @@ void do_print_working_directory(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
char *pathname = NULL;
|
char *pathname = NULL;
|
||||||
|
|
||||||
if (common_args_process(argc, argv, 1, 1,
|
if (common_args_process(argc, argv, 1, 1,
|
||||||
"print_working_directory", "", 0))
|
"print_working_directory", "", 0))
|
||||||
return;
|
return;
|
||||||
|
@ -1026,22 +1026,22 @@ static int ext2_file_type(unsigned int mode)
|
||||||
|
|
||||||
if (LINUX_S_ISDIR(mode))
|
if (LINUX_S_ISDIR(mode))
|
||||||
return EXT2_FT_DIR;
|
return EXT2_FT_DIR;
|
||||||
|
|
||||||
if (LINUX_S_ISCHR(mode))
|
if (LINUX_S_ISCHR(mode))
|
||||||
return EXT2_FT_CHRDEV;
|
return EXT2_FT_CHRDEV;
|
||||||
|
|
||||||
if (LINUX_S_ISBLK(mode))
|
if (LINUX_S_ISBLK(mode))
|
||||||
return EXT2_FT_BLKDEV;
|
return EXT2_FT_BLKDEV;
|
||||||
|
|
||||||
if (LINUX_S_ISLNK(mode))
|
if (LINUX_S_ISLNK(mode))
|
||||||
return EXT2_FT_SYMLINK;
|
return EXT2_FT_SYMLINK;
|
||||||
|
|
||||||
if (LINUX_S_ISFIFO(mode))
|
if (LINUX_S_ISFIFO(mode))
|
||||||
return EXT2_FT_FIFO;
|
return EXT2_FT_FIFO;
|
||||||
|
|
||||||
if (LINUX_S_ISSOCK(mode))
|
if (LINUX_S_ISSOCK(mode))
|
||||||
return EXT2_FT_SOCK;
|
return EXT2_FT_SOCK;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,7 +1066,7 @@ static void make_link(char *sourcename, char *destname)
|
||||||
base_name = sourcename;
|
base_name = sourcename;
|
||||||
/*
|
/*
|
||||||
* Figure out the destination. First see if it exists and is
|
* Figure out the destination. First see if it exists and is
|
||||||
* a directory.
|
* a directory.
|
||||||
*/
|
*/
|
||||||
if (! (retval=ext2fs_namei(current_fs, root, cwd, destname, &dir)))
|
if (! (retval=ext2fs_namei(current_fs, root, cwd, destname, &dir)))
|
||||||
dest = base_name;
|
dest = base_name;
|
||||||
|
@ -1090,8 +1090,8 @@ static void make_link(char *sourcename, char *destname)
|
||||||
|
|
||||||
if (debugfs_read_inode(ino, &inode, sourcename))
|
if (debugfs_read_inode(ino, &inode, sourcename))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
retval = ext2fs_link(current_fs, dir, dest, ino,
|
retval = ext2fs_link(current_fs, dir, dest, ino,
|
||||||
ext2_file_type(inode.i_mode));
|
ext2_file_type(inode.i_mode));
|
||||||
if (retval)
|
if (retval)
|
||||||
com_err("make_link", retval, 0);
|
com_err("make_link", retval, 0);
|
||||||
|
@ -1109,7 +1109,7 @@ void do_link(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mark_blocks_proc(ext2_filsys fs, blk_t *blocknr,
|
static int mark_blocks_proc(ext2_filsys fs, blk_t *blocknr,
|
||||||
int blockcnt EXT2FS_ATTR((unused)),
|
int blockcnt EXT2FS_ATTR((unused)),
|
||||||
void *private EXT2FS_ATTR((unused)))
|
void *private EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
blk_t block;
|
blk_t block;
|
||||||
|
@ -1143,7 +1143,7 @@ void do_undel(int argc, char *argv[])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX this function doesn't handle changing the links count on the
|
* XXX this function doesn't handle changing the links count on the
|
||||||
* parent directory when undeleting a directory.
|
* parent directory when undeleting a directory.
|
||||||
*/
|
*/
|
||||||
inode.i_links_count = LINUX_S_ISDIR(inode.i_mode) ? 2 : 1;
|
inode.i_links_count = LINUX_S_ISDIR(inode.i_mode) ? 2 : 1;
|
||||||
inode.i_dtime = 0;
|
inode.i_dtime = 0;
|
||||||
|
@ -1165,7 +1165,7 @@ static void unlink_file_by_name(char *filename)
|
||||||
int retval;
|
int retval;
|
||||||
ext2_ino_t dir;
|
ext2_ino_t dir;
|
||||||
char *base_name;
|
char *base_name;
|
||||||
|
|
||||||
base_name = strrchr(filename, '/');
|
base_name = strrchr(filename, '/');
|
||||||
if (base_name) {
|
if (base_name) {
|
||||||
*base_name++ = '\0';
|
*base_name++ = '\0';
|
||||||
|
@ -1197,7 +1197,7 @@ void do_find_free_block(int argc, char *argv[])
|
||||||
int count;
|
int count;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if ((argc > 3) || (argc==2 && *argv[1] == '?')) {
|
if ((argc > 3) || (argc==2 && *argv[1] == '?')) {
|
||||||
com_err(argv[0], 0, "Usage: find_free_block [count [goal]]");
|
com_err(argv[0], 0, "Usage: find_free_block [count [goal]]");
|
||||||
return;
|
return;
|
||||||
|
@ -1225,7 +1225,7 @@ void do_find_free_block(int argc, char *argv[])
|
||||||
goal = current_fs->super->s_first_data_block;
|
goal = current_fs->super->s_first_data_block;
|
||||||
|
|
||||||
printf("Free blocks found: ");
|
printf("Free blocks found: ");
|
||||||
free_blk = goal - 1;
|
free_blk = goal - 1;
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
retval = ext2fs_new_block(current_fs, free_blk + 1, 0,
|
retval = ext2fs_new_block(current_fs, free_blk + 1, 0,
|
||||||
&free_blk);
|
&free_blk);
|
||||||
|
@ -1249,7 +1249,7 @@ void do_find_free_inode(int argc, char *argv[])
|
||||||
int mode;
|
int mode;
|
||||||
int retval;
|
int retval;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if (argc > 3 || (argc>1 && *argv[1] == '?')) {
|
if (argc > 3 || (argc>1 && *argv[1] == '?')) {
|
||||||
com_err(argv[0], 0, "Usage: find_free_inode [dir] [mode]");
|
com_err(argv[0], 0, "Usage: find_free_inode [dir] [mode]");
|
||||||
return;
|
return;
|
||||||
|
@ -1383,11 +1383,11 @@ void do_write(int argc, char *argv[])
|
||||||
ext2fs_inode_alloc_stats2(current_fs, newfile, +1, 0);
|
ext2fs_inode_alloc_stats2(current_fs, newfile, +1, 0);
|
||||||
memset(&inode, 0, sizeof(inode));
|
memset(&inode, 0, sizeof(inode));
|
||||||
inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG;
|
inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG;
|
||||||
inode.i_atime = inode.i_ctime = inode.i_mtime =
|
inode.i_atime = inode.i_ctime = inode.i_mtime =
|
||||||
current_fs->now ? current_fs->now : time(0);
|
current_fs->now ? current_fs->now : time(0);
|
||||||
inode.i_links_count = 1;
|
inode.i_links_count = 1;
|
||||||
inode.i_size = statbuf.st_size;
|
inode.i_size = statbuf.st_size;
|
||||||
if (current_fs->super->s_feature_incompat &
|
if (current_fs->super->s_feature_incompat &
|
||||||
EXT3_FEATURE_INCOMPAT_EXTENTS)
|
EXT3_FEATURE_INCOMPAT_EXTENTS)
|
||||||
inode.i_flags |= EXT4_EXTENTS_FL;
|
inode.i_flags |= EXT4_EXTENTS_FL;
|
||||||
if (debugfs_write_new_inode(newfile, &inode, argv[0])) {
|
if (debugfs_write_new_inode(newfile, &inode, argv[0])) {
|
||||||
|
@ -1474,7 +1474,7 @@ void do_mknod(int argc, char *argv[])
|
||||||
ext2fs_mark_ib_dirty(current_fs);
|
ext2fs_mark_ib_dirty(current_fs);
|
||||||
memset(&inode, 0, sizeof(inode));
|
memset(&inode, 0, sizeof(inode));
|
||||||
inode.i_mode = mode;
|
inode.i_mode = mode;
|
||||||
inode.i_atime = inode.i_ctime = inode.i_mtime =
|
inode.i_atime = inode.i_ctime = inode.i_mtime =
|
||||||
current_fs->now ? current_fs->now : time(0);
|
current_fs->now ? current_fs->now : time(0);
|
||||||
if ((major < 256) && (minor < 256)) {
|
if ((major < 256) && (minor < 256)) {
|
||||||
inode.i_block[0] = major*256+minor;
|
inode.i_block[0] = major*256+minor;
|
||||||
|
@ -1531,7 +1531,7 @@ try_again:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr,
|
static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr,
|
||||||
int blockcnt EXT2FS_ATTR((unused)),
|
int blockcnt EXT2FS_ATTR((unused)),
|
||||||
void *private EXT2FS_ATTR((unused)))
|
void *private EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
blk_t block;
|
blk_t block;
|
||||||
|
@ -1631,7 +1631,7 @@ static int rmdir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
|
||||||
rds->empty = 0;
|
rds->empty = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_rmdir(int argc, char *argv[])
|
void do_rmdir(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -1688,7 +1688,7 @@ void do_rmdir(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_show_debugfs_params(int argc EXT2FS_ATTR((unused)),
|
void do_show_debugfs_params(int argc EXT2FS_ATTR((unused)),
|
||||||
char *argv[] EXT2FS_ATTR((unused)))
|
char *argv[] EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
FILE *out = stdout;
|
FILE *out = stdout;
|
||||||
|
@ -1717,7 +1717,7 @@ void do_expand_dir(int argc, char *argv[])
|
||||||
void do_features(int argc, char *argv[])
|
void do_features(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (check_fs_open(argv[0]))
|
if (check_fs_open(argv[0]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1740,7 +1740,7 @@ void do_bmap(int argc, char *argv[])
|
||||||
blk_t blk, pblk;
|
blk_t blk, pblk;
|
||||||
int err;
|
int err;
|
||||||
errcode_t errcode;
|
errcode_t errcode;
|
||||||
|
|
||||||
if (common_args_process(argc, argv, 3, 3, argv[0],
|
if (common_args_process(argc, argv, 3, 3, argv[0],
|
||||||
"<file> logical_blk", 0))
|
"<file> logical_blk", 0))
|
||||||
return;
|
return;
|
||||||
|
@ -1780,7 +1780,7 @@ void do_imap(int argc, char *argv[])
|
||||||
group);
|
group);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
block_nr = current_fs->group_desc[(unsigned)group].bg_inode_table +
|
block_nr = current_fs->group_desc[(unsigned)group].bg_inode_table +
|
||||||
block;
|
block;
|
||||||
offset &= (EXT2_BLOCK_SIZE(current_fs->super) - 1);
|
offset &= (EXT2_BLOCK_SIZE(current_fs->super) - 1);
|
||||||
|
|
||||||
|
@ -1929,7 +1929,7 @@ int main(int argc, char **argv)
|
||||||
blk_t blocksize = 0;
|
blk_t blocksize = 0;
|
||||||
int catastrophic = 0;
|
int catastrophic = 0;
|
||||||
char *data_filename = 0;
|
char *data_filename = 0;
|
||||||
|
|
||||||
if (debug_prog_name == 0)
|
if (debug_prog_name == 0)
|
||||||
debug_prog_name = "debugfs";
|
debug_prog_name = "debugfs";
|
||||||
|
|
||||||
|
@ -1955,11 +1955,11 @@ int main(int argc, char **argv)
|
||||||
open_flags |= EXT2_FLAG_RW;
|
open_flags |= EXT2_FLAG_RW;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
blocksize = parse_ulong(optarg, argv[0],
|
blocksize = parse_ulong(optarg, argv[0],
|
||||||
"block size", 0);
|
"block size", 0);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
superblock = parse_ulong(optarg, argv[0],
|
superblock = parse_ulong(optarg, argv[0],
|
||||||
"superblock number", 0);
|
"superblock number", 0);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
@ -1979,7 +1979,7 @@ int main(int argc, char **argv)
|
||||||
open_filesystem(argv[optind], open_flags,
|
open_filesystem(argv[optind], open_flags,
|
||||||
superblock, blocksize, catastrophic,
|
superblock, blocksize, catastrophic,
|
||||||
data_filename);
|
data_filename);
|
||||||
|
|
||||||
sci_idx = ss_create_invocation(debug_prog_name, "0.0", (char *) NULL,
|
sci_idx = ss_create_invocation(debug_prog_name, "0.0", (char *) NULL,
|
||||||
&debug_cmds, &retval);
|
&debug_cmds, &retval);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
@ -2014,7 +2014,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if (current_fs)
|
if (current_fs)
|
||||||
close_filesystem();
|
close_filesystem();
|
||||||
|
|
||||||
remove_error_table(&et_ext2_error_table);
|
remove_error_table(&et_ext2_error_table);
|
||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ extern void do_set_block_group_descriptor(int argc, char **);
|
||||||
extern void do_dump_unused(int argc, char **argv);
|
extern void do_dump_unused(int argc, char **argv);
|
||||||
|
|
||||||
/* debugfs.c */
|
/* debugfs.c */
|
||||||
extern void internal_dump_inode(FILE *, const char *, ext2_ino_t,
|
extern void internal_dump_inode(FILE *, const char *, ext2_ino_t,
|
||||||
struct ext2_inode *, int);
|
struct ext2_inode *, int);
|
||||||
|
|
||||||
extern void do_dirty_filesys(int argc, char **argv);
|
extern void do_dirty_filesys(int argc, char **argv);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* dump.c --- dump the contents of an inode out to a file
|
* dump.c --- dump the contents of an inode out to a file
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,7 +51,7 @@ static struct {
|
||||||
{ LINUX_S_IXOTH, S_IXOTH },
|
{ LINUX_S_IXOTH, S_IXOTH },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static mode_t mode_xlate(__u16 lmode)
|
static mode_t mode_xlate(__u16 lmode)
|
||||||
{
|
{
|
||||||
mode_t mode = 0;
|
mode_t mode = 0;
|
||||||
|
@ -106,7 +106,7 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd,
|
||||||
ext2_file_t e2_file;
|
ext2_file_t e2_file;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
unsigned int got;
|
unsigned int got;
|
||||||
|
|
||||||
if (debugfs_read_inode(ino, &inode, cmdname))
|
if (debugfs_read_inode(ino, &inode, cmdname))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd,
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
retval = ext2fs_file_read(e2_file, buf, sizeof(buf), &got);
|
retval = ext2fs_file_read(e2_file, buf, sizeof(buf), &got);
|
||||||
if (retval)
|
if (retval)
|
||||||
com_err(cmdname, retval, "while reading ext2 file");
|
com_err(cmdname, retval, "while reading ext2 file");
|
||||||
if (got == 0)
|
if (got == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -130,12 +130,12 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd,
|
||||||
com_err(cmdname, retval, "while closing ext2 file");
|
com_err(cmdname, retval, "while closing ext2 file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preserve)
|
if (preserve)
|
||||||
fix_perms("dump_file", &inode, fd, outname);
|
fix_perms("dump_file", &inode, fd, outname);
|
||||||
else if (fd != 1)
|
else if (fd != 1)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ void do_dump(int argc, char **argv)
|
||||||
int preserve = 0;
|
int preserve = 0;
|
||||||
const char *dump_usage = "Usage: dump_inode [-p] <file> <output_file>";
|
const char *dump_usage = "Usage: dump_inode [-p] <file> <output_file>";
|
||||||
char *in_fn, *out_fn;
|
char *in_fn, *out_fn;
|
||||||
|
|
||||||
reset_getopt();
|
reset_getopt();
|
||||||
while ((c = getopt (argc, argv, "p")) != EOF) {
|
while ((c = getopt (argc, argv, "p")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -171,7 +171,7 @@ void do_dump(int argc, char **argv)
|
||||||
out_fn = argv[optind+1];
|
out_fn = argv[optind+1];
|
||||||
|
|
||||||
inode = string_to_inode(in_fn);
|
inode = string_to_inode(in_fn);
|
||||||
if (!inode)
|
if (!inode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fd = open(out_fn, O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE, 0666);
|
fd = open(out_fn, O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE, 0666);
|
||||||
|
@ -289,7 +289,7 @@ errout:
|
||||||
free(fullname);
|
free(fullname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rdump_dirent(struct ext2_dir_entry *dirent,
|
static int rdump_dirent(struct ext2_dir_entry *dirent,
|
||||||
int offset EXT2FS_ATTR((unused)),
|
int offset EXT2FS_ATTR((unused)),
|
||||||
int blocksize EXT2FS_ATTR((unused)),
|
int blocksize EXT2FS_ATTR((unused)),
|
||||||
char *buf EXT2FS_ATTR((unused)), void *private)
|
char *buf EXT2FS_ATTR((unused)), void *private)
|
||||||
|
@ -360,7 +360,7 @@ void do_cat(int argc, char **argv)
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
dump_file(argv[0], inode, 1, 0, argv[2]);
|
dump_file(argv[0], inode, 1, 0, argv[2]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* htree.c --- hash tree routines
|
* htree.c --- hash tree routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 2002 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +40,7 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino,
|
||||||
blk_t pblk;
|
blk_t pblk;
|
||||||
ext2_dirhash_t hash, minor_hash;
|
ext2_dirhash_t hash, minor_hash;
|
||||||
int rec_len, hash_alg;
|
int rec_len, hash_alg;
|
||||||
|
|
||||||
errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk);
|
errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk);
|
||||||
if (errcode) {
|
if (errcode) {
|
||||||
com_err("htree_dump_leaf_node", errcode,
|
com_err("htree_dump_leaf_node", errcode,
|
||||||
|
@ -105,13 +105,13 @@ static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino,
|
||||||
static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
|
static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
|
||||||
struct ext2_inode *inode,
|
struct ext2_inode *inode,
|
||||||
struct ext2_dx_root_info * rootnode,
|
struct ext2_dx_root_info * rootnode,
|
||||||
struct ext2_dx_entry *ent,
|
struct ext2_dx_entry *ent,
|
||||||
char *buf, int level)
|
char *buf, int level)
|
||||||
{
|
{
|
||||||
struct ext2_dx_countlimit limit;
|
struct ext2_dx_countlimit limit;
|
||||||
struct ext2_dx_entry e;
|
struct ext2_dx_entry e;
|
||||||
int hash, i;
|
int hash, i;
|
||||||
|
|
||||||
|
|
||||||
limit = *((struct ext2_dx_countlimit *) ent);
|
limit = *((struct ext2_dx_countlimit *) ent);
|
||||||
limit.count = ext2fs_le16_to_cpu(limit.count);
|
limit.count = ext2fs_le16_to_cpu(limit.count);
|
||||||
|
@ -159,7 +159,7 @@ static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino,
|
||||||
fprintf(pager, "Couldn't allocate child block.\n");
|
fprintf(pager, "Couldn't allocate child block.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk);
|
errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk);
|
||||||
if (errcode) {
|
if (errcode) {
|
||||||
com_err("htree_dump_int_block", errcode,
|
com_err("htree_dump_int_block", errcode,
|
||||||
|
@ -232,7 +232,7 @@ void do_htree_dump(int argc, char *argv[])
|
||||||
com_err(argv[0], 0, "Not a directory");
|
com_err(argv[0], 0, "Not a directory");
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((inode.i_flags & EXT2_BTREE_FL) == 0) {
|
if ((inode.i_flags & EXT2_BTREE_FL) == 0) {
|
||||||
com_err(argv[0], 0, "Not a hash-indexed directory");
|
com_err(argv[0], 0, "Not a hash-indexed directory");
|
||||||
goto errout;
|
goto errout;
|
||||||
|
@ -251,7 +251,7 @@ void do_htree_dump(int argc, char *argv[])
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode = io_channel_read_blk(current_fs->io, blk,
|
errcode = io_channel_read_blk(current_fs->io, blk,
|
||||||
1, buf);
|
1, buf);
|
||||||
if (errcode) {
|
if (errcode) {
|
||||||
com_err(argv[0], errcode, "Error reading root node");
|
com_err(argv[0], errcode, "Error reading root node");
|
||||||
|
@ -290,7 +290,7 @@ void do_dx_hash(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
int hash_version = 0;
|
int hash_version = 0;
|
||||||
__u32 hash_seed[4];
|
__u32 hash_seed[4];
|
||||||
|
|
||||||
hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0;
|
hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0;
|
||||||
|
|
||||||
reset_getopt();
|
reset_getopt();
|
||||||
|
@ -330,14 +330,14 @@ struct process_block_struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
|
static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
|
||||||
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
||||||
int ref_offset, void *priv_data);
|
int ref_offset, void *priv_data);
|
||||||
|
|
||||||
void do_dirsearch(int argc, char *argv[])
|
void do_dirsearch(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ext2_ino_t inode;
|
ext2_ino_t inode;
|
||||||
struct process_block_struct pb;
|
struct process_block_struct pb;
|
||||||
|
|
||||||
if (check_fs_open(argv[0]))
|
if (check_fs_open(argv[0]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ void do_dirsearch(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
pb.search_name = argv[2];
|
pb.search_name = argv[2];
|
||||||
pb.len = strlen(pb.search_name);
|
pb.len = strlen(pb.search_name);
|
||||||
|
|
||||||
ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, 0,
|
ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, 0,
|
||||||
search_dir_block, &pb);
|
search_dir_block, &pb);
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ void do_dirsearch(int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
|
static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
|
||||||
e2_blkcnt_t blockcnt,
|
e2_blkcnt_t blockcnt,
|
||||||
blk_t ref_blk EXT2FS_ATTR((unused)),
|
blk_t ref_blk EXT2FS_ATTR((unused)),
|
||||||
int ref_offset EXT2FS_ATTR((unused)),
|
int ref_offset EXT2FS_ATTR((unused)),
|
||||||
void *priv_data)
|
void *priv_data)
|
||||||
|
@ -394,7 +394,7 @@ static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
|
||||||
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
|
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
|
||||||
dirent->rec_len : 65536;
|
dirent->rec_len : 65536;
|
||||||
if (dirent->inode &&
|
if (dirent->inode &&
|
||||||
p->len == (dirent->name_len & 0xFF) &&
|
p->len == (dirent->name_len & 0xFF) &&
|
||||||
strncmp(p->search_name, dirent->name,
|
strncmp(p->search_name, dirent->name,
|
||||||
p->len) == 0) {
|
p->len) == 0) {
|
||||||
printf("Entry found at logical block %lld, "
|
printf("Entry found at logical block %lld, "
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* icheck.c --- given a list of blocks, generate a list of inodes
|
* icheck.c --- given a list of blocks, generate a list of inodes
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -48,7 +48,7 @@ static int icheck_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
}
|
}
|
||||||
if (!bw->blocks_left)
|
if (!bw->blocks_left)
|
||||||
return BLOCK_ABORT;
|
return BLOCK_ABORT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ void do_icheck(int argc, char **argv)
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
char *block_buf;
|
char *block_buf;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
com_err(argv[0], 0, "Usage: icheck <block number> ...");
|
com_err(argv[0], 0, "Usage: icheck <block number> ...");
|
||||||
return;
|
return;
|
||||||
|
@ -104,7 +104,7 @@ void do_icheck(int argc, char **argv)
|
||||||
com_err("icheck", retval, "while starting inode scan");
|
com_err("icheck", retval, "while starting inode scan");
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ino) {
|
while (ino) {
|
||||||
if (!inode.i_links_count)
|
if (!inode.i_links_count)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* logdump.c --- dump the contents of the journal out to a file
|
* logdump.c --- dump the contents of the journal out to a file
|
||||||
*
|
*
|
||||||
* Authro: Stephen C. Tweedie, 2001 <sct@redhat.com>
|
* Authro: Stephen C. Tweedie, 2001 <sct@redhat.com>
|
||||||
* Copyright (C) 2001 Red Hat, Inc.
|
* Copyright (C) 2001 Red Hat, Inc.
|
||||||
* Based on portions Copyright (C) 1994 Theodore Ts'o.
|
* Based on portions Copyright (C) 1994 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,7 +43,7 @@ blk_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
|
||||||
unsigned int group_to_dump, inode_offset_to_dump;
|
unsigned int group_to_dump, inode_offset_to_dump;
|
||||||
ext2_ino_t inode_to_dump;
|
ext2_ino_t inode_to_dump;
|
||||||
|
|
||||||
struct journal_source
|
struct journal_source
|
||||||
{
|
{
|
||||||
enum journal_location where;
|
enum journal_location where;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -60,7 +60,7 @@ static void dump_revoke_block(FILE *, char *, journal_superblock_t *,
|
||||||
unsigned int, int, tid_t);
|
unsigned int, int, tid_t);
|
||||||
|
|
||||||
static void dump_metadata_block(FILE *, struct journal_source *,
|
static void dump_metadata_block(FILE *, struct journal_source *,
|
||||||
journal_superblock_t*,
|
journal_superblock_t*,
|
||||||
unsigned int, unsigned int, int, tid_t);
|
unsigned int, unsigned int, int, tid_t);
|
||||||
|
|
||||||
static void do_hexdump (FILE *, char *, int);
|
static void do_hexdump (FILE *, char *, int);
|
||||||
|
@ -76,7 +76,7 @@ void do_logdump(int argc, char **argv)
|
||||||
int retval;
|
int retval;
|
||||||
char *out_fn;
|
char *out_fn;
|
||||||
FILE *out_file;
|
FILE *out_file;
|
||||||
|
|
||||||
char *inode_spec = NULL;
|
char *inode_spec = NULL;
|
||||||
char *journal_fn = NULL;
|
char *journal_fn = NULL;
|
||||||
int journal_fd = 0;
|
int journal_fd = 0;
|
||||||
|
@ -87,7 +87,7 @@ void do_logdump(int argc, char **argv)
|
||||||
char *tmp;
|
char *tmp;
|
||||||
struct journal_source journal_source;
|
struct journal_source journal_source;
|
||||||
struct ext2_super_block *es = NULL;
|
struct ext2_super_block *es = NULL;
|
||||||
|
|
||||||
journal_source.where = 0;
|
journal_source.where = 0;
|
||||||
journal_source.fd = 0;
|
journal_source.fd = 0;
|
||||||
journal_source.file = 0;
|
journal_source.file = 0;
|
||||||
|
@ -98,7 +98,7 @@ void do_logdump(int argc, char **argv)
|
||||||
bitmap_to_dump = -1;
|
bitmap_to_dump = -1;
|
||||||
inode_block_to_dump = ANY_BLOCK;
|
inode_block_to_dump = ANY_BLOCK;
|
||||||
inode_to_dump = -1;
|
inode_to_dump = -1;
|
||||||
|
|
||||||
reset_getopt();
|
reset_getopt();
|
||||||
while ((c = getopt (argc, argv, "ab:ci:f:s")) != EOF) {
|
while ((c = getopt (argc, argv, "ab:ci:f:s")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -152,11 +152,11 @@ void do_logdump(int argc, char **argv)
|
||||||
/ es->s_inodes_per_group);
|
/ es->s_inodes_per_group);
|
||||||
group_offset = ((inode_to_dump - 1)
|
group_offset = ((inode_to_dump - 1)
|
||||||
% es->s_inodes_per_group);
|
% es->s_inodes_per_group);
|
||||||
inodes_per_block = (current_fs->blocksize
|
inodes_per_block = (current_fs->blocksize
|
||||||
/ sizeof(struct ext2_inode));
|
/ sizeof(struct ext2_inode));
|
||||||
|
|
||||||
inode_block_to_dump =
|
inode_block_to_dump =
|
||||||
current_fs->group_desc[inode_group].bg_inode_table +
|
current_fs->group_desc[inode_group].bg_inode_table +
|
||||||
(group_offset / inodes_per_block);
|
(group_offset / inodes_per_block);
|
||||||
inode_offset_to_dump = ((group_offset % inodes_per_block)
|
inode_offset_to_dump = ((group_offset % inodes_per_block)
|
||||||
* sizeof(struct ext2_inode));
|
* sizeof(struct ext2_inode));
|
||||||
|
@ -178,7 +178,7 @@ void do_logdump(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block_to_dump != ANY_BLOCK && current_fs != NULL) {
|
if (block_to_dump != ANY_BLOCK && current_fs != NULL) {
|
||||||
group_to_dump = ((block_to_dump -
|
group_to_dump = ((block_to_dump -
|
||||||
es->s_first_data_block)
|
es->s_first_data_block)
|
||||||
/ es->s_blocks_per_group);
|
/ es->s_blocks_per_group);
|
||||||
bitmap_to_dump = current_fs->group_desc[group_to_dump].bg_block_bitmap;
|
bitmap_to_dump = current_fs->group_desc[group_to_dump].bg_block_bitmap;
|
||||||
|
@ -195,7 +195,7 @@ void do_logdump(int argc, char **argv)
|
||||||
journal_fn);
|
journal_fn);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
journal_source.where = JOURNAL_IS_EXTERNAL;
|
journal_source.where = JOURNAL_IS_EXTERNAL;
|
||||||
journal_source.fd = journal_fd;
|
journal_source.fd = journal_fd;
|
||||||
} else if ((journal_inum = es->s_journal_inum)) {
|
} else if ((journal_inum = es->s_journal_inum)) {
|
||||||
|
@ -206,17 +206,17 @@ void do_logdump(int argc, char **argv)
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
memset(&journal_inode, 0, sizeof(struct ext2_inode));
|
memset(&journal_inode, 0, sizeof(struct ext2_inode));
|
||||||
memcpy(&journal_inode.i_block[0], es->s_jnl_blocks,
|
memcpy(&journal_inode.i_block[0], es->s_jnl_blocks,
|
||||||
EXT2_N_BLOCKS*4);
|
EXT2_N_BLOCKS*4);
|
||||||
journal_inode.i_size = es->s_jnl_blocks[16];
|
journal_inode.i_size = es->s_jnl_blocks[16];
|
||||||
journal_inode.i_links_count = 1;
|
journal_inode.i_links_count = 1;
|
||||||
journal_inode.i_mode = LINUX_S_IFREG | 0600;
|
journal_inode.i_mode = LINUX_S_IFREG | 0600;
|
||||||
} else {
|
} else {
|
||||||
if (debugfs_read_inode(journal_inum, &journal_inode,
|
if (debugfs_read_inode(journal_inum, &journal_inode,
|
||||||
argv[0]))
|
argv[0]))
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = ext2fs_file_open2(current_fs, journal_inum,
|
retval = ext2fs_file_open2(current_fs, journal_inum,
|
||||||
&journal_inode, 0, &journal_file);
|
&journal_inode, 0, &journal_file);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
@ -227,7 +227,7 @@ void do_logdump(int argc, char **argv)
|
||||||
journal_source.file = journal_file;
|
journal_source.file = journal_file;
|
||||||
} else {
|
} else {
|
||||||
char uuid[37];
|
char uuid[37];
|
||||||
|
|
||||||
uuid_unparse(es->s_journal_uuid, uuid);
|
uuid_unparse(es->s_journal_uuid, uuid);
|
||||||
journal_fn = blkid_get_devname(NULL, "UUID", uuid);
|
journal_fn = blkid_get_devname(NULL, "UUID", uuid);
|
||||||
if (!journal_fn)
|
if (!journal_fn)
|
||||||
|
@ -269,12 +269,12 @@ print_usage:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int read_journal_block(const char *cmd, struct journal_source *source,
|
static int read_journal_block(const char *cmd, struct journal_source *source,
|
||||||
off_t offset, char *buf, int size,
|
off_t offset, char *buf, int size,
|
||||||
unsigned int *got)
|
unsigned int *got)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (source->where == JOURNAL_IS_EXTERNAL) {
|
if (source->where == JOURNAL_IS_EXTERNAL) {
|
||||||
if (lseek(source->fd, offset, SEEK_SET) < 0) {
|
if (lseek(source->fd, offset, SEEK_SET) < 0) {
|
||||||
retval = errno;
|
retval = errno;
|
||||||
|
@ -288,23 +288,23 @@ static int read_journal_block(const char *cmd, struct journal_source *source,
|
||||||
} else
|
} else
|
||||||
retval = errno;
|
retval = errno;
|
||||||
} else {
|
} else {
|
||||||
retval = ext2fs_file_lseek(source->file, offset,
|
retval = ext2fs_file_lseek(source->file, offset,
|
||||||
EXT2_SEEK_SET, NULL);
|
EXT2_SEEK_SET, NULL);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err(cmd, retval, "while seeking in reading journal");
|
com_err(cmd, retval, "while seeking in reading journal");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = ext2fs_file_read(source->file, buf, size, got);
|
retval = ext2fs_file_read(source->file, buf, size, got);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval)
|
if (retval)
|
||||||
com_err(cmd, retval, "while while reading journal");
|
com_err(cmd, retval, "while while reading journal");
|
||||||
else if (*got != (unsigned int) size) {
|
else if (*got != (unsigned int) size) {
|
||||||
com_err(cmd, 0, "short read (read %d, expected %d) while while reading journal", *got, size);
|
com_err(cmd, 0, "short read (read %d, expected %d) while while reading journal", *got, size);
|
||||||
retval = -1;
|
retval = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ static const char *type_to_name(int btype)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dump_journal(char *cmdname, FILE *out_file,
|
static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
struct journal_source *source)
|
struct journal_source *source)
|
||||||
{
|
{
|
||||||
struct ext2_super_block *sb;
|
struct ext2_super_block *sb;
|
||||||
|
@ -338,12 +338,12 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
int retval;
|
int retval;
|
||||||
__u32 magic, sequence, blocktype;
|
__u32 magic, sequence, blocktype;
|
||||||
journal_header_t *header;
|
journal_header_t *header;
|
||||||
|
|
||||||
tid_t transaction;
|
tid_t transaction;
|
||||||
unsigned int blocknr = 0;
|
unsigned int blocknr = 0;
|
||||||
|
|
||||||
/* First, check to see if there's an ext2 superblock header */
|
/* First, check to see if there's an ext2 superblock header */
|
||||||
retval = read_journal_block(cmdname, source, 0,
|
retval = read_journal_block(cmdname, source, 0,
|
||||||
buf, 2048, &got);
|
buf, 2048, &got);
|
||||||
if (retval)
|
if (retval)
|
||||||
return;
|
return;
|
||||||
|
@ -351,10 +351,10 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
jsb = (journal_superblock_t *) buf;
|
jsb = (journal_superblock_t *) buf;
|
||||||
sb = (struct ext2_super_block *) (buf+1024);
|
sb = (struct ext2_super_block *) (buf+1024);
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
|
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
|
||||||
ext2fs_swap_super(sb);
|
ext2fs_swap_super(sb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) &&
|
if ((be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) &&
|
||||||
(sb->s_magic == EXT2_SUPER_MAGIC) &&
|
(sb->s_magic == EXT2_SUPER_MAGIC) &&
|
||||||
(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
|
(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
|
||||||
|
@ -369,10 +369,10 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
(unsigned long) sb->s_blocks_count);
|
(unsigned long) sb->s_blocks_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next, read the journal superblock */
|
/* Next, read the journal superblock */
|
||||||
|
|
||||||
retval = read_journal_block(cmdname, source, blocknr*blocksize,
|
retval = read_journal_block(cmdname, source, blocknr*blocksize,
|
||||||
jsb_buffer, 1024, &got);
|
jsb_buffer, 1024, &got);
|
||||||
if (retval)
|
if (retval)
|
||||||
return;
|
return;
|
||||||
|
@ -393,29 +393,29 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
if (!blocknr)
|
if (!blocknr)
|
||||||
/* Empty journal, nothing to do. */
|
/* Empty journal, nothing to do. */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
retval = read_journal_block(cmdname, source,
|
retval = read_journal_block(cmdname, source,
|
||||||
blocknr*blocksize, buf,
|
blocknr*blocksize, buf,
|
||||||
blocksize, &got);
|
blocksize, &got);
|
||||||
if (retval || got != blocksize)
|
if (retval || got != blocksize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
header = (journal_header_t *) buf;
|
header = (journal_header_t *) buf;
|
||||||
|
|
||||||
magic = be32_to_cpu(header->h_magic);
|
magic = be32_to_cpu(header->h_magic);
|
||||||
sequence = be32_to_cpu(header->h_sequence);
|
sequence = be32_to_cpu(header->h_sequence);
|
||||||
blocktype = be32_to_cpu(header->h_blocktype);
|
blocktype = be32_to_cpu(header->h_blocktype);
|
||||||
|
|
||||||
if (magic != JFS_MAGIC_NUMBER) {
|
if (magic != JFS_MAGIC_NUMBER) {
|
||||||
fprintf (out_file, "No magic number at block %u: "
|
fprintf (out_file, "No magic number at block %u: "
|
||||||
"end of journal.\n", blocknr);
|
"end of journal.\n", blocknr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sequence != transaction) {
|
if (sequence != transaction) {
|
||||||
fprintf (out_file, "Found sequence %u (not %u) at "
|
fprintf (out_file, "Found sequence %u (not %u) at "
|
||||||
"block %u: end of journal.\n",
|
"block %u: end of journal.\n",
|
||||||
sequence, transaction, blocknr);
|
sequence, transaction, blocknr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -423,13 +423,13 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
if (dump_descriptors) {
|
if (dump_descriptors) {
|
||||||
fprintf (out_file, "Found expected sequence %u, "
|
fprintf (out_file, "Found expected sequence %u, "
|
||||||
"type %u (%s) at block %u\n",
|
"type %u (%s) at block %u\n",
|
||||||
sequence, blocktype,
|
sequence, blocktype,
|
||||||
type_to_name(blocktype), blocknr);
|
type_to_name(blocktype), blocknr);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (blocktype) {
|
switch (blocktype) {
|
||||||
case JFS_DESCRIPTOR_BLOCK:
|
case JFS_DESCRIPTOR_BLOCK:
|
||||||
dump_descriptor_block(out_file, source, buf, jsb,
|
dump_descriptor_block(out_file, source, buf, jsb,
|
||||||
&blocknr, blocksize,
|
&blocknr, blocksize,
|
||||||
transaction);
|
transaction);
|
||||||
continue;
|
continue;
|
||||||
|
@ -439,10 +439,10 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
blocknr++;
|
blocknr++;
|
||||||
WRAP(jsb, blocknr);
|
WRAP(jsb, blocknr);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case JFS_REVOKE_BLOCK:
|
case JFS_REVOKE_BLOCK:
|
||||||
dump_revoke_block(out_file, buf, jsb,
|
dump_revoke_block(out_file, buf, jsb,
|
||||||
blocknr, blocksize,
|
blocknr, blocksize,
|
||||||
transaction);
|
transaction);
|
||||||
blocknr++;
|
blocknr++;
|
||||||
WRAP(jsb, blocknr);
|
WRAP(jsb, blocknr);
|
||||||
|
@ -457,10 +457,10 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dump_descriptor_block(FILE *out_file,
|
static void dump_descriptor_block(FILE *out_file,
|
||||||
struct journal_source *source,
|
struct journal_source *source,
|
||||||
char *buf,
|
char *buf,
|
||||||
journal_superblock_t *jsb,
|
journal_superblock_t *jsb,
|
||||||
unsigned int *blockp, int blocksize,
|
unsigned int *blockp, int blocksize,
|
||||||
tid_t transaction)
|
tid_t transaction)
|
||||||
{
|
{
|
||||||
|
@ -470,20 +470,20 @@ static void dump_descriptor_block(FILE *out_file,
|
||||||
unsigned int blocknr;
|
unsigned int blocknr;
|
||||||
__u32 tag_block;
|
__u32 tag_block;
|
||||||
__u32 tag_flags;
|
__u32 tag_flags;
|
||||||
|
|
||||||
|
|
||||||
offset = sizeof(journal_header_t);
|
offset = sizeof(journal_header_t);
|
||||||
blocknr = *blockp;
|
blocknr = *blockp;
|
||||||
|
|
||||||
if (dump_all)
|
if (dump_all)
|
||||||
fprintf(out_file, "Dumping descriptor block, sequence %u, at "
|
fprintf(out_file, "Dumping descriptor block, sequence %u, at "
|
||||||
"block %u:\n", transaction, blocknr);
|
"block %u:\n", transaction, blocknr);
|
||||||
|
|
||||||
++blocknr;
|
++blocknr;
|
||||||
WRAP(jsb, blocknr);
|
WRAP(jsb, blocknr);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Work out the location of the current tag, and skip to
|
/* Work out the location of the current tag, and skip to
|
||||||
* the next one... */
|
* the next one... */
|
||||||
tagp = &buf[offset];
|
tagp = &buf[offset];
|
||||||
tag = (journal_block_tag_t *) tagp;
|
tag = (journal_block_tag_t *) tagp;
|
||||||
|
@ -493,40 +493,40 @@ static void dump_descriptor_block(FILE *out_file,
|
||||||
end of this block. */
|
end of this block. */
|
||||||
if (offset > blocksize)
|
if (offset > blocksize)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tag_block = be32_to_cpu(tag->t_blocknr);
|
tag_block = be32_to_cpu(tag->t_blocknr);
|
||||||
tag_flags = be32_to_cpu(tag->t_flags);
|
tag_flags = be32_to_cpu(tag->t_flags);
|
||||||
|
|
||||||
if (!(tag_flags & JFS_FLAG_SAME_UUID))
|
if (!(tag_flags & JFS_FLAG_SAME_UUID))
|
||||||
offset += 16;
|
offset += 16;
|
||||||
|
|
||||||
dump_metadata_block(out_file, source, jsb,
|
dump_metadata_block(out_file, source, jsb,
|
||||||
blocknr, tag_block, blocksize,
|
blocknr, tag_block, blocksize,
|
||||||
transaction);
|
transaction);
|
||||||
|
|
||||||
++blocknr;
|
++blocknr;
|
||||||
WRAP(jsb, blocknr);
|
WRAP(jsb, blocknr);
|
||||||
|
|
||||||
} while (!(tag_flags & JFS_FLAG_LAST_TAG));
|
} while (!(tag_flags & JFS_FLAG_LAST_TAG));
|
||||||
|
|
||||||
*blockp = blocknr;
|
*blockp = blocknr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dump_revoke_block(FILE *out_file, char *buf,
|
static void dump_revoke_block(FILE *out_file, char *buf,
|
||||||
journal_superblock_t *jsb EXT2FS_ATTR((unused)),
|
journal_superblock_t *jsb EXT2FS_ATTR((unused)),
|
||||||
unsigned int blocknr,
|
unsigned int blocknr,
|
||||||
int blocksize EXT2FS_ATTR((unused)),
|
int blocksize EXT2FS_ATTR((unused)),
|
||||||
tid_t transaction)
|
tid_t transaction)
|
||||||
{
|
{
|
||||||
int offset, max;
|
int offset, max;
|
||||||
journal_revoke_header_t *header;
|
journal_revoke_header_t *header;
|
||||||
unsigned int *entry, rblock;
|
unsigned int *entry, rblock;
|
||||||
|
|
||||||
if (dump_all)
|
if (dump_all)
|
||||||
fprintf(out_file, "Dumping revoke block, sequence %u, at "
|
fprintf(out_file, "Dumping revoke block, sequence %u, at "
|
||||||
"block %u:\n", transaction, blocknr);
|
"block %u:\n", transaction, blocknr);
|
||||||
|
|
||||||
header = (journal_revoke_header_t *) buf;
|
header = (journal_revoke_header_t *) buf;
|
||||||
offset = sizeof(journal_revoke_header_t);
|
offset = sizeof(journal_revoke_header_t);
|
||||||
max = be32_to_cpu(header->r_count);
|
max = be32_to_cpu(header->r_count);
|
||||||
|
@ -551,7 +551,7 @@ static void show_extent(FILE *out_file, int start_extent, int end_extent,
|
||||||
__u32 first_block)
|
__u32 first_block)
|
||||||
{
|
{
|
||||||
if (start_extent >= 0 && first_block != 0)
|
if (start_extent >= 0 && first_block != 0)
|
||||||
fprintf(out_file, "(%d+%u): %u ",
|
fprintf(out_file, "(%d+%u): %u ",
|
||||||
start_extent, end_extent-start_extent, first_block);
|
start_extent, end_extent-start_extent, first_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,79 +564,79 @@ static void show_indirect(FILE *out_file, const char *name, __u32 where)
|
||||||
|
|
||||||
static void dump_metadata_block(FILE *out_file, struct journal_source *source,
|
static void dump_metadata_block(FILE *out_file, struct journal_source *source,
|
||||||
journal_superblock_t *jsb EXT2FS_ATTR((unused)),
|
journal_superblock_t *jsb EXT2FS_ATTR((unused)),
|
||||||
unsigned int log_blocknr,
|
unsigned int log_blocknr,
|
||||||
unsigned int fs_blocknr,
|
unsigned int fs_blocknr,
|
||||||
int blocksize,
|
int blocksize,
|
||||||
tid_t transaction)
|
tid_t transaction)
|
||||||
{
|
{
|
||||||
unsigned int got;
|
unsigned int got;
|
||||||
int retval;
|
int retval;
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
|
|
||||||
if (!(dump_all
|
if (!(dump_all
|
||||||
|| (fs_blocknr == block_to_dump)
|
|| (fs_blocknr == block_to_dump)
|
||||||
|| (fs_blocknr == inode_block_to_dump)
|
|| (fs_blocknr == inode_block_to_dump)
|
||||||
|| (fs_blocknr == bitmap_to_dump)))
|
|| (fs_blocknr == bitmap_to_dump)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf(out_file, " FS block %u logged at ", fs_blocknr);
|
fprintf(out_file, " FS block %u logged at ", fs_blocknr);
|
||||||
if (!dump_all)
|
if (!dump_all)
|
||||||
fprintf(out_file, "sequence %u, ", transaction);
|
fprintf(out_file, "sequence %u, ", transaction);
|
||||||
fprintf(out_file, "journal block %u\n", log_blocknr);
|
fprintf(out_file, "journal block %u\n", log_blocknr);
|
||||||
|
|
||||||
/* There are two major special cases to parse:
|
/* There are two major special cases to parse:
|
||||||
*
|
*
|
||||||
* If this block is a block
|
* If this block is a block
|
||||||
* bitmap block, we need to give it special treatment so that we
|
* bitmap block, we need to give it special treatment so that we
|
||||||
* can log any allocates and deallocates which affect the
|
* can log any allocates and deallocates which affect the
|
||||||
* block_to_dump query block.
|
* block_to_dump query block.
|
||||||
*
|
*
|
||||||
* If the block is an inode block for the inode being searched
|
* If the block is an inode block for the inode being searched
|
||||||
* for, then we need to dump the contents of that inode
|
* for, then we need to dump the contents of that inode
|
||||||
* structure symbolically.
|
* structure symbolically.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(dump_contents && dump_all)
|
if (!(dump_contents && dump_all)
|
||||||
&& fs_blocknr != block_to_dump
|
&& fs_blocknr != block_to_dump
|
||||||
&& fs_blocknr != bitmap_to_dump
|
&& fs_blocknr != bitmap_to_dump
|
||||||
&& fs_blocknr != inode_block_to_dump)
|
&& fs_blocknr != inode_block_to_dump)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
retval = read_journal_block("logdump", source,
|
retval = read_journal_block("logdump", source,
|
||||||
blocksize * log_blocknr,
|
blocksize * log_blocknr,
|
||||||
buf, blocksize, &got);
|
buf, blocksize, &got);
|
||||||
if (retval)
|
if (retval)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fs_blocknr == bitmap_to_dump) {
|
if (fs_blocknr == bitmap_to_dump) {
|
||||||
struct ext2_super_block *super;
|
struct ext2_super_block *super;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
super = current_fs->super;
|
super = current_fs->super;
|
||||||
offset = ((fs_blocknr - super->s_first_data_block) %
|
offset = ((fs_blocknr - super->s_first_data_block) %
|
||||||
super->s_blocks_per_group);
|
super->s_blocks_per_group);
|
||||||
|
|
||||||
fprintf(out_file, " (block bitmap for block %u: "
|
fprintf(out_file, " (block bitmap for block %u: "
|
||||||
"block is %s)\n",
|
"block is %s)\n",
|
||||||
block_to_dump,
|
block_to_dump,
|
||||||
ext2fs_test_bit(offset, buf) ? "SET" : "CLEAR");
|
ext2fs_test_bit(offset, buf) ? "SET" : "CLEAR");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs_blocknr == inode_block_to_dump) {
|
if (fs_blocknr == inode_block_to_dump) {
|
||||||
struct ext2_inode *inode;
|
struct ext2_inode *inode;
|
||||||
int first, prev, this, start_extent, i;
|
int first, prev, this, start_extent, i;
|
||||||
|
|
||||||
fprintf(out_file, " (inode block for inode %u):\n",
|
fprintf(out_file, " (inode block for inode %u):\n",
|
||||||
inode_to_dump);
|
inode_to_dump);
|
||||||
|
|
||||||
inode = (struct ext2_inode *) (buf + inode_offset_to_dump);
|
inode = (struct ext2_inode *) (buf + inode_offset_to_dump);
|
||||||
internal_dump_inode(out_file, " ", inode_to_dump, inode, 0);
|
internal_dump_inode(out_file, " ", inode_to_dump, inode, 0);
|
||||||
|
|
||||||
/* Dump out the direct/indirect blocks here:
|
/* Dump out the direct/indirect blocks here:
|
||||||
* internal_dump_inode can only dump them from the main
|
* internal_dump_inode can only dump them from the main
|
||||||
* on-disk inode, not from the journaled copy of the
|
* on-disk inode, not from the journaled copy of the
|
||||||
* inode. */
|
* inode. */
|
||||||
|
|
||||||
fprintf (out_file, " Blocks: ");
|
fprintf (out_file, " Blocks: ");
|
||||||
first = prev = start_extent = -1;
|
first = prev = start_extent = -1;
|
||||||
|
|
||||||
|
@ -655,13 +655,13 @@ static void dump_metadata_block(FILE *out_file, struct journal_source *source,
|
||||||
show_indirect(out_file, "IND", inode->i_block[i++]);
|
show_indirect(out_file, "IND", inode->i_block[i++]);
|
||||||
show_indirect(out_file, "DIND", inode->i_block[i++]);
|
show_indirect(out_file, "DIND", inode->i_block[i++]);
|
||||||
show_indirect(out_file, "TIND", inode->i_block[i++]);
|
show_indirect(out_file, "TIND", inode->i_block[i++]);
|
||||||
|
|
||||||
fprintf(out_file, "\n");
|
fprintf(out_file, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump_contents)
|
if (dump_contents)
|
||||||
do_hexdump(out_file, buf, blocksize);
|
do_hexdump(out_file, buf, blocksize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_hexdump (FILE *out_file, char *buf, int blocksize)
|
static void do_hexdump (FILE *out_file, char *buf, int blocksize)
|
||||||
|
@ -670,10 +670,10 @@ static void do_hexdump (FILE *out_file, char *buf, int blocksize)
|
||||||
int *intp;
|
int *intp;
|
||||||
char *charp;
|
char *charp;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
intp = (int *) buf;
|
intp = (int *) buf;
|
||||||
charp = (char *) buf;
|
charp = (char *) buf;
|
||||||
|
|
||||||
for (i=0; i<blocksize; i+=16) {
|
for (i=0; i<blocksize; i+=16) {
|
||||||
fprintf(out_file, " %04x: ", i);
|
fprintf(out_file, " %04x: ", i);
|
||||||
for (j=0; j<16; j+=4)
|
for (j=0; j<16; j+=4)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ls.c --- list directories
|
* ls.c --- list directories
|
||||||
*
|
*
|
||||||
* Copyright (C) 1997 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 1997 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +40,7 @@ struct list_dir_struct {
|
||||||
|
|
||||||
static const char *monstr[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
static const char *monstr[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
|
||||||
static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
|
static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
|
||||||
int entry,
|
int entry,
|
||||||
struct ext2_dir_entry *dirent,
|
struct ext2_dir_entry *dirent,
|
||||||
|
@ -127,7 +127,7 @@ void do_list_dir(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
int flags;
|
int flags;
|
||||||
struct list_dir_struct ls;
|
struct list_dir_struct ls;
|
||||||
|
|
||||||
ls.options = 0;
|
ls.options = 0;
|
||||||
if (check_fs_open(argv[0]))
|
if (check_fs_open(argv[0]))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lsdel.c --- routines to try to help a user recover a deleted file.
|
* lsdel.c --- routines to try to help a user recover a deleted file.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
* Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||||
* Theodore Ts'o. This file may be redistributed under the terms of
|
* Theodore Ts'o. This file may be redistributed under the terms of
|
||||||
* the GNU Public License.
|
* the GNU Public License.
|
||||||
|
@ -85,7 +85,7 @@ void do_lsdel(int argc, char **argv)
|
||||||
char *tmp;
|
char *tmp;
|
||||||
time_t now;
|
time_t now;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
||||||
if (common_args_process(argc, argv, 1, 2, "ls_deleted_inodes",
|
if (common_args_process(argc, argv, 1, 2, "ls_deleted_inodes",
|
||||||
"[secs]", 0))
|
"[secs]", 0))
|
||||||
return;
|
return;
|
||||||
|
@ -129,7 +129,7 @@ void do_lsdel(int argc, char **argv)
|
||||||
"while starting inode scan");
|
"while starting inode scan");
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ino) {
|
while (ino) {
|
||||||
if ((inode.i_dtime == 0) ||
|
if ((inode.i_dtime == 0) ||
|
||||||
(secs && ((unsigned) abs(now - secs) > inode.i_dtime)))
|
(secs && ((unsigned) abs(now - secs) > inode.i_dtime)))
|
||||||
|
@ -139,7 +139,7 @@ void do_lsdel(int argc, char **argv)
|
||||||
lsd.num_blocks = 0;
|
lsd.num_blocks = 0;
|
||||||
lsd.free_blocks = 0;
|
lsd.free_blocks = 0;
|
||||||
lsd.bad_blocks = 0;
|
lsd.bad_blocks = 0;
|
||||||
|
|
||||||
retval = ext2fs_block_iterate2(current_fs, ino,
|
retval = ext2fs_block_iterate2(current_fs, ino,
|
||||||
BLOCK_FLAG_READ_ONLY, block_buf,
|
BLOCK_FLAG_READ_ONLY, block_buf,
|
||||||
lsdel_proc, &lsd);
|
lsdel_proc, &lsd);
|
||||||
|
@ -160,20 +160,20 @@ void do_lsdel(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delarray[num_delarray].ino = ino;
|
delarray[num_delarray].ino = ino;
|
||||||
delarray[num_delarray].mode = inode.i_mode;
|
delarray[num_delarray].mode = inode.i_mode;
|
||||||
delarray[num_delarray].uid = inode_uid(inode);
|
delarray[num_delarray].uid = inode_uid(inode);
|
||||||
delarray[num_delarray].size = inode.i_size;
|
delarray[num_delarray].size = inode.i_size;
|
||||||
if (!LINUX_S_ISDIR(inode.i_mode))
|
if (!LINUX_S_ISDIR(inode.i_mode))
|
||||||
delarray[num_delarray].size |=
|
delarray[num_delarray].size |=
|
||||||
((__u64) inode.i_size_high << 32);
|
((__u64) inode.i_size_high << 32);
|
||||||
delarray[num_delarray].dtime = inode.i_dtime;
|
delarray[num_delarray].dtime = inode.i_dtime;
|
||||||
delarray[num_delarray].num_blocks = lsd.num_blocks;
|
delarray[num_delarray].num_blocks = lsd.num_blocks;
|
||||||
delarray[num_delarray].free_blocks = lsd.free_blocks;
|
delarray[num_delarray].free_blocks = lsd.free_blocks;
|
||||||
num_delarray++;
|
num_delarray++;
|
||||||
}
|
}
|
||||||
|
|
||||||
next:
|
next:
|
||||||
do {
|
do {
|
||||||
retval = ext2fs_get_next_inode(scan, &ino, &inode);
|
retval = ext2fs_get_next_inode(scan, &ino, &inode);
|
||||||
|
@ -186,22 +186,22 @@ void do_lsdel(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
out = open_pager();
|
out = open_pager();
|
||||||
|
|
||||||
fprintf(out, " Inode Owner Mode Size Blocks Time deleted\n");
|
fprintf(out, " Inode Owner Mode Size Blocks Time deleted\n");
|
||||||
|
|
||||||
qsort(delarray, num_delarray, sizeof(struct deleted_info),
|
qsort(delarray, num_delarray, sizeof(struct deleted_info),
|
||||||
deleted_info_compare);
|
deleted_info_compare);
|
||||||
|
|
||||||
for (i = 0; i < num_delarray; i++) {
|
for (i = 0; i < num_delarray; i++) {
|
||||||
fprintf(out, "%6u %6d %6o %6llu %6lld/%6lld %s",
|
fprintf(out, "%6u %6d %6o %6llu %6lld/%6lld %s",
|
||||||
delarray[i].ino,
|
delarray[i].ino,
|
||||||
delarray[i].uid, delarray[i].mode, delarray[i].size,
|
delarray[i].uid, delarray[i].mode, delarray[i].size,
|
||||||
delarray[i].free_blocks, delarray[i].num_blocks,
|
delarray[i].free_blocks, delarray[i].num_blocks,
|
||||||
time_to_string(delarray[i].dtime));
|
time_to_string(delarray[i].dtime));
|
||||||
}
|
}
|
||||||
fprintf(out, "%d deleted inodes found.\n", num_delarray);
|
fprintf(out, "%d deleted inodes found.\n", num_delarray);
|
||||||
close_pager(out);
|
close_pager(out);
|
||||||
|
|
||||||
error_out:
|
error_out:
|
||||||
free(block_buf);
|
free(block_buf);
|
||||||
free(delarray);
|
free(delarray);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ncheck.c --- given a list of inodes, generate a list of names
|
* ncheck.c --- given a list of inodes, generate a list of names
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -52,7 +52,7 @@ static int ncheck_proc(struct ext2_dir_entry *dirent,
|
||||||
}
|
}
|
||||||
if (!iw->inodes_left)
|
if (!iw->inodes_left)
|
||||||
return DIRENT_ABORT;
|
return DIRENT_ABORT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void do_ncheck(int argc, char **argv)
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
com_err(argv[0], 0, "Usage: ncheck <inode number> ...");
|
com_err(argv[0], 0, "Usage: ncheck <inode number> ...");
|
||||||
return;
|
return;
|
||||||
|
@ -105,7 +105,7 @@ void do_ncheck(int argc, char **argv)
|
||||||
com_err("ncheck", retval, "while starting inode scan");
|
com_err("ncheck", retval, "while starting inode scan");
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ino) {
|
while (ino) {
|
||||||
if (!inode.i_links_count)
|
if (!inode.i_links_count)
|
||||||
goto next;
|
goto next;
|
||||||
|
@ -121,7 +121,7 @@ void do_ncheck(int argc, char **argv)
|
||||||
|
|
||||||
iw.position = 0;
|
iw.position = 0;
|
||||||
iw.parent = ino;
|
iw.parent = ino;
|
||||||
|
|
||||||
retval = ext2fs_dir_iterate(current_fs, ino, 0, 0,
|
retval = ext2fs_dir_iterate(current_fs, ino, 0, 0,
|
||||||
ncheck_proc, &iw);
|
ncheck_proc, &iw);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
@ -155,7 +155,7 @@ void do_ncheck(int argc, char **argv)
|
||||||
"while resolving pathname for inode %d (%d)",
|
"while resolving pathname for inode %d (%d)",
|
||||||
iinfo->parent, iinfo->ino);
|
iinfo->parent, iinfo->ino);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Inode\tPathname\n");
|
printf("Inode\tPathname\n");
|
||||||
for (i=0, iinfo = iw.iarray; i < iw.num_inodes; i++, iinfo++) {
|
for (i=0, iinfo = iw.iarray; i < iw.num_inodes; i++, iinfo++) {
|
||||||
if (iinfo->parent == 0) {
|
if (iinfo->parent == 0) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* set_fields.c --- set a superblock value
|
* set_fields.c --- set a superblock value
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000, 2001, 2002, 2003, 2004 by Theodore Ts'o.
|
* Copyright (C) 2000, 2001, 2002, 2003, 2004 by Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
|
@ -97,12 +97,12 @@ static struct field_set_info super_fields[] = {
|
||||||
{ "block_group_nr", &set_sb.s_block_group_nr, 2, parse_uint },
|
{ "block_group_nr", &set_sb.s_block_group_nr, 2, parse_uint },
|
||||||
{ "feature_compat", &set_sb.s_feature_compat, 4, parse_uint },
|
{ "feature_compat", &set_sb.s_feature_compat, 4, parse_uint },
|
||||||
{ "feature_incompat", &set_sb.s_feature_incompat, 4, parse_uint },
|
{ "feature_incompat", &set_sb.s_feature_incompat, 4, parse_uint },
|
||||||
{ "feature_ro_compat", &set_sb.s_feature_ro_compat, 4, parse_uint },
|
{ "feature_ro_compat", &set_sb.s_feature_ro_compat, 4, parse_uint },
|
||||||
{ "uuid", &set_sb.s_uuid, 16, parse_uuid },
|
{ "uuid", &set_sb.s_uuid, 16, parse_uuid },
|
||||||
{ "volume_name", &set_sb.s_volume_name, 16, parse_string },
|
{ "volume_name", &set_sb.s_volume_name, 16, parse_string },
|
||||||
{ "last_mounted", &set_sb.s_last_mounted, 64, parse_string },
|
{ "last_mounted", &set_sb.s_last_mounted, 64, parse_string },
|
||||||
{ "lastcheck", &set_sb.s_lastcheck, 4, parse_uint },
|
{ "lastcheck", &set_sb.s_lastcheck, 4, parse_uint },
|
||||||
{ "algorithm_usage_bitmap", &set_sb.s_algorithm_usage_bitmap,
|
{ "algorithm_usage_bitmap", &set_sb.s_algorithm_usage_bitmap,
|
||||||
4, parse_uint },
|
4, parse_uint },
|
||||||
{ "prealloc_blocks", &set_sb.s_prealloc_blocks, 1, parse_uint },
|
{ "prealloc_blocks", &set_sb.s_prealloc_blocks, 1, parse_uint },
|
||||||
{ "prealloc_dir_blocks", &set_sb.s_prealloc_dir_blocks, 1,
|
{ "prealloc_dir_blocks", &set_sb.s_prealloc_dir_blocks, 1,
|
||||||
|
@ -120,7 +120,7 @@ static struct field_set_info super_fields[] = {
|
||||||
{ "default_mount_opts", &set_sb.s_default_mount_opts, 4, parse_uint },
|
{ "default_mount_opts", &set_sb.s_default_mount_opts, 4, parse_uint },
|
||||||
{ "first_meta_bg", &set_sb.s_first_meta_bg, 4, parse_uint },
|
{ "first_meta_bg", &set_sb.s_first_meta_bg, 4, parse_uint },
|
||||||
{ "mkfs_time", &set_sb.s_mkfs_time, 4, parse_time },
|
{ "mkfs_time", &set_sb.s_mkfs_time, 4, parse_time },
|
||||||
{ "jnl_blocks", &set_sb.s_jnl_blocks[0], 4, parse_uint, FLAG_ARRAY,
|
{ "jnl_blocks", &set_sb.s_jnl_blocks[0], 4, parse_uint, FLAG_ARRAY,
|
||||||
17 },
|
17 },
|
||||||
{ "blocks_count_hi", &set_sb.s_blocks_count_hi, 4, parse_uint },
|
{ "blocks_count_hi", &set_sb.s_blocks_count_hi, 4, parse_uint },
|
||||||
{ "r_blocks_count_hi", &set_sb.s_r_blocks_count_hi, 4, parse_uint },
|
{ "r_blocks_count_hi", &set_sb.s_r_blocks_count_hi, 4, parse_uint },
|
||||||
|
@ -151,7 +151,7 @@ static struct field_set_info inode_fields[] = {
|
||||||
{ "flags", &set_inode.i_flags, 4, parse_uint },
|
{ "flags", &set_inode.i_flags, 4, parse_uint },
|
||||||
{ "version", &set_inode.osd1.linux1.l_i_version, 4, parse_uint },
|
{ "version", &set_inode.osd1.linux1.l_i_version, 4, parse_uint },
|
||||||
{ "translator", &set_inode.osd1.hurd1.h_i_translator, 4, parse_uint },
|
{ "translator", &set_inode.osd1.hurd1.h_i_translator, 4, parse_uint },
|
||||||
{ "block", &set_inode.i_block[0], 4, parse_uint, FLAG_ARRAY,
|
{ "block", &set_inode.i_block[0], 4, parse_uint, FLAG_ARRAY,
|
||||||
EXT2_NDIR_BLOCKS },
|
EXT2_NDIR_BLOCKS },
|
||||||
{ "block[IND]", &set_inode.i_block[EXT2_IND_BLOCK], 4, parse_uint },
|
{ "block[IND]", &set_inode.i_block[EXT2_IND_BLOCK], 4, parse_uint },
|
||||||
{ "block[DIND]", &set_inode.i_block[EXT2_DIND_BLOCK], 4, parse_uint },
|
{ "block[DIND]", &set_inode.i_block[EXT2_DIND_BLOCK], 4, parse_uint },
|
||||||
|
@ -218,7 +218,7 @@ static struct field_set_info *find_field(struct field_set_info *fields,
|
||||||
else
|
else
|
||||||
*delim = 0;
|
*delim = 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Can we parse the number?
|
* Can we parse the number?
|
||||||
*/
|
*/
|
||||||
if (idx) {
|
if (idx) {
|
||||||
|
@ -353,7 +353,7 @@ static errcode_t parse_time(struct field_set_info *info, char *arg)
|
||||||
static errcode_t parse_uuid(struct field_set_info *info, char *arg)
|
static errcode_t parse_uuid(struct field_set_info *info, char *arg)
|
||||||
{
|
{
|
||||||
unsigned char * p = (unsigned char *) info->ptr;
|
unsigned char * p = (unsigned char *) info->ptr;
|
||||||
|
|
||||||
if ((strcasecmp(arg, "null") == 0) ||
|
if ((strcasecmp(arg, "null") == 0) ||
|
||||||
(strcasecmp(arg, "clear") == 0)) {
|
(strcasecmp(arg, "clear") == 0)) {
|
||||||
uuid_clear(p);
|
uuid_clear(p);
|
||||||
|
@ -397,7 +397,7 @@ static errcode_t parse_bmap(struct field_set_info *info, char *arg)
|
||||||
}
|
}
|
||||||
blk = num;
|
blk = num;
|
||||||
|
|
||||||
retval = ext2fs_bmap(current_fs, set_ino, &set_inode, 0, BMAP_SET,
|
retval = ext2fs_bmap(current_fs, set_ino, &set_inode, 0, BMAP_SET,
|
||||||
array_idx, &blk);
|
array_idx, &blk);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err("set_inode", retval, "while setting block map");
|
com_err("set_inode", retval, "while setting block map");
|
||||||
|
@ -411,7 +411,7 @@ static errcode_t parse_gd_csum(struct field_set_info *info, char *arg)
|
||||||
if (strcmp(arg, "calc") == 0) {
|
if (strcmp(arg, "calc") == 0) {
|
||||||
ext2fs_group_desc_csum_set(current_fs, set_bg);
|
ext2fs_group_desc_csum_set(current_fs, set_bg);
|
||||||
set_gd = current_fs->group_desc[set_bg];
|
set_gd = current_fs->group_desc[set_bg];
|
||||||
printf("Checksum set to 0x%04x\n",
|
printf("Checksum set to 0x%04x\n",
|
||||||
current_fs->group_desc[set_bg].bg_checksum);
|
current_fs->group_desc[set_bg].bg_checksum);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ static void print_possible_fields(struct field_set_info *fields)
|
||||||
type = "set physical->logical block map";
|
type = "set physical->logical block map";
|
||||||
strcpy(name, ss->name);
|
strcpy(name, ss->name);
|
||||||
if (ss->flags & FLAG_ARRAY) {
|
if (ss->flags & FLAG_ARRAY) {
|
||||||
if (ss->max_idx > 0)
|
if (ss->max_idx > 0)
|
||||||
sprintf(idx, "[%d]", ss->max_idx);
|
sprintf(idx, "[%d]", ss->max_idx);
|
||||||
else
|
else
|
||||||
strcpy(idx, "[]");
|
strcpy(idx, "[]");
|
||||||
|
@ -476,7 +476,7 @@ void do_set_super(int argc, char *argv[])
|
||||||
"\t\"set_super_value -l\" will list the names of "
|
"\t\"set_super_value -l\" will list the names of "
|
||||||
"superblock fields\n\twhich can be set.";
|
"superblock fields\n\twhich can be set.";
|
||||||
static struct field_set_info *ss;
|
static struct field_set_info *ss;
|
||||||
|
|
||||||
if ((argc == 2) && !strcmp(argv[1], "-l")) {
|
if ((argc == 2) && !strcmp(argv[1], "-l")) {
|
||||||
print_possible_fields(super_fields);
|
print_possible_fields(super_fields);
|
||||||
return;
|
return;
|
||||||
|
@ -503,7 +503,7 @@ void do_set_inode(int argc, char *argv[])
|
||||||
"\t\"set_inode_field -l\" will list the names of "
|
"\t\"set_inode_field -l\" will list the names of "
|
||||||
"the fields in an ext2 inode\n\twhich can be set.";
|
"the fields in an ext2 inode\n\twhich can be set.";
|
||||||
static struct field_set_info *ss;
|
static struct field_set_info *ss;
|
||||||
|
|
||||||
if ((argc == 2) && !strcmp(argv[1], "-l")) {
|
if ((argc == 2) && !strcmp(argv[1], "-l")) {
|
||||||
print_possible_fields(inode_fields);
|
print_possible_fields(inode_fields);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* unused.c --- quick and dirty unused space dumper
|
* unused.c --- quick and dirty unused space dumper
|
||||||
*
|
*
|
||||||
* Copyright (C) 1997 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 1997 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* util.c --- utilities for the debugfs program
|
* util.c --- utilities for the debugfs program
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
|
* Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
|
||||||
* redistributed under the terms of the GNU Public License.
|
* redistributed under the terms of the GNU Public License.
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +40,7 @@ extern int optreset; /* defined by BSD, but not others */
|
||||||
* affairs is that BSD-derived versions of getopt() misbehave if
|
* affairs is that BSD-derived versions of getopt() misbehave if
|
||||||
* optind is set to 0 in order to reset getopt(), and glibc's getopt()
|
* optind is set to 0 in order to reset getopt(), and glibc's getopt()
|
||||||
* will core dump if optind is set 1 in order to reset getopt().
|
* will core dump if optind is set 1 in order to reset getopt().
|
||||||
*
|
*
|
||||||
* More modern versions of BSD require that optreset be set to 1 in
|
* More modern versions of BSD require that optreset be set to 1 in
|
||||||
* order to reset getopt(). Sigh. Standards, anyone?
|
* order to reset getopt(). Sigh. Standards, anyone?
|
||||||
*
|
*
|
||||||
|
@ -88,7 +88,7 @@ FILE *open_pager(void)
|
||||||
pager = getenv("PAGER");
|
pager = getenv("PAGER");
|
||||||
if (!pager)
|
if (!pager)
|
||||||
pager = find_pager(buf);
|
pager = find_pager(buf);
|
||||||
if (!pager ||
|
if (!pager ||
|
||||||
(strcmp(pager, "__none__") == 0) ||
|
(strcmp(pager, "__none__") == 0) ||
|
||||||
((outfile = popen(pager, "w")) == 0))
|
((outfile = popen(pager, "w")) == 0))
|
||||||
return stdout;
|
return stdout;
|
||||||
|
@ -251,7 +251,7 @@ unsigned long parse_ulong(const char *str, const char *cmd,
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
|
|
||||||
ret = strtoul(str, &tmp, 0);
|
ret = strtoul(str, &tmp, 0);
|
||||||
if (*tmp == 0) {
|
if (*tmp == 0) {
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -317,9 +317,9 @@ int common_inode_args_process(int argc, char *argv[],
|
||||||
{
|
{
|
||||||
if (common_args_process(argc, argv, 2, 2, argv[0], "<file>", flags))
|
if (common_args_process(argc, argv, 2, 2, argv[0], "<file>", flags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
*inode = string_to_inode(argv[1]);
|
*inode = string_to_inode(argv[1]);
|
||||||
if (!*inode)
|
if (!*inode)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* argv_parse.c --- utility function for parsing a string into a
|
* argv_parse.c --- utility function for parsing a string into a
|
||||||
* argc, argv array.
|
* argc, argv array.
|
||||||
*
|
*
|
||||||
* This file defines a function argv_parse() which parsing a
|
* This file defines a function argv_parse() which parsing a
|
||||||
* passed-in string, handling double quotes and backslashes, and
|
* passed-in string, handling double quotes and backslashes, and
|
||||||
* creates an allocated argv vector which can be freed using the
|
* creates an allocated argv vector which can be freed using the
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
* See argv_parse.h for the formal definition of the functions.
|
* See argv_parse.h for the formal definition of the functions.
|
||||||
*
|
*
|
||||||
* Copyright 1999 by Theodore Ts'o.
|
* Copyright 1999 by Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for
|
* Permission to use, copy, modify, and distribute this software for
|
||||||
* any purpose with or without fee is hereby granted, provided that
|
* any purpose with or without fee is hereby granted, provided that
|
||||||
* the above copyright notice and this permission notice appear in all
|
* the above copyright notice and this permission notice appear in all
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* This file defines the interface for the functions argv_parse() and
|
* This file defines the interface for the functions argv_parse() and
|
||||||
* argv_free().
|
* argv_free().
|
||||||
*
|
*
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
|
* int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
|
||||||
*
|
*
|
||||||
|
@ -16,12 +16,12 @@
|
||||||
* ret_argc and ret_argv, respectively.
|
* ret_argc and ret_argv, respectively.
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
* extern void argv_free(char **argv);
|
* extern void argv_free(char **argv);
|
||||||
*
|
*
|
||||||
* This function frees the argument vector created by argv_parse().
|
* This function frees the argument vector created by argv_parse().
|
||||||
***********************************************************************
|
***********************************************************************
|
||||||
*
|
*
|
||||||
* Copyright 1999 by Theodore Ts'o.
|
* Copyright 1999 by Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for
|
* Permission to use, copy, modify, and distribute this software for
|
||||||
* any purpose with or without fee is hereby granted, provided that
|
* any purpose with or without fee is hereby granted, provided that
|
||||||
* the above copyright notice and this permission notice appear in all
|
* the above copyright notice and this permission notice appear in all
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* badblocks.c --- replace/append bad blocks to the bad block inode
|
* badblocks.c --- replace/append bad blocks to the bad block inode
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
|
* Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
|
||||||
* redistributed under the terms of the GNU Public License.
|
* redistributed under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +45,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
|
||||||
_("while sanity checking the bad blocks inode"));
|
_("while sanity checking the bad blocks inode"));
|
||||||
goto fatal;
|
goto fatal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we're appending to the bad blocks inode, read in the
|
* If we're appending to the bad blocks inode, read in the
|
||||||
* current bad blocks.
|
* current bad blocks.
|
||||||
|
@ -58,7 +58,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
|
||||||
goto fatal;
|
goto fatal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now read in the bad blocks from the file; if
|
* Now read in the bad blocks from the file; if
|
||||||
* bad_blocks_file is null, then try to run the badblocks
|
* bad_blocks_file is null, then try to run the badblocks
|
||||||
|
@ -84,7 +84,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retval = ext2fs_read_bb_FILE(fs, f, &bb_list, invalid_block);
|
retval = ext2fs_read_bb_FILE(fs, f, &bb_list, invalid_block);
|
||||||
if (bad_blocks_file)
|
if (bad_blocks_file)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
else
|
else
|
||||||
pclose(f);
|
pclose(f);
|
||||||
|
@ -93,7 +93,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
|
||||||
_("while reading in list of bad blocks from file"));
|
_("while reading in list of bad blocks from file"));
|
||||||
goto fatal;
|
goto fatal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finally, update the bad blocks from the bad_block_map
|
* Finally, update the bad blocks from the bad_block_map
|
||||||
*/
|
*/
|
||||||
|
@ -107,15 +107,15 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
|
||||||
|
|
||||||
ext2fs_badblocks_list_free(bb_list);
|
ext2fs_badblocks_list_free(bb_list);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fatal:
|
fatal:
|
||||||
ctx->flags |= E2F_FLAG_ABORT;
|
ctx->flags |= E2F_FLAG_ABORT;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_bb_inode_blocks(ext2_filsys fs,
|
static int check_bb_inode_blocks(ext2_filsys fs,
|
||||||
blk_t *block_nr,
|
blk_t *block_nr,
|
||||||
int blockcnt EXT2FS_ATTR((unused)),
|
int blockcnt EXT2FS_ATTR((unused)),
|
||||||
void *priv_data EXT2FS_ATTR((unused)))
|
void *priv_data EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@ static const char rcsid[] = "$Id: dict.c,v 1.40.2.7 2000/11/13 01:36:44 kaz Exp
|
||||||
/*
|
/*
|
||||||
* These macros provide short convenient names for structure members,
|
* These macros provide short convenient names for structure members,
|
||||||
* which are embellished with dict_ prefixes so that they are
|
* which are embellished with dict_ prefixes so that they are
|
||||||
* properly confined to the documented namespace. It's legal for a
|
* properly confined to the documented namespace. It's legal for a
|
||||||
* program which uses dict to define, for instance, a macro called ``parent''.
|
* program which uses dict to define, for instance, a macro called ``parent''.
|
||||||
* Such a macro would interfere with the dnode_t struct definition.
|
* Such a macro would interfere with the dnode_t struct definition.
|
||||||
* In general, highly portable and reusable C modules which expose their
|
* In general, highly portable and reusable C modules which expose their
|
||||||
|
@ -150,7 +150,7 @@ static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
|
||||||
* dict_next() successor function, verifying that the key of each node is
|
* dict_next() successor function, verifying that the key of each node is
|
||||||
* strictly lower than that of its successor, if duplicates are not allowed,
|
* strictly lower than that of its successor, if duplicates are not allowed,
|
||||||
* or lower or equal if duplicates are allowed. This function is used for
|
* or lower or equal if duplicates are allowed. This function is used for
|
||||||
* debugging purposes.
|
* debugging purposes.
|
||||||
*/
|
*/
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
static int verify_bintree(dict_t *dict)
|
static int verify_bintree(dict_t *dict)
|
||||||
|
@ -209,7 +209,7 @@ static unsigned int verify_redblack(dnode_t *nil, dnode_t *root)
|
||||||
if (root->color != dnode_black)
|
if (root->color != dnode_black)
|
||||||
return 0;
|
return 0;
|
||||||
return height_left + 1;
|
return height_left + 1;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef E2FSCK_NOTUSED
|
#ifdef E2FSCK_NOTUSED
|
||||||
/*
|
/*
|
||||||
* Initialize a dictionary in the likeness of another dictionary
|
* Initialize a dictionary in the likeness of another dictionary
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ static void dict_clear(dict_t *dict)
|
||||||
* debugging purposes, and should be placed in assert statements. Just because
|
* debugging purposes, and should be placed in assert statements. Just because
|
||||||
* this function succeeds doesn't mean that the tree is not corrupt. Certain
|
* this function succeeds doesn't mean that the tree is not corrupt. Certain
|
||||||
* corruptions in the tree may simply cause undefined behavior.
|
* corruptions in the tree may simply cause undefined behavior.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int dict_verify(dict_t *dict)
|
int dict_verify(dict_t *dict)
|
||||||
{
|
{
|
||||||
|
@ -446,7 +446,7 @@ int dict_similar(const dict_t *left, const dict_t *right)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate a node in the dictionary having the given key.
|
* Locate a node in the dictionary having the given key.
|
||||||
* If the node is not found, a null a pointer is returned (rather than
|
* If the node is not found, a null a pointer is returned (rather than
|
||||||
* a pointer that dictionary's nil sentinel node), otherwise a pointer to the
|
* a pointer that dictionary's nil sentinel node), otherwise a pointer to the
|
||||||
* located node is returned.
|
* located node is returned.
|
||||||
*/
|
*/
|
||||||
|
@ -511,9 +511,9 @@ dnode_t *dict_lower_bound(dict_t *dict, const void *key)
|
||||||
tentative = root;
|
tentative = root;
|
||||||
root = root->left;
|
root = root->left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tentative;
|
return tentative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,9 +543,9 @@ dnode_t *dict_upper_bound(dict_t *dict, const void *key)
|
||||||
tentative = root;
|
tentative = root;
|
||||||
root = root->right;
|
root = root->right;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tentative;
|
return tentative;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -727,10 +727,10 @@ dnode_t *dict_delete(dict_t *dict, dnode_t *delete)
|
||||||
|
|
||||||
child = (delete->left != nil) ? delete->left : delete->right;
|
child = (delete->left != nil) ? delete->left : delete->right;
|
||||||
|
|
||||||
child->parent = delparent = delete->parent;
|
child->parent = delparent = delete->parent;
|
||||||
|
|
||||||
if (delete == delparent->left) {
|
if (delete == delparent->left) {
|
||||||
delparent->left = child;
|
delparent->left = child;
|
||||||
} else {
|
} else {
|
||||||
assert (delete == delparent->right);
|
assert (delete == delparent->right);
|
||||||
delparent->right = child;
|
delparent->right = child;
|
||||||
|
@ -1058,7 +1058,7 @@ void dict_load_next(dict_load_t *load, dnode_t *newnode, const void *key)
|
||||||
{
|
{
|
||||||
dict_t *dict = load->dictptr;
|
dict_t *dict = load->dictptr;
|
||||||
dnode_t *nil = &load->nilnode;
|
dnode_t *nil = &load->nilnode;
|
||||||
|
|
||||||
assert (!dnode_is_in_a_dict(newnode));
|
assert (!dnode_is_in_a_dict(newnode));
|
||||||
assert (dict->nodecount < dict->maxcount);
|
assert (dict->nodecount < dict->maxcount);
|
||||||
|
|
||||||
|
@ -1164,7 +1164,7 @@ void dict_merge(dict_t *dest, dict_t *source)
|
||||||
dict_load_t load;
|
dict_load_t load;
|
||||||
dnode_t *leftnode = dict_first(dest), *rightnode = dict_first(source);
|
dnode_t *leftnode = dict_first(dest), *rightnode = dict_first(source);
|
||||||
|
|
||||||
assert (dict_similar(dest, source));
|
assert (dict_similar(dest, source));
|
||||||
|
|
||||||
if (source == dest)
|
if (source == dest)
|
||||||
return;
|
return;
|
||||||
|
@ -1197,7 +1197,7 @@ void dict_merge(dict_t *dest, dict_t *source)
|
||||||
leftnode = next;
|
leftnode = next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyright:
|
copyright:
|
||||||
{
|
{
|
||||||
dnode_t *next = dict_next(source, rightnode);
|
dnode_t *next = dict_next(source, rightnode);
|
||||||
|
@ -1226,7 +1226,7 @@ typedef char input_t[256];
|
||||||
|
|
||||||
static int tokenize(char *string, ...)
|
static int tokenize(char *string, ...)
|
||||||
{
|
{
|
||||||
char **tokptr;
|
char **tokptr;
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
int tokcount = 0;
|
int tokcount = 0;
|
||||||
|
|
||||||
|
@ -1290,7 +1290,7 @@ static void construct(dict_t *d)
|
||||||
dnode_t *dn;
|
dnode_t *dn;
|
||||||
char *tok1, *tok2, *val;
|
char *tok1, *tok2, *val;
|
||||||
const char *key;
|
const char *key;
|
||||||
char *help =
|
char *help =
|
||||||
"p turn prompt on\n"
|
"p turn prompt on\n"
|
||||||
"q finish construction\n"
|
"q finish construction\n"
|
||||||
"a <key> <val> add new entry\n";
|
"a <key> <val> add new entry\n";
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
/*
|
/*
|
||||||
* This subroutine is called during pass1 to create a directory info
|
* This subroutine is called during pass1 to create a directory info
|
||||||
* entry. During pass1, the passed-in parent is 0; it will get filled
|
* entry. During pass1, the passed-in parent is 0; it will get filled
|
||||||
* in during pass2.
|
* in during pass2.
|
||||||
*/
|
*/
|
||||||
void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
|
void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
|
||||||
* sizeof (struct dx_dir_info),
|
* sizeof (struct dx_dir_info),
|
||||||
"directory map");
|
"directory map");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->dx_dir_info_count >= ctx->dx_dir_info_size) {
|
if (ctx->dx_dir_info_count >= ctx->dx_dir_info_size) {
|
||||||
old_size = ctx->dx_dir_info_size * sizeof(struct dx_dir_info);
|
old_size = ctx->dx_dir_info_size * sizeof(struct dx_dir_info);
|
||||||
ctx->dx_dir_info_size += 10;
|
ctx->dx_dir_info_size += 10;
|
||||||
|
@ -59,12 +59,12 @@ void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
|
||||||
if (ctx->dx_dir_info[i-1].ino < ino)
|
if (ctx->dx_dir_info[i-1].ino < ino)
|
||||||
break;
|
break;
|
||||||
dir = &ctx->dx_dir_info[i];
|
dir = &ctx->dx_dir_info[i];
|
||||||
if (dir->ino != ino)
|
if (dir->ino != ino)
|
||||||
for (j = ctx->dx_dir_info_count++; j > i; j--)
|
for (j = ctx->dx_dir_info_count++; j > i; j--)
|
||||||
ctx->dx_dir_info[j] = ctx->dx_dir_info[j-1];
|
ctx->dx_dir_info[j] = ctx->dx_dir_info[j-1];
|
||||||
} else
|
} else
|
||||||
dir = &ctx->dx_dir_info[ctx->dx_dir_info_count++];
|
dir = &ctx->dx_dir_info[ctx->dx_dir_info_count++];
|
||||||
|
|
||||||
dir->ino = ino;
|
dir->ino = ino;
|
||||||
dir->numblocks = num_blocks;
|
dir->numblocks = num_blocks;
|
||||||
dir->hashversion = 0;
|
dir->hashversion = 0;
|
||||||
|
@ -112,7 +112,7 @@ void e2fsck_free_dx_dir_info(e2fsck_t ctx)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct dx_dir_info *dir;
|
struct dx_dir_info *dir;
|
||||||
|
|
||||||
if (ctx->dx_dir_info) {
|
if (ctx->dx_dir_info) {
|
||||||
dir = ctx->dx_dir_info;
|
dir = ctx->dx_dir_info;
|
||||||
for (i=0; i < ctx->dx_dir_info_count; i++) {
|
for (i=0; i < ctx->dx_dir_info_count; i++) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* e2fsck.c - a consistency checker for the new extended file system.
|
* e2fsck.c - a consistency checker for the new extended file system.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
#include "problem.h"
|
#include "problem.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function allocates an e2fsck context
|
* This function allocates an e2fsck context
|
||||||
*/
|
*/
|
||||||
errcode_t e2fsck_allocate_context(e2fsck_t *ret)
|
errcode_t e2fsck_allocate_context(e2fsck_t *ret)
|
||||||
{
|
{
|
||||||
|
@ -26,13 +26,13 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
|
||||||
retval = ext2fs_get_mem(sizeof(struct e2fsck_struct), &context);
|
retval = ext2fs_get_mem(sizeof(struct e2fsck_struct), &context);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
memset(context, 0, sizeof(struct e2fsck_struct));
|
memset(context, 0, sizeof(struct e2fsck_struct));
|
||||||
|
|
||||||
context->process_inode_size = 256;
|
context->process_inode_size = 256;
|
||||||
context->ext_attr_ver = 2;
|
context->ext_attr_ver = 2;
|
||||||
context->blocks_per_page = 1;
|
context->blocks_per_page = 1;
|
||||||
|
|
||||||
time_env = getenv("E2FSCK_TIME");
|
time_env = getenv("E2FSCK_TIME");
|
||||||
if (time_env)
|
if (time_env)
|
||||||
context->now = strtoul(time_env, NULL, 0);
|
context->now = strtoul(time_env, NULL, 0);
|
||||||
|
@ -159,7 +159,7 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
|
||||||
|
|
||||||
/* Reset the superblock to the user's requested value */
|
/* Reset the superblock to the user's requested value */
|
||||||
ctx->superblock = ctx->use_superblock;
|
ctx->superblock = ctx->use_superblock;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ void e2fsck_free_context(e2fsck_t ctx)
|
||||||
{
|
{
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e2fsck_reset_context(ctx);
|
e2fsck_reset_context(ctx);
|
||||||
if (ctx->blkid)
|
if (ctx->blkid)
|
||||||
blkid_put_cache(ctx->blkid);
|
blkid_put_cache(ctx->blkid);
|
||||||
|
@ -177,10 +177,10 @@ void e2fsck_free_context(e2fsck_t ctx)
|
||||||
|
|
||||||
if (ctx->filesystem_name)
|
if (ctx->filesystem_name)
|
||||||
ext2fs_free_mem(&ctx->filesystem_name);
|
ext2fs_free_mem(&ctx->filesystem_name);
|
||||||
|
|
||||||
if (ctx->device_name)
|
if (ctx->device_name)
|
||||||
ext2fs_free_mem(&ctx->device_name);
|
ext2fs_free_mem(&ctx->device_name);
|
||||||
|
|
||||||
ext2fs_free_mem(&ctx);
|
ext2fs_free_mem(&ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ int e2fsck_run(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
ctx->flags |= E2F_FLAG_SETJMP_OK;
|
ctx->flags |= E2F_FLAG_SETJMP_OK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) {
|
for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) {
|
||||||
if (ctx->flags & E2F_FLAG_RUN_RETURN)
|
if (ctx->flags & E2F_FLAG_RUN_RETURN)
|
||||||
break;
|
break;
|
||||||
|
@ -217,7 +217,7 @@ int e2fsck_run(e2fsck_t ctx)
|
||||||
(void) (ctx->progress)(ctx, 0, 0, 0);
|
(void) (ctx->progress)(ctx, 0, 0, 0);
|
||||||
}
|
}
|
||||||
ctx->flags &= ~E2F_FLAG_SETJMP_OK;
|
ctx->flags &= ~E2F_FLAG_SETJMP_OK;
|
||||||
|
|
||||||
if (ctx->flags & E2F_FLAG_RUN_RETURN)
|
if (ctx->flags & E2F_FLAG_RUN_RETURN)
|
||||||
return (ctx->flags & E2F_FLAG_RUN_RETURN);
|
return (ctx->flags & E2F_FLAG_RUN_RETURN);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* e2fsck.h
|
* e2fsck.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
|
* Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
|
||||||
* redistributed under the terms of the GNU Public License.
|
* redistributed under the terms of the GNU Public License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _E2FSCK_H
|
#ifndef _E2FSCK_H
|
||||||
|
@ -114,9 +114,9 @@ struct dx_dirblock_info {
|
||||||
blk_t phys;
|
blk_t phys;
|
||||||
int flags;
|
int flags;
|
||||||
blk_t parent;
|
blk_t parent;
|
||||||
ext2_dirhash_t min_hash;
|
ext2_dirhash_t min_hash;
|
||||||
ext2_dirhash_t max_hash;
|
ext2_dirhash_t max_hash;
|
||||||
ext2_dirhash_t node_min_hash;
|
ext2_dirhash_t node_min_hash;
|
||||||
ext2_dirhash_t node_max_hash;
|
ext2_dirhash_t node_max_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ struct resource_track {
|
||||||
#define E2F_FLAG_PROG_BAR 0x0020 /* Progress bar on screen */
|
#define E2F_FLAG_PROG_BAR 0x0020 /* Progress bar on screen */
|
||||||
#define E2F_FLAG_PROG_SUPPRESS 0x0040 /* Progress suspended */
|
#define E2F_FLAG_PROG_SUPPRESS 0x0040 /* Progress suspended */
|
||||||
#define E2F_FLAG_JOURNAL_INODE 0x0080 /* Create a new ext3 journal inode */
|
#define E2F_FLAG_JOURNAL_INODE 0x0080 /* Create a new ext3 journal inode */
|
||||||
#define E2F_FLAG_SB_SPECIFIED 0x0100 /* The superblock was explicitly
|
#define E2F_FLAG_SB_SPECIFIED 0x0100 /* The superblock was explicitly
|
||||||
* specified by the user */
|
* specified by the user */
|
||||||
#define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */
|
#define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */
|
||||||
#define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */
|
#define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */
|
||||||
|
@ -265,7 +265,7 @@ struct e2fsck_struct {
|
||||||
*/
|
*/
|
||||||
ext2_ino_t lost_and_found;
|
ext2_ino_t lost_and_found;
|
||||||
int bad_lost_and_found;
|
int bad_lost_and_found;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Directory information
|
* Directory information
|
||||||
*/
|
*/
|
||||||
|
@ -311,7 +311,7 @@ struct e2fsck_struct {
|
||||||
unsigned int progress_last_time;
|
unsigned int progress_last_time;
|
||||||
int interactive; /* Are we connected directly to a tty? */
|
int interactive; /* Are we connected directly to a tty? */
|
||||||
char start_meta[2], stop_meta[2];
|
char start_meta[2], stop_meta[2];
|
||||||
|
|
||||||
/* File counts */
|
/* File counts */
|
||||||
__u32 fs_directory_count;
|
__u32 fs_directory_count;
|
||||||
__u32 fs_regular_count;
|
__u32 fs_regular_count;
|
||||||
|
@ -386,16 +386,16 @@ extern void e2fsck_add_dir_info(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
|
||||||
extern void e2fsck_free_dir_info(e2fsck_t ctx);
|
extern void e2fsck_free_dir_info(e2fsck_t ctx);
|
||||||
extern int e2fsck_get_num_dirinfo(e2fsck_t ctx);
|
extern int e2fsck_get_num_dirinfo(e2fsck_t ctx);
|
||||||
extern struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx);
|
extern struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx);
|
||||||
extern struct dir_info *e2fsck_dir_info_iter(e2fsck_t ctx,
|
extern struct dir_info *e2fsck_dir_info_iter(e2fsck_t ctx,
|
||||||
struct dir_info_iter *);
|
struct dir_info_iter *);
|
||||||
extern void e2fsck_dir_info_iter_end(e2fsck_t ctx, struct dir_info_iter *);
|
extern void e2fsck_dir_info_iter_end(e2fsck_t ctx, struct dir_info_iter *);
|
||||||
extern int e2fsck_dir_info_set_parent(e2fsck_t ctx, ext2_ino_t ino,
|
extern int e2fsck_dir_info_set_parent(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
ext2_ino_t parent);
|
ext2_ino_t parent);
|
||||||
extern int e2fsck_dir_info_set_dotdot(e2fsck_t ctx, ext2_ino_t ino,
|
extern int e2fsck_dir_info_set_dotdot(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
ext2_ino_t dotdot);
|
ext2_ino_t dotdot);
|
||||||
extern int e2fsck_dir_info_get_parent(e2fsck_t ctx, ext2_ino_t ino,
|
extern int e2fsck_dir_info_get_parent(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
ext2_ino_t *parent);
|
ext2_ino_t *parent);
|
||||||
extern int e2fsck_dir_info_get_dotdot(e2fsck_t ctx, ext2_ino_t ino,
|
extern int e2fsck_dir_info_get_dotdot(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
ext2_ino_t *dotdot);
|
ext2_ino_t *dotdot);
|
||||||
|
|
||||||
/* dx_dirinfo.c */
|
/* dx_dirinfo.c */
|
||||||
|
@ -431,7 +431,7 @@ extern void e2fsck_move_ext3_journal(e2fsck_t ctx);
|
||||||
extern int e2fsck_fix_ext3_journal_hint(e2fsck_t ctx);
|
extern int e2fsck_fix_ext3_journal_hint(e2fsck_t ctx);
|
||||||
|
|
||||||
/* pass1.c */
|
/* pass1.c */
|
||||||
extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
|
extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
|
||||||
ext2_icount_t *ret);
|
ext2_icount_t *ret);
|
||||||
extern void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool);
|
extern void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool);
|
||||||
extern int e2fsck_pass1_check_device_inode(ext2_filsys fs,
|
extern int e2fsck_pass1_check_device_inode(ext2_filsys fs,
|
||||||
|
@ -451,7 +451,7 @@ extern int e2fsck_reconnect_file(e2fsck_t ctx, ext2_ino_t inode);
|
||||||
extern errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
|
extern errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
int num, int gauranteed_size);
|
int num, int gauranteed_size);
|
||||||
extern ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix);
|
extern ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix);
|
||||||
extern errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino,
|
extern errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
int adj);
|
int adj);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ea_refcount.c
|
* ea_refcount.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2001 Theodore Ts'o. This file may be
|
* Copyright (C) 2001 Theodore Ts'o. This file may be
|
||||||
* redistributed under the terms of the GNU Public License.
|
* redistributed under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
* follows. We keep a sorted array of first EA blocks and its
|
* follows. We keep a sorted array of first EA blocks and its
|
||||||
* reference counts. Once the refcount has dropped to zero, it is
|
* reference counts. Once the refcount has dropped to zero, it is
|
||||||
* removed from the array to save memory space. Once the EA block is
|
* removed from the array to save memory space. Once the EA block is
|
||||||
* checked, its bit is set in the block_ea_map bitmap.
|
* checked, its bit is set in the block_ea_map bitmap.
|
||||||
*/
|
*/
|
||||||
struct ea_refcount_el {
|
struct ea_refcount_el {
|
||||||
blk_t ea_blk;
|
blk_t ea_blk;
|
||||||
|
@ -118,7 +118,7 @@ static struct ea_refcount_el *insert_refcount_el(ext2_refcount_t refcount,
|
||||||
new_size = refcount->size + 100;
|
new_size = refcount->size + 100;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Reallocating refcount %d entries...\n", new_size);
|
printf("Reallocating refcount %d entries...\n", new_size);
|
||||||
#endif
|
#endif
|
||||||
retval = ext2fs_resize_mem((size_t) refcount->size *
|
retval = ext2fs_resize_mem((size_t) refcount->size *
|
||||||
sizeof(struct ea_refcount_el),
|
sizeof(struct ea_refcount_el),
|
||||||
(size_t) new_size *
|
(size_t) new_size *
|
||||||
|
@ -170,7 +170,7 @@ retry:
|
||||||
}
|
}
|
||||||
if (refcount->count == 0)
|
if (refcount->count == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (refcount->cursor >= refcount->count)
|
if (refcount->cursor >= refcount->count)
|
||||||
refcount->cursor = 0;
|
refcount->cursor = 0;
|
||||||
if (blk == refcount->list[refcount->cursor].ea_blk)
|
if (blk == refcount->list[refcount->cursor].ea_blk)
|
||||||
|
@ -193,7 +193,7 @@ retry:
|
||||||
range = 0;
|
range = 0;
|
||||||
else if (blk > highval)
|
else if (blk > highval)
|
||||||
range = 1;
|
range = 1;
|
||||||
else
|
else
|
||||||
range = ((float) (blk - lowval)) /
|
range = ((float) (blk - lowval)) /
|
||||||
(highval - lowval);
|
(highval - lowval);
|
||||||
mid = low + ((int) (range * (high-low)));
|
mid = low + ((int) (range * (high-low)));
|
||||||
|
@ -227,7 +227,7 @@ errcode_t ea_refcount_fetch(ext2_refcount_t refcount, blk_t blk,
|
||||||
int *ret)
|
int *ret)
|
||||||
{
|
{
|
||||||
struct ea_refcount_el *el;
|
struct ea_refcount_el *el;
|
||||||
|
|
||||||
el = get_refcount_el(refcount, blk, 0);
|
el = get_refcount_el(refcount, blk, 0);
|
||||||
if (!el) {
|
if (!el) {
|
||||||
*ret = 0;
|
*ret = 0;
|
||||||
|
@ -298,7 +298,7 @@ blk_t ea_refcount_intr_next(ext2_refcount_t refcount,
|
||||||
int *ret)
|
int *ret)
|
||||||
{
|
{
|
||||||
struct ea_refcount_el *list;
|
struct ea_refcount_el *list;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (refcount->cursor >= refcount->count)
|
if (refcount->cursor >= refcount->count)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -320,7 +320,7 @@ errcode_t ea_refcount_validate(ext2_refcount_t refcount, FILE *out)
|
||||||
errcode_t ret = 0;
|
errcode_t ret = 0;
|
||||||
int i;
|
int i;
|
||||||
const char *bad = "bad refcount";
|
const char *bad = "bad refcount";
|
||||||
|
|
||||||
if (refcount->count > refcount->size) {
|
if (refcount->count > refcount->size) {
|
||||||
fprintf(out, "%s: count > size\n", bad);
|
fprintf(out, "%s: count > size\n", bad);
|
||||||
return EXT2_ET_INVALID_ARGUMENT;
|
return EXT2_ET_INVALID_ARGUMENT;
|
||||||
|
@ -460,7 +460,7 @@ int main(int argc, char **argv)
|
||||||
case BCODE_LIST:
|
case BCODE_LIST:
|
||||||
ea_refcount_intr_begin(refcount);
|
ea_refcount_intr_begin(refcount);
|
||||||
while (1) {
|
while (1) {
|
||||||
blk = ea_refcount_intr_next(refcount,
|
blk = ea_refcount_intr_next(refcount,
|
||||||
&arg);
|
&arg);
|
||||||
if (!blk)
|
if (!blk)
|
||||||
break;
|
break;
|
||||||
|
@ -472,7 +472,7 @@ int main(int argc, char **argv)
|
||||||
refcount_collapse(refcount);
|
refcount_collapse(refcount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* ehandler.c --- handle bad block errors which come up during the
|
* ehandler.c --- handle bad block errors which come up during the
|
||||||
* course of an e2fsck session.
|
* course of an e2fsck session.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
* Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
|
||||||
* under the terms of the GNU Public License.
|
* under the terms of the GNU Public License.
|
||||||
*/
|
*/
|
||||||
|
@ -77,7 +77,7 @@ static errcode_t e2fsck_handle_write_error(io_channel channel,
|
||||||
const char *p;
|
const char *p;
|
||||||
ext2_filsys fs = (ext2_filsys) channel->app_data;
|
ext2_filsys fs = (ext2_filsys) channel->app_data;
|
||||||
e2fsck_t ctx;
|
e2fsck_t ctx;
|
||||||
|
|
||||||
ctx = (e2fsck_t) fs->priv_data;
|
ctx = (e2fsck_t) fs->priv_data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -95,7 +95,7 @@ static errcode_t e2fsck_handle_write_error(io_channel channel,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation)
|
if (operation)
|
||||||
printf(_("Error writing block %lu (%s) while %s. "), block,
|
printf(_("Error writing block %lu (%s) while %s. "), block,
|
||||||
error_message(error), operation);
|
error_message(error), operation);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* emptydir.c --- clear empty directory blocks
|
* emptydir.c --- clear empty directory blocks
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 Theodore Ts'o
|
* Copyright (C) 1998 Theodore Ts'o
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -52,7 +52,7 @@ empty_dir_info init_empty_dir(e2fsck_t ctx)
|
||||||
retval = ext2fs_init_dblist(ctx->fs, &edi->empty_dblist);
|
retval = ext2fs_init_dblist(ctx->fs, &edi->empty_dblist);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
retval = ext2fs_allocate_block_bitmap(ctx->fs, _("empty dirblocks"),
|
retval = ext2fs_allocate_block_bitmap(ctx->fs, _("empty dirblocks"),
|
||||||
&edi->empty_dir_blocks);
|
&edi->empty_dir_blocks);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
@ -122,7 +122,7 @@ int empty_pass1(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt,
|
||||||
empty_dir_info edi = (empty_dir_info) priv_data;
|
empty_dir_info edi = (empty_dir_info) priv_data;
|
||||||
blk_t block, new_block;
|
blk_t block, new_block;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
if (blockcnt < 0)
|
if (blockcnt < 0)
|
||||||
return 0;
|
return 0;
|
||||||
block = *block_nr;
|
block = *block_nr;
|
||||||
|
@ -150,7 +150,7 @@ static int fix_directory(ext2_filsys fs,
|
||||||
void *priv_data)
|
void *priv_data)
|
||||||
{
|
{
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
empty_dir_info edi = (empty_dir_info) priv_data;
|
empty_dir_info edi = (empty_dir_info) priv_data;
|
||||||
|
|
||||||
edi->logblk = 0;
|
edi->logblk = 0;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* extend.c --- extend a file so that it has at least a specified
|
* extend.c --- extend a file so that it has at least a specified
|
||||||
* number of blocks.
|
* number of blocks.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* flushb.c --- This routine flushes the disk buffers for a disk
|
* flushb.c --- This routine flushes the disk buffers for a disk
|
||||||
*
|
*
|
||||||
* Copyright 1997, 2000, by Theodore Ts'o.
|
* Copyright 1997, 2000, by Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* WARNING: use of flushb on some older 2.2 kernels on a heavily loaded
|
* WARNING: use of flushb on some older 2.2 kernels on a heavily loaded
|
||||||
* system will corrupt filesystems. This program is not really useful
|
* system will corrupt filesystems. This program is not really useful
|
||||||
* beyond for benchmarking scripts.
|
* beyond for benchmarking scripts.
|
||||||
|
@ -33,12 +33,12 @@ static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("Usage: %s disk\n"), progname);
|
fprintf(stderr, _("Usage: %s disk\n"), progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
progname = argv[0];
|
progname = argv[0];
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
|
@ -60,7 +60,7 @@ static void PRS(int argc, char *argv[])
|
||||||
setbuf(stdout, NULL);
|
setbuf(stdout, NULL);
|
||||||
setbuf(stderr, NULL);
|
setbuf(stderr, NULL);
|
||||||
initialize_ext2_error_table();
|
initialize_ext2_error_table();
|
||||||
|
|
||||||
if (argc && *argv)
|
if (argc && *argv)
|
||||||
program_name = *argv;
|
program_name = *argv;
|
||||||
while ((c = getopt (argc, argv, "FI")) != EOF)
|
while ((c = getopt (argc, argv, "FI")) != EOF)
|
||||||
|
@ -91,7 +91,7 @@ static void PRS(int argc, char *argv[])
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
errcode_t retval = 0;
|
errcode_t retval = 0;
|
||||||
|
@ -101,7 +101,7 @@ int main (int argc, char *argv[])
|
||||||
__u32 num_inodes = 0;
|
__u32 num_inodes = 0;
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
ext2_inode_scan scan;
|
ext2_inode_scan scan;
|
||||||
|
|
||||||
init_resource_track(&global_rtrack);
|
init_resource_track(&global_rtrack);
|
||||||
|
|
||||||
PRS(argc, argv);
|
PRS(argc, argv);
|
||||||
|
@ -115,7 +115,7 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
ehandler_init(fs->io);
|
ehandler_init(fs->io);
|
||||||
|
|
||||||
retval = ext2fs_open_inode_scan(fs, inode_buffer_blocks, &scan);
|
retval = ext2fs_open_inode_scan(fs, inode_buffer_blocks, &scan);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err(program_name, retval, _("while opening inode scan"));
|
com_err(program_name, retval, _("while opening inode scan"));
|
||||||
|
@ -133,9 +133,9 @@ int main (int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
num_inodes++;
|
num_inodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_resource_track(NULL, &global_rtrack);
|
print_resource_track(NULL, &global_rtrack);
|
||||||
printf(_("%u inodes scanned.\n"), num_inodes);
|
printf(_("%u inodes scanned.\n"), num_inodes);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ typedef struct kdev_s *kdev_t;
|
||||||
#define unlock_buffer(bh) do {} while(0)
|
#define unlock_buffer(bh) do {} while(0)
|
||||||
#define buffer_req(bh) 1
|
#define buffer_req(bh) 1
|
||||||
#define do_readahead(journal, start) do {} while(0)
|
#define do_readahead(journal, start) do {} while(0)
|
||||||
|
|
||||||
extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
|
extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -72,12 +72,12 @@ typedef unsigned int __be32;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use the standard libext2fs portability tricks for inline
|
* We use the standard libext2fs portability tricks for inline
|
||||||
* functions.
|
* functions.
|
||||||
*/
|
*/
|
||||||
extern lkmem_cache_t * do_cache_create(int len);
|
extern lkmem_cache_t * do_cache_create(int len);
|
||||||
extern void do_cache_destroy(lkmem_cache_t *cache);
|
extern void do_cache_destroy(lkmem_cache_t *cache);
|
||||||
extern size_t journal_tag_bytes(journal_t *journal);
|
extern size_t journal_tag_bytes(journal_t *journal);
|
||||||
|
|
||||||
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
||||||
#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
|
#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
|
||||||
#define _INLINE_ extern
|
#define _INLINE_ extern
|
||||||
|
|
|
@ -58,7 +58,7 @@ int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval= ext2fs_bmap(inode->i_ctx->fs, inode->i_ino,
|
retval= ext2fs_bmap(inode->i_ctx->fs, inode->i_ino,
|
||||||
&inode->i_ext2, NULL, 0, block, &pblk);
|
&inode->i_ext2, NULL, 0, block, &pblk);
|
||||||
*phys = pblk;
|
*phys = pblk;
|
||||||
return (retval);
|
return (retval);
|
||||||
|
@ -83,7 +83,7 @@ struct buffer_head *getblk(kdev_t kdev, blk_t blocknr, int blocksize)
|
||||||
bh->b_ctx = kdev->k_ctx;
|
bh->b_ctx = kdev->k_ctx;
|
||||||
if (kdev->k_dev == K_DEV_FS)
|
if (kdev->k_dev == K_DEV_FS)
|
||||||
bh->b_io = kdev->k_ctx->fs->io;
|
bh->b_io = kdev->k_ctx->fs->io;
|
||||||
else
|
else
|
||||||
bh->b_io = kdev->k_ctx->journal_io;
|
bh->b_io = kdev->k_ctx->journal_io;
|
||||||
bh->b_size = blocksize;
|
bh->b_size = blocksize;
|
||||||
bh->b_blocknr = blocknr;
|
bh->b_blocknr = blocknr;
|
||||||
|
@ -97,7 +97,7 @@ void sync_blockdev(kdev_t kdev)
|
||||||
|
|
||||||
if (kdev->k_dev == K_DEV_FS)
|
if (kdev->k_dev == K_DEV_FS)
|
||||||
io = kdev->k_ctx->fs->io;
|
io = kdev->k_ctx->fs->io;
|
||||||
else
|
else
|
||||||
io = kdev->k_ctx->journal_io;
|
io = kdev->k_ctx->journal_io;
|
||||||
|
|
||||||
io_channel_flush(io);
|
io_channel_flush(io);
|
||||||
|
@ -111,28 +111,28 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[])
|
||||||
for (; nr > 0; --nr) {
|
for (; nr > 0; --nr) {
|
||||||
bh = *bhp++;
|
bh = *bhp++;
|
||||||
if (rw == READ && !bh->b_uptodate) {
|
if (rw == READ && !bh->b_uptodate) {
|
||||||
jfs_debug(3, "reading block %lu/%p\n",
|
jfs_debug(3, "reading block %lu/%p\n",
|
||||||
(unsigned long) bh->b_blocknr, (void *) bh);
|
(unsigned long) bh->b_blocknr, (void *) bh);
|
||||||
retval = io_channel_read_blk(bh->b_io,
|
retval = io_channel_read_blk(bh->b_io,
|
||||||
bh->b_blocknr,
|
bh->b_blocknr,
|
||||||
1, bh->b_data);
|
1, bh->b_data);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err(bh->b_ctx->device_name, retval,
|
com_err(bh->b_ctx->device_name, retval,
|
||||||
"while reading block %lu\n",
|
"while reading block %lu\n",
|
||||||
(unsigned long) bh->b_blocknr);
|
(unsigned long) bh->b_blocknr);
|
||||||
bh->b_err = retval;
|
bh->b_err = retval;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bh->b_uptodate = 1;
|
bh->b_uptodate = 1;
|
||||||
} else if (rw == WRITE && bh->b_dirty) {
|
} else if (rw == WRITE && bh->b_dirty) {
|
||||||
jfs_debug(3, "writing block %lu/%p\n",
|
jfs_debug(3, "writing block %lu/%p\n",
|
||||||
(unsigned long) bh->b_blocknr, (void *) bh);
|
(unsigned long) bh->b_blocknr, (void *) bh);
|
||||||
retval = io_channel_write_blk(bh->b_io,
|
retval = io_channel_write_blk(bh->b_io,
|
||||||
bh->b_blocknr,
|
bh->b_blocknr,
|
||||||
1, bh->b_data);
|
1, bh->b_data);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err(bh->b_ctx->device_name, retval,
|
com_err(bh->b_ctx->device_name, retval,
|
||||||
"while writing block %lu\n",
|
"while writing block %lu\n",
|
||||||
(unsigned long) bh->b_blocknr);
|
(unsigned long) bh->b_blocknr);
|
||||||
bh->b_err = retval;
|
bh->b_err = retval;
|
||||||
continue;
|
continue;
|
||||||
|
@ -141,7 +141,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[])
|
||||||
bh->b_uptodate = 1;
|
bh->b_uptodate = 1;
|
||||||
} else {
|
} else {
|
||||||
jfs_debug(3, "no-op %s for block %lu\n",
|
jfs_debug(3, "no-op %s for block %lu\n",
|
||||||
rw == READ ? "read" : "write",
|
rw == READ ? "read" : "write",
|
||||||
(unsigned long) bh->b_blocknr);
|
(unsigned long) bh->b_blocknr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
|
||||||
tried_backup_jnl)
|
tried_backup_jnl)
|
||||||
goto errout;
|
goto errout;
|
||||||
memset(&j_inode->i_ext2, 0, sizeof(struct ext2_inode));
|
memset(&j_inode->i_ext2, 0, sizeof(struct ext2_inode));
|
||||||
memcpy(&j_inode->i_ext2.i_block[0], sb->s_jnl_blocks,
|
memcpy(&j_inode->i_ext2.i_block[0], sb->s_jnl_blocks,
|
||||||
EXT2_N_BLOCKS*4);
|
EXT2_N_BLOCKS*4);
|
||||||
j_inode->i_ext2.i_size = sb->s_jnl_blocks[16];
|
j_inode->i_ext2.i_size = sb->s_jnl_blocks[16];
|
||||||
j_inode->i_ext2.i_links_count = 1;
|
j_inode->i_ext2.i_links_count = 1;
|
||||||
|
@ -306,9 +306,9 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
|
||||||
}
|
}
|
||||||
pb.last_block = -1;
|
pb.last_block = -1;
|
||||||
retval = ext2fs_block_iterate2(ctx->fs, j_inode->i_ino,
|
retval = ext2fs_block_iterate2(ctx->fs, j_inode->i_ino,
|
||||||
BLOCK_FLAG_HOLE, 0,
|
BLOCK_FLAG_HOLE, 0,
|
||||||
process_journal_block, &pb);
|
process_journal_block, &pb);
|
||||||
if ((pb.last_block+1) * ctx->fs->blocksize <
|
if ((pb.last_block+1) * ctx->fs->blocksize <
|
||||||
j_inode->i_ext2.i_size) {
|
j_inode->i_ext2.i_size) {
|
||||||
retval = EXT2_ET_JOURNAL_TOO_SMALL;
|
retval = EXT2_ET_JOURNAL_TOO_SMALL;
|
||||||
goto try_backup_journal;
|
goto try_backup_journal;
|
||||||
|
@ -390,7 +390,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
|
||||||
sizeof(jsuper));
|
sizeof(jsuper));
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
|
if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
|
||||||
ext2fs_swap_super(&jsuper);
|
ext2fs_swap_super(&jsuper);
|
||||||
#endif
|
#endif
|
||||||
if (jsuper.s_magic != EXT2_SUPER_MAGIC ||
|
if (jsuper.s_magic != EXT2_SUPER_MAGIC ||
|
||||||
|
@ -520,7 +520,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal)
|
||||||
jsb->s_nr_users)
|
jsb->s_nr_users)
|
||||||
clear_v2_journal_fields(journal);
|
clear_v2_journal_fields(journal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JFS_SUPERBLOCK_V2:
|
case JFS_SUPERBLOCK_V2:
|
||||||
journal->j_format_version = 2;
|
journal->j_format_version = 2;
|
||||||
if (ntohl(jsb->s_nr_users) > 1 &&
|
if (ntohl(jsb->s_nr_users) > 1 &&
|
||||||
|
@ -540,7 +540,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal)
|
||||||
case JFS_COMMIT_BLOCK:
|
case JFS_COMMIT_BLOCK:
|
||||||
case JFS_REVOKE_BLOCK:
|
case JFS_REVOKE_BLOCK:
|
||||||
return EXT2_ET_CORRUPT_SUPERBLOCK;
|
return EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
|
||||||
/* If we don't understand the superblock major type, but there
|
/* If we don't understand the superblock major type, but there
|
||||||
* is a magic number, then it is likely to be a new format we
|
* is a magic number, then it is likely to be a new format we
|
||||||
* just don't understand, so leave it alone. */
|
* just don't understand, so leave it alone. */
|
||||||
|
@ -550,7 +550,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal)
|
||||||
|
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(journal, ~JFS_KNOWN_INCOMPAT_FEATURES))
|
if (JFS_HAS_INCOMPAT_FEATURE(journal, ~JFS_KNOWN_INCOMPAT_FEATURES))
|
||||||
return EXT2_ET_UNSUPP_FEATURE;
|
return EXT2_ET_UNSUPP_FEATURE;
|
||||||
|
|
||||||
if (JFS_HAS_RO_COMPAT_FEATURE(journal, ~JFS_KNOWN_ROCOMPAT_FEATURES))
|
if (JFS_HAS_RO_COMPAT_FEATURE(journal, ~JFS_KNOWN_ROCOMPAT_FEATURES))
|
||||||
return EXT2_ET_RO_UNSUPP_FEATURE;
|
return EXT2_ET_RO_UNSUPP_FEATURE;
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ static void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb,
|
||||||
/* Leave a valid existing V1 superblock signature alone.
|
/* Leave a valid existing V1 superblock signature alone.
|
||||||
* Anything unrecognisable we overwrite with a new V2
|
* Anything unrecognisable we overwrite with a new V2
|
||||||
* signature. */
|
* signature. */
|
||||||
|
|
||||||
if (jsb->s_header.h_magic != htonl(JFS_MAGIC_NUMBER) ||
|
if (jsb->s_header.h_magic != htonl(JFS_MAGIC_NUMBER) ||
|
||||||
jsb->s_header.h_blocktype != htonl(JFS_SUPERBLOCK_V1)) {
|
jsb->s_header.h_blocktype != htonl(JFS_SUPERBLOCK_V1)) {
|
||||||
jsb->s_header.h_magic = htonl(JFS_MAGIC_NUMBER);
|
jsb->s_header.h_magic = htonl(JFS_MAGIC_NUMBER);
|
||||||
|
@ -604,7 +604,7 @@ static void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero out everything else beyond the superblock header */
|
/* Zero out everything else beyond the superblock header */
|
||||||
|
|
||||||
p = ((char *) jsb) + sizeof(journal_header_t);
|
p = ((char *) jsb) + sizeof(journal_header_t);
|
||||||
memset (p, 0, ctx->fs->blocksize-sizeof(journal_header_t));
|
memset (p, 0, ctx->fs->blocksize-sizeof(journal_header_t));
|
||||||
|
|
||||||
|
@ -670,7 +670,7 @@ static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
|
||||||
io_channel_close(ctx->journal_io);
|
io_channel_close(ctx->journal_io);
|
||||||
ctx->journal_io = 0;
|
ctx->journal_io = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_INODE_IO
|
#ifndef USE_INODE_IO
|
||||||
if (journal->j_inode)
|
if (journal->j_inode)
|
||||||
ext2fs_free_mem(&journal->j_inode);
|
ext2fs_free_mem(&journal->j_inode);
|
||||||
|
@ -788,7 +788,7 @@ no_has_journal:
|
||||||
* ignore the fact that journal apparently has data;
|
* ignore the fact that journal apparently has data;
|
||||||
* accidentally replaying over valid data would be far
|
* accidentally replaying over valid data would be far
|
||||||
* worse than skipping a questionable recovery.
|
* worse than skipping a questionable recovery.
|
||||||
*
|
*
|
||||||
* XXX should we abort with a fatal error here? What
|
* XXX should we abort with a fatal error here? What
|
||||||
* will the ext3 kernel code do if a filesystem with
|
* will the ext3 kernel code do if a filesystem with
|
||||||
* !NEEDS_RECOVERY but with a non-zero
|
* !NEEDS_RECOVERY but with a non-zero
|
||||||
|
@ -820,11 +820,11 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
|
||||||
retval = journal_init_revoke(journal, 1024);
|
retval = journal_init_revoke(journal, 1024);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
retval = -journal_recover(journal);
|
retval = -journal_recover(journal);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
if (journal->j_failed_commit) {
|
if (journal->j_failed_commit) {
|
||||||
pctx.ino = journal->j_failed_commit;
|
pctx.ino = journal->j_failed_commit;
|
||||||
fix_problem(ctx, PR_0_JNL_TXN_CORRUPT, &pctx);
|
fix_problem(ctx, PR_0_JNL_TXN_CORRUPT, &pctx);
|
||||||
|
@ -839,7 +839,7 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
|
||||||
journal->j_superblock->s_errno = 0;
|
journal->j_superblock->s_errno = 0;
|
||||||
mark_buffer_dirty(journal->j_sb_buffer);
|
mark_buffer_dirty(journal->j_sb_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
journal_destroy_revoke(journal);
|
journal_destroy_revoke(journal);
|
||||||
journal_destroy_revoke_caches();
|
journal_destroy_revoke_caches();
|
||||||
|
@ -864,7 +864,7 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx)
|
||||||
ext2fs_flush(ctx->fs); /* Force out any modifications */
|
ext2fs_flush(ctx->fs); /* Force out any modifications */
|
||||||
|
|
||||||
recover_retval = recover_ext3_journal(ctx);
|
recover_retval = recover_ext3_journal(ctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reload the filesystem context to get up-to-date data from disk
|
* Reload the filesystem context to get up-to-date data from disk
|
||||||
* because journal recovery will change the filesystem under us.
|
* because journal recovery will change the filesystem under us.
|
||||||
|
@ -906,7 +906,7 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx)
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
const char * const * cpp;
|
const char * const * cpp;
|
||||||
int group, mount_flags;
|
int group, mount_flags;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -945,7 +945,7 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx)
|
||||||
*/
|
*/
|
||||||
if (sb->s_journal_inum == EXT2_JOURNAL_INO)
|
if (sb->s_journal_inum == EXT2_JOURNAL_INO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The journal inode had better have only one link and not be readable.
|
* The journal inode had better have only one link and not be readable.
|
||||||
*/
|
*/
|
||||||
|
@ -981,7 +981,7 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx)
|
||||||
pctx.str = *cpp;
|
pctx.str = *cpp;
|
||||||
if (!fix_problem(ctx, PR_0_MOVE_JOURNAL, &pctx))
|
if (!fix_problem(ctx, PR_0_MOVE_JOURNAL, &pctx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OK, we've done all the checks, let's actually move the
|
* OK, we've done all the checks, let's actually move the
|
||||||
* journal inode. Errors at this point mean we need to force
|
* journal inode. Errors at this point mean we need to force
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
* @o orphaned
|
* @o orphaned
|
||||||
* @p problem in
|
* @p problem in
|
||||||
* @r root inode
|
* @r root inode
|
||||||
* @s should be
|
* @s should be
|
||||||
* @S superblock
|
* @S superblock
|
||||||
* @u unattached
|
* @u unattached
|
||||||
* @v device
|
* @v device
|
||||||
|
@ -199,7 +199,7 @@ static void print_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino)
|
||||||
fputs(_(special_inode_name[ino]), stdout);
|
fputs(_(special_inode_name[ino]), stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = ext2fs_get_pathname(fs, dir, ino, &path);
|
retval = ext2fs_get_pathname(fs, dir, ino, &path);
|
||||||
if (retval)
|
if (retval)
|
||||||
fputs("???", stdout);
|
fputs("???", stdout);
|
||||||
|
@ -212,14 +212,14 @@ static void print_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino)
|
||||||
/*
|
/*
|
||||||
* This function handles the '@' expansion. We allow recursive
|
* This function handles the '@' expansion. We allow recursive
|
||||||
* expansion; an @ expression can contain further '@' and '%'
|
* expansion; an @ expression can contain further '@' and '%'
|
||||||
* expressions.
|
* expressions.
|
||||||
*/
|
*/
|
||||||
static _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch,
|
static _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch,
|
||||||
struct problem_context *pctx,
|
struct problem_context *pctx,
|
||||||
int *first, int recurse)
|
int *first, int recurse)
|
||||||
{
|
{
|
||||||
const char **cpp, *str;
|
const char **cpp, *str;
|
||||||
|
|
||||||
/* Search for the abbreviation */
|
/* Search for the abbreviation */
|
||||||
for (cpp = abbrevs; *cpp; cpp++) {
|
for (cpp = abbrevs; *cpp; cpp++) {
|
||||||
if (ch == *cpp[0])
|
if (ch == *cpp[0])
|
||||||
|
@ -239,7 +239,7 @@ static _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch,
|
||||||
/*
|
/*
|
||||||
* This function expands '%IX' expressions
|
* This function expands '%IX' expressions
|
||||||
*/
|
*/
|
||||||
static _INLINE_ void expand_inode_expression(char ch,
|
static _INLINE_ void expand_inode_expression(char ch,
|
||||||
struct problem_context *ctx)
|
struct problem_context *ctx)
|
||||||
{
|
{
|
||||||
struct ext2_inode *inode;
|
struct ext2_inode *inode;
|
||||||
|
@ -250,7 +250,7 @@ static _INLINE_ void expand_inode_expression(char ch,
|
||||||
|
|
||||||
if (!ctx || !ctx->inode)
|
if (!ctx || !ctx->inode)
|
||||||
goto no_inode;
|
goto no_inode;
|
||||||
|
|
||||||
inode = ctx->inode;
|
inode = ctx->inode;
|
||||||
large_inode = (struct ext2_inode_large *) inode;
|
large_inode = (struct ext2_inode_large *) inode;
|
||||||
|
|
||||||
|
@ -317,17 +317,17 @@ static _INLINE_ void expand_inode_expression(char ch,
|
||||||
printf("%d", inode_gid(*inode));
|
printf("%d", inode_gid(*inode));
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (LINUX_S_ISREG(inode->i_mode))
|
if (LINUX_S_ISREG(inode->i_mode))
|
||||||
printf(_("regular file"));
|
printf(_("regular file"));
|
||||||
else if (LINUX_S_ISDIR(inode->i_mode))
|
else if (LINUX_S_ISDIR(inode->i_mode))
|
||||||
printf(_("directory"));
|
printf(_("directory"));
|
||||||
else if (LINUX_S_ISCHR(inode->i_mode))
|
else if (LINUX_S_ISCHR(inode->i_mode))
|
||||||
printf(_("character device"));
|
printf(_("character device"));
|
||||||
else if (LINUX_S_ISBLK(inode->i_mode))
|
else if (LINUX_S_ISBLK(inode->i_mode))
|
||||||
printf(_("block device"));
|
printf(_("block device"));
|
||||||
else if (LINUX_S_ISFIFO(inode->i_mode))
|
else if (LINUX_S_ISFIFO(inode->i_mode))
|
||||||
printf(_("named pipe"));
|
printf(_("named pipe"));
|
||||||
else if (LINUX_S_ISLNK(inode->i_mode))
|
else if (LINUX_S_ISLNK(inode->i_mode))
|
||||||
printf(_("symbolic link"));
|
printf(_("symbolic link"));
|
||||||
else if (LINUX_S_ISSOCK(inode->i_mode))
|
else if (LINUX_S_ISSOCK(inode->i_mode))
|
||||||
printf(_("socket"));
|
printf(_("socket"));
|
||||||
|
@ -350,12 +350,12 @@ static _INLINE_ void expand_dirent_expression(char ch,
|
||||||
{
|
{
|
||||||
struct ext2_dir_entry *dirent;
|
struct ext2_dir_entry *dirent;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!ctx || !ctx->dirent)
|
if (!ctx || !ctx->dirent)
|
||||||
goto no_dirent;
|
goto no_dirent;
|
||||||
|
|
||||||
dirent = ctx->dirent;
|
dirent = ctx->dirent;
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'i':
|
case 'i':
|
||||||
printf("%u", dirent->inode);
|
printf("%u", dirent->inode);
|
||||||
|
@ -389,7 +389,7 @@ static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch,
|
||||||
{
|
{
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
goto no_context;
|
goto no_context;
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '%':
|
case '%':
|
||||||
fputc('%', stdout);
|
fputc('%', stdout);
|
||||||
|
@ -468,7 +468,7 @@ static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch,
|
||||||
printf("%%%c", ch);
|
printf("%%%c", ch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_e2fsck_message(e2fsck_t ctx, const char *msg,
|
void print_e2fsck_message(e2fsck_t ctx, const char *msg,
|
||||||
struct problem_context *pctx, int first,
|
struct problem_context *pctx, int first,
|
||||||
|
|
|
@ -47,7 +47,7 @@ static __ptr_t (*tr_old_malloc_hook) __P ((size_t size));
|
||||||
static __ptr_t (*tr_old_realloc_hook) __P ((__ptr_t ptr, size_t size));
|
static __ptr_t (*tr_old_realloc_hook) __P ((__ptr_t ptr, size_t size));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Added by TYT, 10/10/93 --- so that we can print
|
* Added by TYT, 10/10/93 --- so that we can print
|
||||||
*/
|
*/
|
||||||
FILE *malloc_get_mallstream()
|
FILE *malloc_get_mallstream()
|
||||||
{
|
{
|
||||||
|
|
182
e2fsck/pass1.c
182
e2fsck/pass1.c
|
@ -1,13 +1,13 @@
|
||||||
/*
|
/*
|
||||||
* pass1.c -- pass #1 of e2fsck: sequential scan of the inode table
|
* pass1.c -- pass #1 of e2fsck: sequential scan of the inode table
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
* Pass 1 of e2fsck iterates over all the inodes in the filesystems,
|
* Pass 1 of e2fsck iterates over all the inodes in the filesystems,
|
||||||
* and applies the following tests to each inode:
|
* and applies the following tests to each inode:
|
||||||
*
|
*
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int process_block(ext2_filsys fs, blk_t *blocknr,
|
static int process_block(ext2_filsys fs, blk_t *blocknr,
|
||||||
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
||||||
int ref_offset, void *priv_data);
|
int ref_offset, void *priv_data);
|
||||||
static int process_bad_block(ext2_filsys fs, blk_t *block_nr,
|
static int process_bad_block(ext2_filsys fs, blk_t *block_nr,
|
||||||
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
||||||
|
@ -72,7 +72,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf);
|
||||||
static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b);
|
static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b);
|
||||||
static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
|
static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
|
||||||
dgrp_t group, void * priv_data);
|
dgrp_t group, void * priv_data);
|
||||||
static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
|
static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
|
||||||
char *block_buf, int adjust_sign);
|
char *block_buf, int adjust_sign);
|
||||||
/* static char *describe_illegal_block(ext2_filsys fs, blk_t block); */
|
/* static char *describe_illegal_block(ext2_filsys fs, blk_t block); */
|
||||||
|
|
||||||
|
@ -126,9 +126,9 @@ static void unwind_pass1(ext2_filsys fs EXT2FS_ATTR((unused)))
|
||||||
*
|
*
|
||||||
* Note: this routine is now also used to check FIFO's and Sockets,
|
* Note: this routine is now also used to check FIFO's and Sockets,
|
||||||
* since they have the same requirement; the i_block fields should be
|
* since they have the same requirement; the i_block fields should be
|
||||||
* zero.
|
* zero.
|
||||||
*/
|
*/
|
||||||
int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
|
int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
struct ext2_inode *inode)
|
struct ext2_inode *inode)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -152,7 +152,7 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
* the kernel has been fixed we can change this...
|
* the kernel has been fixed we can change this...
|
||||||
*/
|
*/
|
||||||
if (inode->i_flags & (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL)) {
|
if (inode->i_flags & (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL)) {
|
||||||
for (i=4; i < EXT2_N_BLOCKS; i++)
|
for (i=4; i < EXT2_N_BLOCKS; i++)
|
||||||
if (inode->i_block[i])
|
if (inode->i_block[i])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -254,18 +254,18 @@ static void check_immutable(e2fsck_t ctx, struct problem_context *pctx)
|
||||||
static void check_size(e2fsck_t ctx, struct problem_context *pctx)
|
static void check_size(e2fsck_t ctx, struct problem_context *pctx)
|
||||||
{
|
{
|
||||||
struct ext2_inode *inode = pctx->inode;
|
struct ext2_inode *inode = pctx->inode;
|
||||||
|
|
||||||
if ((inode->i_size == 0) && (inode->i_size_high == 0))
|
if ((inode->i_size == 0) && (inode->i_size_high == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!fix_problem(ctx, PR_1_SET_NONZSIZE, pctx))
|
if (!fix_problem(ctx, PR_1_SET_NONZSIZE, pctx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
inode->i_size = 0;
|
inode->i_size = 0;
|
||||||
inode->i_size_high = 0;
|
inode->i_size_high = 0;
|
||||||
e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
|
e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx)
|
static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx)
|
||||||
{
|
{
|
||||||
struct ext2_super_block *sb = ctx->fs->super;
|
struct ext2_super_block *sb = ctx->fs->super;
|
||||||
|
@ -286,14 +286,14 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx)
|
||||||
/* scan all entry's headers first */
|
/* scan all entry's headers first */
|
||||||
|
|
||||||
/* take finish entry 0UL into account */
|
/* take finish entry 0UL into account */
|
||||||
remain = storage_size - sizeof(__u32);
|
remain = storage_size - sizeof(__u32);
|
||||||
|
|
||||||
while (!EXT2_EXT_IS_LAST_ENTRY(entry)) {
|
while (!EXT2_EXT_IS_LAST_ENTRY(entry)) {
|
||||||
__u32 hash;
|
__u32 hash;
|
||||||
|
|
||||||
/* header eats this space */
|
/* header eats this space */
|
||||||
remain -= sizeof(struct ext2_ext_attr_entry);
|
remain -= sizeof(struct ext2_ext_attr_entry);
|
||||||
|
|
||||||
/* is attribute name valid? */
|
/* is attribute name valid? */
|
||||||
if (EXT2_EXT_ATTR_SIZE(entry->e_name_len) > remain) {
|
if (EXT2_EXT_ATTR_SIZE(entry->e_name_len) > remain) {
|
||||||
pctx->num = entry->e_name_len;
|
pctx->num = entry->e_name_len;
|
||||||
|
@ -362,11 +362,11 @@ static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx)
|
||||||
#if 0
|
#if 0
|
||||||
printf("inode #%u, i_extra_size %d\n", pctx->ino,
|
printf("inode #%u, i_extra_size %d\n", pctx->ino,
|
||||||
inode->i_extra_isize);
|
inode->i_extra_isize);
|
||||||
#endif
|
#endif
|
||||||
/* i_extra_isize must cover i_extra_isize + i_pad1 at least */
|
/* i_extra_isize must cover i_extra_isize + i_pad1 at least */
|
||||||
min = sizeof(inode->i_extra_isize) + sizeof(inode->i_pad1);
|
min = sizeof(inode->i_extra_isize) + sizeof(inode->i_pad1);
|
||||||
max = EXT2_INODE_SIZE(sb) - EXT2_GOOD_OLD_INODE_SIZE;
|
max = EXT2_INODE_SIZE(sb) - EXT2_GOOD_OLD_INODE_SIZE;
|
||||||
/*
|
/*
|
||||||
* For now we will allow i_extra_isize to be 0, but really
|
* For now we will allow i_extra_isize to be 0, but really
|
||||||
* implementations should never allow i_extra_isize to be 0
|
* implementations should never allow i_extra_isize to be 0
|
||||||
*/
|
*/
|
||||||
|
@ -388,7 +388,7 @@ static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if the inode might really be a directory, despite i_mode
|
* Check to see if the inode might really be a directory, despite i_mode
|
||||||
*
|
*
|
||||||
* This is a lot of complexity for something for which I'm not really
|
* This is a lot of complexity for something for which I'm not really
|
||||||
|
@ -423,7 +423,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
return; /* Invalid block, can't be dir */
|
return; /* Invalid block, can't be dir */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((LINUX_S_ISCHR(inode->i_mode) || LINUX_S_ISBLK(inode->i_mode)) &&
|
if ((LINUX_S_ISCHR(inode->i_mode) || LINUX_S_ISBLK(inode->i_mode)) &&
|
||||||
(inode->i_links_count == 1) && !not_device)
|
(inode->i_links_count == 1) && !not_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -456,13 +456,13 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
|
|
||||||
if (fix_problem(ctx, PR_1_TREAT_AS_DIRECTORY, pctx)) {
|
if (fix_problem(ctx, PR_1_TREAT_AS_DIRECTORY, pctx)) {
|
||||||
inode->i_mode = (inode->i_mode & 07777) | LINUX_S_IFDIR;
|
inode->i_mode = (inode->i_mode & 07777) | LINUX_S_IFDIR;
|
||||||
e2fsck_write_inode_full(ctx, pctx->ino, inode,
|
e2fsck_write_inode_full(ctx, pctx->ino, inode,
|
||||||
EXT2_INODE_SIZE(ctx->fs->super),
|
EXT2_INODE_SIZE(ctx->fs->super),
|
||||||
"check_is_really_dir");
|
"check_is_really_dir");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
|
extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
|
||||||
ext2_icount_t *ret)
|
ext2_icount_t *ret)
|
||||||
{
|
{
|
||||||
unsigned int threshold;
|
unsigned int threshold;
|
||||||
|
@ -513,7 +513,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
int imagic_fs, extent_fs;
|
int imagic_fs, extent_fs;
|
||||||
int busted_fs_time = 0;
|
int busted_fs_time = 0;
|
||||||
int inode_size;
|
int inode_size;
|
||||||
|
|
||||||
#ifdef RESOURCE_TRACK
|
#ifdef RESOURCE_TRACK
|
||||||
init_resource_track(&rtrack, ctx->fs->io);
|
init_resource_track(&rtrack, ctx->fs->io);
|
||||||
#endif
|
#endif
|
||||||
|
@ -628,7 +628,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
"block interate buffer");
|
"block interate buffer");
|
||||||
e2fsck_use_inode_shortcuts(ctx, 1);
|
e2fsck_use_inode_shortcuts(ctx, 1);
|
||||||
old_op = ehandler_operation(_("opening inode scan"));
|
old_op = ehandler_operation(_("opening inode scan"));
|
||||||
pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
|
pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
|
||||||
&scan);
|
&scan);
|
||||||
ehandler_operation(old_op);
|
ehandler_operation(old_op);
|
||||||
if (pctx.errcode) {
|
if (pctx.errcode) {
|
||||||
|
@ -652,7 +652,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
old_op = ehandler_operation(_("getting next inode from scan"));
|
old_op = ehandler_operation(_("getting next inode from scan"));
|
||||||
pctx.errcode = ext2fs_get_next_inode_full(scan, &ino,
|
pctx.errcode = ext2fs_get_next_inode_full(scan, &ino,
|
||||||
inode, inode_size);
|
inode, inode_size);
|
||||||
ehandler_operation(old_op);
|
ehandler_operation(old_op);
|
||||||
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
||||||
|
@ -675,7 +675,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
pctx.inode = inode;
|
pctx.inode = inode;
|
||||||
ctx->stashed_ino = ino;
|
ctx->stashed_ino = ino;
|
||||||
if (inode->i_links_count) {
|
if (inode->i_links_count) {
|
||||||
pctx.errcode = ext2fs_icount_store(ctx->inode_link_info,
|
pctx.errcode = ext2fs_icount_store(ctx->inode_link_info,
|
||||||
ino, inode->i_links_count);
|
ino, inode->i_links_count);
|
||||||
if (pctx.errcode) {
|
if (pctx.errcode) {
|
||||||
pctx.num = inode->i_links_count;
|
pctx.num = inode->i_links_count;
|
||||||
|
@ -700,10 +700,10 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
* extent_header_verify is ok. If the inode is cleared,
|
* extent_header_verify is ok. If the inode is cleared,
|
||||||
* no need to swap... so no extra swapping here.
|
* no need to swap... so no extra swapping here.
|
||||||
*/
|
*/
|
||||||
if ((inode->i_flags & EXT4_EXTENTS_FL) && !extent_fs &&
|
if ((inode->i_flags & EXT4_EXTENTS_FL) && !extent_fs &&
|
||||||
(inode->i_links_count || (ino == EXT2_BAD_INO) ||
|
(inode->i_links_count || (ino == EXT2_BAD_INO) ||
|
||||||
(ino == EXT2_ROOT_INO) || (ino == EXT2_JOURNAL_INO))) {
|
(ino == EXT2_ROOT_INO) || (ino == EXT2_JOURNAL_INO))) {
|
||||||
if ((ext2fs_extent_header_verify(inode->i_block,
|
if ((ext2fs_extent_header_verify(inode->i_block,
|
||||||
sizeof(inode->i_block)) == 0) &&
|
sizeof(inode->i_block)) == 0) &&
|
||||||
fix_problem(ctx, PR_1_EXTENT_FEATURE, &pctx)) {
|
fix_problem(ctx, PR_1_EXTENT_FEATURE, &pctx)) {
|
||||||
sb->s_feature_incompat |= EXT3_FEATURE_INCOMPAT_EXTENTS;
|
sb->s_feature_incompat |= EXT3_FEATURE_INCOMPAT_EXTENTS;
|
||||||
|
@ -713,7 +713,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
clear_inode:
|
clear_inode:
|
||||||
e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
|
e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
|
||||||
if (ino == EXT2_BAD_INO)
|
if (ino == EXT2_BAD_INO)
|
||||||
ext2fs_mark_inode_bitmap(ctx->inode_used_map,
|
ext2fs_mark_inode_bitmap(ctx->inode_used_map,
|
||||||
ino);
|
ino);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -742,12 +742,12 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
#else
|
#else
|
||||||
ehp = inode->i_block;
|
ehp = inode->i_block;
|
||||||
#endif
|
#endif
|
||||||
if ((ext2fs_extent_header_verify(ehp,
|
if ((ext2fs_extent_header_verify(ehp,
|
||||||
sizeof(inode->i_block)) == 0) &&
|
sizeof(inode->i_block)) == 0) &&
|
||||||
(fix_problem(ctx, PR_1_UNSET_EXTENT_FL, &pctx))) {
|
(fix_problem(ctx, PR_1_UNSET_EXTENT_FL, &pctx))) {
|
||||||
inode->i_flags |= EXT4_EXTENTS_FL;
|
inode->i_flags |= EXT4_EXTENTS_FL;
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
memcpy(inode->i_block, tmp_block,
|
memcpy(inode->i_block, tmp_block,
|
||||||
sizeof(inode->i_block));
|
sizeof(inode->i_block));
|
||||||
#endif
|
#endif
|
||||||
e2fsck_write_inode(ctx, ino, inode, "pass1");
|
e2fsck_write_inode(ctx, ino, inode, "pass1");
|
||||||
|
@ -756,7 +756,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
|
|
||||||
if (ino == EXT2_BAD_INO) {
|
if (ino == EXT2_BAD_INO) {
|
||||||
struct process_block_struct pb;
|
struct process_block_struct pb;
|
||||||
|
|
||||||
pctx.errcode = ext2fs_copy_bitmap(ctx->block_found_map,
|
pctx.errcode = ext2fs_copy_bitmap(ctx->block_found_map,
|
||||||
&pb.fs_meta_blocks);
|
&pb.fs_meta_blocks);
|
||||||
if (pctx.errcode) {
|
if (pctx.errcode) {
|
||||||
|
@ -773,7 +773,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
pb.inode = inode;
|
pb.inode = inode;
|
||||||
pb.pctx = &pctx;
|
pb.pctx = &pctx;
|
||||||
pb.ctx = ctx;
|
pb.ctx = ctx;
|
||||||
pctx.errcode = ext2fs_block_iterate2(fs, ino, 0,
|
pctx.errcode = ext2fs_block_iterate2(fs, ino, 0,
|
||||||
block_buf, process_bad_block, &pb);
|
block_buf, process_bad_block, &pb);
|
||||||
ext2fs_free_block_bitmap(pb.fs_meta_blocks);
|
ext2fs_free_block_bitmap(pb.fs_meta_blocks);
|
||||||
if (pctx.errcode) {
|
if (pctx.errcode) {
|
||||||
|
@ -830,17 +830,17 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
if ((inode->i_links_count || inode->i_blocks ||
|
if ((inode->i_links_count || inode->i_blocks ||
|
||||||
inode->i_blocks || inode->i_block[0]) &&
|
inode->i_blocks || inode->i_block[0]) &&
|
||||||
fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
|
fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
|
||||||
&pctx)) {
|
&pctx)) {
|
||||||
memset(inode, 0, inode_size);
|
memset(inode, 0, inode_size);
|
||||||
ext2fs_icount_store(ctx->inode_link_info,
|
ext2fs_icount_store(ctx->inode_link_info,
|
||||||
ino, 0);
|
ino, 0);
|
||||||
e2fsck_write_inode_full(ctx, ino, inode,
|
e2fsck_write_inode_full(ctx, ino, inode,
|
||||||
inode_size, "pass1");
|
inode_size, "pass1");
|
||||||
}
|
}
|
||||||
} else if (ino < EXT2_FIRST_INODE(fs->super)) {
|
} else if (ino < EXT2_FIRST_INODE(fs->super)) {
|
||||||
int problem = 0;
|
int problem = 0;
|
||||||
|
|
||||||
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
|
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
|
||||||
if (ino == EXT2_BOOT_LOADER_INO) {
|
if (ino == EXT2_BOOT_LOADER_INO) {
|
||||||
if (LINUX_S_ISDIR(inode->i_mode))
|
if (LINUX_S_ISDIR(inode->i_mode))
|
||||||
|
@ -868,7 +868,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
* orphaned list linked list. They should have gotten
|
* orphaned list linked list. They should have gotten
|
||||||
* dealt with by now, unless the list had somehow been
|
* dealt with by now, unless the list had somehow been
|
||||||
* corrupted.
|
* corrupted.
|
||||||
*
|
*
|
||||||
* FIXME: In the future, inodes which are still in use
|
* FIXME: In the future, inodes which are still in use
|
||||||
* (and which are therefore) pending truncation should
|
* (and which are therefore) pending truncation should
|
||||||
* be handled specially. Right now we just clear the
|
* be handled specially. Right now we just clear the
|
||||||
|
@ -889,10 +889,10 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
"pass1");
|
"pass1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This code assumes that deleted inodes have
|
* This code assumes that deleted inodes have
|
||||||
* i_links_count set to 0.
|
* i_links_count set to 0.
|
||||||
*/
|
*/
|
||||||
if (!inode->i_links_count) {
|
if (!inode->i_links_count) {
|
||||||
if (!inode->i_dtime && inode->i_mode) {
|
if (!inode->i_dtime && inode->i_mode) {
|
||||||
|
@ -913,7 +913,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
* we now assume that the case of non-zero
|
* we now assume that the case of non-zero
|
||||||
* i_links_count and non-zero dtime means that we
|
* i_links_count and non-zero dtime means that we
|
||||||
* should keep the file, not delete it.
|
* should keep the file, not delete it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (inode->i_dtime) {
|
if (inode->i_dtime) {
|
||||||
if (fix_problem(ctx, PR_1_SET_DTIME, &pctx)) {
|
if (fix_problem(ctx, PR_1_SET_DTIME, &pctx)) {
|
||||||
|
@ -921,7 +921,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
e2fsck_write_inode(ctx, ino, inode, "pass1");
|
e2fsck_write_inode(ctx, ino, inode, "pass1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
|
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
|
||||||
switch (fs->super->s_creator_os) {
|
switch (fs->super->s_creator_os) {
|
||||||
case EXT2_OS_HURD:
|
case EXT2_OS_HURD:
|
||||||
|
@ -931,12 +931,12 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
default:
|
default:
|
||||||
frag = fsize = 0;
|
frag = fsize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inode->i_faddr || frag || fsize ||
|
if (inode->i_faddr || frag || fsize ||
|
||||||
(LINUX_S_ISDIR(inode->i_mode) && inode->i_dir_acl))
|
(LINUX_S_ISDIR(inode->i_mode) && inode->i_dir_acl))
|
||||||
mark_inode_bad(ctx, ino);
|
mark_inode_bad(ctx, ino);
|
||||||
if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
|
if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
|
||||||
!(fs->super->s_feature_ro_compat &
|
!(fs->super->s_feature_ro_compat &
|
||||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) &&
|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) &&
|
||||||
(inode->osd2.linux2.l_i_blocks_hi != 0))
|
(inode->osd2.linux2.l_i_blocks_hi != 0))
|
||||||
mark_inode_bad(ctx, ino);
|
mark_inode_bad(ctx, ino);
|
||||||
|
@ -988,7 +988,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
check_size(ctx, &pctx);
|
check_size(ctx, &pctx);
|
||||||
ctx->fs_blockdev_count++;
|
ctx->fs_blockdev_count++;
|
||||||
} else if (LINUX_S_ISLNK (inode->i_mode) &&
|
} else if (LINUX_S_ISLNK (inode->i_mode) &&
|
||||||
e2fsck_pass1_check_symlink(fs, ino, inode,
|
e2fsck_pass1_check_symlink(fs, ino, inode,
|
||||||
block_buf)) {
|
block_buf)) {
|
||||||
check_immutable(ctx, &pctx);
|
check_immutable(ctx, &pctx);
|
||||||
ctx->fs_symlinks_count++;
|
ctx->fs_symlinks_count++;
|
||||||
|
@ -1058,7 +1058,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
ea_refcount_free(ctx->refcount_extra);
|
ea_refcount_free(ctx->refcount_extra);
|
||||||
ctx->refcount_extra = 0;
|
ctx->refcount_extra = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->invalid_bitmaps)
|
if (ctx->invalid_bitmaps)
|
||||||
handle_fs_bad_blocks(ctx);
|
handle_fs_bad_blocks(ctx);
|
||||||
|
|
||||||
|
@ -1084,12 +1084,12 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
|
e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
|
||||||
"recreate inode");
|
"recreate inode");
|
||||||
inode->i_mtime = ctx->now;
|
inode->i_mtime = ctx->now;
|
||||||
e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
|
e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
|
||||||
"recreate inode");
|
"recreate inode");
|
||||||
fs->block_map = save_bmap;
|
fs->block_map = save_bmap;
|
||||||
ctx->flags &= ~E2F_FLAG_RESIZE_INODE;
|
ctx->flags &= ~E2F_FLAG_RESIZE_INODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->flags & E2F_FLAG_RESTART) {
|
if (ctx->flags & E2F_FLAG_RESTART) {
|
||||||
/*
|
/*
|
||||||
* Only the master copy of the superblock and block
|
* Only the master copy of the superblock and block
|
||||||
|
@ -1112,7 +1112,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
||||||
ext2fs_free_mem(&inodes_to_process);
|
ext2fs_free_mem(&inodes_to_process);
|
||||||
endit:
|
endit:
|
||||||
e2fsck_use_inode_shortcuts(ctx, 0);
|
e2fsck_use_inode_shortcuts(ctx, 0);
|
||||||
|
|
||||||
ext2fs_free_mem(&block_buf);
|
ext2fs_free_mem(&block_buf);
|
||||||
ext2fs_free_mem(&inode);
|
ext2fs_free_mem(&inode);
|
||||||
|
|
||||||
|
@ -1128,7 +1128,7 @@ endit:
|
||||||
* When the inode_scan routines call this callback at the end of the
|
* When the inode_scan routines call this callback at the end of the
|
||||||
* glock group, call process_inodes.
|
* glock group, call process_inodes.
|
||||||
*/
|
*/
|
||||||
static errcode_t scan_callback(ext2_filsys fs,
|
static errcode_t scan_callback(ext2_filsys fs,
|
||||||
ext2_inode_scan scan EXT2FS_ATTR((unused)),
|
ext2_inode_scan scan EXT2FS_ATTR((unused)),
|
||||||
dgrp_t group, void * priv_data)
|
dgrp_t group, void * priv_data)
|
||||||
{
|
{
|
||||||
|
@ -1137,7 +1137,7 @@ static errcode_t scan_callback(ext2_filsys fs,
|
||||||
|
|
||||||
scan_struct = (struct scan_callback_struct *) priv_data;
|
scan_struct = (struct scan_callback_struct *) priv_data;
|
||||||
ctx = scan_struct->ctx;
|
ctx = scan_struct->ctx;
|
||||||
|
|
||||||
process_inodes((e2fsck_t) fs->priv_data, scan_struct->block_buf);
|
process_inodes((e2fsck_t) fs->priv_data, scan_struct->block_buf);
|
||||||
|
|
||||||
if (ctx->progress)
|
if (ctx->progress)
|
||||||
|
@ -1159,7 +1159,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf)
|
||||||
const char *old_operation;
|
const char *old_operation;
|
||||||
char buf[80];
|
char buf[80];
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("begin process_inodes: ");
|
printf("begin process_inodes: ");
|
||||||
#endif
|
#endif
|
||||||
|
@ -1174,7 +1174,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf)
|
||||||
for (i=0; i < process_inode_count; i++) {
|
for (i=0; i < process_inode_count; i++) {
|
||||||
pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
|
pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
|
||||||
pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino;
|
pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("%u ", pctx.ino);
|
printf("%u ", pctx.ino);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1201,7 +1201,7 @@ static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b)
|
||||||
const struct process_inode_block *ib_b =
|
const struct process_inode_block *ib_b =
|
||||||
(const struct process_inode_block *) b;
|
(const struct process_inode_block *) b;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = (ib_a->inode.i_block[EXT2_IND_BLOCK] -
|
ret = (ib_a->inode.i_block[EXT2_IND_BLOCK] -
|
||||||
ib_b->inode.i_block[EXT2_IND_BLOCK]);
|
ib_b->inode.i_block[EXT2_IND_BLOCK]);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
@ -1218,7 +1218,7 @@ static void mark_inode_bad(e2fsck_t ctx, ino_t ino)
|
||||||
|
|
||||||
if (!ctx->inode_bad_map) {
|
if (!ctx->inode_bad_map) {
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
|
pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
|
||||||
_("bad inode map"), &ctx->inode_bad_map);
|
_("bad inode map"), &ctx->inode_bad_map);
|
||||||
if (pctx.errcode) {
|
if (pctx.errcode) {
|
||||||
|
@ -1239,7 +1239,7 @@ static void mark_inode_bad(e2fsck_t ctx, ino_t ino)
|
||||||
static void alloc_bb_map(e2fsck_t ctx)
|
static void alloc_bb_map(e2fsck_t ctx)
|
||||||
{
|
{
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
|
pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
|
||||||
_("inode in bad block map"),
|
_("inode in bad block map"),
|
||||||
|
@ -1259,7 +1259,7 @@ static void alloc_bb_map(e2fsck_t ctx)
|
||||||
static void alloc_imagic_map(e2fsck_t ctx)
|
static void alloc_imagic_map(e2fsck_t ctx)
|
||||||
{
|
{
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
|
pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
|
||||||
_("imagic inode map"),
|
_("imagic inode map"),
|
||||||
|
@ -1283,9 +1283,9 @@ static void alloc_imagic_map(e2fsck_t ctx)
|
||||||
static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
|
static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
|
||||||
{
|
{
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
if (ext2fs_fast_test_block_bitmap(ctx->block_found_map, block)) {
|
if (ext2fs_fast_test_block_bitmap(ctx->block_found_map, block)) {
|
||||||
if (!ctx->block_dup_map) {
|
if (!ctx->block_dup_map) {
|
||||||
pctx.errcode = ext2fs_allocate_block_bitmap(ctx->fs,
|
pctx.errcode = ext2fs_allocate_block_bitmap(ctx->fs,
|
||||||
|
@ -1293,7 +1293,7 @@ static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
|
||||||
&ctx->block_dup_map);
|
&ctx->block_dup_map);
|
||||||
if (pctx.errcode) {
|
if (pctx.errcode) {
|
||||||
pctx.num = 3;
|
pctx.num = 3;
|
||||||
fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR,
|
fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR,
|
||||||
&pctx);
|
&pctx);
|
||||||
/* Should never get here */
|
/* Should never get here */
|
||||||
ctx->flags |= E2F_FLAG_ABORT;
|
ctx->flags |= E2F_FLAG_ABORT;
|
||||||
|
@ -1313,7 +1313,7 @@ static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
|
||||||
* EA blocks that had extra references as accounted for in
|
* EA blocks that had extra references as accounted for in
|
||||||
* ctx->refcount_extra.
|
* ctx->refcount_extra.
|
||||||
*/
|
*/
|
||||||
static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
|
static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
|
||||||
char *block_buf, int adjust_sign)
|
char *block_buf, int adjust_sign)
|
||||||
{
|
{
|
||||||
struct ext2_ext_attr_header *header;
|
struct ext2_ext_attr_header *header;
|
||||||
|
@ -1324,7 +1324,7 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
ea_refcount_intr_begin(refcount);
|
ea_refcount_intr_begin(refcount);
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((blk = ea_refcount_intr_next(refcount, &count)) == 0)
|
if ((blk = ea_refcount_intr_next(refcount, &count)) == 0)
|
||||||
|
@ -1566,7 +1566,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
retval = io_channel_read_blk(fs->io, blk, 1, block_buf);
|
retval = io_channel_read_blk(fs->io, blk, 1, block_buf);
|
||||||
if (retval && fix_problem(ctx, PR_1_HTREE_BADROOT, pctx))
|
if (retval && fix_problem(ctx, PR_1_HTREE_BADROOT, pctx))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* XXX should check that beginning matches a directory */
|
/* XXX should check that beginning matches a directory */
|
||||||
root = (struct ext2_dx_root_info *) (block_buf + 24);
|
root = (struct ext2_dx_root_info *) (block_buf + 24);
|
||||||
|
|
||||||
|
@ -1580,7 +1580,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
(root->hash_version != EXT2_HASH_TEA) &&
|
(root->hash_version != EXT2_HASH_TEA) &&
|
||||||
fix_problem(ctx, PR_1_HTREE_HASHV, pctx))
|
fix_problem(ctx, PR_1_HTREE_HASHV, pctx))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((root->unused_flags & EXT2_HASH_FLAG_INCOMPAT) &&
|
if ((root->unused_flags & EXT2_HASH_FLAG_INCOMPAT) &&
|
||||||
fix_problem(ctx, PR_1_HTREE_INCOMPAT, pctx))
|
fix_problem(ctx, PR_1_HTREE_INCOMPAT, pctx))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1589,7 +1589,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
if ((root->indirect_levels > 1) &&
|
if ((root->indirect_levels > 1) &&
|
||||||
fix_problem(ctx, PR_1_HTREE_DEPTH, pctx))
|
fix_problem(ctx, PR_1_HTREE_DEPTH, pctx))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1791,7 +1791,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
int dirty_inode = 0;
|
int dirty_inode = 0;
|
||||||
int extent_fs;
|
int extent_fs;
|
||||||
__u64 size;
|
__u64 size;
|
||||||
|
|
||||||
pb.ino = ino;
|
pb.ino = ino;
|
||||||
pb.num_blocks = 0;
|
pb.num_blocks = 0;
|
||||||
pb.last_block = -1;
|
pb.last_block = -1;
|
||||||
|
@ -1853,7 +1853,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
"check_blocks");
|
"check_blocks");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb.is_dir) {
|
if (pb.is_dir) {
|
||||||
while (1) {
|
while (1) {
|
||||||
struct ext2_db_entry *entry;
|
struct ext2_db_entry *entry;
|
||||||
|
@ -1863,7 +1863,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
(entry->blk != 0) ||
|
(entry->blk != 0) ||
|
||||||
(entry->blockcnt == 0))
|
(entry->blockcnt == 0))
|
||||||
break;
|
break;
|
||||||
/* printf("Dropping ino %lu blk %lu blockcnt %d\n",
|
/* printf("Dropping ino %lu blk %lu blockcnt %d\n",
|
||||||
entry->ino, entry->blk, entry->blockcnt); */
|
entry->ino, entry->blk, entry->blockcnt); */
|
||||||
ext2fs_dblist_drop_last(fs->dblist);
|
ext2fs_dblist_drop_last(fs->dblist);
|
||||||
if (ext2fs_dblist_get_last(fs->dblist, &entry) ||
|
if (ext2fs_dblist_get_last(fs->dblist, &entry) ||
|
||||||
|
@ -1888,7 +1888,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
!(inode->i_flags & EXT2_INDEX_FL) &&
|
!(inode->i_flags & EXT2_INDEX_FL) &&
|
||||||
((inode->i_size / fs->blocksize) >= 3))
|
((inode->i_size / fs->blocksize) >= 3))
|
||||||
ext2fs_u32_list_add(ctx->dirs_to_hash, ino);
|
ext2fs_u32_list_add(ctx->dirs_to_hash, ino);
|
||||||
|
|
||||||
if (!pb.num_blocks && pb.is_dir) {
|
if (!pb.num_blocks && pb.is_dir) {
|
||||||
if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) {
|
if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) {
|
||||||
e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks");
|
e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks");
|
||||||
|
@ -1908,7 +1908,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
#endif
|
#endif
|
||||||
if (pb.is_dir) {
|
if (pb.is_dir) {
|
||||||
int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
|
int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
|
||||||
if (inode->i_size & (fs->blocksize - 1))
|
if (inode->i_size & (fs->blocksize - 1))
|
||||||
bad_size = 5;
|
bad_size = 5;
|
||||||
else if (nblock > (pb.last_block + 1))
|
else if (nblock > (pb.last_block + 1))
|
||||||
bad_size = 1;
|
bad_size = 1;
|
||||||
|
@ -2095,7 +2095,7 @@ static int process_block(ext2_filsys fs,
|
||||||
printf("Process_block, inode %lu, block %u, #%d\n", p->ino, blk,
|
printf("Process_block, inode %lu, block %u, #%d\n", p->ino, blk,
|
||||||
blockcnt);
|
blockcnt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simplistic fragmentation check. We merely require that the
|
* Simplistic fragmentation check. We merely require that the
|
||||||
* file be contiguous. (Which can never be true for really
|
* file be contiguous. (Which can never be true for really
|
||||||
|
@ -2120,7 +2120,7 @@ static int process_block(ext2_filsys fs,
|
||||||
problem = PR_1_TOOBIG_REG;
|
problem = PR_1_TOOBIG_REG;
|
||||||
if (!p->is_dir && !p->is_reg && blockcnt > 0)
|
if (!p->is_dir && !p->is_reg && blockcnt > 0)
|
||||||
problem = PR_1_TOOBIG_SYMLINK;
|
problem = PR_1_TOOBIG_SYMLINK;
|
||||||
|
|
||||||
if (blk < fs->super->s_first_data_block ||
|
if (blk < fs->super->s_first_data_block ||
|
||||||
blk >= fs->super->s_blocks_count)
|
blk >= fs->super->s_blocks_count)
|
||||||
problem = PR_1_ILLEGAL_BLOCK_NUM;
|
problem = PR_1_ILLEGAL_BLOCK_NUM;
|
||||||
|
@ -2149,7 +2149,7 @@ static int process_block(ext2_filsys fs,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->ino == EXT2_RESIZE_INO) {
|
if (p->ino == EXT2_RESIZE_INO) {
|
||||||
/*
|
/*
|
||||||
* The resize inode has already be sanity checked
|
* The resize inode has already be sanity checked
|
||||||
* during pass #0 (the superblock checks). All we
|
* during pass #0 (the superblock checks). All we
|
||||||
* have to do is mark the double indirect block as
|
* have to do is mark the double indirect block as
|
||||||
|
@ -2200,11 +2200,11 @@ static int process_bad_block(ext2_filsys fs,
|
||||||
|
|
||||||
if (!blk)
|
if (!blk)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
p = (struct process_block_struct *) priv_data;
|
p = (struct process_block_struct *) priv_data;
|
||||||
ctx = p->ctx;
|
ctx = p->ctx;
|
||||||
pctx = p->pctx;
|
pctx = p->pctx;
|
||||||
|
|
||||||
pctx->ino = EXT2_BAD_INO;
|
pctx->ino = EXT2_BAD_INO;
|
||||||
pctx->blk = blk;
|
pctx->blk = blk;
|
||||||
pctx->blkcount = blockcnt;
|
pctx->blkcount = blockcnt;
|
||||||
|
@ -2225,10 +2225,10 @@ static int process_bad_block(ext2_filsys fs,
|
||||||
*block_nr = 0;
|
*block_nr = 0;
|
||||||
return BLOCK_CHANGED;
|
return BLOCK_CHANGED;
|
||||||
}
|
}
|
||||||
} else if (ext2fs_test_block_bitmap(ctx->block_found_map,
|
} else if (ext2fs_test_block_bitmap(ctx->block_found_map,
|
||||||
blk)) {
|
blk)) {
|
||||||
p->bbcheck = 1;
|
p->bbcheck = 1;
|
||||||
if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK,
|
if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK,
|
||||||
pctx)) {
|
pctx)) {
|
||||||
*block_nr = 0;
|
*block_nr = 0;
|
||||||
return BLOCK_CHANGED;
|
return BLOCK_CHANGED;
|
||||||
|
@ -2239,7 +2239,7 @@ static int process_bad_block(ext2_filsys fs,
|
||||||
mark_block_used(ctx, blk);
|
mark_block_used(ctx, blk);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
printf ("DEBUG: Marking %u as bad.\n", blk);
|
printf ("DEBUG: Marking %u as bad.\n", blk);
|
||||||
#endif
|
#endif
|
||||||
ctx->fs_badblocks_count++;
|
ctx->fs_badblocks_count++;
|
||||||
|
@ -2257,7 +2257,7 @@ static int process_bad_block(ext2_filsys fs,
|
||||||
* Try to find the where the filesystem block was used...
|
* Try to find the where the filesystem block was used...
|
||||||
*/
|
*/
|
||||||
first_block = fs->super->s_first_data_block;
|
first_block = fs->super->s_first_data_block;
|
||||||
|
|
||||||
for (i = 0; i < fs->group_desc_count; i++ ) {
|
for (i = 0; i < fs->group_desc_count; i++ ) {
|
||||||
pctx->group = i;
|
pctx->group = i;
|
||||||
pctx->blk = blk;
|
pctx->blk = blk;
|
||||||
|
@ -2343,7 +2343,7 @@ static int process_bad_block(ext2_filsys fs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void new_table_block(e2fsck_t ctx, blk_t first_block, int group,
|
static void new_table_block(e2fsck_t ctx, blk_t first_block, int group,
|
||||||
const char *name, int num, blk_t *new_block)
|
const char *name, int num, blk_t *new_block)
|
||||||
{
|
{
|
||||||
ext2_filsys fs = ctx->fs;
|
ext2_filsys fs = ctx->fs;
|
||||||
|
@ -2426,7 +2426,7 @@ static void handle_fs_bad_blocks(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
if (ctx->invalid_inode_table_flag[i]) {
|
if (ctx->invalid_inode_table_flag[i]) {
|
||||||
new_table_block(ctx, first_block, i, _("inode table"),
|
new_table_block(ctx, first_block, i, _("inode table"),
|
||||||
fs->inode_blocks_per_group,
|
fs->inode_blocks_per_group,
|
||||||
&fs->group_desc[i].bg_inode_table);
|
&fs->group_desc[i].bg_inode_table);
|
||||||
ctx->flags |= E2F_FLAG_RESTART;
|
ctx->flags |= E2F_FLAG_RESTART;
|
||||||
}
|
}
|
||||||
|
@ -2445,9 +2445,9 @@ static void mark_table_blocks(e2fsck_t ctx)
|
||||||
dgrp_t i;
|
dgrp_t i;
|
||||||
int j;
|
int j;
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
for (i = 0; i < fs->group_desc_count; i++) {
|
for (i = 0; i < fs->group_desc_count; i++) {
|
||||||
pctx.group = i;
|
pctx.group = i;
|
||||||
|
|
||||||
|
@ -2474,9 +2474,9 @@ static void mark_table_blocks(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark block used for the block bitmap
|
* Mark block used for the block bitmap
|
||||||
*/
|
*/
|
||||||
if (fs->group_desc[i].bg_block_bitmap) {
|
if (fs->group_desc[i].bg_block_bitmap) {
|
||||||
if (ext2fs_test_block_bitmap(ctx->block_found_map,
|
if (ext2fs_test_block_bitmap(ctx->block_found_map,
|
||||||
|
@ -2490,10 +2490,10 @@ static void mark_table_blocks(e2fsck_t ctx)
|
||||||
ext2fs_mark_block_bitmap(ctx->block_found_map,
|
ext2fs_mark_block_bitmap(ctx->block_found_map,
|
||||||
fs->group_desc[i].bg_block_bitmap);
|
fs->group_desc[i].bg_block_bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Mark block used for the inode bitmap
|
* Mark block used for the inode bitmap
|
||||||
*/
|
*/
|
||||||
if (fs->group_desc[i].bg_inode_bitmap) {
|
if (fs->group_desc[i].bg_inode_bitmap) {
|
||||||
if (ext2fs_test_block_bitmap(ctx->block_found_map,
|
if (ext2fs_test_block_bitmap(ctx->block_found_map,
|
||||||
|
@ -2502,7 +2502,7 @@ static void mark_table_blocks(e2fsck_t ctx)
|
||||||
if (fix_problem(ctx, PR_1_IB_CONFLICT, &pctx)) {
|
if (fix_problem(ctx, PR_1_IB_CONFLICT, &pctx)) {
|
||||||
ctx->invalid_inode_bitmap_flag[i]++;
|
ctx->invalid_inode_bitmap_flag[i]++;
|
||||||
ctx->invalid_bitmaps++;
|
ctx->invalid_bitmaps++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ext2fs_mark_block_bitmap(ctx->block_found_map,
|
ext2fs_mark_block_bitmap(ctx->block_found_map,
|
||||||
fs->group_desc[i].bg_inode_bitmap);
|
fs->group_desc[i].bg_inode_bitmap);
|
||||||
|
@ -2510,7 +2510,7 @@ static void mark_table_blocks(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Thes subroutines short circuits ext2fs_get_blocks and
|
* Thes subroutines short circuits ext2fs_get_blocks and
|
||||||
* ext2fs_check_directory; we use them since we already have the inode
|
* ext2fs_check_directory; we use them since we already have the inode
|
||||||
|
@ -2522,7 +2522,7 @@ static errcode_t pass1_get_blocks(ext2_filsys fs, ext2_ino_t ino,
|
||||||
{
|
{
|
||||||
e2fsck_t ctx = (e2fsck_t) fs->priv_data;
|
e2fsck_t ctx = (e2fsck_t) fs->priv_data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((ino != ctx->stashed_ino) || !ctx->stashed_inode)
|
if ((ino != ctx->stashed_ino) || !ctx->stashed_inode)
|
||||||
return EXT2_ET_CALLBACK_NOTHANDLED;
|
return EXT2_ET_CALLBACK_NOTHANDLED;
|
||||||
|
|
||||||
|
@ -2573,7 +2573,7 @@ static errcode_t e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal,
|
||||||
blk_t new_block;
|
blk_t new_block;
|
||||||
|
|
||||||
if (ctx->block_found_map) {
|
if (ctx->block_found_map) {
|
||||||
retval = ext2fs_new_block(fs, (blk_t) goal,
|
retval = ext2fs_new_block(fs, (blk_t) goal,
|
||||||
ctx->block_found_map, &new_block);
|
ctx->block_found_map, &new_block);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -2588,7 +2588,7 @@ static errcode_t e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal,
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ret = new_block;
|
*ret = new_block;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -2599,10 +2599,10 @@ static void e2fsck_block_alloc_stats(ext2_filsys fs, blk64_t blk, int inuse)
|
||||||
|
|
||||||
if (ctx->block_found_map) {
|
if (ctx->block_found_map) {
|
||||||
if (inuse > 0)
|
if (inuse > 0)
|
||||||
ext2fs_mark_block_bitmap(ctx->block_found_map,
|
ext2fs_mark_block_bitmap(ctx->block_found_map,
|
||||||
(blk_t) blk);
|
(blk_t) blk);
|
||||||
else
|
else
|
||||||
ext2fs_unmark_block_bitmap(ctx->block_found_map,
|
ext2fs_unmark_block_bitmap(ctx->block_found_map,
|
||||||
(blk_t) blk);
|
(blk_t) blk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* This file contains pass1B, pass1C, and pass1D of e2fsck. They are
|
* This file contains pass1B, pass1C, and pass1D of e2fsck. They are
|
||||||
* only invoked if pass 1 discovered blocks which are in use by more
|
* only invoked if pass 1 discovered blocks which are in use by more
|
||||||
* than one inode.
|
* than one inode.
|
||||||
*
|
*
|
||||||
* Pass1B scans the data blocks of all the inodes again, generating a
|
* Pass1B scans the data blocks of all the inodes again, generating a
|
||||||
* complete list of duplicate blocks and which inodes have claimed
|
* complete list of duplicate blocks and which inodes have claimed
|
||||||
* them.
|
* them.
|
||||||
|
@ -17,14 +17,14 @@
|
||||||
* blocks, the user is prompted if s/he would like to clone the file
|
* blocks, the user is prompted if s/he would like to clone the file
|
||||||
* (so that the file gets a fresh copy of the duplicated blocks) or
|
* (so that the file gets a fresh copy of the duplicated blocks) or
|
||||||
* simply to delete the file.
|
* simply to delete the file.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -83,7 +83,7 @@ struct dup_inode {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int process_pass1b_block(ext2_filsys fs, blk_t *blocknr,
|
static int process_pass1b_block(ext2_filsys fs, blk_t *blocknr,
|
||||||
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
||||||
int ref_offset, void *priv_data);
|
int ref_offset, void *priv_data);
|
||||||
static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
|
static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
struct dup_inode *dp, char *block_buf);
|
struct dup_inode *dp, char *block_buf);
|
||||||
|
@ -169,7 +169,7 @@ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk,
|
||||||
/*
|
/*
|
||||||
* Free a duplicate inode record
|
* Free a duplicate inode record
|
||||||
*/
|
*/
|
||||||
static void inode_dnode_free(dnode_t *node,
|
static void inode_dnode_free(dnode_t *node,
|
||||||
void *context EXT2FS_ATTR((unused)))
|
void *context EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
struct dup_inode *di;
|
struct dup_inode *di;
|
||||||
|
@ -186,7 +186,7 @@ static void inode_dnode_free(dnode_t *node,
|
||||||
/*
|
/*
|
||||||
* Free a duplicate block record
|
* Free a duplicate block record
|
||||||
*/
|
*/
|
||||||
static void block_dnode_free(dnode_t *node,
|
static void block_dnode_free(dnode_t *node,
|
||||||
void *context EXT2FS_ATTR((unused)))
|
void *context EXT2FS_ATTR((unused)))
|
||||||
{
|
{
|
||||||
struct dup_block *db;
|
struct dup_block *db;
|
||||||
|
@ -210,7 +210,7 @@ void e2fsck_pass1_dupblocks(e2fsck_t ctx, char *block_buf)
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
pctx.errcode = ext2fs_allocate_inode_bitmap(fs,
|
pctx.errcode = ext2fs_allocate_inode_bitmap(fs,
|
||||||
_("multiply claimed inode map"), &inode_dup_map);
|
_("multiply claimed inode map"), &inode_dup_map);
|
||||||
if (pctx.errcode) {
|
if (pctx.errcode) {
|
||||||
|
@ -223,7 +223,7 @@ void e2fsck_pass1_dupblocks(e2fsck_t ctx, char *block_buf)
|
||||||
dict_init(&blk_dict, DICTCOUNT_T_MAX, dict_int_cmp);
|
dict_init(&blk_dict, DICTCOUNT_T_MAX, dict_int_cmp);
|
||||||
dict_set_allocator(&ino_dict, NULL, inode_dnode_free, NULL);
|
dict_set_allocator(&ino_dict, NULL, inode_dnode_free, NULL);
|
||||||
dict_set_allocator(&blk_dict, NULL, block_dnode_free, NULL);
|
dict_set_allocator(&blk_dict, NULL, block_dnode_free, NULL);
|
||||||
|
|
||||||
pass1b(ctx, block_buf);
|
pass1b(ctx, block_buf);
|
||||||
pass1c(ctx, block_buf);
|
pass1c(ctx, block_buf);
|
||||||
pass1d(ctx, block_buf);
|
pass1d(ctx, block_buf);
|
||||||
|
@ -255,9 +255,9 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
|
||||||
ext2_inode_scan scan;
|
ext2_inode_scan scan;
|
||||||
struct process_block_struct pb;
|
struct process_block_struct pb;
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
if (!(ctx->options & E2F_OPT_PREEN))
|
if (!(ctx->options & E2F_OPT_PREEN))
|
||||||
fix_problem(ctx, PR_1B_PASS_HEADER, &pctx);
|
fix_problem(ctx, PR_1B_PASS_HEADER, &pctx);
|
||||||
pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
|
pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
|
||||||
|
@ -315,7 +315,7 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
|
||||||
static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)),
|
static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
blk_t *block_nr,
|
blk_t *block_nr,
|
||||||
e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
|
e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
|
||||||
blk_t ref_blk EXT2FS_ATTR((unused)),
|
blk_t ref_blk EXT2FS_ATTR((unused)),
|
||||||
int ref_offset EXT2FS_ATTR((unused)),
|
int ref_offset EXT2FS_ATTR((unused)),
|
||||||
void *priv_data)
|
void *priv_data)
|
||||||
{
|
{
|
||||||
|
@ -326,10 +326,10 @@ static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
return 0;
|
return 0;
|
||||||
p = (struct process_block_struct *) priv_data;
|
p = (struct process_block_struct *) priv_data;
|
||||||
ctx = p->ctx;
|
ctx = p->ctx;
|
||||||
|
|
||||||
if (!ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr))
|
if (!ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* OK, this is a duplicate block */
|
/* OK, this is a duplicate block */
|
||||||
if (p->ino != EXT2_BAD_INO) {
|
if (p->ino != EXT2_BAD_INO) {
|
||||||
p->pctx->blk = *block_nr;
|
p->pctx->blk = *block_nr;
|
||||||
|
@ -339,7 +339,7 @@ static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
ext2fs_mark_inode_bitmap(inode_dup_map, p->ino);
|
ext2fs_mark_inode_bitmap(inode_dup_map, p->ino);
|
||||||
|
|
||||||
add_dupe(ctx, p->ino, *block_nr, p->inode);
|
add_dupe(ctx, p->ino, *block_nr, p->inode);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,9 +356,9 @@ struct search_dir_struct {
|
||||||
|
|
||||||
static int search_dirent_proc(ext2_ino_t dir, int entry,
|
static int search_dirent_proc(ext2_ino_t dir, int entry,
|
||||||
struct ext2_dir_entry *dirent,
|
struct ext2_dir_entry *dirent,
|
||||||
int offset EXT2FS_ATTR((unused)),
|
int offset EXT2FS_ATTR((unused)),
|
||||||
int blocksize EXT2FS_ATTR((unused)),
|
int blocksize EXT2FS_ATTR((unused)),
|
||||||
char *buf EXT2FS_ATTR((unused)),
|
char *buf EXT2FS_ATTR((unused)),
|
||||||
void *priv_data)
|
void *priv_data)
|
||||||
{
|
{
|
||||||
struct search_dir_struct *sd;
|
struct search_dir_struct *sd;
|
||||||
|
@ -369,7 +369,7 @@ static int search_dirent_proc(ext2_ino_t dir, int entry,
|
||||||
|
|
||||||
if (dirent->inode > sd->max_inode)
|
if (dirent->inode > sd->max_inode)
|
||||||
/* Should abort this inode, but not everything */
|
/* Should abort this inode, but not everything */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((dirent->inode < sd->first_inode) || (entry < DIRENT_OTHER_FILE) ||
|
if ((dirent->inode < sd->first_inode) || (entry < DIRENT_OTHER_FILE) ||
|
||||||
!ext2fs_test_inode_bitmap(inode_dup_map, dirent->inode))
|
!ext2fs_test_inode_bitmap(inode_dup_map, dirent->inode))
|
||||||
|
@ -408,7 +408,7 @@ static void pass1c(e2fsck_t ctx, char *block_buf)
|
||||||
sd.max_inode = fs->super->s_inodes_count;
|
sd.max_inode = fs->super->s_inodes_count;
|
||||||
ext2fs_dblist_dir_iterate(fs->dblist, 0, block_buf,
|
ext2fs_dblist_dir_iterate(fs->dblist, 0, block_buf,
|
||||||
search_dirent_proc, &sd);
|
search_dirent_proc, &sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pass1d(e2fsck_t ctx, char *block_buf)
|
static void pass1d(e2fsck_t ctx, char *block_buf)
|
||||||
{
|
{
|
||||||
|
@ -424,9 +424,9 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
|
||||||
dnode_t *n, *m;
|
dnode_t *n, *m;
|
||||||
struct block_el *s;
|
struct block_el *s;
|
||||||
struct inode_el *r;
|
struct inode_el *r;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
if (!(ctx->options & E2F_OPT_PREEN))
|
if (!(ctx->options & E2F_OPT_PREEN))
|
||||||
fix_problem(ctx, PR_1D_PASS_HEADER, &pctx);
|
fix_problem(ctx, PR_1D_PASS_HEADER, &pctx);
|
||||||
e2fsck_read_bitmaps(ctx);
|
e2fsck_read_bitmaps(ctx);
|
||||||
|
@ -461,7 +461,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
|
||||||
file_ok = 0;
|
file_ok = 0;
|
||||||
meta_data = 1;
|
meta_data = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add all inodes used by this block to the
|
* Add all inodes used by this block to the
|
||||||
* shared[] --- which is a unique list, so
|
* shared[] --- which is a unique list, so
|
||||||
|
@ -491,10 +491,10 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
|
||||||
fix_problem(ctx, PR_1D_DUP_FILE, &pctx);
|
fix_problem(ctx, PR_1D_DUP_FILE, &pctx);
|
||||||
pctx.blkcount = 0;
|
pctx.blkcount = 0;
|
||||||
pctx.num = 0;
|
pctx.num = 0;
|
||||||
|
|
||||||
if (meta_data)
|
if (meta_data)
|
||||||
fix_problem(ctx, PR_1D_SHARE_METADATA, &pctx);
|
fix_problem(ctx, PR_1D_SHARE_METADATA, &pctx);
|
||||||
|
|
||||||
for (i = 0; i < shared_len; i++) {
|
for (i = 0; i < shared_len; i++) {
|
||||||
m = dict_lookup(&ino_dict, INT_TO_VOIDPTR(shared[i]));
|
m = dict_lookup(&ino_dict, INT_TO_VOIDPTR(shared[i]));
|
||||||
if (!m)
|
if (!m)
|
||||||
|
@ -570,10 +570,10 @@ static int delete_file_block(ext2_filsys fs,
|
||||||
ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr);
|
ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr);
|
||||||
ext2fs_block_alloc_stats(fs, *block_nr, -1);
|
ext2fs_block_alloc_stats(fs, *block_nr, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
|
static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
struct dup_inode *dp, char* block_buf)
|
struct dup_inode *dp, char* block_buf)
|
||||||
{
|
{
|
||||||
|
@ -591,7 +591,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
|
|
||||||
e2fsck_read_inode(ctx, ino, &inode, "delete_file");
|
e2fsck_read_inode(ctx, ino, &inode, "delete_file");
|
||||||
if (ext2fs_inode_has_valid_blocks(&inode))
|
if (ext2fs_inode_has_valid_blocks(&inode))
|
||||||
pctx.errcode = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_READ_ONLY,
|
pctx.errcode = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_READ_ONLY,
|
||||||
block_buf, delete_file_block, &pb);
|
block_buf, delete_file_block, &pb);
|
||||||
if (pctx.errcode)
|
if (pctx.errcode)
|
||||||
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
|
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
|
||||||
|
@ -623,7 +623,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
*/
|
*/
|
||||||
if ((count == 0) ||
|
if ((count == 0) ||
|
||||||
ext2fs_test_block_bitmap(ctx->block_dup_map,
|
ext2fs_test_block_bitmap(ctx->block_dup_map,
|
||||||
inode.i_file_acl))
|
inode.i_file_acl))
|
||||||
delete_file_block(fs, &inode.i_file_acl,
|
delete_file_block(fs, &inode.i_file_acl,
|
||||||
BLOCK_COUNT_EXTATTR, 0, 0, &pb);
|
BLOCK_COUNT_EXTATTR, 0, 0, &pb);
|
||||||
}
|
}
|
||||||
|
@ -651,7 +651,7 @@ static int clone_file_block(ext2_filsys fs,
|
||||||
e2fsck_t ctx;
|
e2fsck_t ctx;
|
||||||
|
|
||||||
ctx = cs->ctx;
|
ctx = cs->ctx;
|
||||||
|
|
||||||
if (HOLE_BLKADDR(*block_nr))
|
if (HOLE_BLKADDR(*block_nr))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -702,7 +702,7 @@ static int clone_file_block(ext2_filsys fs,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
|
static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
struct dup_inode *dp, char* block_buf)
|
struct dup_inode *dp, char* block_buf)
|
||||||
{
|
{
|
||||||
|
@ -758,7 +758,7 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
*/
|
*/
|
||||||
n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk));
|
n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk));
|
||||||
if (!n) {
|
if (!n) {
|
||||||
com_err("clone_file", 0,
|
com_err("clone_file", 0,
|
||||||
_("internal error: couldn't lookup EA "
|
_("internal error: couldn't lookup EA "
|
||||||
"block record for %u"), blk);
|
"block record for %u"), blk);
|
||||||
retval = 0; /* OK to stumble on... */
|
retval = 0; /* OK to stumble on... */
|
||||||
|
@ -770,9 +770,9 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
continue;
|
continue;
|
||||||
n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode));
|
n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode));
|
||||||
if (!n) {
|
if (!n) {
|
||||||
com_err("clone_file", 0,
|
com_err("clone_file", 0,
|
||||||
_("internal error: couldn't lookup EA "
|
_("internal error: couldn't lookup EA "
|
||||||
"inode record for %u"),
|
"inode record for %u"),
|
||||||
ino_el->inode);
|
ino_el->inode);
|
||||||
retval = 0; /* OK to stumble on... */
|
retval = 0; /* OK to stumble on... */
|
||||||
goto errout;
|
goto errout;
|
||||||
|
@ -801,7 +801,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
|
||||||
ext2_filsys fs = ctx->fs;
|
ext2_filsys fs = ctx->fs;
|
||||||
blk_t first_block;
|
blk_t first_block;
|
||||||
dgrp_t i;
|
dgrp_t i;
|
||||||
|
|
||||||
first_block = fs->super->s_first_data_block;
|
first_block = fs->super->s_first_data_block;
|
||||||
for (i = 0; i < fs->group_desc_count; i++) {
|
for (i = 0; i < fs->group_desc_count; i++) {
|
||||||
|
|
||||||
|
@ -811,7 +811,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
|
||||||
(test_block <= first_block + fs->desc_blocks))
|
(test_block <= first_block + fs->desc_blocks))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the inode table */
|
/* Check the inode table */
|
||||||
if ((fs->group_desc[i].bg_inode_table) &&
|
if ((fs->group_desc[i].bg_inode_table) &&
|
||||||
(test_block >= fs->group_desc[i].bg_inode_table) &&
|
(test_block >= fs->group_desc[i].bg_inode_table) &&
|
||||||
|
@ -823,7 +823,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
|
||||||
if ((test_block == fs->group_desc[i].bg_block_bitmap) ||
|
if ((test_block == fs->group_desc[i].bg_block_bitmap) ||
|
||||||
(test_block == fs->group_desc[i].bg_inode_bitmap))
|
(test_block == fs->group_desc[i].bg_inode_bitmap))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
first_block += fs->super->s_blocks_per_group;
|
first_block += fs->super->s_blocks_per_group;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
102
e2fsck/pass2.c
102
e2fsck/pass2.c
|
@ -1,13 +1,13 @@
|
||||||
/*
|
/*
|
||||||
* pass2.c --- check directory structure
|
* pass2.c --- check directory structure
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
* Pass 2 of e2fsck iterates through all active directory inodes, and
|
* Pass 2 of e2fsck iterates through all active directory inodes, and
|
||||||
* applies to following tests to each directory entry in the directory
|
* applies to following tests to each directory entry in the directory
|
||||||
* blocks in the inodes:
|
* blocks in the inodes:
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
* least 8 bytes, and no more than the remaining space
|
* least 8 bytes, and no more than the remaining space
|
||||||
* left in the directory block.
|
* left in the directory block.
|
||||||
* - The length of the name in the directory entry (name_len)
|
* - The length of the name in the directory entry (name_len)
|
||||||
* should be less than (rec_len - 8).
|
* should be less than (rec_len - 8).
|
||||||
* - The inode number in the directory entry should be within
|
* - The inode number in the directory entry should be within
|
||||||
* legal bounds.
|
* legal bounds.
|
||||||
* - The inode number should refer to a in-use inode.
|
* - The inode number should refer to a in-use inode.
|
||||||
|
@ -70,7 +70,7 @@ static int update_dir_block(ext2_filsys fs,
|
||||||
blk_t *block_nr,
|
blk_t *block_nr,
|
||||||
e2_blkcnt_t blockcnt,
|
e2_blkcnt_t blockcnt,
|
||||||
blk_t ref_block,
|
blk_t ref_block,
|
||||||
int ref_offset,
|
int ref_offset,
|
||||||
void *priv_data);
|
void *priv_data);
|
||||||
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
|
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
|
||||||
static int htree_depth(struct dx_dir_info *dx_dir,
|
static int htree_depth(struct dx_dir_info *dx_dir,
|
||||||
|
@ -82,7 +82,7 @@ struct check_dir_struct {
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
int count, max;
|
int count, max;
|
||||||
e2fsck_t ctx;
|
e2fsck_t ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
void e2fsck_pass2(e2fsck_t ctx)
|
void e2fsck_pass2(e2fsck_t ctx)
|
||||||
{
|
{
|
||||||
|
@ -114,12 +114,12 @@ void e2fsck_pass2(e2fsck_t ctx)
|
||||||
if (!(ctx->options & E2F_OPT_PREEN))
|
if (!(ctx->options & E2F_OPT_PREEN))
|
||||||
fix_problem(ctx, PR_2_PASS_HEADER, &cd.pctx);
|
fix_problem(ctx, PR_2_PASS_HEADER, &cd.pctx);
|
||||||
|
|
||||||
e2fsck_setup_tdb_icount(ctx, EXT2_ICOUNT_OPT_INCREMENT,
|
e2fsck_setup_tdb_icount(ctx, EXT2_ICOUNT_OPT_INCREMENT,
|
||||||
&ctx->inode_count);
|
&ctx->inode_count);
|
||||||
if (ctx->inode_count)
|
if (ctx->inode_count)
|
||||||
cd.pctx.errcode = 0;
|
cd.pctx.errcode = 0;
|
||||||
else
|
else
|
||||||
cd.pctx.errcode = ext2fs_create_icount2(fs,
|
cd.pctx.errcode = ext2fs_create_icount2(fs,
|
||||||
EXT2_ICOUNT_OPT_INCREMENT,
|
EXT2_ICOUNT_OPT_INCREMENT,
|
||||||
0, ctx->inode_link_info,
|
0, ctx->inode_link_info,
|
||||||
&ctx->inode_count);
|
&ctx->inode_count);
|
||||||
|
@ -148,7 +148,7 @@ void e2fsck_pass2(e2fsck_t ctx)
|
||||||
|
|
||||||
if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX)
|
if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX)
|
||||||
ext2fs_dblist_sort(fs->dblist, special_dir_block_cmp);
|
ext2fs_dblist_sort(fs->dblist, special_dir_block_cmp);
|
||||||
|
|
||||||
cd.pctx.errcode = ext2fs_dblist_iterate(fs->dblist, check_dir_block,
|
cd.pctx.errcode = ext2fs_dblist_iterate(fs->dblist, check_dir_block,
|
||||||
&cd);
|
&cd);
|
||||||
if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
|
||||||
|
@ -195,7 +195,7 @@ void e2fsck_pass2(e2fsck_t ctx)
|
||||||
if (dx_db->flags & DX_FLAG_LAST)
|
if (dx_db->flags & DX_FLAG_LAST)
|
||||||
dx_parent->max_hash = dx_db->max_hash;
|
dx_parent->max_hash = dx_db->max_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (b=0, dx_db = dx_dir->dx_block;
|
for (b=0, dx_db = dx_dir->dx_block;
|
||||||
b < dx_dir->numblocks;
|
b < dx_dir->numblocks;
|
||||||
b++, dx_db++) {
|
b++, dx_db++) {
|
||||||
|
@ -220,7 +220,7 @@ void e2fsck_pass2(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* This test doesn't apply for the root block
|
* This test doesn't apply for the root block
|
||||||
* at block #0
|
* at block #0
|
||||||
*/
|
*/
|
||||||
if (b &&
|
if (b &&
|
||||||
|
@ -277,7 +277,7 @@ void e2fsck_pass2(e2fsck_t ctx)
|
||||||
ext2fs_mark_super_dirty(fs);
|
ext2fs_mark_super_dirty(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RESOURCE_TRACK
|
#ifdef RESOURCE_TRACK
|
||||||
if (ctx->options & E2F_OPT_TIME2) {
|
if (ctx->options & E2F_OPT_TIME2) {
|
||||||
e2fsck_clear_progbar(ctx);
|
e2fsck_clear_progbar(ctx);
|
||||||
|
@ -333,10 +333,10 @@ static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b)
|
||||||
|
|
||||||
if (!db_a->blockcnt && db_b->blockcnt)
|
if (!db_a->blockcnt && db_b->blockcnt)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (db_a->blk != db_b->blk)
|
if (db_a->blk != db_b->blk)
|
||||||
return (int) (db_a->blk - db_b->blk);
|
return (int) (db_a->blk - db_b->blk);
|
||||||
|
|
||||||
if (db_a->ino != db_b->ino)
|
if (db_a->ino != db_b->ino)
|
||||||
return (int) (db_a->ino - db_b->ino);
|
return (int) (db_a->ino - db_b->ino);
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ static int check_dot(e2fsck_t ctx,
|
||||||
int created = 0;
|
int created = 0;
|
||||||
int rec_len, new_len;
|
int rec_len, new_len;
|
||||||
int problem = 0;
|
int problem = 0;
|
||||||
|
|
||||||
if (!dirent->inode)
|
if (!dirent->inode)
|
||||||
problem = PR_2_MISSING_DOT;
|
problem = PR_2_MISSING_DOT;
|
||||||
else if (((dirent->name_len & 0xFF) != 1) ||
|
else if (((dirent->name_len & 0xFF) != 1) ||
|
||||||
|
@ -414,7 +414,7 @@ static int check_dotdot(e2fsck_t ctx,
|
||||||
ext2_ino_t ino, struct problem_context *pctx)
|
ext2_ino_t ino, struct problem_context *pctx)
|
||||||
{
|
{
|
||||||
int rec_len, problem = 0;
|
int rec_len, problem = 0;
|
||||||
|
|
||||||
if (!dirent->inode)
|
if (!dirent->inode)
|
||||||
problem = PR_2_MISSING_DOT_DOT;
|
problem = PR_2_MISSING_DOT_DOT;
|
||||||
else if (((dirent->name_len & 0xFF) != 2) ||
|
else if (((dirent->name_len & 0xFF) != 2) ||
|
||||||
|
@ -441,7 +441,7 @@ static int check_dotdot(e2fsck_t ctx,
|
||||||
dirent->name[1] = '.';
|
dirent->name[1] = '.';
|
||||||
dirent->name[2] = '\0';
|
dirent->name[2] = '\0';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (e2fsck_dir_info_set_dotdot(ctx, ino, dirent->inode)) {
|
if (e2fsck_dir_info_set_dotdot(ctx, ino, dirent->inode)) {
|
||||||
|
@ -457,13 +457,13 @@ static int check_dotdot(e2fsck_t ctx,
|
||||||
*/
|
*/
|
||||||
static int check_name(e2fsck_t ctx,
|
static int check_name(e2fsck_t ctx,
|
||||||
struct ext2_dir_entry *dirent,
|
struct ext2_dir_entry *dirent,
|
||||||
ext2_ino_t dir_ino EXT2FS_ATTR((unused)),
|
ext2_ino_t dir_ino EXT2FS_ATTR((unused)),
|
||||||
struct problem_context *pctx)
|
struct problem_context *pctx)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int fixup = -1;
|
int fixup = -1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for ( i = 0; i < (dirent->name_len & 0xFF); i++) {
|
for ( i = 0; i < (dirent->name_len & 0xFF); i++) {
|
||||||
if (dirent->name[i] == '/' || dirent->name[i] == '\0') {
|
if (dirent->name[i] == '/' || dirent->name[i] == '\0') {
|
||||||
if (fixup < 0) {
|
if (fixup < 0) {
|
||||||
|
@ -520,7 +520,7 @@ static _INLINE_ int check_filetype(e2fsck_t ctx,
|
||||||
if (fix_problem(ctx, filetype ? PR_2_BAD_FILETYPE : PR_2_SET_FILETYPE,
|
if (fix_problem(ctx, filetype ? PR_2_BAD_FILETYPE : PR_2_SET_FILETYPE,
|
||||||
pctx) == 0)
|
pctx) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dirent->name_len = (dirent->name_len & 0xFF) | should_be << 8;
|
dirent->name_len = (dirent->name_len & 0xFF) | should_be << 8;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ static void parse_int_node(ext2_filsys fs,
|
||||||
|
|
||||||
if (db->blockcnt == 0) {
|
if (db->blockcnt == 0) {
|
||||||
root = (struct ext2_dx_root_info *) (block_buf + 24);
|
root = (struct ext2_dx_root_info *) (block_buf + 24);
|
||||||
|
|
||||||
#ifdef DX_DEBUG
|
#ifdef DX_DEBUG
|
||||||
printf("Root node dump:\n");
|
printf("Root node dump:\n");
|
||||||
printf("\t Reserved zero: %u\n", root->reserved_zero);
|
printf("\t Reserved zero: %u\n", root->reserved_zero);
|
||||||
|
@ -561,9 +561,9 @@ static void parse_int_node(ext2_filsys fs,
|
||||||
limit = (struct ext2_dx_countlimit *) ent;
|
limit = (struct ext2_dx_countlimit *) ent;
|
||||||
|
|
||||||
#ifdef DX_DEBUG
|
#ifdef DX_DEBUG
|
||||||
printf("Number of entries (count): %d\n",
|
printf("Number of entries (count): %d\n",
|
||||||
ext2fs_le16_to_cpu(limit->count));
|
ext2fs_le16_to_cpu(limit->count));
|
||||||
printf("Number of entries (limit): %d\n",
|
printf("Number of entries (limit): %d\n",
|
||||||
ext2fs_le16_to_cpu(limit->limit));
|
ext2fs_le16_to_cpu(limit->limit));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ static void parse_int_node(ext2_filsys fs,
|
||||||
goto clear_and_exit;
|
goto clear_and_exit;
|
||||||
count = expect_limit;
|
count = expect_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i < count; i++) {
|
for (i=0; i < count; i++) {
|
||||||
prev_hash = hash;
|
prev_hash = hash;
|
||||||
hash = i ? (ext2fs_le32_to_cpu(ent[i].hash) & ~1) : 0;
|
hash = i ? (ext2fs_le32_to_cpu(ent[i].hash) & ~1) : 0;
|
||||||
|
@ -614,7 +614,7 @@ static void parse_int_node(ext2_filsys fs,
|
||||||
max_hash = hash;
|
max_hash = hash;
|
||||||
dx_db->node_min_hash = hash;
|
dx_db->node_min_hash = hash;
|
||||||
if ((i+1) < count)
|
if ((i+1) < count)
|
||||||
dx_db->node_max_hash =
|
dx_db->node_max_hash =
|
||||||
ext2fs_le32_to_cpu(ent[i+1].hash) & ~1;
|
ext2fs_le32_to_cpu(ent[i+1].hash) & ~1;
|
||||||
else {
|
else {
|
||||||
dx_db->node_max_hash = 0xfffffffe;
|
dx_db->node_max_hash = 0xfffffffe;
|
||||||
|
@ -640,7 +640,7 @@ clear_and_exit:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given a busted directory, try to salvage it somehow.
|
* Given a busted directory, try to salvage it somehow.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void salvage_directory(ext2_filsys fs,
|
static void salvage_directory(ext2_filsys fs,
|
||||||
struct ext2_dir_entry *dirent,
|
struct ext2_dir_entry *dirent,
|
||||||
|
@ -739,15 +739,15 @@ static int check_dir_block(ext2_filsys fs,
|
||||||
|
|
||||||
if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
|
||||||
return DIRENT_ABORT;
|
return DIRENT_ABORT;
|
||||||
|
|
||||||
if (ctx->progress && (ctx->progress)(ctx, 2, cd->count++, cd->max))
|
if (ctx->progress && (ctx->progress)(ctx, 2, cd->count++, cd->max))
|
||||||
return DIRENT_ABORT;
|
return DIRENT_ABORT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the inode is still in use (could have been
|
* Make sure the inode is still in use (could have been
|
||||||
* deleted in the duplicate/bad blocks pass.
|
* deleted in the duplicate/bad blocks pass.
|
||||||
*/
|
*/
|
||||||
if (!(ext2fs_test_inode_bitmap(ctx->inode_used_map, ino)))
|
if (!(ext2fs_test_inode_bitmap(ctx->inode_used_map, ino)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cd->pctx.ino = ino;
|
cd->pctx.ino = ino;
|
||||||
|
@ -762,7 +762,7 @@ static int check_dir_block(ext2_filsys fs,
|
||||||
return 0;
|
return 0;
|
||||||
block_nr = db->blk;
|
block_nr = db->blk;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db->blockcnt)
|
if (db->blockcnt)
|
||||||
dot_state = 2;
|
dot_state = 2;
|
||||||
else
|
else
|
||||||
|
@ -776,7 +776,7 @@ static int check_dir_block(ext2_filsys fs,
|
||||||
printf("In process_dir_block block %lu, #%d, inode %lu\n", block_nr,
|
printf("In process_dir_block block %lu, #%d, inode %lu\n", block_nr,
|
||||||
db->blockcnt, ino);
|
db->blockcnt, ino);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
old_op = ehandler_operation(_("reading directory block"));
|
old_op = ehandler_operation(_("reading directory block"));
|
||||||
cd->pctx.errcode = ext2fs_read_dir_block(fs, block_nr, buf);
|
cd->pctx.errcode = ext2fs_read_dir_block(fs, block_nr, buf);
|
||||||
ehandler_operation(0);
|
ehandler_operation(0);
|
||||||
|
@ -793,7 +793,7 @@ static int check_dir_block(ext2_filsys fs,
|
||||||
dx_dir = e2fsck_get_dx_dir_info(ctx, ino);
|
dx_dir = e2fsck_get_dx_dir_info(ctx, ino);
|
||||||
if (dx_dir && dx_dir->numblocks) {
|
if (dx_dir && dx_dir->numblocks) {
|
||||||
if (db->blockcnt >= dx_dir->numblocks) {
|
if (db->blockcnt >= dx_dir->numblocks) {
|
||||||
if (fix_problem(ctx, PR_2_UNEXPECTED_HTREE_BLOCK,
|
if (fix_problem(ctx, PR_2_UNEXPECTED_HTREE_BLOCK,
|
||||||
&pctx)) {
|
&pctx)) {
|
||||||
clear_htree(ctx, ino);
|
clear_htree(ctx, ino);
|
||||||
dx_dir->numblocks = 0;
|
dx_dir->numblocks = 0;
|
||||||
|
@ -807,7 +807,7 @@ static int check_dir_block(ext2_filsys fs,
|
||||||
dx_db->phys = block_nr;
|
dx_db->phys = block_nr;
|
||||||
dx_db->min_hash = ~0;
|
dx_db->min_hash = ~0;
|
||||||
dx_db->max_hash = 0;
|
dx_db->max_hash = 0;
|
||||||
|
|
||||||
dirent = (struct ext2_dir_entry *) buf;
|
dirent = (struct ext2_dir_entry *) buf;
|
||||||
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
|
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
|
||||||
dirent->rec_len : 65536;
|
dirent->rec_len : 65536;
|
||||||
|
@ -832,8 +832,8 @@ static int check_dir_block(ext2_filsys fs,
|
||||||
} else if ((dirent->inode == 0) &&
|
} else if ((dirent->inode == 0) &&
|
||||||
(rec_len == fs->blocksize) &&
|
(rec_len == fs->blocksize) &&
|
||||||
(dirent->name_len == 0) &&
|
(dirent->name_len == 0) &&
|
||||||
(ext2fs_le16_to_cpu(limit->limit) ==
|
(ext2fs_le16_to_cpu(limit->limit) ==
|
||||||
((fs->blocksize-8) /
|
((fs->blocksize-8) /
|
||||||
sizeof(struct ext2_dx_entry))))
|
sizeof(struct ext2_dx_entry))))
|
||||||
dx_db->type = DX_DIRBLOCK_NODE;
|
dx_db->type = DX_DIRBLOCK_NODE;
|
||||||
}
|
}
|
||||||
|
@ -887,12 +887,12 @@ out_htree:
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dirent->inode)
|
if (!dirent->inode)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the inode listed is a legal one.
|
* Make sure the inode listed is a legal one.
|
||||||
*/
|
*/
|
||||||
if (((dirent->inode != EXT2_ROOT_INO) &&
|
if (((dirent->inode != EXT2_ROOT_INO) &&
|
||||||
(dirent->inode < EXT2_FIRST_INODE(fs->super))) ||
|
(dirent->inode < EXT2_FIRST_INODE(fs->super))) ||
|
||||||
(dirent->inode > fs->super->s_inodes_count)) {
|
(dirent->inode > fs->super->s_inodes_count)) {
|
||||||
|
@ -916,7 +916,7 @@ out_htree:
|
||||||
problem = PR_2_DUP_DOT;
|
problem = PR_2_DUP_DOT;
|
||||||
} else if ((dot_state > 1) &&
|
} else if ((dot_state > 1) &&
|
||||||
((dirent->name_len & 0xFF) == 2) &&
|
((dirent->name_len & 0xFF) == 2) &&
|
||||||
(dirent->name[0] == '.') &&
|
(dirent->name[0] == '.') &&
|
||||||
(dirent->name[1] == '.')) {
|
(dirent->name[1] == '.')) {
|
||||||
/*
|
/*
|
||||||
* If there's a '..' entry in anything other
|
* If there's a '..' entry in anything other
|
||||||
|
@ -1078,7 +1078,7 @@ out_htree:
|
||||||
}
|
}
|
||||||
cd->pctx.ino2 = 0;
|
cd->pctx.ino2 = 0;
|
||||||
} else {
|
} else {
|
||||||
(void) e2fsck_dir_info_set_parent(ctx,
|
(void) e2fsck_dir_info_set_parent(ctx,
|
||||||
dirent->inode, ino);
|
dirent->inode, ino);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1097,7 +1097,7 @@ out_htree:
|
||||||
dups_found++;
|
dups_found++;
|
||||||
} else
|
} else
|
||||||
dict_alloc_insert(&de_dict, dirent, dirent);
|
dict_alloc_insert(&de_dict, dirent, dirent);
|
||||||
|
|
||||||
ext2fs_icount_increment(ctx->inode_count, dirent->inode,
|
ext2fs_icount_increment(ctx->inode_count, dirent->inode,
|
||||||
&links);
|
&links);
|
||||||
if (links > 1)
|
if (links > 1)
|
||||||
|
@ -1164,7 +1164,7 @@ static int deallocate_inode_block(ext2_filsys fs,
|
||||||
void *priv_data)
|
void *priv_data)
|
||||||
{
|
{
|
||||||
e2fsck_t ctx = (e2fsck_t) priv_data;
|
e2fsck_t ctx = (e2fsck_t) priv_data;
|
||||||
|
|
||||||
if (HOLE_BLKADDR(*block_nr))
|
if (HOLE_BLKADDR(*block_nr))
|
||||||
return 0;
|
return 0;
|
||||||
if ((*block_nr < fs->super->s_first_data_block) ||
|
if ((*block_nr < fs->super->s_first_data_block) ||
|
||||||
|
@ -1174,7 +1174,7 @@ static int deallocate_inode_block(ext2_filsys fs,
|
||||||
ext2fs_block_alloc_stats(fs, *block_nr, -1);
|
ext2fs_block_alloc_stats(fs, *block_nr, -1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This fuction deallocates an inode
|
* This fuction deallocates an inode
|
||||||
*/
|
*/
|
||||||
|
@ -1184,7 +1184,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
__u32 count;
|
__u32 count;
|
||||||
|
|
||||||
e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode");
|
e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode");
|
||||||
e2fsck_clear_inode(ctx, ino, &inode, 0, "deallocate_inode");
|
e2fsck_clear_inode(ctx, ino, &inode, 0, "deallocate_inode");
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
@ -1240,7 +1240,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
|
||||||
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino)
|
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino)
|
||||||
{
|
{
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
|
|
||||||
e2fsck_read_inode(ctx, ino, &inode, "clear_htree");
|
e2fsck_read_inode(ctx, ino, &inode, "clear_htree");
|
||||||
inode.i_flags = inode.i_flags & ~EXT2_INDEX_FL;
|
inode.i_flags = inode.i_flags & ~EXT2_INDEX_FL;
|
||||||
e2fsck_write_inode(ctx, ino, &inode, "clear_htree");
|
e2fsck_write_inode(ctx, ino, &inode, "clear_htree");
|
||||||
|
@ -1308,7 +1308,7 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
not_fixed++;
|
not_fixed++;
|
||||||
problem = 0;
|
problem = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inode.i_faddr) {
|
if (inode.i_faddr) {
|
||||||
if (fix_problem(ctx, PR_2_FADDR_ZERO, &pctx)) {
|
if (fix_problem(ctx, PR_2_FADDR_ZERO, &pctx)) {
|
||||||
inode.i_faddr = 0;
|
inode.i_faddr = 0;
|
||||||
|
@ -1345,7 +1345,7 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
|
if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
|
||||||
!(fs->super->s_feature_ro_compat &
|
!(fs->super->s_feature_ro_compat &
|
||||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) &&
|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) &&
|
||||||
(inode.osd2.linux2.l_i_blocks_hi != 0)) {
|
(inode.osd2.linux2.l_i_blocks_hi != 0)) {
|
||||||
pctx.num = inode.osd2.linux2.l_i_blocks_hi;
|
pctx.num = inode.osd2.linux2.l_i_blocks_hi;
|
||||||
|
@ -1389,7 +1389,7 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
*/
|
*/
|
||||||
static int allocate_dir_block(e2fsck_t ctx,
|
static int allocate_dir_block(e2fsck_t ctx,
|
||||||
struct ext2_db_entry *db,
|
struct ext2_db_entry *db,
|
||||||
char *buf EXT2FS_ATTR((unused)),
|
char *buf EXT2FS_ATTR((unused)),
|
||||||
struct problem_context *pctx)
|
struct problem_context *pctx)
|
||||||
{
|
{
|
||||||
ext2_filsys fs = ctx->fs;
|
ext2_filsys fs = ctx->fs;
|
||||||
|
@ -1405,7 +1405,7 @@ static int allocate_dir_block(e2fsck_t ctx,
|
||||||
* them.
|
* them.
|
||||||
*/
|
*/
|
||||||
e2fsck_read_bitmaps(ctx);
|
e2fsck_read_bitmaps(ctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, find a free block
|
* First, find a free block
|
||||||
*/
|
*/
|
||||||
|
@ -1473,7 +1473,7 @@ static int update_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||||
blk_t *block_nr,
|
blk_t *block_nr,
|
||||||
e2_blkcnt_t blockcnt,
|
e2_blkcnt_t blockcnt,
|
||||||
blk_t ref_block EXT2FS_ATTR((unused)),
|
blk_t ref_block EXT2FS_ATTR((unused)),
|
||||||
int ref_offset EXT2FS_ATTR((unused)),
|
int ref_offset EXT2FS_ATTR((unused)),
|
||||||
void *priv_data)
|
void *priv_data)
|
||||||
{
|
{
|
||||||
struct ext2_db_entry *db;
|
struct ext2_db_entry *db;
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
* Pass #3 assures that all directories are connected to the
|
* Pass #3 assures that all directories are connected to the
|
||||||
* filesystem tree, using the following algorithm:
|
* filesystem tree, using the following algorithm:
|
||||||
*
|
*
|
||||||
* First, the root directory is checked to make sure it exists; if
|
* First, the root directory is checked to make sure it exists; if
|
||||||
* not, e2fsck will offer to create a new one. It is then marked as
|
* not, e2fsck will offer to create a new one. It is then marked as
|
||||||
* "done".
|
* "done".
|
||||||
*
|
*
|
||||||
* Then, pass3 interates over all directory inodes; for each directory
|
* Then, pass3 interates over all directory inodes; for each directory
|
||||||
* it attempts to trace up the filesystem tree, using dirinfo.parent
|
* it attempts to trace up the filesystem tree, using dirinfo.parent
|
||||||
* until it reaches a directory which has been marked "done". If it
|
* until it reaches a directory which has been marked "done". If it
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
* twice, then it has detected a filesystem loop, and it will again
|
* twice, then it has detected a filesystem loop, and it will again
|
||||||
* offer to reconnect the directory to /lost+found in to break the
|
* offer to reconnect the directory to /lost+found in to break the
|
||||||
* filesystem loop.
|
* filesystem loop.
|
||||||
*
|
*
|
||||||
* Pass 3 also contains the subroutine, e2fsck_reconnect_file() to
|
* Pass 3 also contains the subroutine, e2fsck_reconnect_file() to
|
||||||
* reconnect inodes to /lost+found; this subroutine is also used by
|
* reconnect inodes to /lost+found; this subroutine is also used by
|
||||||
* pass 4. e2fsck_reconnect_file() calls get_lost_and_found(), which
|
* pass 4. e2fsck_reconnect_file() calls get_lost_and_found(), which
|
||||||
|
@ -48,7 +48,7 @@ static void fix_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent);
|
||||||
|
|
||||||
static ext2fs_inode_bitmap inode_loop_detect = 0;
|
static ext2fs_inode_bitmap inode_loop_detect = 0;
|
||||||
static ext2fs_inode_bitmap inode_done_map = 0;
|
static ext2fs_inode_bitmap inode_done_map = 0;
|
||||||
|
|
||||||
void e2fsck_pass3(e2fsck_t ctx)
|
void e2fsck_pass3(e2fsck_t ctx)
|
||||||
{
|
{
|
||||||
ext2_filsys fs = ctx->fs;
|
ext2_filsys fs = ctx->fs;
|
||||||
|
@ -104,7 +104,7 @@ void e2fsck_pass3(e2fsck_t ctx)
|
||||||
if (ctx->progress)
|
if (ctx->progress)
|
||||||
if ((ctx->progress)(ctx, 3, 0, maxdirs))
|
if ((ctx->progress)(ctx, 3, 0, maxdirs))
|
||||||
goto abort_exit;
|
goto abort_exit;
|
||||||
|
|
||||||
iter = e2fsck_dir_info_iter_begin(ctx);
|
iter = e2fsck_dir_info_iter_begin(ctx);
|
||||||
while ((dir = e2fsck_dir_info_iter(ctx, iter)) != 0) {
|
while ((dir = e2fsck_dir_info_iter(ctx, iter)) != 0) {
|
||||||
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
||||||
|
@ -128,7 +128,7 @@ void e2fsck_pass3(e2fsck_t ctx)
|
||||||
* optimized, do it here.
|
* optimized, do it here.
|
||||||
*/
|
*/
|
||||||
e2fsck_rehash_directories(ctx);
|
e2fsck_rehash_directories(ctx);
|
||||||
|
|
||||||
abort_exit:
|
abort_exit:
|
||||||
e2fsck_free_dir_info(ctx);
|
e2fsck_free_dir_info(ctx);
|
||||||
if (inode_loop_detect) {
|
if (inode_loop_detect) {
|
||||||
|
@ -159,9 +159,9 @@ static void check_root(e2fsck_t ctx)
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
char * block;
|
char * block;
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
if (ext2fs_test_inode_bitmap(ctx->inode_used_map, EXT2_ROOT_INO)) {
|
if (ext2fs_test_inode_bitmap(ctx->inode_used_map, EXT2_ROOT_INO)) {
|
||||||
/*
|
/*
|
||||||
* If the root inode is not a directory, die here. The
|
* If the root inode is not a directory, die here. The
|
||||||
|
@ -183,7 +183,7 @@ static void check_root(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
e2fsck_read_bitmaps(ctx);
|
e2fsck_read_bitmaps(ctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, find a free block
|
* First, find a free block
|
||||||
*/
|
*/
|
||||||
|
@ -240,7 +240,7 @@ static void check_root(e2fsck_t ctx)
|
||||||
ctx->flags |= E2F_FLAG_ABORT;
|
ctx->flags |= E2F_FLAG_ABORT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Miscellaneous bookkeeping...
|
* Miscellaneous bookkeeping...
|
||||||
*/
|
*/
|
||||||
|
@ -261,7 +261,7 @@ static void check_root(e2fsck_t ctx)
|
||||||
* the lost+found. We have to do loop detection; if we ever discover
|
* the lost+found. We have to do loop detection; if we ever discover
|
||||||
* a loop, we treat that as a disconnected directory and offer to
|
* a loop, we treat that as a disconnected directory and offer to
|
||||||
* reparent it to lost+found.
|
* reparent it to lost+found.
|
||||||
*
|
*
|
||||||
* However, loop detection is expensive, because for very large
|
* However, loop detection is expensive, because for very large
|
||||||
* filesystems, the inode_loop_detect bitmap is huge, and clearing it
|
* filesystems, the inode_loop_detect bitmap is huge, and clearing it
|
||||||
* is non-trivial. Loops in filesystems are also a rare error case,
|
* is non-trivial. Loops in filesystems are also a rare error case,
|
||||||
|
@ -302,7 +302,7 @@ static int check_directory(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
* reparent it to lost+found
|
* reparent it to lost+found
|
||||||
*/
|
*/
|
||||||
if (!parent ||
|
if (!parent ||
|
||||||
(loop_pass &&
|
(loop_pass &&
|
||||||
(ext2fs_test_inode_bitmap(inode_loop_detect,
|
(ext2fs_test_inode_bitmap(inode_loop_detect,
|
||||||
parent)))) {
|
parent)))) {
|
||||||
pctx->ino = ino;
|
pctx->ino = ino;
|
||||||
|
@ -310,7 +310,7 @@ static int check_directory(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
if (e2fsck_reconnect_file(ctx, pctx->ino))
|
if (e2fsck_reconnect_file(ctx, pctx->ino))
|
||||||
ext2fs_unmark_valid(fs);
|
ext2fs_unmark_valid(fs);
|
||||||
else {
|
else {
|
||||||
fix_dotdot(ctx, pctx->ino,
|
fix_dotdot(ctx, pctx->ino,
|
||||||
ctx->lost_and_found);
|
ctx->lost_and_found);
|
||||||
parent = ctx->lost_and_found;
|
parent = ctx->lost_and_found;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ static int check_directory(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
pctx->errcode = ext2fs_allocate_inode_bitmap(fs, _("inode loop detection bitmap"), &inode_loop_detect);
|
pctx->errcode = ext2fs_allocate_inode_bitmap(fs, _("inode loop detection bitmap"), &inode_loop_detect);
|
||||||
if (pctx->errcode) {
|
if (pctx->errcode) {
|
||||||
pctx->num = 1;
|
pctx->num = 1;
|
||||||
fix_problem(ctx,
|
fix_problem(ctx,
|
||||||
PR_3_ALLOCATE_IBITMAP_ERROR, pctx);
|
PR_3_ALLOCATE_IBITMAP_ERROR, pctx);
|
||||||
ctx->flags |= E2F_FLAG_ABORT;
|
ctx->flags |= E2F_FLAG_ABORT;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -380,7 +380,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix)
|
||||||
return ctx->lost_and_found;
|
return ctx->lost_and_found;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name,
|
retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name,
|
||||||
sizeof(name)-1, 0, &ino);
|
sizeof(name)-1, 0, &ino);
|
||||||
if (retval && !fix)
|
if (retval && !fix)
|
||||||
|
@ -390,7 +390,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix)
|
||||||
ctx->lost_and_found = ino;
|
ctx->lost_and_found = ino;
|
||||||
return ino;
|
return ino;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lost+found isn't a directory! */
|
/* Lost+found isn't a directory! */
|
||||||
if (!fix)
|
if (!fix)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -419,7 +419,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix)
|
||||||
* them.
|
* them.
|
||||||
*/
|
*/
|
||||||
e2fsck_read_bitmaps(ctx);
|
e2fsck_read_bitmaps(ctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, find a free block
|
* First, find a free block
|
||||||
*/
|
*/
|
||||||
|
@ -531,7 +531,7 @@ int e2fsck_reconnect_file(e2fsck_t ctx, ext2_ino_t ino)
|
||||||
fix_problem(ctx, PR_3_NO_LPF, &pctx);
|
fix_problem(ctx, PR_3_NO_LPF, &pctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(name, "#%u", ino);
|
sprintf(name, "#%u", ino);
|
||||||
if (ext2fs_read_inode(fs, ino, &inode) == 0)
|
if (ext2fs_read_inode(fs, ino, &inode) == 0)
|
||||||
file_type = ext2_file_type(inode.i_mode);
|
file_type = ext2_file_type(inode.i_mode);
|
||||||
|
@ -539,7 +539,7 @@ int e2fsck_reconnect_file(e2fsck_t ctx, ext2_ino_t ino)
|
||||||
if (retval == EXT2_ET_DIR_NO_SPACE) {
|
if (retval == EXT2_ET_DIR_NO_SPACE) {
|
||||||
if (!fix_problem(ctx, PR_3_EXPAND_LF_DIR, &pctx))
|
if (!fix_problem(ctx, PR_3_EXPAND_LF_DIR, &pctx))
|
||||||
return 1;
|
return 1;
|
||||||
retval = e2fsck_expand_directory(ctx, ctx->lost_and_found,
|
retval = e2fsck_expand_directory(ctx, ctx->lost_and_found,
|
||||||
1, 0);
|
1, 0);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
pctx.errcode = retval;
|
pctx.errcode = retval;
|
||||||
|
@ -567,7 +567,7 @@ errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino, int adj)
|
||||||
ext2_filsys fs = ctx->fs;
|
ext2_filsys fs = ctx->fs;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
|
|
||||||
if (!ino)
|
if (!ino)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino, int adj)
|
||||||
ext2fs_icount_decrement(ctx->inode_link_info, ino, 0);
|
ext2fs_icount_decrement(ctx->inode_link_info, ino, 0);
|
||||||
inode.i_links_count--;
|
inode.i_links_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = ext2fs_write_inode(fs, ino, &inode);
|
retval = ext2fs_write_inode(fs, ino, &inode);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -627,7 +627,7 @@ static int fix_dotdot_proc(struct ext2_dir_entry *dirent,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
retval = e2fsck_adjust_inode_count(fp->ctx, dirent->inode, -1);
|
retval = e2fsck_adjust_inode_count(fp->ctx, dirent->inode, -1);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
pctx.errcode = retval;
|
pctx.errcode = retval;
|
||||||
|
@ -641,7 +641,7 @@ static int fix_dotdot_proc(struct ext2_dir_entry *dirent,
|
||||||
dirent->inode = fp->parent;
|
dirent->inode = fp->parent;
|
||||||
if (fp->ctx->fs->super->s_feature_incompat &
|
if (fp->ctx->fs->super->s_feature_incompat &
|
||||||
EXT2_FEATURE_INCOMPAT_FILETYPE)
|
EXT2_FEATURE_INCOMPAT_FILETYPE)
|
||||||
dirent->name_len = (dirent->name_len & 0xFF) |
|
dirent->name_len = (dirent->name_len & 0xFF) |
|
||||||
(EXT2_FT_DIR << 8);
|
(EXT2_FT_DIR << 8);
|
||||||
else
|
else
|
||||||
dirent->name_len = dirent->name_len & 0xFF;
|
dirent->name_len = dirent->name_len & 0xFF;
|
||||||
|
@ -665,7 +665,7 @@ static void fix_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
|
||||||
#if 0
|
#if 0
|
||||||
printf("Fixing '..' of inode %lu to be %lu...\n", ino, parent);
|
printf("Fixing '..' of inode %lu to be %lu...\n", ino, parent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
pctx.ino = ino;
|
pctx.ino = ino;
|
||||||
retval = ext2fs_dir_iterate(fs, ino, DIRENT_FLAG_INCLUDE_EMPTY,
|
retval = ext2fs_dir_iterate(fs, ino, DIRENT_FLAG_INCLUDE_EMPTY,
|
||||||
|
@ -712,7 +712,7 @@ static int expand_dir_proc(ext2_filsys fs,
|
||||||
e2fsck_t ctx;
|
e2fsck_t ctx;
|
||||||
|
|
||||||
ctx = es->ctx;
|
ctx = es->ctx;
|
||||||
|
|
||||||
if (es->guaranteed_size && blockcnt >= es->guaranteed_size)
|
if (es->guaranteed_size && blockcnt >= es->guaranteed_size)
|
||||||
return BLOCK_ABORT;
|
return BLOCK_ABORT;
|
||||||
|
|
||||||
|
@ -744,7 +744,7 @@ static int expand_dir_proc(ext2_filsys fs,
|
||||||
}
|
}
|
||||||
memset(block, 0, fs->blocksize);
|
memset(block, 0, fs->blocksize);
|
||||||
retval = io_channel_write_blk(fs->io, new_blk, 1, block);
|
retval = io_channel_write_blk(fs->io, new_blk, 1, block);
|
||||||
}
|
}
|
||||||
if (retval) {
|
if (retval) {
|
||||||
es->err = retval;
|
es->err = retval;
|
||||||
return BLOCK_ABORT;
|
return BLOCK_ABORT;
|
||||||
|
@ -754,7 +754,7 @@ static int expand_dir_proc(ext2_filsys fs,
|
||||||
ext2fs_mark_block_bitmap(ctx->block_found_map, new_blk);
|
ext2fs_mark_block_bitmap(ctx->block_found_map, new_blk);
|
||||||
ext2fs_block_alloc_stats(fs, new_blk, +1);
|
ext2fs_block_alloc_stats(fs, new_blk, +1);
|
||||||
es->newblocks++;
|
es->newblocks++;
|
||||||
|
|
||||||
if (es->num == 0)
|
if (es->num == 0)
|
||||||
return (BLOCK_CHANGED | BLOCK_ABORT);
|
return (BLOCK_CHANGED | BLOCK_ABORT);
|
||||||
else
|
else
|
||||||
|
@ -768,7 +768,7 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
struct expand_dir_struct es;
|
struct expand_dir_struct es;
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
|
|
||||||
if (!(fs->flags & EXT2_FLAG_RW))
|
if (!(fs->flags & EXT2_FLAG_RW))
|
||||||
return EXT2_ET_RO_FILSYS;
|
return EXT2_ET_RO_FILSYS;
|
||||||
|
|
||||||
|
@ -781,14 +781,14 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
retval = ext2fs_check_directory(fs, dir);
|
retval = ext2fs_check_directory(fs, dir);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
es.num = num;
|
es.num = num;
|
||||||
es.guaranteed_size = guaranteed_size;
|
es.guaranteed_size = guaranteed_size;
|
||||||
es.last_block = 0;
|
es.last_block = 0;
|
||||||
es.err = 0;
|
es.err = 0;
|
||||||
es.newblocks = 0;
|
es.newblocks = 0;
|
||||||
es.ctx = ctx;
|
es.ctx = ctx;
|
||||||
|
|
||||||
retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND,
|
retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND,
|
||||||
0, expand_dir_proc, &es);
|
0, expand_dir_proc, &es);
|
||||||
|
|
||||||
|
@ -801,7 +801,7 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
|
||||||
retval = ext2fs_read_inode(fs, dir, &inode);
|
retval = ext2fs_read_inode(fs, dir, &inode);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
inode.i_size = (es.last_block + 1) * fs->blocksize;
|
inode.i_size = (es.last_block + 1) * fs->blocksize;
|
||||||
ext2fs_iblk_add_blocks(fs, &inode, es.newblocks);
|
ext2fs_iblk_add_blocks(fs, &inode, es.newblocks);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
/*
|
/*
|
||||||
* This routine is called when an inode is not connected to the
|
* This routine is called when an inode is not connected to the
|
||||||
* directory tree.
|
* directory tree.
|
||||||
*
|
*
|
||||||
* This subroutine returns 1 then the caller shouldn't bother with the
|
* This subroutine returns 1 then the caller shouldn't bother with the
|
||||||
* rest of the pass 4 tests.
|
* rest of the pass 4 tests.
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +42,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
pctx.ino = i;
|
pctx.ino = i;
|
||||||
pctx.inode = inode;
|
pctx.inode = inode;
|
||||||
|
|
||||||
if (EXT2_INODE_SIZE(fs->super) -EXT2_GOOD_OLD_INODE_SIZE -extra_size >0)
|
if (EXT2_INODE_SIZE(fs->super) -EXT2_GOOD_OLD_INODE_SIZE -extra_size >0)
|
||||||
eamagic = *(__u32 *)(((char *)inode) +EXT2_GOOD_OLD_INODE_SIZE +
|
eamagic = *(__u32 *)(((char *)inode) +EXT2_GOOD_OLD_INODE_SIZE +
|
||||||
extra_size);
|
extra_size);
|
||||||
|
@ -55,7 +55,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
|
||||||
if (!inode->i_blocks && eamagic != EXT2_EXT_ATTR_MAGIC &&
|
if (!inode->i_blocks && eamagic != EXT2_EXT_ATTR_MAGIC &&
|
||||||
(LINUX_S_ISREG(inode->i_mode) || LINUX_S_ISDIR(inode->i_mode))) {
|
(LINUX_S_ISREG(inode->i_mode) || LINUX_S_ISDIR(inode->i_mode))) {
|
||||||
if (fix_problem(ctx, PR_4_ZERO_LEN_INODE, &pctx)) {
|
if (fix_problem(ctx, PR_4_ZERO_LEN_INODE, &pctx)) {
|
||||||
e2fsck_clear_inode(ctx, i, inode, 0,
|
e2fsck_clear_inode(ctx, i, inode, 0,
|
||||||
"disconnect_inode");
|
"disconnect_inode");
|
||||||
/*
|
/*
|
||||||
* Fix up the bitmaps...
|
* Fix up the bitmaps...
|
||||||
|
@ -66,7 +66,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prompt to reconnect.
|
* Prompt to reconnect.
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +98,7 @@ void e2fsck_pass4(e2fsck_t ctx)
|
||||||
__u16 link_count, link_counted;
|
__u16 link_count, link_counted;
|
||||||
char *buf = 0;
|
char *buf = 0;
|
||||||
int group, maxgroup;
|
int group, maxgroup;
|
||||||
|
|
||||||
#ifdef RESOURCE_TRACK
|
#ifdef RESOURCE_TRACK
|
||||||
init_resource_track(&rtrack, ctx->fs->io);
|
init_resource_track(&rtrack, ctx->fs->io);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*
|
/*
|
||||||
* pass5.c --- check block and inode bitmaps against on-disk bitmaps
|
* pass5.c --- check block and inode bitmaps against on-disk bitmaps
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "e2fsck.h"
|
#include "e2fsck.h"
|
||||||
|
@ -24,7 +24,7 @@ void e2fsck_pass5(e2fsck_t ctx)
|
||||||
struct resource_track rtrack;
|
struct resource_track rtrack;
|
||||||
#endif
|
#endif
|
||||||
struct problem_context pctx;
|
struct problem_context pctx;
|
||||||
|
|
||||||
#ifdef MTRACE
|
#ifdef MTRACE
|
||||||
mtrace_print("Pass 5");
|
mtrace_print("Pass 5");
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,7 @@ void e2fsck_pass5(e2fsck_t ctx)
|
||||||
#ifdef RESOURCE_TRACK
|
#ifdef RESOURCE_TRACK
|
||||||
init_resource_track(&rtrack, ctx->fs->io);
|
init_resource_track(&rtrack, ctx->fs->io);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
if (!(ctx->options & E2F_OPT_PREEN))
|
if (!(ctx->options & E2F_OPT_PREEN))
|
||||||
|
@ -571,7 +571,7 @@ static void check_inode_end(e2fsck_t ctx)
|
||||||
if (save_inodes_count == end)
|
if (save_inodes_count == end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* protect loop from wrap-around if end is maxed */
|
/* protect loop from wrap-around if end is maxed */
|
||||||
for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) {
|
for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) {
|
||||||
if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) {
|
if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) {
|
||||||
if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) {
|
if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) {
|
||||||
|
@ -616,7 +616,7 @@ static void check_block_end(e2fsck_t ctx)
|
||||||
if (save_blocks_count == end)
|
if (save_blocks_count == end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Protect loop from wrap-around if end is maxed */
|
/* Protect loop from wrap-around if end is maxed */
|
||||||
for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) {
|
for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) {
|
||||||
if (!ext2fs_test_block_bitmap(fs->block_map, i)) {
|
if (!ext2fs_test_block_bitmap(fs->block_map, i)) {
|
||||||
if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
|
if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
|
||||||
|
|
|
@ -39,5 +39,5 @@ struct latch_descr {
|
||||||
#define PR_NO_NOMSG 0x010000 /* Don't print a message if e2fsck -n */
|
#define PR_NO_NOMSG 0x010000 /* Don't print a message if e2fsck -n */
|
||||||
#define PR_PREEN_NO 0x020000 /* Use No as an answer if preening */
|
#define PR_PREEN_NO 0x020000 /* Use No as an answer if preening */
|
||||||
#define PR_PREEN_NOHDR 0x040000 /* Don't print the preen header */
|
#define PR_PREEN_NOHDR 0x040000 /* Don't print the preen header */
|
||||||
#define PR_CONFIG 0x080000 /* This problem has been customized
|
#define PR_CONFIG 0x080000 /* This problem has been customized
|
||||||
from the config file */
|
from the config file */
|
||||||
|
|
108
e2fsck/profile.c
108
e2fsck/profile.c
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* profile.c -- A simple configuration file parsing "library in a file"
|
* profile.c -- A simple configuration file parsing "library in a file"
|
||||||
*
|
*
|
||||||
* The profile library was originally written by Theodore Ts'o in 1995
|
* The profile library was originally written by Theodore Ts'o in 1995
|
||||||
* for use in the MIT Kerberos v5 library. It has been
|
* for use in the MIT Kerberos v5 library. It has been
|
||||||
* modified/enhanced/bug-fixed over time by other members of the MIT
|
* modified/enhanced/bug-fixed over time by other members of the MIT
|
||||||
|
@ -18,16 +18,16 @@
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
* Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
|
* Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Export of this software from the United States of America may require
|
* Export of this software from the United States of America may require
|
||||||
* a specific license from the United States Government. It is the
|
* a specific license from the United States Government. It is the
|
||||||
* responsibility of any person or organization contemplating export to
|
* responsibility of any person or organization contemplating export to
|
||||||
* obtain such a license before exporting.
|
* obtain such a license before exporting.
|
||||||
*
|
*
|
||||||
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
||||||
* distribute this software and its documentation for any purpose and
|
* distribute this software and its documentation for any purpose and
|
||||||
* without fee is hereby granted, provided that the above copyright
|
* without fee is hereby granted, provided that the above copyright
|
||||||
|
@ -41,11 +41,11 @@
|
||||||
* M.I.T. makes no representations about the suitability of this software
|
* M.I.T. makes no representations about the suitability of this software
|
||||||
* for any purpose. It is provided "as is" without express or implied
|
* for any purpose. It is provided "as is" without express or implied
|
||||||
* warranty.
|
* warranty.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
@ -218,12 +218,12 @@ static errcode_t profile_get_value(profile_t profile, const char *name,
|
||||||
* object.
|
* object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int compstr(const void *m1, const void *m2)
|
static int compstr(const void *m1, const void *m2)
|
||||||
{
|
{
|
||||||
const char *s1 = *((const char * const *) m1);
|
const char *s1 = *((const char * const *) m1);
|
||||||
const char *s2 = *((const char * const *) m2);
|
const char *s2 = *((const char * const *) m2);
|
||||||
|
|
||||||
return strcmp(s1, s2);
|
return strcmp(s1, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_list(char **list)
|
static void free_list(char **list)
|
||||||
|
@ -232,7 +232,7 @@ static void free_list(char **list)
|
||||||
|
|
||||||
if (list == 0)
|
if (list == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (cp = list; *cp; cp++)
|
for (cp = list; *cp; cp++)
|
||||||
free(*cp);
|
free(*cp);
|
||||||
free(list);
|
free(list);
|
||||||
|
@ -295,7 +295,7 @@ errout:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_init(const char **files, profile_t *ret_profile)
|
profile_init(const char **files, profile_t *ret_profile)
|
||||||
{
|
{
|
||||||
const char **fs;
|
const char **fs;
|
||||||
|
@ -327,7 +327,7 @@ profile_init(const char **files, profile_t *ret_profile)
|
||||||
*last = new_file;
|
*last = new_file;
|
||||||
last = &new_file->next;
|
last = &new_file->next;
|
||||||
}
|
}
|
||||||
} else if ((retval != ENOTDIR) &&
|
} else if ((retval != ENOTDIR) &&
|
||||||
strcmp(*fs, default_filename))
|
strcmp(*fs, default_filename))
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ errout:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
profile_release(profile_t profile)
|
profile_release(profile_t profile)
|
||||||
{
|
{
|
||||||
prf_file_t p, next;
|
prf_file_t p, next;
|
||||||
|
@ -431,7 +431,7 @@ errcode_t profile_set_default(profile_t profile, const char *def_string)
|
||||||
if (retval) {
|
if (retval) {
|
||||||
errout:
|
errout:
|
||||||
if (syntax_err_cb)
|
if (syntax_err_cb)
|
||||||
(syntax_err_cb)(prf->filespec, retval,
|
(syntax_err_cb)(prf->filespec, retval,
|
||||||
state.line_num);
|
state.line_num);
|
||||||
free(line);
|
free(line);
|
||||||
if (prf->root)
|
if (prf->root)
|
||||||
|
@ -494,7 +494,7 @@ errcode_t profile_open_file(const char * filespec,
|
||||||
}
|
}
|
||||||
expanded_filename = malloc(len);
|
expanded_filename = malloc(len);
|
||||||
if (expanded_filename == 0) {
|
if (expanded_filename == 0) {
|
||||||
profile_free_file(prf);
|
profile_free_file(prf);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
if (home_env) {
|
if (home_env) {
|
||||||
|
@ -583,7 +583,7 @@ errcode_t profile_update_file(prf_file_t prf)
|
||||||
retval = parse_line(buf, &state);
|
retval = parse_line(buf, &state);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
if (syntax_err_cb)
|
if (syntax_err_cb)
|
||||||
(syntax_err_cb)(prf->filespec, retval,
|
(syntax_err_cb)(prf->filespec, retval,
|
||||||
state.line_num);
|
state.line_num);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -686,7 +686,7 @@ static errcode_t parse_line(char *line, struct parse_state *state)
|
||||||
struct profile_node *node;
|
struct profile_node *node;
|
||||||
int do_subsection = 0;
|
int do_subsection = 0;
|
||||||
void *iter = 0;
|
void *iter = 0;
|
||||||
|
|
||||||
state->line_num++;
|
state->line_num++;
|
||||||
if (state->state == STATE_GET_OBRACE) {
|
if (state->state == STATE_GET_OBRACE) {
|
||||||
cp = skip_over_blanks(line);
|
cp = skip_over_blanks(line);
|
||||||
|
@ -726,7 +726,7 @@ static errcode_t parse_line(char *line, struct parse_state *state)
|
||||||
if (*cp == 0)
|
if (*cp == 0)
|
||||||
return PROF_SECTION_SYNTAX;
|
return PROF_SECTION_SYNTAX;
|
||||||
}
|
}
|
||||||
retval = profile_find_node(state->root_section, cp, 0, 1,
|
retval = profile_find_node(state->root_section, cp, 0, 1,
|
||||||
&iter, &state->current_section);
|
&iter, &state->current_section);
|
||||||
if (retval == PROF_NO_SECTION) {
|
if (retval == PROF_NO_SECTION) {
|
||||||
retval = profile_add_node(state->root_section,
|
retval = profile_add_node(state->root_section,
|
||||||
|
@ -746,7 +746,7 @@ static errcode_t parse_line(char *line, struct parse_state *state)
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Spaces or comments after ']' should not be fatal
|
* Spaces or comments after ']' should not be fatal
|
||||||
*/
|
*/
|
||||||
cp = skip_over_blanks(cp);
|
cp = skip_over_blanks(cp);
|
||||||
if (!end_or_comment(*cp))
|
if (!end_or_comment(*cp))
|
||||||
|
@ -902,7 +902,7 @@ static void dump_profile(struct profile_node *root, int level,
|
||||||
struct profile_node *p;
|
struct profile_node *p;
|
||||||
void *iter;
|
void *iter;
|
||||||
long retval;
|
long retval;
|
||||||
|
|
||||||
iter = 0;
|
iter = 0;
|
||||||
do {
|
do {
|
||||||
retval = profile_find_node(root, 0, 0, 0, &iter, &p);
|
retval = profile_find_node(root, 0, 0, 0, &iter, &p);
|
||||||
|
@ -1024,16 +1024,16 @@ errcode_t profile_write_tree_to_buffer(struct profile_node *root,
|
||||||
/*
|
/*
|
||||||
* prof_tree.c --- these routines maintain the parse tree of the
|
* prof_tree.c --- these routines maintain the parse tree of the
|
||||||
* config file.
|
* config file.
|
||||||
*
|
*
|
||||||
* All of the details of how the tree is stored is abstracted away in
|
* All of the details of how the tree is stored is abstracted away in
|
||||||
* this file; all of the other profile routines build, access, and
|
* this file; all of the other profile routines build, access, and
|
||||||
* modify the tree via the accessor functions found in this file.
|
* modify the tree via the accessor functions found in this file.
|
||||||
*
|
*
|
||||||
* Each node may represent either a relation or a section header.
|
* Each node may represent either a relation or a section header.
|
||||||
*
|
*
|
||||||
* A section header must have its value field set to 0, and may a one
|
* A section header must have its value field set to 0, and may a one
|
||||||
* or more child nodes, pointed to by first_child.
|
* or more child nodes, pointed to by first_child.
|
||||||
*
|
*
|
||||||
* A relation has as its value a pointer to allocated memory
|
* A relation has as its value a pointer to allocated memory
|
||||||
* containing a string. Its first_child pointer must be null.
|
* containing a string. Its first_child pointer must be null.
|
||||||
*
|
*
|
||||||
|
@ -1048,7 +1048,7 @@ void profile_free_node(struct profile_node *node)
|
||||||
|
|
||||||
if (node->magic != PROF_MAGIC_NODE)
|
if (node->magic != PROF_MAGIC_NODE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (node->name)
|
if (node->name)
|
||||||
free(node->name);
|
free(node->name);
|
||||||
if (node->value)
|
if (node->value)
|
||||||
|
@ -1059,7 +1059,7 @@ void profile_free_node(struct profile_node *node)
|
||||||
profile_free_node(child);
|
profile_free_node(child);
|
||||||
}
|
}
|
||||||
node->magic = 0;
|
node->magic = 0;
|
||||||
|
|
||||||
free(node);
|
free(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,7 +1156,7 @@ errcode_t profile_add_node(struct profile_node *section, const char *name,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the place to insert the new node. We look for the
|
* Find the place to insert the new node. We look for the
|
||||||
* place *after* the last match of the node name, since
|
* place *after* the last match of the node name, since
|
||||||
* order matters.
|
* order matters.
|
||||||
*/
|
*/
|
||||||
for (p=section->first_child, last = 0; p; last = p, p = p->next) {
|
for (p=section->first_child, last = 0; p; last = p, p = p->next) {
|
||||||
|
@ -1191,7 +1191,7 @@ errcode_t profile_add_node(struct profile_node *section, const char *name,
|
||||||
* section which matches the name; don't return relations. If value
|
* section which matches the name; don't return relations. If value
|
||||||
* is non-NULL, then only return relations which match the requested
|
* is non-NULL, then only return relations which match the requested
|
||||||
* value. (The value argument is ignored if section_flag is non-zero.)
|
* value. (The value argument is ignored if section_flag is non-zero.)
|
||||||
*
|
*
|
||||||
* The first time this routine is called, the state pointer must be
|
* The first time this routine is called, the state pointer must be
|
||||||
* null. When this profile_find_node_relation() returns, if the state
|
* null. When this profile_find_node_relation() returns, if the state
|
||||||
* pointer is non-NULL, then this routine should be called again.
|
* pointer is non-NULL, then this routine should be called again.
|
||||||
|
@ -1210,7 +1210,7 @@ errcode_t profile_find_node(struct profile_node *section, const char *name,
|
||||||
CHECK_MAGIC(p);
|
CHECK_MAGIC(p);
|
||||||
} else
|
} else
|
||||||
p = section->first_child;
|
p = section->first_child;
|
||||||
|
|
||||||
for (; p; p = p->next) {
|
for (; p; p = p->next) {
|
||||||
if (name && (strcmp(p->name, name)))
|
if (name && (strcmp(p->name, name)))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1260,7 +1260,7 @@ errcode_t profile_find_node(struct profile_node *section, const char *name,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a general-purpose iterator for returning all nodes that
|
* This is a general-purpose iterator for returning all nodes that
|
||||||
* match the specified name array.
|
* match the specified name array.
|
||||||
*/
|
*/
|
||||||
struct profile_iterator {
|
struct profile_iterator {
|
||||||
prf_magic_t magic;
|
prf_magic_t magic;
|
||||||
|
@ -1275,7 +1275,7 @@ struct profile_iterator {
|
||||||
int num;
|
int num;
|
||||||
};
|
};
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_iterator_create(profile_t profile, const char *const *names, int flags,
|
profile_iterator_create(profile_t profile, const char *const *names, int flags,
|
||||||
void **ret_iter)
|
void **ret_iter)
|
||||||
{
|
{
|
||||||
|
@ -1346,7 +1346,7 @@ errcode_t profile_node_iterator(void **iter_p, struct profile_node **ret_node,
|
||||||
* If the file has changed, then the node pointer is invalid,
|
* If the file has changed, then the node pointer is invalid,
|
||||||
* so we'll have search the file again looking for it.
|
* so we'll have search the file again looking for it.
|
||||||
*/
|
*/
|
||||||
if (iter->node && (iter->file &&
|
if (iter->node && (iter->file &&
|
||||||
iter->file->upd_serial != iter->file_serial)) {
|
iter->file->upd_serial != iter->file_serial)) {
|
||||||
iter->flags &= ~PROFILE_ITER_FINAL_SEEN;
|
iter->flags &= ~PROFILE_ITER_FINAL_SEEN;
|
||||||
skip_num = iter->num;
|
skip_num = iter->num;
|
||||||
|
@ -1483,13 +1483,13 @@ errcode_t profile_get_value(profile_t profile, const char *name,
|
||||||
*ret_value = value;
|
*ret_value = value;
|
||||||
else
|
else
|
||||||
retval = PROF_NO_RELATION;
|
retval = PROF_NO_RELATION;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
profile_iterator_free(&state);
|
profile_iterator_free(&state);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_get_string(profile_t profile, const char *name, const char *subname,
|
profile_get_string(profile_t profile, const char *name, const char *subname,
|
||||||
const char *subsubname, const char *def_val,
|
const char *subsubname, const char *def_val,
|
||||||
char **ret_string)
|
char **ret_string)
|
||||||
|
@ -1498,7 +1498,7 @@ profile_get_string(profile_t profile, const char *name, const char *subname,
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
if (profile) {
|
if (profile) {
|
||||||
retval = profile_get_value(profile, name, subname,
|
retval = profile_get_value(profile, name, subname,
|
||||||
subsubname, &value);
|
subsubname, &value);
|
||||||
if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION)
|
if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION)
|
||||||
value = def_val;
|
value = def_val;
|
||||||
|
@ -1506,7 +1506,7 @@ profile_get_string(profile_t profile, const char *name, const char *subname,
|
||||||
return retval;
|
return retval;
|
||||||
} else
|
} else
|
||||||
value = def_val;
|
value = def_val;
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
*ret_string = malloc(strlen(value)+1);
|
*ret_string = malloc(strlen(value)+1);
|
||||||
if (*ret_string == 0)
|
if (*ret_string == 0)
|
||||||
|
@ -1517,7 +1517,7 @@ profile_get_string(profile_t profile, const char *name, const char *subname,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_get_integer(profile_t profile, const char *name, const char *subname,
|
profile_get_integer(profile_t profile, const char *name, const char *subname,
|
||||||
const char *subsubname, int def_val, int *ret_int)
|
const char *subsubname, int def_val, int *ret_int)
|
||||||
{
|
{
|
||||||
|
@ -1552,15 +1552,15 @@ profile_get_integer(profile_t profile, const char *name, const char *subname,
|
||||||
/* Garbage in string. */
|
/* Garbage in string. */
|
||||||
if (end_value != value + strlen (value))
|
if (end_value != value + strlen (value))
|
||||||
return PROF_BAD_INTEGER;
|
return PROF_BAD_INTEGER;
|
||||||
|
|
||||||
|
|
||||||
*ret_int = ret_long;
|
*ret_int = ret_long;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_get_uint(profile_t profile, const char *name, const char *subname,
|
profile_get_uint(profile_t profile, const char *name, const char *subname,
|
||||||
const char *subsubname, unsigned int def_val,
|
const char *subsubname, unsigned int def_val,
|
||||||
unsigned int *ret_int)
|
unsigned int *ret_int)
|
||||||
{
|
{
|
||||||
const char *value;
|
const char *value;
|
||||||
|
@ -1594,7 +1594,7 @@ profile_get_uint(profile_t profile, const char *name, const char *subname,
|
||||||
/* Garbage in string. */
|
/* Garbage in string. */
|
||||||
if (end_value != value + strlen (value))
|
if (end_value != value + strlen (value))
|
||||||
return PROF_BAD_INTEGER;
|
return PROF_BAD_INTEGER;
|
||||||
|
|
||||||
*ret_int = ret_long;
|
*ret_int = ret_long;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1613,7 +1613,7 @@ static errcode_t
|
||||||
profile_parse_boolean(const char *s, int *ret_boolean)
|
profile_parse_boolean(const char *s, int *ret_boolean)
|
||||||
{
|
{
|
||||||
const char *const *p;
|
const char *const *p;
|
||||||
|
|
||||||
if (ret_boolean == NULL)
|
if (ret_boolean == NULL)
|
||||||
return PROF_EINVAL;
|
return PROF_EINVAL;
|
||||||
|
|
||||||
|
@ -1630,11 +1630,11 @@ profile_parse_boolean(const char *s, int *ret_boolean)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PROF_BAD_BOOLEAN;
|
return PROF_BAD_BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_get_boolean(profile_t profile, const char *name, const char *subname,
|
profile_get_boolean(profile_t profile, const char *name, const char *subname,
|
||||||
const char *subsubname, int def_val, int *ret_boolean)
|
const char *subsubname, int def_val, int *ret_boolean)
|
||||||
{
|
{
|
||||||
|
@ -1652,16 +1652,16 @@ profile_get_boolean(profile_t profile, const char *name, const char *subname,
|
||||||
return 0;
|
return 0;
|
||||||
} else if (retval)
|
} else if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
return profile_parse_boolean (value, ret_boolean);
|
return profile_parse_boolean (value, ret_boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_iterator(void **iter_p, char **ret_name, char **ret_value)
|
profile_iterator(void **iter_p, char **ret_name, char **ret_value)
|
||||||
{
|
{
|
||||||
char *name, *value;
|
char *name, *value;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
retval = profile_node_iterator(iter_p, 0, &name, &value);
|
retval = profile_node_iterator(iter_p, 0, &name, &value);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1734,19 +1734,19 @@ static void do_cmd(profile_t profile, char **argv)
|
||||||
if (subname)
|
if (subname)
|
||||||
subsubname = names[2];
|
subsubname = names[2];
|
||||||
if (subsubname && names[3]) {
|
if (subsubname && names[3]) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Only 3 levels are allowed with query1\n");
|
"Only 3 levels are allowed with query1\n");
|
||||||
retval = EINVAL;
|
retval = EINVAL;
|
||||||
} else
|
} else
|
||||||
retval = profile_get_value(profile, name, subname,
|
retval = profile_get_value(profile, name, subname,
|
||||||
subsubname, &value);
|
subsubname, &value);
|
||||||
print_status = PRINT_VALUE;
|
print_status = PRINT_VALUE;
|
||||||
} else if (!strcmp(cmd, "list_sections")) {
|
} else if (!strcmp(cmd, "list_sections")) {
|
||||||
retval = profile_get_subsection_names(profile, names,
|
retval = profile_get_subsection_names(profile, names,
|
||||||
&values);
|
&values);
|
||||||
print_status = PRINT_VALUES;
|
print_status = PRINT_VALUES;
|
||||||
} else if (!strcmp(cmd, "list_relations")) {
|
} else if (!strcmp(cmd, "list_relations")) {
|
||||||
retval = profile_get_relation_names(profile, names,
|
retval = profile_get_relation_names(profile, names,
|
||||||
&values);
|
&values);
|
||||||
print_status = PRINT_VALUES;
|
print_status = PRINT_VALUES;
|
||||||
} else if (!strcmp(cmd, "dump")) {
|
} else if (!strcmp(cmd, "dump")) {
|
||||||
|
@ -1813,7 +1813,7 @@ static void do_batchmode(profile_t profile)
|
||||||
}
|
}
|
||||||
profile_release(profile);
|
profile_release(profile);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void syntax_err_report(const char *filename, long err, int line_num)
|
void syntax_err_report(const char *filename, long err, int line_num)
|
||||||
|
@ -1830,7 +1830,7 @@ int main(int argc, char **argv)
|
||||||
profile_t profile;
|
profile_t profile;
|
||||||
long retval;
|
long retval;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: %s filename [cmd argset]\n", program_name);
|
fprintf(stderr, "Usage: %s filename [cmd argset]\n", program_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1839,7 +1839,7 @@ int main(int argc, char **argv)
|
||||||
initialize_prof_error_table();
|
initialize_prof_error_table();
|
||||||
|
|
||||||
profile_set_syntax_err_cb(syntax_err_report);
|
profile_set_syntax_err_cb(syntax_err_report);
|
||||||
|
|
||||||
retval = profile_init_path(argv[1], &profile);
|
retval = profile_init_path(argv[1], &profile);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err(program_name, retval, "while initializing profile");
|
com_err(program_name, retval, "while initializing profile");
|
||||||
|
|
|
@ -7,16 +7,16 @@
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
* Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
|
* Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Export of this software from the United States of America may require
|
* Export of this software from the United States of America may require
|
||||||
* a specific license from the United States Government. It is the
|
* a specific license from the United States Government. It is the
|
||||||
* responsibility of any person or organization contemplating export to
|
* responsibility of any person or organization contemplating export to
|
||||||
* obtain such a license before exporting.
|
* obtain such a license before exporting.
|
||||||
*
|
*
|
||||||
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
||||||
* distribute this software and its documentation for any purpose and
|
* distribute this software and its documentation for any purpose and
|
||||||
* without fee is hereby granted, provided that the above copyright
|
* without fee is hereby granted, provided that the above copyright
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
* M.I.T. makes no representations about the suitability of this software
|
* M.I.T. makes no representations about the suitability of this software
|
||||||
* for any purpose. It is provided "as is" without express or implied
|
* for any purpose. It is provided "as is" without express or implied
|
||||||
* warranty.
|
* warranty.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
typedef struct _profile_t *profile_t;
|
typedef struct _profile_t *profile_t;
|
||||||
|
|
||||||
typedef void (*profile_syntax_err_cb_t)(const char *file, long err,
|
typedef void (*profile_syntax_err_cb_t)(const char *file, long err,
|
||||||
int line_num);
|
int line_num);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -65,7 +65,7 @@ long profile_set_default
|
||||||
(profile_t profile, const char *def_string);
|
(profile_t profile, const char *def_string);
|
||||||
|
|
||||||
long profile_get_string
|
long profile_get_string
|
||||||
(profile_t profile, const char *name, const char *subname,
|
(profile_t profile, const char *name, const char *subname,
|
||||||
const char *subsubname, const char *def_val,
|
const char *subsubname, const char *def_val,
|
||||||
char **ret_string);
|
char **ret_string);
|
||||||
long profile_get_integer
|
long profile_get_integer
|
||||||
|
@ -75,7 +75,7 @@ long profile_get_integer
|
||||||
|
|
||||||
long profile_get_uint
|
long profile_get_uint
|
||||||
(profile_t profile, const char *name, const char *subname,
|
(profile_t profile, const char *name, const char *subname,
|
||||||
const char *subsubname, unsigned int def_val,
|
const char *subsubname, unsigned int def_val,
|
||||||
unsigned int *ret_int);
|
unsigned int *ret_int);
|
||||||
|
|
||||||
long profile_get_boolean
|
long profile_get_boolean
|
||||||
|
@ -89,7 +89,7 @@ long profile_iterator_create
|
||||||
|
|
||||||
void profile_iterator_free
|
void profile_iterator_free
|
||||||
(void **iter_p);
|
(void **iter_p);
|
||||||
|
|
||||||
long profile_iterator
|
long profile_iterator
|
||||||
(void **iter_p, char **ret_name, char **ret_value);
|
(void **iter_p, char **ret_name, char **ret_value);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* relation that is listed more than once. This functionality can all
|
* relation that is listed more than once. This functionality can all
|
||||||
* be done using the profile_iterator abstraction, but it is less
|
* be done using the profile_iterator abstraction, but it is less
|
||||||
* convenient.
|
* convenient.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 by Theodore Ts'o.
|
* Copyright (C) 2006 by Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -89,7 +89,7 @@ static errcode_t add_to_list(struct profile_string_list *list, char *str)
|
||||||
{
|
{
|
||||||
char **newlist;
|
char **newlist;
|
||||||
int newmax;
|
int newmax;
|
||||||
|
|
||||||
if (list->num+1 >= list->max) {
|
if (list->num+1 >= list->max) {
|
||||||
newmax = list->max + 10;
|
newmax = list->max + 10;
|
||||||
newlist = realloc(list->list, newmax * sizeof(char *));
|
newlist = realloc(list->list, newmax * sizeof(char *));
|
||||||
|
@ -119,8 +119,8 @@ static int is_list_member(struct profile_string_list *list, const char *str)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function frees a null-terminated list as returned by
|
* This function frees a null-terminated list as returned by
|
||||||
* profile_get_values.
|
* profile_get_values.
|
||||||
|
@ -131,7 +131,7 @@ void profile_free_list(char **list)
|
||||||
|
|
||||||
if (list == 0)
|
if (list == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (cp = list; *cp; cp++)
|
for (cp = list; *cp; cp++)
|
||||||
free(*cp);
|
free(*cp);
|
||||||
free(list);
|
free(list);
|
||||||
|
@ -168,7 +168,7 @@ profile_get_values(profile_t profile, const char *const *names,
|
||||||
|
|
||||||
end_list(&values, ret_values);
|
end_list(&values, ret_values);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
end_list(&values, 0);
|
end_list(&values, 0);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -178,7 +178,7 @@ cleanup:
|
||||||
* This function will return the list of the names of subections in the
|
* This function will return the list of the names of subections in the
|
||||||
* under the specified section name.
|
* under the specified section name.
|
||||||
*/
|
*/
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_get_subsection_names(profile_t profile, const char **names,
|
profile_get_subsection_names(profile_t profile, const char **names,
|
||||||
char ***ret_names)
|
char ***ret_names)
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ profile_get_subsection_names(profile_t profile, const char **names,
|
||||||
|
|
||||||
end_list(&values, ret_names);
|
end_list(&values, ret_names);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
end_list(&values, 0);
|
end_list(&values, 0);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -214,7 +214,7 @@ cleanup:
|
||||||
* This function will return the list of the names of relations in the
|
* This function will return the list of the names of relations in the
|
||||||
* under the specified section name.
|
* under the specified section name.
|
||||||
*/
|
*/
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_get_relation_names(profile_t profile, const char **names,
|
profile_get_relation_names(profile_t profile, const char **names,
|
||||||
char ***ret_names)
|
char ***ret_names)
|
||||||
{
|
{
|
||||||
|
@ -244,20 +244,20 @@ profile_get_relation_names(profile_t profile, const char **names,
|
||||||
|
|
||||||
end_list(&values, ret_names);
|
end_list(&values, ret_names);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
end_list(&values, 0);
|
end_list(&values, 0);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
profile_release_string(char *str)
|
profile_release_string(char *str)
|
||||||
{
|
{
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode_t
|
errcode_t
|
||||||
profile_init_path(const char * filepath,
|
profile_init_path(const char * filepath,
|
||||||
profile_t *ret_profile)
|
profile_t *ret_profile)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +272,7 @@ profile_init_path(const char * filepath,
|
||||||
if (*s == ':')
|
if (*s == ':')
|
||||||
n_entries++;
|
n_entries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the array is NULL terminated */
|
/* the array is NULL terminated */
|
||||||
filenames = (char **) malloc((n_entries+1) * sizeof(char*));
|
filenames = (char **) malloc((n_entries+1) * sizeof(char*));
|
||||||
if (filenames == 0)
|
if (filenames == 0)
|
||||||
|
@ -298,7 +298,7 @@ profile_init_path(const char * filepath,
|
||||||
/* cap the array */
|
/* cap the array */
|
||||||
filenames[i] = 0;
|
filenames[i] = 0;
|
||||||
|
|
||||||
retval = profile_init((const char **) filenames,
|
retval = profile_init((const char **) filenames,
|
||||||
ret_profile);
|
ret_profile);
|
||||||
|
|
||||||
/* count back down and free the entries */
|
/* count back down and free the entries */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* region.c --- code which manages allocations within a region.
|
* region.c --- code which manages allocations within a region.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2001 Theodore Ts'o.
|
* Copyright (C) 2001 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -154,7 +154,7 @@ void region_print(region_t region, FILE *f)
|
||||||
{
|
{
|
||||||
struct region_el *r;
|
struct region_el *r;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
fprintf(f, "Printing region (min=%d. max=%d)\n\t", region->min,
|
fprintf(f, "Printing region (min=%d. max=%d)\n\t", region->min,
|
||||||
region->max);
|
region->max);
|
||||||
for (r = region->allocated; r; r = r->next) {
|
for (r = region->allocated; r; r = r->next) {
|
||||||
|
@ -171,7 +171,7 @@ int main(int argc, char **argv)
|
||||||
int pc = 0, ret;
|
int pc = 0, ret;
|
||||||
region_addr_t start, end, len;
|
region_addr_t start, end, len;
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (bcode_program[pc++]) {
|
switch (bcode_program[pc++]) {
|
||||||
case BCODE_END:
|
case BCODE_END:
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*
|
/*
|
||||||
* rehash.c --- rebuild hash tree directories
|
* rehash.c --- rebuild hash tree directories
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Theodore Ts'o
|
* Copyright (C) 2002 Theodore Ts'o
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
* This algorithm is designed for simplicity of implementation and to
|
* This algorithm is designed for simplicity of implementation and to
|
||||||
* pack the directory as much as possible. It however requires twice
|
* pack the directory as much as possible. It however requires twice
|
||||||
* as much memory as the size of the directory. The maximum size
|
* as much memory as the size of the directory. The maximum size
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
* --------------------------------------------------------
|
* --------------------------------------------------------
|
||||||
* ^ ptr ^ptr
|
* ^ ptr ^ptr
|
||||||
* tail new head old
|
* tail new head old
|
||||||
*
|
*
|
||||||
* This is going to be a pain in the tuckus to implement, and will
|
* This is going to be a pain in the tuckus to implement, and will
|
||||||
* require a lot more disk accesses. So I'm going to skip it for now;
|
* require a lot more disk accesses. So I'm going to skip it for now;
|
||||||
* it's only really going to be an issue for really, really big
|
* it's only really going to be an issue for really, really big
|
||||||
|
@ -90,7 +90,7 @@ static int fill_dir_block(ext2_filsys fs,
|
||||||
char *dir;
|
char *dir;
|
||||||
unsigned int offset, dir_offset;
|
unsigned int offset, dir_offset;
|
||||||
int rec_len, hash_alg;
|
int rec_len, hash_alg;
|
||||||
|
|
||||||
if (blockcnt < 0)
|
if (blockcnt < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ static int fill_dir_block(ext2_filsys fs,
|
||||||
return BLOCK_ABORT;
|
return BLOCK_ABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b)
|
||||||
const struct hash_entry *he_a = (const struct hash_entry *) a;
|
const struct hash_entry *he_a = (const struct hash_entry *) a;
|
||||||
const struct hash_entry *he_b = (const struct hash_entry *) b;
|
const struct hash_entry *he_b = (const struct hash_entry *) b;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (he_a->hash > he_b->hash)
|
if (he_a->hash > he_b->hash)
|
||||||
ret = 1;
|
ret = 1;
|
||||||
else if (he_a->hash < he_b->hash)
|
else if (he_a->hash < he_b->hash)
|
||||||
|
@ -221,7 +221,7 @@ static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
|
static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
|
||||||
int blocks)
|
int blocks)
|
||||||
{
|
{
|
||||||
void *new_mem;
|
void *new_mem;
|
||||||
|
@ -280,7 +280,7 @@ static void mutate_name(char *str, __u16 *len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
__u16 l = *len & 0xFF, h = *len & 0xff00;
|
__u16 l = *len & 0xFF, h = *len & 0xff00;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First check to see if it looks the name has been mutated
|
* First check to see if it looks the name has been mutated
|
||||||
* already
|
* already
|
||||||
|
@ -323,7 +323,7 @@ static void mutate_name(char *str, __u16 *len)
|
||||||
} else {
|
} else {
|
||||||
if (str[0] == '~')
|
if (str[0] == '~')
|
||||||
str[0] = 'a';
|
str[0] = 'a';
|
||||||
else
|
else
|
||||||
str[0]++;
|
str[0]++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -341,7 +341,7 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs,
|
||||||
char new_name[256];
|
char new_name[256];
|
||||||
__u16 new_len;
|
__u16 new_len;
|
||||||
int hash_alg;
|
int hash_alg;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
pctx.ino = ino;
|
pctx.ino = ino;
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs,
|
||||||
new_len & 0xFF)))
|
new_len & 0xFF)))
|
||||||
continue;
|
continue;
|
||||||
mutate_name(new_name, &new_len);
|
mutate_name(new_name, &new_len);
|
||||||
|
|
||||||
j = -1;
|
j = -1;
|
||||||
}
|
}
|
||||||
new_name[new_len & 0xFF] = 0;
|
new_name[new_len & 0xFF] = 0;
|
||||||
|
@ -408,7 +408,7 @@ static errcode_t copy_dir_entries(ext2_filsys fs,
|
||||||
int i, rec_len, left;
|
int i, rec_len, left;
|
||||||
ext2_dirhash_t prev_hash;
|
ext2_dirhash_t prev_hash;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
outdir->max = 0;
|
outdir->max = 0;
|
||||||
retval = alloc_size_dir(fs, outdir,
|
retval = alloc_size_dir(fs, outdir,
|
||||||
(fd->dir_size / fs->blocksize) + 2);
|
(fd->dir_size / fs->blocksize) + 2);
|
||||||
|
@ -473,7 +473,7 @@ static struct ext2_dx_root_info *set_root_node(ext2_filsys fs, char *buf,
|
||||||
|
|
||||||
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE)
|
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE)
|
||||||
filetype = EXT2_FT_DIR << 8;
|
filetype = EXT2_FT_DIR << 8;
|
||||||
|
|
||||||
memset(buf, 0, fs->blocksize);
|
memset(buf, 0, fs->blocksize);
|
||||||
dir = (struct ext2_dir_entry *) buf;
|
dir = (struct ext2_dir_entry *) buf;
|
||||||
dir->inode = ino;
|
dir->inode = ino;
|
||||||
|
@ -486,7 +486,7 @@ static struct ext2_dx_root_info *set_root_node(ext2_filsys fs, char *buf,
|
||||||
dir->name[1] = '.';
|
dir->name[1] = '.';
|
||||||
dir->name_len = 2 | filetype;
|
dir->name_len = 2 | filetype;
|
||||||
dir->rec_len = fs->blocksize - 12;
|
dir->rec_len = fs->blocksize - 12;
|
||||||
|
|
||||||
root = (struct ext2_dx_root_info *) (buf+24);
|
root = (struct ext2_dx_root_info *) (buf+24);
|
||||||
root->reserved_zero = 0;
|
root->reserved_zero = 0;
|
||||||
root->hash_version = fs->super->s_def_hash_version;
|
root->hash_version = fs->super->s_def_hash_version;
|
||||||
|
@ -511,7 +511,7 @@ static struct ext2_dx_entry *set_int_node(ext2_filsys fs, char *buf)
|
||||||
dir = (struct ext2_dir_entry *) buf;
|
dir = (struct ext2_dir_entry *) buf;
|
||||||
dir->inode = 0;
|
dir->inode = 0;
|
||||||
dir->rec_len = fs->blocksize;
|
dir->rec_len = fs->blocksize;
|
||||||
|
|
||||||
limits = (struct ext2_dx_countlimit *) (buf+8);
|
limits = (struct ext2_dx_countlimit *) (buf+8);
|
||||||
limits->limit = (fs->blocksize - 8) / sizeof(struct ext2_dx_entry);
|
limits->limit = (fs->blocksize - 8) / sizeof(struct ext2_dx_entry);
|
||||||
limits->count = 0;
|
limits->count = 0;
|
||||||
|
@ -535,7 +535,7 @@ static errcode_t calculate_tree(ext2_filsys fs,
|
||||||
char * block_start;
|
char * block_start;
|
||||||
int i, c1, c2, nblks;
|
int i, c1, c2, nblks;
|
||||||
int limit_offset, root_offset;
|
int limit_offset, root_offset;
|
||||||
|
|
||||||
root_info = set_root_node(fs, outdir->buf, ino, parent);
|
root_info = set_root_node(fs, outdir->buf, ino, parent);
|
||||||
root_offset = limit_offset = ((char *) root_info - outdir->buf) +
|
root_offset = limit_offset = ((char *) root_info - outdir->buf) +
|
||||||
root_info->info_length;
|
root_info->info_length;
|
||||||
|
@ -564,7 +564,7 @@ static errcode_t calculate_tree(ext2_filsys fs,
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
if (c2 == 0) {
|
if (c2 == 0) {
|
||||||
if (limit)
|
if (limit)
|
||||||
limit->limit = limit->count =
|
limit->limit = limit->count =
|
||||||
ext2fs_cpu_to_le16(limit->limit);
|
ext2fs_cpu_to_le16(limit->limit);
|
||||||
root = (struct ext2_dx_entry *)
|
root = (struct ext2_dx_entry *)
|
||||||
(outdir->buf + root_offset);
|
(outdir->buf + root_offset);
|
||||||
|
@ -612,7 +612,7 @@ static int write_dir_block(ext2_filsys fs,
|
||||||
blk_t *block_nr,
|
blk_t *block_nr,
|
||||||
e2_blkcnt_t blockcnt,
|
e2_blkcnt_t blockcnt,
|
||||||
blk_t ref_block EXT2FS_ATTR((unused)),
|
blk_t ref_block EXT2FS_ATTR((unused)),
|
||||||
int ref_offset EXT2FS_ATTR((unused)),
|
int ref_offset EXT2FS_ATTR((unused)),
|
||||||
void *priv_data)
|
void *priv_data)
|
||||||
{
|
{
|
||||||
struct write_dir_struct *wd = (struct write_dir_struct *) priv_data;
|
struct write_dir_struct *wd = (struct write_dir_struct *) priv_data;
|
||||||
|
@ -684,7 +684,7 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
|
||||||
char *dir_buf = 0;
|
char *dir_buf = 0;
|
||||||
struct fill_dir_struct fd;
|
struct fill_dir_struct fd;
|
||||||
struct out_dir outdir;
|
struct out_dir outdir;
|
||||||
|
|
||||||
outdir.max = outdir.num = 0;
|
outdir.max = outdir.num = 0;
|
||||||
outdir.buf = 0;
|
outdir.buf = 0;
|
||||||
outdir.hashes = 0;
|
outdir.hashes = 0;
|
||||||
|
@ -753,7 +753,7 @@ resort:
|
||||||
retval = copy_dir_entries(fs, &fd, &outdir);
|
retval = copy_dir_entries(fs, &fd, &outdir);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
free(dir_buf); dir_buf = 0;
|
free(dir_buf); dir_buf = 0;
|
||||||
|
|
||||||
if (!fd.compress) {
|
if (!fd.compress) {
|
||||||
|
@ -762,7 +762,7 @@ resort:
|
||||||
if (retval)
|
if (retval)
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = write_directory(ctx, fs, &outdir, ino, fd.compress);
|
retval = write_directory(ctx, fs, &outdir, ino, fd.compress);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
@ -800,7 +800,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e2fsck_get_lost_and_found(ctx, 0);
|
e2fsck_get_lost_and_found(ctx, 0);
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
dir_index = ctx->fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX;
|
dir_index = ctx->fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX;
|
||||||
|
@ -809,7 +809,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
|
||||||
dirinfo_iter = e2fsck_dir_info_iter_begin(ctx);
|
dirinfo_iter = e2fsck_dir_info_iter_begin(ctx);
|
||||||
max = e2fsck_get_num_dirinfo(ctx);
|
max = e2fsck_get_num_dirinfo(ctx);
|
||||||
} else {
|
} else {
|
||||||
retval = ext2fs_u32_list_iterate_begin(ctx->dirs_to_hash,
|
retval = ext2fs_u32_list_iterate_begin(ctx->dirs_to_hash,
|
||||||
&iter);
|
&iter);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
pctx.errcode = retval;
|
pctx.errcode = retval;
|
||||||
|
@ -820,7 +820,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
if (all_dirs) {
|
if (all_dirs) {
|
||||||
if ((dir = e2fsck_dir_info_iter(ctx,
|
if ((dir = e2fsck_dir_info_iter(ctx,
|
||||||
dirinfo_iter)) == 0)
|
dirinfo_iter)) == 0)
|
||||||
break;
|
break;
|
||||||
ino = dir->ino;
|
ino = dir->ino;
|
||||||
|
@ -852,7 +852,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
|
||||||
e2fsck_dir_info_iter_end(ctx, dirinfo_iter);
|
e2fsck_dir_info_iter_end(ctx, dirinfo_iter);
|
||||||
else
|
else
|
||||||
ext2fs_u32_list_iterate_end(iter);
|
ext2fs_u32_list_iterate_end(iter);
|
||||||
|
|
||||||
if (ctx->dirs_to_hash)
|
if (ctx->dirs_to_hash)
|
||||||
ext2fs_u32_list_free(ctx->dirs_to_hash);
|
ext2fs_u32_list_free(ctx->dirs_to_hash);
|
||||||
ctx->dirs_to_hash = 0;
|
ctx->dirs_to_hash = 0;
|
||||||
|
|
114
e2fsck/revoke.c
114
e2fsck/revoke.c
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* linux/fs/revoke.c
|
* linux/fs/revoke.c
|
||||||
*
|
*
|
||||||
* Written by Stephen C. Tweedie <sct@redhat.com>, 2000
|
* Written by Stephen C. Tweedie <sct@redhat.com>, 2000
|
||||||
*
|
*
|
||||||
* Copyright 2000 Red Hat corp --- All Rights Reserved
|
* Copyright 2000 Red Hat corp --- All Rights Reserved
|
||||||
|
@ -15,10 +15,10 @@
|
||||||
* Revoke is the mechanism used to prevent old log records for deleted
|
* Revoke is the mechanism used to prevent old log records for deleted
|
||||||
* metadata from being replayed on top of newer data using the same
|
* metadata from being replayed on top of newer data using the same
|
||||||
* blocks. The revoke mechanism is used in two separate places:
|
* blocks. The revoke mechanism is used in two separate places:
|
||||||
*
|
*
|
||||||
* + Commit: during commit we write the entire list of the current
|
* + Commit: during commit we write the entire list of the current
|
||||||
* transaction's revoked blocks to the journal
|
* transaction's revoked blocks to the journal
|
||||||
*
|
*
|
||||||
* + Recovery: during recovery we record the transaction ID of all
|
* + Recovery: during recovery we record the transaction ID of all
|
||||||
* revoked blocks. If there are multiple revoke records in the log
|
* revoked blocks. If there are multiple revoke records in the log
|
||||||
* for a single block, only the last one counts, and if there is a log
|
* for a single block, only the last one counts, and if there is a log
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
* single transaction:
|
* single transaction:
|
||||||
*
|
*
|
||||||
* Block is revoked and then journaled:
|
* Block is revoked and then journaled:
|
||||||
* The desired end result is the journaling of the new block, so we
|
* The desired end result is the journaling of the new block, so we
|
||||||
* cancel the revoke before the transaction commits.
|
* cancel the revoke before the transaction commits.
|
||||||
*
|
*
|
||||||
* Block is journaled and then revoked:
|
* Block is journaled and then revoked:
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
* transaction must have happened after the block was journaled and so
|
* transaction must have happened after the block was journaled and so
|
||||||
* the revoke must take precedence.
|
* the revoke must take precedence.
|
||||||
*
|
*
|
||||||
* Block is revoked and then written as data:
|
* Block is revoked and then written as data:
|
||||||
* The data write is allowed to succeed, but the revoke is _not_
|
* The data write is allowed to succeed, but the revoke is _not_
|
||||||
* cancelled. We still need to prevent old log records from
|
* cancelled. We still need to prevent old log records from
|
||||||
* overwriting the new data. We don't even need to clear the revoke
|
* overwriting the new data. We don't even need to clear the revoke
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
* buffer has not been revoked, and cancel_revoke
|
* buffer has not been revoked, and cancel_revoke
|
||||||
* need do nothing.
|
* need do nothing.
|
||||||
* RevokeValid set, Revoked set:
|
* RevokeValid set, Revoked set:
|
||||||
* buffer has been revoked.
|
* buffer has been revoked.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
#ifndef __KERNEL__
|
||||||
|
@ -78,11 +78,11 @@ static lkmem_cache_t *revoke_table_cache;
|
||||||
journal replay, this involves recording the transaction ID of the
|
journal replay, this involves recording the transaction ID of the
|
||||||
last transaction to revoke this block. */
|
last transaction to revoke this block. */
|
||||||
|
|
||||||
struct jbd_revoke_record_s
|
struct jbd_revoke_record_s
|
||||||
{
|
{
|
||||||
struct list_head hash;
|
struct list_head hash;
|
||||||
tid_t sequence; /* Used for recovery only */
|
tid_t sequence; /* Used for recovery only */
|
||||||
unsigned long blocknr;
|
unsigned long blocknr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ struct jbd_revoke_table_s
|
||||||
{
|
{
|
||||||
/* It is conceivable that we might want a larger hash table
|
/* It is conceivable that we might want a larger hash table
|
||||||
* for recovery. Must be a power of two. */
|
* for recovery. Must be a power of two. */
|
||||||
int hash_size;
|
int hash_size;
|
||||||
int hash_shift;
|
int hash_shift;
|
||||||
struct list_head *hash_table;
|
struct list_head *hash_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ static inline int hash(journal_t *journal, unsigned long block)
|
||||||
{
|
{
|
||||||
struct jbd_revoke_table_s *table = journal->j_revoke;
|
struct jbd_revoke_table_s *table = journal->j_revoke;
|
||||||
int hash_shift = table->hash_shift;
|
int hash_shift = table->hash_shift;
|
||||||
|
|
||||||
return ((block << (hash_shift - 6)) ^
|
return ((block << (hash_shift - 6)) ^
|
||||||
(block >> 13) ^
|
(block >> 13) ^
|
||||||
(block << (hash_shift - 12))) & (table->hash_size - 1);
|
(block << (hash_shift - 12))) & (table->hash_size - 1);
|
||||||
|
@ -156,7 +156,7 @@ static struct jbd_revoke_record_s *find_revoke_record(journal_t *journal,
|
||||||
{
|
{
|
||||||
struct list_head *hash_list;
|
struct list_head *hash_list;
|
||||||
struct jbd_revoke_record_s *record;
|
struct jbd_revoke_record_s *record;
|
||||||
|
|
||||||
hash_list = &journal->j_revoke->hash_table[hash(journal, blocknr)];
|
hash_list = &journal->j_revoke->hash_table[hash(journal, blocknr)];
|
||||||
|
|
||||||
record = (struct jbd_revoke_record_s *) hash_list->next;
|
record = (struct jbd_revoke_record_s *) hash_list->next;
|
||||||
|
@ -185,7 +185,7 @@ int __init journal_init_revoke_caches(void)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void journal_destroy_revoke_caches(void)
|
void journal_destroy_revoke_caches(void)
|
||||||
{
|
{
|
||||||
|
@ -200,13 +200,13 @@ void journal_destroy_revoke_caches(void)
|
||||||
int journal_init_revoke(journal_t *journal, int hash_size)
|
int journal_init_revoke(journal_t *journal, int hash_size)
|
||||||
{
|
{
|
||||||
int shift, tmp;
|
int shift, tmp;
|
||||||
|
|
||||||
J_ASSERT (journal->j_revoke == NULL);
|
J_ASSERT (journal->j_revoke == NULL);
|
||||||
|
|
||||||
journal->j_revoke = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL);
|
journal->j_revoke = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL);
|
||||||
if (!journal->j_revoke)
|
if (!journal->j_revoke)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Check that the hash_size is a power of two */
|
/* Check that the hash_size is a power of two */
|
||||||
J_ASSERT ((hash_size & (hash_size-1)) == 0);
|
J_ASSERT ((hash_size & (hash_size-1)) == 0);
|
||||||
|
|
||||||
|
@ -225,10 +225,10 @@ int journal_init_revoke(journal_t *journal, int hash_size)
|
||||||
journal->j_revoke = NULL;
|
journal->j_revoke = NULL;
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmp = 0; tmp < hash_size; tmp++)
|
for (tmp = 0; tmp < hash_size; tmp++)
|
||||||
INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
|
INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,16 +239,16 @@ void journal_destroy_revoke(journal_t *journal)
|
||||||
struct jbd_revoke_table_s *table;
|
struct jbd_revoke_table_s *table;
|
||||||
struct list_head *hash_list;
|
struct list_head *hash_list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
table = journal->j_revoke;
|
table = journal->j_revoke;
|
||||||
if (!table)
|
if (!table)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i=0; i<table->hash_size; i++) {
|
for (i=0; i<table->hash_size; i++) {
|
||||||
hash_list = &table->hash_table[i];
|
hash_list = &table->hash_table[i];
|
||||||
J_ASSERT (list_empty(hash_list));
|
J_ASSERT (list_empty(hash_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(table->hash_table);
|
kfree(table->hash_table);
|
||||||
kmem_cache_free(revoke_table_cache, table);
|
kmem_cache_free(revoke_table_cache, table);
|
||||||
journal->j_revoke = NULL;
|
journal->j_revoke = NULL;
|
||||||
|
@ -257,22 +257,22 @@ void journal_destroy_revoke(journal_t *journal)
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* journal_revoke: revoke a given buffer_head from the journal. This
|
* journal_revoke: revoke a given buffer_head from the journal. This
|
||||||
* prevents the block from being replayed during recovery if we take a
|
* prevents the block from being replayed during recovery if we take a
|
||||||
* crash after this current transaction commits. Any subsequent
|
* crash after this current transaction commits. Any subsequent
|
||||||
* metadata writes of the buffer in this transaction cancel the
|
* metadata writes of the buffer in this transaction cancel the
|
||||||
* revoke.
|
* revoke.
|
||||||
*
|
*
|
||||||
* Note that this call may block --- it is up to the caller to make
|
* Note that this call may block --- it is up to the caller to make
|
||||||
* sure that there are no further calls to journal_write_metadata
|
* sure that there are no further calls to journal_write_metadata
|
||||||
* before the revoke is complete. In ext3, this implies calling the
|
* before the revoke is complete. In ext3, this implies calling the
|
||||||
* revoke before clearing the block bitmap when we are deleting
|
* revoke before clearing the block bitmap when we are deleting
|
||||||
* metadata.
|
* metadata.
|
||||||
*
|
*
|
||||||
* Revoke performs a journal_forget on any buffer_head passed in as a
|
* Revoke performs a journal_forget on any buffer_head passed in as a
|
||||||
* parameter, but does _not_ forget the buffer_head if the bh was only
|
* parameter, but does _not_ forget the buffer_head if the bh was only
|
||||||
* found implicitly.
|
* found implicitly.
|
||||||
*
|
*
|
||||||
* bh_in may not be a journalled buffer - it may have come off
|
* bh_in may not be a journalled buffer - it may have come off
|
||||||
* the hash tables without an attached journal_head.
|
* the hash tables without an attached journal_head.
|
||||||
|
@ -281,7 +281,7 @@ void journal_destroy_revoke(journal_t *journal)
|
||||||
* by one.
|
* by one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int journal_revoke(handle_t *handle, unsigned long blocknr,
|
int journal_revoke(handle_t *handle, unsigned long blocknr,
|
||||||
struct buffer_head *bh_in)
|
struct buffer_head *bh_in)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh = NULL;
|
struct buffer_head *bh = NULL;
|
||||||
|
@ -379,7 +379,7 @@ int journal_cancel_revoke(handle_t *handle, struct journal_head *jh)
|
||||||
int need_cancel;
|
int need_cancel;
|
||||||
int did_revoke = 0; /* akpm: debug */
|
int did_revoke = 0; /* akpm: debug */
|
||||||
struct buffer_head *bh = jh2bh(jh);
|
struct buffer_head *bh = jh2bh(jh);
|
||||||
|
|
||||||
jbd_debug(4, "journal_head %p, cancelling revoke\n", jh);
|
jbd_debug(4, "journal_head %p, cancelling revoke\n", jh);
|
||||||
|
|
||||||
/* Is the existing Revoke bit valid? If so, we trust it, and
|
/* Is the existing Revoke bit valid? If so, we trust it, and
|
||||||
|
@ -422,7 +422,7 @@ int journal_cancel_revoke(handle_t *handle, struct journal_head *jh)
|
||||||
__brelse(bh2);
|
__brelse(bh2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return did_revoke;
|
return did_revoke;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ int journal_cancel_revoke(handle_t *handle, struct journal_head *jh)
|
||||||
* Called with the journal lock held.
|
* Called with the journal lock held.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void journal_write_revoke_records(journal_t *journal,
|
void journal_write_revoke_records(journal_t *journal,
|
||||||
transaction_t *transaction)
|
transaction_t *transaction)
|
||||||
{
|
{
|
||||||
struct journal_head *descriptor;
|
struct journal_head *descriptor;
|
||||||
|
@ -443,38 +443,38 @@ void journal_write_revoke_records(journal_t *journal,
|
||||||
struct list_head *hash_list;
|
struct list_head *hash_list;
|
||||||
int i, offset, count;
|
int i, offset, count;
|
||||||
|
|
||||||
descriptor = NULL;
|
descriptor = NULL;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
revoke = journal->j_revoke;
|
revoke = journal->j_revoke;
|
||||||
|
|
||||||
for (i = 0; i < revoke->hash_size; i++) {
|
for (i = 0; i < revoke->hash_size; i++) {
|
||||||
hash_list = &revoke->hash_table[i];
|
hash_list = &revoke->hash_table[i];
|
||||||
|
|
||||||
while (!list_empty(hash_list)) {
|
while (!list_empty(hash_list)) {
|
||||||
record = (struct jbd_revoke_record_s *)
|
record = (struct jbd_revoke_record_s *)
|
||||||
hash_list->next;
|
hash_list->next;
|
||||||
write_one_revoke_record(journal, transaction,
|
write_one_revoke_record(journal, transaction,
|
||||||
&descriptor, &offset,
|
&descriptor, &offset,
|
||||||
record);
|
record);
|
||||||
count++;
|
count++;
|
||||||
list_del(&record->hash);
|
list_del(&record->hash);
|
||||||
kmem_cache_free(revoke_record_cache, record);
|
kmem_cache_free(revoke_record_cache, record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (descriptor)
|
if (descriptor)
|
||||||
flush_descriptor(journal, descriptor, offset);
|
flush_descriptor(journal, descriptor, offset);
|
||||||
jbd_debug(1, "Wrote %d revoke records\n", count);
|
jbd_debug(1, "Wrote %d revoke records\n", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write out one revoke record. We need to create a new descriptor
|
* Write out one revoke record. We need to create a new descriptor
|
||||||
* block if the old one is full or if we have not already created one.
|
* block if the old one is full or if we have not already created one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void write_one_revoke_record(journal_t *journal,
|
static void write_one_revoke_record(journal_t *journal,
|
||||||
transaction_t *transaction,
|
transaction_t *transaction,
|
||||||
struct journal_head **descriptorp,
|
struct journal_head **descriptorp,
|
||||||
int *offsetp,
|
int *offsetp,
|
||||||
struct jbd_revoke_record_s *record)
|
struct jbd_revoke_record_s *record)
|
||||||
{
|
{
|
||||||
|
@ -499,7 +499,7 @@ static void write_one_revoke_record(journal_t *journal,
|
||||||
descriptor = NULL;
|
descriptor = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!descriptor) {
|
if (!descriptor) {
|
||||||
descriptor = journal_get_descriptor_buffer(journal);
|
descriptor = journal_get_descriptor_buffer(journal);
|
||||||
if (!descriptor)
|
if (!descriptor)
|
||||||
|
@ -516,22 +516,22 @@ static void write_one_revoke_record(journal_t *journal,
|
||||||
offset = sizeof(journal_revoke_header_t);
|
offset = sizeof(journal_revoke_header_t);
|
||||||
*descriptorp = descriptor;
|
*descriptorp = descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
* ((unsigned int *)(&jh2bh(descriptor)->b_data[offset])) =
|
* ((unsigned int *)(&jh2bh(descriptor)->b_data[offset])) =
|
||||||
htonl(record->blocknr);
|
htonl(record->blocknr);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
*offsetp = offset;
|
*offsetp = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flush a revoke descriptor out to the journal. If we are aborting,
|
* Flush a revoke descriptor out to the journal. If we are aborting,
|
||||||
* this is a noop; otherwise we are generating a buffer which needs to
|
* this is a noop; otherwise we are generating a buffer which needs to
|
||||||
* be waited for during commit, so it has to go onto the appropriate
|
* be waited for during commit, so it has to go onto the appropriate
|
||||||
* journal buffer list.
|
* journal buffer list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void flush_descriptor(journal_t *journal,
|
static void flush_descriptor(journal_t *journal,
|
||||||
struct journal_head *descriptor,
|
struct journal_head *descriptor,
|
||||||
int offset)
|
int offset)
|
||||||
{
|
{
|
||||||
journal_revoke_header_t *header;
|
journal_revoke_header_t *header;
|
||||||
|
@ -541,7 +541,7 @@ static void flush_descriptor(journal_t *journal,
|
||||||
__brelse(jh2bh(descriptor));
|
__brelse(jh2bh(descriptor));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
header = (journal_revoke_header_t *) jh2bh(descriptor)->b_data;
|
header = (journal_revoke_header_t *) jh2bh(descriptor)->b_data;
|
||||||
header->r_count = htonl(offset);
|
header->r_count = htonl(offset);
|
||||||
set_bit(BH_JWrite, &jh2bh(descriptor)->b_state);
|
set_bit(BH_JWrite, &jh2bh(descriptor)->b_state);
|
||||||
|
@ -554,7 +554,7 @@ static void flush_descriptor(journal_t *journal,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Revoke support for recovery.
|
* Revoke support for recovery.
|
||||||
*
|
*
|
||||||
* Recovery needs to be able to:
|
* Recovery needs to be able to:
|
||||||
|
@ -565,7 +565,7 @@ static void flush_descriptor(journal_t *journal,
|
||||||
* check whether a given block in a given transaction should be replayed
|
* check whether a given block in a given transaction should be replayed
|
||||||
* (ie. has not been revoked by a revoke record in that or a subsequent
|
* (ie. has not been revoked by a revoke record in that or a subsequent
|
||||||
* transaction)
|
* transaction)
|
||||||
*
|
*
|
||||||
* empty the revoke table after recovery.
|
* empty the revoke table after recovery.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -573,15 +573,15 @@ static void flush_descriptor(journal_t *journal,
|
||||||
* First, setting revoke records. We create a new revoke record for
|
* First, setting revoke records. We create a new revoke record for
|
||||||
* every block ever revoked in the log as we scan it for recovery, and
|
* every block ever revoked in the log as we scan it for recovery, and
|
||||||
* we update the existing records if we find multiple revokes for a
|
* we update the existing records if we find multiple revokes for a
|
||||||
* single block.
|
* single block.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int journal_set_revoke(journal_t *journal,
|
int journal_set_revoke(journal_t *journal,
|
||||||
unsigned long blocknr,
|
unsigned long blocknr,
|
||||||
tid_t sequence)
|
tid_t sequence)
|
||||||
{
|
{
|
||||||
struct jbd_revoke_record_s *record;
|
struct jbd_revoke_record_s *record;
|
||||||
|
|
||||||
record = find_revoke_record(journal, blocknr);
|
record = find_revoke_record(journal, blocknr);
|
||||||
if (record) {
|
if (record) {
|
||||||
/* If we have multiple occurences, only record the
|
/* If we have multiple occurences, only record the
|
||||||
|
@ -589,23 +589,23 @@ int journal_set_revoke(journal_t *journal,
|
||||||
if (tid_gt(sequence, record->sequence))
|
if (tid_gt(sequence, record->sequence))
|
||||||
record->sequence = sequence;
|
record->sequence = sequence;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return insert_revoke_hash(journal, blocknr, sequence);
|
return insert_revoke_hash(journal, blocknr, sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test revoke records. For a given block referenced in the log, has
|
* Test revoke records. For a given block referenced in the log, has
|
||||||
* that block been revoked? A revoke record with a given transaction
|
* that block been revoked? A revoke record with a given transaction
|
||||||
* sequence number revokes all blocks in that transaction and earlier
|
* sequence number revokes all blocks in that transaction and earlier
|
||||||
* ones, but later transactions still need replayed.
|
* ones, but later transactions still need replayed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int journal_test_revoke(journal_t *journal,
|
int journal_test_revoke(journal_t *journal,
|
||||||
unsigned long blocknr,
|
unsigned long blocknr,
|
||||||
tid_t sequence)
|
tid_t sequence)
|
||||||
{
|
{
|
||||||
struct jbd_revoke_record_s *record;
|
struct jbd_revoke_record_s *record;
|
||||||
|
|
||||||
record = find_revoke_record(journal, blocknr);
|
record = find_revoke_record(journal, blocknr);
|
||||||
if (!record)
|
if (!record)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -625,9 +625,9 @@ void journal_clear_revoke(journal_t *journal)
|
||||||
struct list_head *hash_list;
|
struct list_head *hash_list;
|
||||||
struct jbd_revoke_record_s *record;
|
struct jbd_revoke_record_s *record;
|
||||||
struct jbd_revoke_table_s *revoke;
|
struct jbd_revoke_table_s *revoke;
|
||||||
|
|
||||||
revoke = journal->j_revoke;
|
revoke = journal->j_revoke;
|
||||||
|
|
||||||
for (i = 0; i < revoke->hash_size; i++) {
|
for (i = 0; i < revoke->hash_size; i++) {
|
||||||
hash_list = &revoke->hash_table[i];
|
hash_list = &revoke->hash_table[i];
|
||||||
while (!list_empty(hash_list)) {
|
while (!list_empty(hash_list)) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct resource_track global_rtrack;
|
||||||
void init_resource_track(struct resource_track *track)
|
void init_resource_track(struct resource_track *track)
|
||||||
{
|
{
|
||||||
struct rusage r;
|
struct rusage r;
|
||||||
|
|
||||||
track->brk_start = sbrk(0);
|
track->brk_start = sbrk(0);
|
||||||
gettimeofday(&track->time_start, 0);
|
gettimeofday(&track->time_start, 0);
|
||||||
getrusage(RUSAGE_SELF, &r);
|
getrusage(RUSAGE_SELF, &r);
|
||||||
|
@ -100,7 +100,7 @@ int main (int argc, char *argv[])
|
||||||
printf(_("size of inode=%d\n"), sizeof(inode));
|
printf(_("size of inode=%d\n"), sizeof(inode));
|
||||||
|
|
||||||
device_name = "/dev/hda3";
|
device_name = "/dev/hda3";
|
||||||
|
|
||||||
init_resource_track(&global_rtrack);
|
init_resource_track(&global_rtrack);
|
||||||
|
|
||||||
retval = ext2fs_open(device_name, 0,
|
retval = ext2fs_open(device_name, 0,
|
||||||
|
@ -133,11 +133,11 @@ int main (int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ext2fs_close(fs);
|
ext2fs_close(fs);
|
||||||
|
|
||||||
print_resource_track(&global_rtrack);
|
print_resource_track(&global_rtrack);
|
||||||
|
|
||||||
return exit_value;
|
return exit_value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* e2fsck.c - superblock checks
|
* e2fsck.c - superblock checks
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -102,7 +102,7 @@ static int release_inode_block(ext2_filsys fs,
|
||||||
if (blockcnt < 0) {
|
if (blockcnt < 0) {
|
||||||
int i, limit;
|
int i, limit;
|
||||||
blk_t *bp;
|
blk_t *bp;
|
||||||
|
|
||||||
pb->errcode = io_channel_read_blk(fs->io, blk, 1,
|
pb->errcode = io_channel_read_blk(fs->io, blk, 1,
|
||||||
pb->buf);
|
pb->buf);
|
||||||
if (pb->errcode)
|
if (pb->errcode)
|
||||||
|
@ -140,11 +140,11 @@ static int release_inode_block(ext2_filsys fs,
|
||||||
*block_nr = 0;
|
*block_nr = 0;
|
||||||
retval |= BLOCK_CHANGED;
|
retval |= BLOCK_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ext2fs_block_alloc_stats(fs, blk, -1);
|
ext2fs_block_alloc_stats(fs, blk, -1);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function releases an inode. Returns 1 if an inconsistency was
|
* This function releases an inode. Returns 1 if an inconsistency was
|
||||||
* found. If the inode has a link count, then it is being truncated and
|
* found. If the inode has a link count, then it is being truncated and
|
||||||
|
@ -180,7 +180,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
pb.truncate_offset = 0;
|
pb.truncate_offset = 0;
|
||||||
}
|
}
|
||||||
pb.truncated_blocks = 0;
|
pb.truncated_blocks = 0;
|
||||||
retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
|
retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
|
||||||
block_buf, release_inode_block, &pb);
|
block_buf, release_inode_block, &pb);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err("release_inode_blocks", retval,
|
com_err("release_inode_blocks", retval,
|
||||||
|
@ -246,7 +246,7 @@ static int release_orphan_inodes(e2fsck_t ctx)
|
||||||
*/
|
*/
|
||||||
if (fs->super->s_state & EXT2_ERROR_FS)
|
if (fs->super->s_state & EXT2_ERROR_FS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((ino < EXT2_FIRST_INODE(fs->super)) ||
|
if ((ino < EXT2_FIRST_INODE(fs->super)) ||
|
||||||
(ino > fs->super->s_inodes_count)) {
|
(ino > fs->super->s_inodes_count)) {
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
@ -258,7 +258,7 @@ static int release_orphan_inodes(e2fsck_t ctx)
|
||||||
block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4,
|
block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4,
|
||||||
"block iterate buffer");
|
"block iterate buffer");
|
||||||
e2fsck_read_bitmaps(ctx);
|
e2fsck_read_bitmaps(ctx);
|
||||||
|
|
||||||
while (ino) {
|
while (ino) {
|
||||||
e2fsck_read_inode(ctx, ino, &inode, "release_orphan_inodes");
|
e2fsck_read_inode(ctx, ino, &inode, "release_orphan_inodes");
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
@ -317,11 +317,11 @@ static void check_resize_inode(e2fsck_t ctx)
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the resize inode feature isn't set, then
|
* If the resize inode feature isn't set, then
|
||||||
* s_reserved_gdt_blocks must be zero.
|
* s_reserved_gdt_blocks must be zero.
|
||||||
*/
|
*/
|
||||||
if (!(fs->super->s_feature_compat &
|
if (!(fs->super->s_feature_compat &
|
||||||
EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
|
EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
|
||||||
if (fs->super->s_reserved_gdt_blocks) {
|
if (fs->super->s_reserved_gdt_blocks) {
|
||||||
pctx.num = fs->super->s_reserved_gdt_blocks;
|
pctx.num = fs->super->s_reserved_gdt_blocks;
|
||||||
|
@ -337,17 +337,17 @@ static void check_resize_inode(e2fsck_t ctx)
|
||||||
pctx.ino = EXT2_RESIZE_INO;
|
pctx.ino = EXT2_RESIZE_INO;
|
||||||
retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
|
retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
if (fs->super->s_feature_compat &
|
if (fs->super->s_feature_compat &
|
||||||
EXT2_FEATURE_COMPAT_RESIZE_INODE)
|
EXT2_FEATURE_COMPAT_RESIZE_INODE)
|
||||||
ctx->flags |= E2F_FLAG_RESIZE_INODE;
|
ctx->flags |= E2F_FLAG_RESIZE_INODE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the resize inode feature isn't set, check to make sure
|
* If the resize inode feature isn't set, check to make sure
|
||||||
* the resize inode is cleared; then we're done.
|
* the resize inode is cleared; then we're done.
|
||||||
*/
|
*/
|
||||||
if (!(fs->super->s_feature_compat &
|
if (!(fs->super->s_feature_compat &
|
||||||
EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
|
EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
|
||||||
for (i=0; i < EXT2_N_BLOCKS; i++) {
|
for (i=0; i < EXT2_N_BLOCKS; i++) {
|
||||||
if (inode.i_block[i])
|
if (inode.i_block[i])
|
||||||
|
@ -362,7 +362,7 @@ static void check_resize_inode(e2fsck_t ctx)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The resize inode feature is enabled; check to make sure the
|
* The resize inode feature is enabled; check to make sure the
|
||||||
* only block in use is the double indirect block
|
* only block in use is the double indirect block
|
||||||
*/
|
*/
|
||||||
|
@ -398,13 +398,13 @@ static void check_resize_inode(e2fsck_t ctx)
|
||||||
|
|
||||||
gdt_off = fs->desc_blocks;
|
gdt_off = fs->desc_blocks;
|
||||||
pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks;
|
pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks;
|
||||||
for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4;
|
for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4;
|
||||||
i++, gdt_off++, pblk++) {
|
i++, gdt_off++, pblk++) {
|
||||||
gdt_off %= fs->blocksize/4;
|
gdt_off %= fs->blocksize/4;
|
||||||
if (dind_buf[gdt_off] != pblk)
|
if (dind_buf[gdt_off] != pblk)
|
||||||
goto resize_inode_invalid;
|
goto resize_inode_invalid;
|
||||||
retval = ext2fs_read_ind_block(fs, pblk, ind_buf);
|
retval = ext2fs_read_ind_block(fs, pblk, ind_buf);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto resize_inode_invalid;
|
goto resize_inode_invalid;
|
||||||
ind_off = 0;
|
ind_off = 0;
|
||||||
for (j = 1; j < fs->group_desc_count; j++) {
|
for (j = 1; j < fs->group_desc_count; j++) {
|
||||||
|
@ -510,7 +510,7 @@ void check_super_block(e2fsck_t ctx)
|
||||||
MIN_CHECK | MAX_CHECK, inodes_per_block, ipg_max);
|
MIN_CHECK | MAX_CHECK, inodes_per_block, ipg_max);
|
||||||
check_super_value(ctx, "r_blocks_count", sb->s_r_blocks_count,
|
check_super_value(ctx, "r_blocks_count", sb->s_r_blocks_count,
|
||||||
MAX_CHECK, 0, sb->s_blocks_count / 2);
|
MAX_CHECK, 0, sb->s_blocks_count / 2);
|
||||||
check_super_value(ctx, "reserved_gdt_blocks",
|
check_super_value(ctx, "reserved_gdt_blocks",
|
||||||
sb->s_reserved_gdt_blocks, MAX_CHECK, 0,
|
sb->s_reserved_gdt_blocks, MAX_CHECK, 0,
|
||||||
fs->blocksize/4);
|
fs->blocksize/4);
|
||||||
inode_size = EXT2_INODE_SIZE(sb);
|
inode_size = EXT2_INODE_SIZE(sb);
|
||||||
|
@ -524,7 +524,7 @@ void check_super_block(e2fsck_t ctx)
|
||||||
ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
|
ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ctx->flags & E2F_FLAG_GOT_DEVSIZE) &&
|
if ((ctx->flags & E2F_FLAG_GOT_DEVSIZE) &&
|
||||||
(ctx->num_blocks < sb->s_blocks_count)) {
|
(ctx->num_blocks < sb->s_blocks_count)) {
|
||||||
pctx.blk = sb->s_blocks_count;
|
pctx.blk = sb->s_blocks_count;
|
||||||
|
@ -544,7 +544,7 @@ void check_super_block(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
should_be = sb->s_frags_per_group >>
|
should_be = sb->s_frags_per_group >>
|
||||||
(sb->s_log_block_size - sb->s_log_frag_size);
|
(sb->s_log_block_size - sb->s_log_frag_size);
|
||||||
if (sb->s_blocks_per_group != should_be) {
|
if (sb->s_blocks_per_group != should_be) {
|
||||||
pctx.blk = sb->s_blocks_per_group;
|
pctx.blk = sb->s_blocks_per_group;
|
||||||
pctx.blk2 = should_be;
|
pctx.blk2 = should_be;
|
||||||
|
@ -701,7 +701,7 @@ void check_super_block(e2fsck_t ctx)
|
||||||
ext2fs_mark_super_dirty(fs);
|
ext2fs_mark_super_dirty(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sb->s_free_blocks_count > sb->s_blocks_count) ||
|
if ((sb->s_free_blocks_count > sb->s_blocks_count) ||
|
||||||
(sb->s_free_inodes_count > sb->s_inodes_count))
|
(sb->s_free_inodes_count > sb->s_inodes_count))
|
||||||
ext2fs_unmark_valid(fs);
|
ext2fs_unmark_valid(fs);
|
||||||
|
@ -717,7 +717,7 @@ void check_super_block(e2fsck_t ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
|
|
||||||
#ifndef EXT2_SKIP_UUID
|
#ifndef EXT2_SKIP_UUID
|
||||||
/*
|
/*
|
||||||
* If the UUID field isn't assigned, assign it.
|
* If the UUID field isn't assigned, assign it.
|
||||||
|
@ -795,7 +795,7 @@ void check_super_block(e2fsck_t ctx)
|
||||||
0, 0, &buggy_init_scripts);
|
0, 0, &buggy_init_scripts);
|
||||||
ctx->time_fudge = buggy_init_scripts ? 86400 : 0;
|
ctx->time_fudge = buggy_init_scripts ? 86400 : 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if the superblock last mount time or last
|
* Check to see if the superblock last mount time or last
|
||||||
* write time is in the future.
|
* write time is in the future.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* unix.c - The unix-specific code for e2fsck
|
* unix.c - The unix-specific code for e2fsck
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -119,7 +119,7 @@ static void show_stats(e2fsck_t ctx)
|
||||||
|
|
||||||
frag_percent = (10000 * ctx->fs_fragmented) / inodes_used;
|
frag_percent = (10000 * ctx->fs_fragmented) / inodes_used;
|
||||||
frag_percent = (frag_percent + 5) / 10;
|
frag_percent = (frag_percent + 5) / 10;
|
||||||
|
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %u/%u blocks\n"),
|
printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %u/%u blocks\n"),
|
||||||
ctx->device_name, inodes_used, inodes,
|
ctx->device_name, inodes_used, inodes,
|
||||||
|
@ -236,7 +236,7 @@ static int is_on_batt(void)
|
||||||
|
|
||||||
f = fopen("/proc/apm", "r");
|
f = fopen("/proc/apm", "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4)
|
if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4)
|
||||||
acflag = 1;
|
acflag = 1;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return (acflag != 1);
|
return (acflag != 1);
|
||||||
|
@ -246,7 +246,7 @@ static int is_on_batt(void)
|
||||||
while ((de=readdir(d)) != NULL) {
|
while ((de=readdir(d)) != NULL) {
|
||||||
if (!strncmp(".", de->d_name, 1))
|
if (!strncmp(".", de->d_name, 1))
|
||||||
continue;
|
continue;
|
||||||
snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state",
|
snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state",
|
||||||
de->d_name);
|
de->d_name);
|
||||||
f = fopen(fname, "r");
|
f = fopen(fname, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -280,14 +280,14 @@ static void check_if_skip(e2fsck_t ctx)
|
||||||
time_t lastcheck;
|
time_t lastcheck;
|
||||||
|
|
||||||
profile_get_boolean(ctx->profile, "options",
|
profile_get_boolean(ctx->profile, "options",
|
||||||
"defer_check_on_battery", 0, 1,
|
"defer_check_on_battery", 0, 1,
|
||||||
&defer_check_on_battery);
|
&defer_check_on_battery);
|
||||||
if (!defer_check_on_battery)
|
if (!defer_check_on_battery)
|
||||||
batt = 0;
|
batt = 0;
|
||||||
|
|
||||||
if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag)
|
if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lastcheck = fs->super->s_lastcheck;
|
lastcheck = fs->super->s_lastcheck;
|
||||||
if (lastcheck > ctx->now)
|
if (lastcheck > ctx->now)
|
||||||
lastcheck -= ctx->time_fudge;
|
lastcheck -= ctx->time_fudge;
|
||||||
|
@ -303,7 +303,7 @@ static void check_if_skip(e2fsck_t ctx)
|
||||||
(unsigned) fs->super->s_max_mnt_count)) {
|
(unsigned) fs->super->s_max_mnt_count)) {
|
||||||
reason = _(" has been mounted %u times without being checked");
|
reason = _(" has been mounted %u times without being checked");
|
||||||
reason_arg = fs->super->s_mnt_count;
|
reason_arg = fs->super->s_mnt_count;
|
||||||
if (batt && (fs->super->s_mnt_count <
|
if (batt && (fs->super->s_mnt_count <
|
||||||
(unsigned) fs->super->s_max_mnt_count*2))
|
(unsigned) fs->super->s_max_mnt_count*2))
|
||||||
reason = 0;
|
reason = 0;
|
||||||
} else if (fs->super->s_checkinterval && (ctx->now < lastcheck)) {
|
} else if (fs->super->s_checkinterval && (ctx->now < lastcheck)) {
|
||||||
|
@ -311,11 +311,11 @@ static void check_if_skip(e2fsck_t ctx)
|
||||||
if (batt)
|
if (batt)
|
||||||
reason = 0;
|
reason = 0;
|
||||||
} else if (fs->super->s_checkinterval &&
|
} else if (fs->super->s_checkinterval &&
|
||||||
((ctx->now - lastcheck) >=
|
((ctx->now - lastcheck) >=
|
||||||
((time_t) fs->super->s_checkinterval))) {
|
((time_t) fs->super->s_checkinterval))) {
|
||||||
reason = _(" has gone %u days without being checked");
|
reason = _(" has gone %u days without being checked");
|
||||||
reason_arg = (ctx->now - fs->super->s_lastcheck)/(3600*24);
|
reason_arg = (ctx->now - fs->super->s_lastcheck)/(3600*24);
|
||||||
if (batt && ((ctx->now - fs->super->s_lastcheck) <
|
if (batt && ((ctx->now - fs->super->s_lastcheck) <
|
||||||
fs->super->s_checkinterval*2))
|
fs->super->s_checkinterval*2))
|
||||||
reason = 0;
|
reason = 0;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ static void check_if_skip(e2fsck_t ctx)
|
||||||
next_check = 100000;
|
next_check = 100000;
|
||||||
if (fs->super->s_max_mnt_count > 0) {
|
if (fs->super->s_max_mnt_count > 0) {
|
||||||
next_check = fs->super->s_max_mnt_count - fs->super->s_mnt_count;
|
next_check = fs->super->s_max_mnt_count - fs->super->s_mnt_count;
|
||||||
if (next_check <= 0)
|
if (next_check <= 0)
|
||||||
next_check = 1;
|
next_check = 1;
|
||||||
}
|
}
|
||||||
if (fs->super->s_checkinterval &&
|
if (fs->super->s_checkinterval &&
|
||||||
|
@ -341,7 +341,7 @@ static void check_if_skip(e2fsck_t ctx)
|
||||||
next_check = 1;
|
next_check = 1;
|
||||||
if (next_check <= 5) {
|
if (next_check <= 5) {
|
||||||
if (next_check == 1) {
|
if (next_check == 1) {
|
||||||
if (batt)
|
if (batt)
|
||||||
fputs(_(" (check deferred; on battery)"),
|
fputs(_(" (check deferred; on battery)"),
|
||||||
stdout);
|
stdout);
|
||||||
else
|
else
|
||||||
|
@ -372,7 +372,7 @@ static float calc_percent(struct percent_tbl *tbl, int pass, int curr,
|
||||||
int max)
|
int max)
|
||||||
{
|
{
|
||||||
float percent;
|
float percent;
|
||||||
|
|
||||||
if (pass <= 0)
|
if (pass <= 0)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
if (pass > tbl->max_pass || max == 0)
|
if (pass > tbl->max_pass || max == 0)
|
||||||
|
@ -386,7 +386,7 @@ extern void e2fsck_clear_progbar(e2fsck_t ctx)
|
||||||
{
|
{
|
||||||
if (!(ctx->flags & E2F_FLAG_PROG_BAR))
|
if (!(ctx->flags & E2F_FLAG_PROG_BAR))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf("%s%s\r%s", ctx->start_meta, spaces + (sizeof(spaces) - 80),
|
printf("%s%s\r%s", ctx->start_meta, spaces + (sizeof(spaces) - 80),
|
||||||
ctx->stop_meta);
|
ctx->stop_meta);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -409,7 +409,7 @@ int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent,
|
||||||
/*
|
/*
|
||||||
* Calculate the new progress position. If the
|
* Calculate the new progress position. If the
|
||||||
* percentage hasn't changed, then we skip out right
|
* percentage hasn't changed, then we skip out right
|
||||||
* away.
|
* away.
|
||||||
*/
|
*/
|
||||||
fixed_percent = (int) ((10 * percent) + 0.5);
|
fixed_percent = (int) ((10 * percent) + 0.5);
|
||||||
if (ctx->progress_last_percent == fixed_percent)
|
if (ctx->progress_last_percent == fixed_percent)
|
||||||
|
@ -454,7 +454,7 @@ int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent,
|
||||||
else
|
else
|
||||||
fputs(" \r", stdout);
|
fputs(" \r", stdout);
|
||||||
fputs(ctx->stop_meta, stdout);
|
fputs(ctx->stop_meta, stdout);
|
||||||
|
|
||||||
if (fixed_percent == 1000)
|
if (fixed_percent == 1000)
|
||||||
e2fsck_clear_progbar(ctx);
|
e2fsck_clear_progbar(ctx);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -470,9 +470,9 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass,
|
||||||
|
|
||||||
if (pass == 0)
|
if (pass == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ctx->progress_fd) {
|
if (ctx->progress_fd) {
|
||||||
snprintf(buf, sizeof(buf), "%d %lu %lu %s\n",
|
snprintf(buf, sizeof(buf), "%d %lu %lu %s\n",
|
||||||
pass, cur, max, ctx->device_name);
|
pass, cur, max, ctx->device_name);
|
||||||
write(ctx->progress_fd, buf, strlen(buf));
|
write(ctx->progress_fd, buf, strlen(buf));
|
||||||
} else {
|
} else {
|
||||||
|
@ -594,7 +594,7 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts)
|
||||||
|
|
||||||
static void syntax_err_report(const char *filename, long err, int line_num)
|
static void syntax_err_report(const char *filename, long err, int line_num)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
_("Syntax error in e2fsck config file (%s, line #%d)\n\t%s\n"),
|
_("Syntax error in e2fsck config file (%s, line #%d)\n\t%s\n"),
|
||||||
filename, line_num, error_message(err));
|
filename, line_num, error_message(err));
|
||||||
exit(FSCK_ERROR);
|
exit(FSCK_ERROR);
|
||||||
|
@ -640,7 +640,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
|
||||||
add_error_table(&et_ext2_error_table);
|
add_error_table(&et_ext2_error_table);
|
||||||
add_error_table(&et_prof_error_table);
|
add_error_table(&et_prof_error_table);
|
||||||
blkid_get_cache(&ctx->blkid, NULL);
|
blkid_get_cache(&ctx->blkid, NULL);
|
||||||
|
|
||||||
if (argc && *argv)
|
if (argc && *argv)
|
||||||
ctx->program_name = *argv;
|
ctx->program_name = *argv;
|
||||||
else
|
else
|
||||||
|
@ -681,7 +681,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
|
||||||
case 'a':
|
case 'a':
|
||||||
if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) {
|
if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) {
|
||||||
conflict_opt:
|
conflict_opt:
|
||||||
fatal_error(ctx,
|
fatal_error(ctx,
|
||||||
_("Only one of the options -p/-a, -n or -y may be specified."));
|
_("Only one of the options -p/-a, -n or -y may be specified."));
|
||||||
}
|
}
|
||||||
ctx->options |= E2F_OPT_PREEN;
|
ctx->options |= E2F_OPT_PREEN;
|
||||||
|
@ -780,11 +780,11 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
|
||||||
ctx->options |= E2F_OPT_READONLY;
|
ctx->options |= E2F_OPT_READONLY;
|
||||||
|
|
||||||
ctx->io_options = strchr(argv[optind], '?');
|
ctx->io_options = strchr(argv[optind], '?');
|
||||||
if (ctx->io_options)
|
if (ctx->io_options)
|
||||||
*ctx->io_options++ = 0;
|
*ctx->io_options++ = 0;
|
||||||
ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0);
|
ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0);
|
||||||
if (!ctx->filesystem_name) {
|
if (!ctx->filesystem_name) {
|
||||||
com_err(ctx->program_name, 0, _("Unable to resolve '%s'"),
|
com_err(ctx->program_name, 0, _("Unable to resolve '%s'"),
|
||||||
argv[optind]);
|
argv[optind]);
|
||||||
fatal_error(ctx, 0);
|
fatal_error(ctx, 0);
|
||||||
}
|
}
|
||||||
|
@ -895,7 +895,7 @@ int main (int argc, char *argv[])
|
||||||
int sysval, sys_page_size = 4096;
|
int sysval, sys_page_size = 4096;
|
||||||
__u32 features[3];
|
__u32 features[3];
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
clear_problem_context(&pctx);
|
clear_problem_context(&pctx);
|
||||||
#ifdef MTRACE
|
#ifdef MTRACE
|
||||||
mtrace();
|
mtrace();
|
||||||
|
@ -916,7 +916,7 @@ int main (int argc, char *argv[])
|
||||||
"out of date!\n"));
|
"out of date!\n"));
|
||||||
show_version_only++;
|
show_version_only++;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = PRS(argc, argv, &ctx);
|
retval = PRS(argc, argv, &ctx);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
com_err("e2fsck", retval,
|
com_err("e2fsck", retval,
|
||||||
|
@ -924,7 +924,7 @@ int main (int argc, char *argv[])
|
||||||
exit(FSCK_ERROR);
|
exit(FSCK_ERROR);
|
||||||
}
|
}
|
||||||
reserve_stdio_fds();
|
reserve_stdio_fds();
|
||||||
|
|
||||||
#ifdef RESOURCE_TRACK
|
#ifdef RESOURCE_TRACK
|
||||||
init_resource_track(&ctx->global_rtrack, NULL);
|
init_resource_track(&ctx->global_rtrack, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
@ -938,9 +938,9 @@ int main (int argc, char *argv[])
|
||||||
error_message(EXT2_ET_BASE), lib_ver_date);
|
error_message(EXT2_ET_BASE), lib_ver_date);
|
||||||
exit(FSCK_OK);
|
exit(FSCK_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_mount(ctx);
|
check_mount(ctx);
|
||||||
|
|
||||||
if (!(ctx->options & E2F_OPT_PREEN) &&
|
if (!(ctx->options & E2F_OPT_PREEN) &&
|
||||||
!(ctx->options & E2F_OPT_NO) &&
|
!(ctx->options & E2F_OPT_NO) &&
|
||||||
!(ctx->options & E2F_OPT_YES)) {
|
!(ctx->options & E2F_OPT_YES)) {
|
||||||
|
@ -963,22 +963,22 @@ restart:
|
||||||
flags |= EXT2_FLAG_EXCLUSIVE;
|
flags |= EXT2_FLAG_EXCLUSIVE;
|
||||||
|
|
||||||
if (ctx->superblock && ctx->blocksize) {
|
if (ctx->superblock && ctx->blocksize) {
|
||||||
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
|
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
|
||||||
flags, ctx->superblock, ctx->blocksize,
|
flags, ctx->superblock, ctx->blocksize,
|
||||||
io_ptr, &fs);
|
io_ptr, &fs);
|
||||||
} else if (ctx->superblock) {
|
} else if (ctx->superblock) {
|
||||||
int blocksize;
|
int blocksize;
|
||||||
for (blocksize = EXT2_MIN_BLOCK_SIZE;
|
for (blocksize = EXT2_MIN_BLOCK_SIZE;
|
||||||
blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) {
|
blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) {
|
||||||
retval = ext2fs_open2(ctx->filesystem_name,
|
retval = ext2fs_open2(ctx->filesystem_name,
|
||||||
ctx->io_options, flags,
|
ctx->io_options, flags,
|
||||||
ctx->superblock, blocksize,
|
ctx->superblock, blocksize,
|
||||||
io_ptr, &fs);
|
io_ptr, &fs);
|
||||||
if (!retval)
|
if (!retval)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
|
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
|
||||||
flags, 0, 0, io_ptr, &fs);
|
flags, 0, 0, io_ptr, &fs);
|
||||||
if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&
|
if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&
|
||||||
!(ctx->flags & E2F_FLAG_SB_SPECIFIED) &&
|
!(ctx->flags & E2F_FLAG_SB_SPECIFIED) &&
|
||||||
|
@ -991,7 +991,7 @@ restart:
|
||||||
}
|
}
|
||||||
if (!fs || (fs->group_desc_count > 1)) {
|
if (!fs || (fs->group_desc_count > 1)) {
|
||||||
printf(_("%s: %s trying backup blocks...\n"),
|
printf(_("%s: %s trying backup blocks...\n"),
|
||||||
ctx->program_name,
|
ctx->program_name,
|
||||||
retval ? _("Superblock invalid,") :
|
retval ? _("Superblock invalid,") :
|
||||||
_("Group descriptors look bad..."));
|
_("Group descriptors look bad..."));
|
||||||
get_backup_sb(ctx, fs, ctx->filesystem_name, io_ptr);
|
get_backup_sb(ctx, fs, ctx->filesystem_name, io_ptr);
|
||||||
|
@ -1005,11 +1005,11 @@ restart:
|
||||||
(retval == EXT2_ET_RO_UNSUPP_FEATURE)) &&
|
(retval == EXT2_ET_RO_UNSUPP_FEATURE)) &&
|
||||||
fs && fs->super) {
|
fs && fs->super) {
|
||||||
sb = fs->super;
|
sb = fs->super;
|
||||||
features[0] = (sb->s_feature_compat &
|
features[0] = (sb->s_feature_compat &
|
||||||
~EXT2_LIB_FEATURE_COMPAT_SUPP);
|
~EXT2_LIB_FEATURE_COMPAT_SUPP);
|
||||||
features[1] = (sb->s_feature_incompat &
|
features[1] = (sb->s_feature_incompat &
|
||||||
~EXT2_LIB_FEATURE_INCOMPAT_SUPP);
|
~EXT2_LIB_FEATURE_INCOMPAT_SUPP);
|
||||||
features[2] = (sb->s_feature_ro_compat &
|
features[2] = (sb->s_feature_ro_compat &
|
||||||
~EXT2_LIB_FEATURE_RO_COMPAT_SUPP);
|
~EXT2_LIB_FEATURE_RO_COMPAT_SUPP);
|
||||||
if (features[0] || features[1] || features[2])
|
if (features[0] || features[1] || features[2])
|
||||||
goto print_unsupp_features;
|
goto print_unsupp_features;
|
||||||
|
@ -1077,8 +1077,8 @@ restart:
|
||||||
if (pctx.errcode == EBUSY) {
|
if (pctx.errcode == EBUSY) {
|
||||||
ext2fs_close(fs);
|
ext2fs_close(fs);
|
||||||
need_restart++;
|
need_restart++;
|
||||||
pctx.errcode =
|
pctx.errcode =
|
||||||
ext2fs_get_device_size(ctx->filesystem_name,
|
ext2fs_get_device_size(ctx->filesystem_name,
|
||||||
blocksize,
|
blocksize,
|
||||||
&ctx->num_blocks);
|
&ctx->num_blocks);
|
||||||
}
|
}
|
||||||
|
@ -1174,20 +1174,20 @@ restart:
|
||||||
*/
|
*/
|
||||||
features[0] = sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP;
|
features[0] = sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP;
|
||||||
features[1] = sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP;
|
features[1] = sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP;
|
||||||
features[2] = (sb->s_feature_ro_compat &
|
features[2] = (sb->s_feature_ro_compat &
|
||||||
~EXT2_LIB_FEATURE_RO_COMPAT_SUPP);
|
~EXT2_LIB_FEATURE_RO_COMPAT_SUPP);
|
||||||
print_unsupp_features:
|
print_unsupp_features:
|
||||||
if (features[0] || features[1] || features[2]) {
|
if (features[0] || features[1] || features[2]) {
|
||||||
int i, j;
|
int i, j;
|
||||||
__u32 *mask = features, m;
|
__u32 *mask = features, m;
|
||||||
|
|
||||||
fprintf(stderr, _("%s has unsupported feature(s):"),
|
fprintf(stderr, _("%s has unsupported feature(s):"),
|
||||||
ctx->filesystem_name);
|
ctx->filesystem_name);
|
||||||
|
|
||||||
for (i=0; i <3; i++,mask++) {
|
for (i=0; i <3; i++,mask++) {
|
||||||
for (j=0,m=1; j < 32; j++, m<<=1) {
|
for (j=0,m=1; j < 32; j++, m<<=1) {
|
||||||
if (*mask & m)
|
if (*mask & m)
|
||||||
fprintf(stderr, " %s",
|
fprintf(stderr, " %s",
|
||||||
e2p_feature2string(i, m));
|
e2p_feature2string(i, m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1283,7 +1283,7 @@ print_unsupp_features:
|
||||||
fs->super->s_feature_compat &=
|
fs->super->s_feature_compat &=
|
||||||
~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
|
~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
|
||||||
fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
|
fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
|
||||||
com_err(ctx->program_name, 0,
|
com_err(ctx->program_name, 0,
|
||||||
_("Couldn't determine journal size"));
|
_("Couldn't determine journal size"));
|
||||||
goto no_journal;
|
goto no_journal;
|
||||||
}
|
}
|
||||||
|
@ -1342,7 +1342,7 @@ no_journal:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ext2fs_test_valid(fs) ||
|
if (!ext2fs_test_valid(fs) ||
|
||||||
((exit_value & FSCK_CANCELED) &&
|
((exit_value & FSCK_CANCELED) &&
|
||||||
(sb->s_state & EXT2_ERROR_FS))) {
|
(sb->s_state & EXT2_ERROR_FS))) {
|
||||||
printf(_("\n%s: ********** WARNING: Filesystem still has "
|
printf(_("\n%s: ********** WARNING: Filesystem still has "
|
||||||
"errors **********\n\n"), ctx->device_name);
|
"errors **********\n\n"), ctx->device_name);
|
||||||
|
@ -1353,11 +1353,11 @@ no_journal:
|
||||||
int allow_cancellation;
|
int allow_cancellation;
|
||||||
|
|
||||||
profile_get_boolean(ctx->profile, "options",
|
profile_get_boolean(ctx->profile, "options",
|
||||||
"allow_cancellation", 0, 0,
|
"allow_cancellation", 0, 0,
|
||||||
&allow_cancellation);
|
&allow_cancellation);
|
||||||
exit_value &= ~FSCK_NONDESTRUCT;
|
exit_value &= ~FSCK_NONDESTRUCT;
|
||||||
if (allow_cancellation && ext2fs_test_valid(fs) &&
|
if (allow_cancellation && ext2fs_test_valid(fs) &&
|
||||||
(sb->s_state & EXT2_VALID_FS) &&
|
(sb->s_state & EXT2_VALID_FS) &&
|
||||||
!(sb->s_state & EXT2_ERROR_FS))
|
!(sb->s_state & EXT2_ERROR_FS))
|
||||||
exit_value = 0;
|
exit_value = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* util.c --- miscellaneous utilities
|
* util.c --- miscellaneous utilities
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -42,7 +42,7 @@ extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
|
||||||
|
|
||||||
void fatal_error(e2fsck_t ctx, const char *msg)
|
void fatal_error(e2fsck_t ctx, const char *msg)
|
||||||
{
|
{
|
||||||
if (msg)
|
if (msg)
|
||||||
fprintf (stderr, "e2fsck: %s\n", msg);
|
fprintf (stderr, "e2fsck: %s\n", msg);
|
||||||
if (ctx->fs && ctx->fs->io) {
|
if (ctx->fs && ctx->fs->io) {
|
||||||
if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL)
|
if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL)
|
||||||
|
@ -74,11 +74,11 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)),
|
char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)),
|
||||||
const char *str, int len)
|
const char *str, int len)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!len)
|
if (!len)
|
||||||
|
@ -272,7 +272,7 @@ void init_resource_track(struct resource_track *track, io_channel channel)
|
||||||
struct rusage r;
|
struct rusage r;
|
||||||
#endif
|
#endif
|
||||||
io_stats io_start = 0;
|
io_stats io_start = 0;
|
||||||
|
|
||||||
track->brk_start = sbrk(0);
|
track->brk_start = sbrk(0);
|
||||||
gettimeofday(&track->time_start, 0);
|
gettimeofday(&track->time_start, 0);
|
||||||
#ifdef HAVE_GETRUSAGE
|
#ifdef HAVE_GETRUSAGE
|
||||||
|
@ -327,7 +327,7 @@ void print_resource_track(const char *desc, struct resource_track *track,
|
||||||
|
|
||||||
#ifdef HAVE_MALLINFO
|
#ifdef HAVE_MALLINFO
|
||||||
#define kbytes(x) (((x) + 1023) / 1024)
|
#define kbytes(x) (((x) + 1023) / 1024)
|
||||||
|
|
||||||
malloc_info = mallinfo();
|
malloc_info = mallinfo();
|
||||||
printf(_("Memory used: %dk/%dk (%dk/%dk), "),
|
printf(_("Memory used: %dk/%dk (%dk/%dk), "),
|
||||||
kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
|
kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
|
||||||
|
@ -335,7 +335,7 @@ void print_resource_track(const char *desc, struct resource_track *track,
|
||||||
#else
|
#else
|
||||||
printf(_("Memory used: %d, "),
|
printf(_("Memory used: %d, "),
|
||||||
(int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
|
(int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETRUSAGE
|
#ifdef HAVE_GETRUSAGE
|
||||||
getrusage(RUSAGE_SELF, &r);
|
getrusage(RUSAGE_SELF, &r);
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ void print_resource_track(const char *desc, struct resource_track *track,
|
||||||
channel->manager->get_stats(channel, &delta);
|
channel->manager->get_stats(channel, &delta);
|
||||||
if (delta) {
|
if (delta) {
|
||||||
bytes_read = delta->bytes_read - track->bytes_read;
|
bytes_read = delta->bytes_read - track->bytes_read;
|
||||||
bytes_written = delta->bytes_written -
|
bytes_written = delta->bytes_written -
|
||||||
track->bytes_written;
|
track->bytes_written;
|
||||||
}
|
}
|
||||||
printf("I/O read: %lluMB, write: %lluMB, rate: %.2fMB/s\n",
|
printf("I/O read: %lluMB, write: %lluMB, rate: %.2fMB/s\n",
|
||||||
|
@ -443,7 +443,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
int blocksize;
|
int blocksize;
|
||||||
blk_t superblock, ret_sb = 8193;
|
blk_t superblock, ret_sb = 8193;
|
||||||
|
|
||||||
if (fs && fs->super) {
|
if (fs && fs->super) {
|
||||||
ret_sb = (fs->super->s_blocks_per_group +
|
ret_sb = (fs->super->s_blocks_per_group +
|
||||||
fs->super->s_first_data_block);
|
fs->super->s_first_data_block);
|
||||||
|
@ -453,7 +453,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
|
||||||
}
|
}
|
||||||
return ret_sb;
|
return ret_sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
if (ctx->blocksize) {
|
if (ctx->blocksize) {
|
||||||
ret_sb = ctx->blocksize * 8;
|
ret_sb = ctx->blocksize * 8;
|
||||||
|
@ -518,22 +518,22 @@ int ext2_file_type(unsigned int mode)
|
||||||
|
|
||||||
if (LINUX_S_ISDIR(mode))
|
if (LINUX_S_ISDIR(mode))
|
||||||
return EXT2_FT_DIR;
|
return EXT2_FT_DIR;
|
||||||
|
|
||||||
if (LINUX_S_ISCHR(mode))
|
if (LINUX_S_ISCHR(mode))
|
||||||
return EXT2_FT_CHRDEV;
|
return EXT2_FT_CHRDEV;
|
||||||
|
|
||||||
if (LINUX_S_ISBLK(mode))
|
if (LINUX_S_ISBLK(mode))
|
||||||
return EXT2_FT_BLKDEV;
|
return EXT2_FT_BLKDEV;
|
||||||
|
|
||||||
if (LINUX_S_ISLNK(mode))
|
if (LINUX_S_ISLNK(mode))
|
||||||
return EXT2_FT_SYMLINK;
|
return EXT2_FT_SYMLINK;
|
||||||
|
|
||||||
if (LINUX_S_ISFIFO(mode))
|
if (LINUX_S_ISFIFO(mode))
|
||||||
return EXT2_FT_FIFO;
|
return EXT2_FT_FIFO;
|
||||||
|
|
||||||
if (LINUX_S_ISSOCK(mode))
|
if (LINUX_S_ISSOCK(mode))
|
||||||
return EXT2_FT_SOCK;
|
return EXT2_FT_SOCK;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ and dispatches a show command to show the new entry.
|
||||||
{
|
{
|
||||||
unsigned long entry_num;
|
unsigned long entry_num;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer); /* Get the requested entry */
|
ptr=parse_word (command_line,buffer); /* Get the requested entry */
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - No argument specified\n");
|
wprintw (command_win,"Error - No argument specified\n");
|
||||||
|
@ -53,15 +53,15 @@ and dispatches a show command to show the new entry.
|
||||||
|
|
||||||
entry_num=atol (buffer);
|
entry_num=atol (buffer);
|
||||||
|
|
||||||
|
|
||||||
if (entry_num >= file_system_info.super_block.s_blocks_per_group) { /* Check if it is a valid entry number */
|
if (entry_num >= file_system_info.super_block.s_blocks_per_group) { /* Check if it is a valid entry number */
|
||||||
|
|
||||||
wprintw (command_win,"Error - Entry number out of bounds\n");
|
wprintw (command_win,"Error - Entry number out of bounds\n");
|
||||||
refresh_command_win ();return;
|
refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
block_bitmap_info.entry_num=entry_num; /* If it is, just change entry_num and */
|
block_bitmap_info.entry_num=entry_num; /* If it is, just change entry_num and */
|
||||||
strcpy (buffer,"show");dispatch (buffer); /* dispatch a show command */
|
strcpy (buffer,"show");dispatch (buffer); /* dispatch a show command */
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ This function passes to the next entry in the bitmap. We just call the above ent
|
||||||
{
|
{
|
||||||
long entry_offset=1;
|
long entry_offset=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
@ -93,7 +93,7 @@ void type_ext2_block_bitmap___prev (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_offset=1;
|
long entry_offset=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
@ -117,25 +117,25 @@ we need to allocate, and call allocate_block for each one.
|
||||||
{
|
{
|
||||||
long entry_num,num=1;
|
long entry_num,num=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer); /* Get the number of blocks to allocate */
|
ptr=parse_word (command_line,buffer); /* Get the number of blocks to allocate */
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
num=atol (buffer);
|
num=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_num=block_bitmap_info.entry_num;
|
entry_num=block_bitmap_info.entry_num;
|
||||||
/* Check for limits */
|
/* Check for limits */
|
||||||
if (num > file_system_info.super_block.s_blocks_per_group-entry_num) {
|
if (num > file_system_info.super_block.s_blocks_per_group-entry_num) {
|
||||||
wprintw (command_win,"Error - There aren't that much blocks in the group\n");
|
wprintw (command_win,"Error - There aren't that much blocks in the group\n");
|
||||||
refresh_command_win ();return;
|
refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (num) { /* And call allocate_block */
|
while (num) { /* And call allocate_block */
|
||||||
allocate_block (entry_num); /* for each block */
|
allocate_block (entry_num); /* for each block */
|
||||||
num--;entry_num++;
|
num--;entry_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch ("show"); /* Show the result */
|
dispatch ("show"); /* Show the result */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,24 +146,24 @@ void type_ext2_block_bitmap___deallocate (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_num,num=1;
|
long entry_num,num=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
num=atol (buffer);
|
num=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_num=block_bitmap_info.entry_num;
|
entry_num=block_bitmap_info.entry_num;
|
||||||
if (num > file_system_info.super_block.s_blocks_per_group-entry_num) {
|
if (num > file_system_info.super_block.s_blocks_per_group-entry_num) {
|
||||||
wprintw (command_win,"Error - There aren't that much blocks in the group\n");
|
wprintw (command_win,"Error - There aren't that much blocks in the group\n");
|
||||||
refresh_command_win ();return;
|
refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (num) {
|
while (num) {
|
||||||
deallocate_block (entry_num);
|
deallocate_block (entry_num);
|
||||||
num--;entry_num++;
|
num--;entry_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch ("show");
|
dispatch ("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ void allocate_block (long entry_num)
|
||||||
{
|
{
|
||||||
unsigned char bit_mask=1;
|
unsigned char bit_mask=1;
|
||||||
int byte_offset,j;
|
int byte_offset,j;
|
||||||
|
|
||||||
byte_offset=entry_num/8; /* Find the correct byte - entry_num/8 */
|
byte_offset=entry_num/8; /* Find the correct byte - entry_num/8 */
|
||||||
/* The position inside the byte is entry_num %8 */
|
/* The position inside the byte is entry_num %8 */
|
||||||
for (j=0;j<entry_num%8;j++)
|
for (j=0;j<entry_num%8;j++)
|
||||||
|
@ -190,12 +190,12 @@ void deallocate_block (long entry_num)
|
||||||
{
|
{
|
||||||
unsigned char bit_mask=1;
|
unsigned char bit_mask=1;
|
||||||
int byte_offset,j;
|
int byte_offset,j;
|
||||||
|
|
||||||
byte_offset=entry_num/8;
|
byte_offset=entry_num/8;
|
||||||
for (j=0;j<entry_num%8;j++)
|
for (j=0;j<entry_num%8;j++)
|
||||||
bit_mask*=2;
|
bit_mask*=2;
|
||||||
bit_mask^=0xff;
|
bit_mask^=0xff;
|
||||||
|
|
||||||
type_data.u.buffer [byte_offset] &= bit_mask;
|
type_data.u.buffer [byte_offset] &= bit_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ The current position (as known from block_bitmap_info.entry_num) is highlighted.
|
||||||
|
|
||||||
ptr=type_data.u.buffer;
|
ptr=type_data.u.buffer;
|
||||||
show_pad_info.line=0;show_pad_info.max_line=-1;
|
show_pad_info.line=0;show_pad_info.max_line=-1;
|
||||||
|
|
||||||
wmove (show_pad,0,0);
|
wmove (show_pad,0,0);
|
||||||
for (i=0,entry_num=0;i<file_system_info.super_block.s_blocks_per_group/8;i++,ptr++) {
|
for (i=0,entry_num=0;i<file_system_info.super_block.s_blocks_per_group/8;i++,ptr++) {
|
||||||
for (j=1;j<=128;j*=2) { /* j contains the and bit mask */
|
for (j=1;j<=128;j*=2) { /* j contains the and bit mask */
|
||||||
|
@ -240,24 +240,24 @@ The current position (as known from block_bitmap_info.entry_num) is highlighted.
|
||||||
show_pad_info.max_line++;
|
show_pad_info.max_line++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
show_info (); /* Show the usual information */
|
show_info (); /* Show the usual information */
|
||||||
|
|
||||||
/* Show the group number */
|
/* Show the group number */
|
||||||
wmove (show_win,1,0);
|
wmove (show_win,1,0);
|
||||||
wprintw (show_win,"Block bitmap of block group %ld\n",block_bitmap_info.group_num);
|
wprintw (show_win,"Block bitmap of block group %ld\n",block_bitmap_info.group_num);
|
||||||
/* Show the block number */
|
/* Show the block number */
|
||||||
|
|
||||||
block_num=block_bitmap_info.entry_num+block_bitmap_info.group_num*file_system_info.super_block.s_blocks_per_group;
|
block_num=block_bitmap_info.entry_num+block_bitmap_info.group_num*file_system_info.super_block.s_blocks_per_group;
|
||||||
block_num+=file_system_info.super_block.s_first_data_block;
|
block_num+=file_system_info.super_block.s_first_data_block;
|
||||||
|
|
||||||
wprintw (show_win,"Status of block %ld - ",block_num); /* and the allocation status */
|
wprintw (show_win,"Status of block %ld - ",block_num); /* and the allocation status */
|
||||||
ptr=type_data.u.buffer+block_bitmap_info.entry_num/8;
|
ptr=type_data.u.buffer+block_bitmap_info.entry_num/8;
|
||||||
j=1;
|
j=1;
|
||||||
for (i=block_bitmap_info.entry_num % 8;i>0;i--)
|
for (i=block_bitmap_info.entry_num % 8;i>0;i--)
|
||||||
j*=2;
|
j*=2;
|
||||||
if ((*ptr) & j)
|
if ((*ptr) & j)
|
||||||
wprintw (show_win,"Allocated\n");
|
wprintw (show_win,"Allocated\n");
|
||||||
else
|
else
|
||||||
wprintw (show_win,"Free\n");
|
wprintw (show_win,"Free\n");
|
||||||
|
|
112
ext2ed/dir_com.c
112
ext2ed/dir_com.c
|
@ -49,20 +49,20 @@ directories.
|
||||||
|
|
||||||
{
|
{
|
||||||
struct ext2_inode *ptr;
|
struct ext2_inode *ptr;
|
||||||
|
|
||||||
ptr=&type_data.u.t_ext2_inode; /* type_data contains the inode */
|
ptr=&type_data.u.t_ext2_inode; /* type_data contains the inode */
|
||||||
|
|
||||||
info_ptr->inode_ptr=ptr;
|
info_ptr->inode_ptr=ptr;
|
||||||
info_ptr->inode_offset=device_offset; /* device offset contains the inode's offset */
|
info_ptr->inode_offset=device_offset; /* device offset contains the inode's offset */
|
||||||
|
|
||||||
/* Reset the current position to the start */
|
/* Reset the current position to the start */
|
||||||
|
|
||||||
info_ptr->global_block_num=ptr->i_block [0];
|
info_ptr->global_block_num=ptr->i_block [0];
|
||||||
info_ptr->global_block_offset=ptr->i_block [0]*file_system_info.block_size;
|
info_ptr->global_block_offset=ptr->i_block [0]*file_system_info.block_size;
|
||||||
info_ptr->block_num=0;
|
info_ptr->block_num=0;
|
||||||
info_ptr->file_offset=0;
|
info_ptr->file_offset=0;
|
||||||
/* Set the size of the directory */
|
/* Set the size of the directory */
|
||||||
|
|
||||||
info_ptr->blocks_count=(ptr->i_size+file_system_info.block_size-1)/file_system_info.block_size;
|
info_ptr->blocks_count=(ptr->i_size+file_system_info.block_size-1)/file_system_info.block_size;
|
||||||
info_ptr->file_length=ptr->i_size;
|
info_ptr->file_length=ptr->i_size;
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ directories.
|
||||||
info_ptr->dir_entry_offset=0;
|
info_ptr->dir_entry_offset=0;
|
||||||
|
|
||||||
/* Find dir_entries_count */
|
/* Find dir_entries_count */
|
||||||
|
|
||||||
info_ptr->dir_entries_count=count_dir_entries (); /* Set the total number of entries */
|
info_ptr->dir_entries_count=count_dir_entries (); /* Set the total number of entries */
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,34 +86,34 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in
|
||||||
|
|
||||||
This routine runs on all directory entries in the current directory.
|
This routine runs on all directory entries in the current directory.
|
||||||
For each entry, action is called. We'll act according to the return code of action:
|
For each entry, action is called. We'll act according to the return code of action:
|
||||||
|
|
||||||
ABORT - Current dir entry is returned.
|
ABORT - Current dir entry is returned.
|
||||||
CONTINUE - Continue searching.
|
CONTINUE - Continue searching.
|
||||||
FOUND - Current dir entry is returned.
|
FOUND - Current dir entry is returned.
|
||||||
|
|
||||||
If the last entry is reached, it is returned, along with an ABORT status.
|
If the last entry is reached, it is returned, along with an ABORT status.
|
||||||
|
|
||||||
status is updated to the returned code of action.
|
status is updated to the returned code of action.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
struct struct_file_info info; /* Temporary variables used to */
|
struct struct_file_info info; /* Temporary variables used to */
|
||||||
struct ext2_dir_entry_2 *dir_entry_ptr; /* contain the current search entries */
|
struct ext2_dir_entry_2 *dir_entry_ptr; /* contain the current search entries */
|
||||||
int return_code, next;
|
int return_code, next;
|
||||||
|
|
||||||
info=first_file_info; /* Start from the first entry - Read it */
|
info=first_file_info; /* Start from the first entry - Read it */
|
||||||
low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
|
low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
|
||||||
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
|
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
|
||||||
|
|
||||||
while (info.file_offset < info.file_length) { /* While we haven't reached the end */
|
while (info.file_offset < info.file_length) { /* While we haven't reached the end */
|
||||||
|
|
||||||
*status=return_code=action (&info); /* Call the client function to test */
|
*status=return_code=action (&info); /* Call the client function to test */
|
||||||
/* the current entry */
|
/* the current entry */
|
||||||
if (return_code==ABORT || return_code==FOUND)
|
if (return_code==ABORT || return_code==FOUND)
|
||||||
return (info); /* Stop, if so asked */
|
return (info); /* Stop, if so asked */
|
||||||
|
|
||||||
/* Pass to the next entry */
|
/* Pass to the next entry */
|
||||||
|
|
||||||
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
|
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
|
||||||
|
|
||||||
info.dir_entry_num++;
|
info.dir_entry_num++;
|
||||||
|
@ -131,16 +131,16 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in
|
||||||
info.global_block_num=file_block_to_global_block (info.block_num,&info);
|
info.global_block_num=file_block_to_global_block (info.block_num,&info);
|
||||||
info.global_block_offset=info.global_block_num*file_system_info.block_size;
|
info.global_block_offset=info.global_block_num*file_system_info.block_size;
|
||||||
info.file_offset=info.block_num*file_system_info.block_size;
|
info.file_offset=info.block_num*file_system_info.block_size;
|
||||||
info.dir_entry_offset=0;
|
info.dir_entry_offset=0;
|
||||||
/* read it and update the pointer */
|
/* read it and update the pointer */
|
||||||
|
|
||||||
low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
|
low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
|
||||||
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
|
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*status=ABORT;return (info); /* There was no match */
|
*status=ABORT;return (info); /* There was no match */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ The client function is action_count, which just tell search_dir_entries to conti
|
||||||
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
return (search_dir_entries (&action_count,&status).dir_entry_num);
|
return (search_dir_entries (&action_count,&status).dir_entry_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ void type_dir___cd (char *command_line)
|
||||||
1 and into 2/3/4.
|
1 and into 2/3/4.
|
||||||
|
|
||||||
3. It is the first part of the path that we need to search for in the current directory. We search for it using
|
3. It is the first part of the path that we need to search for in the current directory. We search for it using
|
||||||
search_dir_entries, which accepts the action_name function as the client function.
|
search_dir_entries, which accepts the action_name function as the client function.
|
||||||
|
|
||||||
4. search_dir_entries will scan the entire entries and will call our action_name function for each entry.
|
4. search_dir_entries will scan the entire entries and will call our action_name function for each entry.
|
||||||
In action_name, the required name will be checked against the name of the current entry, and FOUND will be
|
In action_name, the required name will be checked against the name of the current entry, and FOUND will be
|
||||||
|
@ -205,7 +205,7 @@ void type_dir___cd (char *command_line)
|
||||||
7. We check the inode's type to see if it is a directory. If it is, we dispatch a dir command to "enter the directory",
|
7. We check the inode's type to see if it is a directory. If it is, we dispatch a dir command to "enter the directory",
|
||||||
and recursively call ourself (The type is dir again) by dispatching a cd command, with the rest of the path
|
and recursively call ourself (The type is dir again) by dispatching a cd command, with the rest of the path
|
||||||
as an argument.
|
as an argument.
|
||||||
|
|
||||||
8. If the inode's type is a symbolic link (only fast symbolic link were meanwhile implemented. I guess this is
|
8. If the inode's type is a symbolic link (only fast symbolic link were meanwhile implemented. I guess this is
|
||||||
typically the case.), we note the path it is pointing at, the saved inode is recalled, we dispatch dir to
|
typically the case.), we note the path it is pointing at, the saved inode is recalled, we dispatch dir to
|
||||||
get back to the original directory, and we call ourself again with the link path/rest of the path argument.
|
get back to the original directory, and we call ourself again with the link path/rest of the path argument.
|
||||||
|
@ -221,9 +221,9 @@ void type_dir___cd (char *command_line)
|
||||||
struct ext2_dir_entry_2 *dir_entry_ptr;
|
struct ext2_dir_entry_2 *dir_entry_ptr;
|
||||||
|
|
||||||
dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset);
|
dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset);
|
||||||
|
|
||||||
ptr=parse_word (command_line,dir_name);
|
ptr=parse_word (command_line,dir_name);
|
||||||
|
|
||||||
if (*ptr==0) { /* cd alone will enter the highlighted directory */
|
if (*ptr==0) { /* cd alone will enter the highlighted directory */
|
||||||
strncpy (full_dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len);
|
strncpy (full_dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len);
|
||||||
full_dir_name [dir_entry_ptr->name_len]=0;
|
full_dir_name [dir_entry_ptr->name_len]=0;
|
||||||
|
@ -232,11 +232,11 @@ void type_dir___cd (char *command_line)
|
||||||
ptr=parse_word (ptr,full_dir_name);
|
ptr=parse_word (ptr,full_dir_name);
|
||||||
|
|
||||||
ptr=strchr (full_dir_name,'/');
|
ptr=strchr (full_dir_name,'/');
|
||||||
|
|
||||||
if (ptr==full_dir_name) { /* Pathname is from root - Let the general cd do the job */
|
if (ptr==full_dir_name) { /* Pathname is from root - Let the general cd do the job */
|
||||||
sprintf (temp,"cd %s",full_dir_name);type_ext2___cd (temp);return;
|
sprintf (temp,"cd %s",full_dir_name);type_ext2___cd (temp);return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr==NULL) {
|
if (ptr==NULL) {
|
||||||
strcpy (dir_name,full_dir_name);
|
strcpy (dir_name,full_dir_name);
|
||||||
full_dir_name [0]=0;
|
full_dir_name [0]=0;
|
||||||
|
@ -251,7 +251,7 @@ void type_dir___cd (char *command_line)
|
||||||
/* full_dir_name contains the rest */
|
/* full_dir_name contains the rest */
|
||||||
|
|
||||||
strcpy (name_search,dir_name); /* name_search is used to hold the required entry name */
|
strcpy (name_search,dir_name); /* name_search is used to hold the required entry name */
|
||||||
|
|
||||||
if (dir_entry_ptr->name_len != strlen (dir_name) ||
|
if (dir_entry_ptr->name_len != strlen (dir_name) ||
|
||||||
strncmp (dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len)!=0)
|
strncmp (dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len)!=0)
|
||||||
info=search_dir_entries (&action_name,&status); /* Search for the entry. Answer in info. */
|
info=search_dir_entries (&action_name,&status); /* Search for the entry. Answer in info. */
|
||||||
|
@ -262,15 +262,15 @@ void type_dir___cd (char *command_line)
|
||||||
if (status==FOUND) { /* If found */
|
if (status==FOUND) { /* If found */
|
||||||
file_info=info; /* Switch to it, by setting the global file_info */
|
file_info=info; /* Switch to it, by setting the global file_info */
|
||||||
dispatch ("remember internal_variable"); /* Move the inode into the objects memory */
|
dispatch ("remember internal_variable"); /* Move the inode into the objects memory */
|
||||||
|
|
||||||
dispatch ("followinode"); /* Go to the inode pointed by this directory entry */
|
dispatch ("followinode"); /* Go to the inode pointed by this directory entry */
|
||||||
|
|
||||||
if (S_ISLNK (type_data.u.t_ext2_inode.i_mode)) {/* Symbolic link ? */
|
if (S_ISLNK (type_data.u.t_ext2_inode.i_mode)) {/* Symbolic link ? */
|
||||||
|
|
||||||
if (type_data.u.t_ext2_inode.i_size > 60) { /* I'm lazy, I guess :-) */
|
if (type_data.u.t_ext2_inode.i_size > 60) { /* I'm lazy, I guess :-) */
|
||||||
wprintw (command_win,"Error - Sorry, Only fast symbolic link following is currently supported\n");
|
wprintw (command_win,"Error - Sorry, Only fast symbolic link following is currently supported\n");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Get the pointed name and append the previous path */
|
/* Get the pointed name and append the previous path */
|
||||||
|
|
||||||
|
@ -280,10 +280,10 @@ void type_dir___cd (char *command_line)
|
||||||
|
|
||||||
dispatch ("recall internal_variable"); /* Return to the original inode */
|
dispatch ("recall internal_variable"); /* Return to the original inode */
|
||||||
dispatch ("dir"); /* and to the directory */
|
dispatch ("dir"); /* and to the directory */
|
||||||
|
|
||||||
sprintf (temp,"cd %s",temp2); /* And continue from there by dispatching a cd command */
|
sprintf (temp,"cd %s",temp2); /* And continue from there by dispatching a cd command */
|
||||||
dispatch (temp); /* (which can call ourself or the general cd) */
|
dispatch (temp); /* (which can call ourself or the general cd) */
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,16 +295,16 @@ void type_dir___cd (char *command_line)
|
||||||
sprintf (temp,"cd %s",full_dir_name);
|
sprintf (temp,"cd %s",full_dir_name);
|
||||||
dispatch (temp);
|
dispatch (temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else { /* If we can't continue from here, we'll just stop */
|
else { /* If we can't continue from here, we'll just stop */
|
||||||
wprintw (command_win,"Can\'t continue - Stopping at last inode\n");refresh_command_win ();
|
wprintw (command_win,"Can\'t continue - Stopping at last inode\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (command_win,"Error - Directory entry %s not found.\n",dir_name); /* Hmm, an invalid path somewhere */
|
wprintw (command_win,"Error - Directory entry %s not found.\n",dir_name); /* Hmm, an invalid path somewhere */
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ Returns FOUND if found, or CONTINUE if not found.
|
||||||
|
|
||||||
if (dir_entry_ptr->name_len != strlen (name_search))
|
if (dir_entry_ptr->name_len != strlen (name_search))
|
||||||
return (CONTINUE);
|
return (CONTINUE);
|
||||||
|
|
||||||
if (strncmp (dir_entry_ptr->name,name_search,dir_entry_ptr->name_len)==0)
|
if (strncmp (dir_entry_ptr->name,name_search,dir_entry_ptr->name_len)==0)
|
||||||
return (FOUND);
|
return (FOUND);
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ search_dir_entries is used along with action_entry_num, in the same fashion as t
|
||||||
int status;
|
int status;
|
||||||
struct struct_file_info info;
|
struct struct_file_info info;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Argument_not_specified\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Argument_not_specified\n");wrefresh (command_win);
|
||||||
|
@ -353,7 +353,7 @@ search_dir_entries is used along with action_entry_num, in the same fashion as t
|
||||||
}
|
}
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
entry_num_search=atol (buffer);
|
entry_num_search=atol (buffer);
|
||||||
|
|
||||||
if (entry_num_search < 0 || entry_num_search >= file_info.dir_entries_count) {
|
if (entry_num_search < 0 || entry_num_search >= file_info.dir_entries_count) {
|
||||||
wprintw (command_win,"Error - Entry number out of range\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Entry number out of range\n");wrefresh (command_win);
|
||||||
return;
|
return;
|
||||||
|
@ -431,7 +431,7 @@ We use search_dir_entries to run on all the entries. Each time, action_show will
|
||||||
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
wmove (show_pad,0,0);
|
wmove (show_pad,0,0);
|
||||||
show_pad_info.max_line=-1;
|
show_pad_info.max_line=-1;
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ Show the current search entry (info) in one line. If the entry happens to be the
|
||||||
{
|
{
|
||||||
unsigned char temp [80];
|
unsigned char temp [80];
|
||||||
struct ext2_dir_entry_2 *dir_entry_ptr;
|
struct ext2_dir_entry_2 *dir_entry_ptr;
|
||||||
|
|
||||||
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info->buffer+info->dir_entry_offset);
|
dir_entry_ptr=(struct ext2_dir_entry_2 *) (info->buffer+info->dir_entry_offset);
|
||||||
|
|
||||||
if (info->dir_entry_num == file_info.dir_entry_num) /* Highlight the current entry */
|
if (info->dir_entry_num == file_info.dir_entry_num) /* Highlight the current entry */
|
||||||
|
@ -486,7 +486,7 @@ This function moves to the next directory entry. It just uses the current inform
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
offset*=atol (buffer);
|
offset*=atol (buffer);
|
||||||
|
@ -503,7 +503,7 @@ void type_dir___prev (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
offset*=atol (buffer);
|
offset*=atol (buffer);
|
||||||
|
@ -522,12 +522,12 @@ Various statistics about the directory.
|
||||||
|
|
||||||
{
|
{
|
||||||
long inode_num;
|
long inode_num;
|
||||||
|
|
||||||
wmove (show_win,0,0);
|
wmove (show_win,0,0);
|
||||||
wprintw (show_win,"Directory listing. Block %ld. ",file_info.global_block_num);
|
wprintw (show_win,"Directory listing. Block %ld. ",file_info.global_block_num);
|
||||||
wprintw (show_win,"Directory entry %ld of %ld.\n",file_info.dir_entry_num,file_info.dir_entries_count-1);
|
wprintw (show_win,"Directory entry %ld of %ld.\n",file_info.dir_entry_num,file_info.dir_entries_count-1);
|
||||||
wprintw (show_win,"Directory Offset %ld of %ld. ",file_info.file_offset,file_info.file_length-1);
|
wprintw (show_win,"Directory Offset %ld of %ld. ",file_info.file_offset,file_info.file_length-1);
|
||||||
|
|
||||||
inode_num=inode_offset_to_inode_num (file_info.inode_offset);
|
inode_num=inode_offset_to_inode_num (file_info.inode_offset);
|
||||||
wprintw (show_win,"File inode %ld. Indirection level %ld.\n",inode_num,file_info.level);
|
wprintw (show_win,"File inode %ld. Indirection level %ld.\n",inode_num,file_info.level);
|
||||||
|
|
||||||
|
@ -548,14 +548,14 @@ inode of the current directory.
|
||||||
long entry_num;
|
long entry_num;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
struct struct_descriptor *descriptor_ptr;
|
struct struct_descriptor *descriptor_ptr;
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
entry_num=remember_lifo.entries_count++;
|
entry_num=remember_lifo.entries_count++;
|
||||||
|
@ -563,7 +563,7 @@ inode of the current directory.
|
||||||
entry_num=0;
|
entry_num=0;
|
||||||
remember_lifo.entries_count--;
|
remember_lifo.entries_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptor_ptr=first_type;
|
descriptor_ptr=first_type;
|
||||||
while (descriptor_ptr!=NULL && !found) {
|
while (descriptor_ptr!=NULL && !found) {
|
||||||
if (strcmp (descriptor_ptr->name,"ext2_inode")==0)
|
if (strcmp (descriptor_ptr->name,"ext2_inode")==0)
|
||||||
|
@ -576,7 +576,7 @@ inode of the current directory.
|
||||||
remember_lifo.offset [entry_num]=device_offset;
|
remember_lifo.offset [entry_num]=device_offset;
|
||||||
remember_lifo.type [entry_num]=descriptor_ptr;
|
remember_lifo.type [entry_num]=descriptor_ptr;
|
||||||
strcpy (remember_lifo.name [entry_num],buffer);
|
strcpy (remember_lifo.name [entry_num],buffer);
|
||||||
|
|
||||||
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer);
|
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer);
|
||||||
wrefresh (command_win);
|
wrefresh (command_win);
|
||||||
}
|
}
|
||||||
|
@ -594,9 +594,9 @@ because it is of variable length.
|
||||||
int found=0;
|
int found=0;
|
||||||
unsigned char *ptr,buffer [80],variable [80],value [80],temp [80];
|
unsigned char *ptr,buffer [80],variable [80],value [80],temp [80];
|
||||||
struct ext2_dir_entry_2 *dir_entry_ptr;
|
struct ext2_dir_entry_2 *dir_entry_ptr;
|
||||||
|
|
||||||
dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset);
|
dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset);
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Missing arguments\n");refresh_command_win ();
|
wprintw (command_win,"Error - Missing arguments\n");refresh_command_win ();
|
||||||
|
@ -641,7 +641,7 @@ because it is of variable length.
|
||||||
wprintw (command_win,"Variable %s set to %s\n",variable,value);refresh_command_win ();
|
wprintw (command_win,"Variable %s set to %s\n",variable,value);refresh_command_win ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
wattrset (show_pad,A_REVERSE);
|
wattrset (show_pad,A_REVERSE);
|
||||||
strncpy (temp,dir_entry_ptr->name,dir_entry_ptr->name_len);
|
strncpy (temp,dir_entry_ptr->name,dir_entry_ptr->name_len);
|
||||||
|
@ -654,7 +654,7 @@ because it is of variable length.
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
show_dir_status ();
|
show_dir_status ();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Variable %s not found\n",variable);
|
wprintw (command_win,"Error - Variable %s not found\n",variable);
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
|
|
|
@ -55,7 +55,7 @@ This function is used when we need to read something from the filesystem.
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (fseek (device_handle,offset,SEEK_SET))==-1) { /* Seek to the required offset */
|
if ( (fseek (device_handle,offset,SEEK_SET))==-1) { /* Seek to the required offset */
|
||||||
wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",offset,device_name);
|
wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",offset,device_name);
|
||||||
|
@ -67,7 +67,7 @@ This function is used when we need to read something from the filesystem.
|
||||||
wprintw (command_win,"Error - Failed to read from offset %ld in device %s\n",offset,device_name);
|
wprintw (command_win,"Error - Failed to read from offset %ld in device %s\n",offset,device_name);
|
||||||
refresh_command_win ();return (0);
|
refresh_command_win ();return (0);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ If logging is enabled, we log the change before writing it to the device.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
char temp [80];
|
char temp [80];
|
||||||
|
|
||||||
if (!write_access) {
|
if (!write_access) {
|
||||||
wprintw (command_win,"Error - Write access not aviable (use enablewrite)\n");
|
wprintw (command_win,"Error - Write access not aviable (use enablewrite)\n");
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -95,7 +95,7 @@ If logging is enabled, we log the change before writing it to the device.
|
||||||
internal_error ("AllowChanges=0 yet enablewrite succeeded","disk","low_write");
|
internal_error ("AllowChanges=0 yet enablewrite succeeded","disk","low_write");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_handle==NULL) {
|
if (device_handle==NULL) {
|
||||||
internal_error ("No device opened yet read requested","disk","low_write");
|
internal_error ("No device opened yet read requested","disk","low_write");
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -107,7 +107,7 @@ If logging is enabled, we log the change before writing it to the device.
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (LogChanges)
|
if (LogChanges)
|
||||||
if (!log_changes (buffer,length,offset))
|
if (!log_changes (buffer,length,offset))
|
||||||
|
@ -124,7 +124,7 @@ If logging is enabled, we log the change before writing it to the device.
|
||||||
refresh_command_win ();return (0);
|
refresh_command_win ();return (0);
|
||||||
};
|
};
|
||||||
|
|
||||||
wprintw (command_win,"Data written");refresh_command_win ();
|
wprintw (command_win,"Data written");refresh_command_win ();
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,29 +139,29 @@ The hex bytes are converted to text, so that they will be readable with a standa
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned char *original;
|
unsigned char *original;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if ((fp=fopen (LogFile,"a+"))==NULL) {
|
if ((fp=fopen (LogFile,"a+"))==NULL) {
|
||||||
wprintw (command_win,"Error - Unable to open log file %s\n",LogFile);
|
wprintw (command_win,"Error - Unable to open log file %s\n",LogFile);
|
||||||
refresh_command_win ();return (0);
|
refresh_command_win ();return (0);
|
||||||
};
|
};
|
||||||
|
|
||||||
current_time=time (NULL);
|
current_time=time (NULL);
|
||||||
|
|
||||||
fprintf (fp,"\n----- EXT2ED log begin -----\n\n");
|
fprintf (fp,"\n----- EXT2ED log begin -----\n\n");
|
||||||
fprintf (fp,"Time: %s\nDevice: %s\n",ctime ((time_t *) ¤t_time),device_name);
|
fprintf (fp,"Time: %s\nDevice: %s\n",ctime ((time_t *) ¤t_time),device_name);
|
||||||
fprintf (fp,"Offset: %lu\nLength: %lu\n",offset,length);
|
fprintf (fp,"Offset: %lu\nLength: %lu\n",offset,length);
|
||||||
|
|
||||||
original=(unsigned char *) malloc (length*sizeof (unsigned char));
|
original=(unsigned char *) malloc (length*sizeof (unsigned char));
|
||||||
|
|
||||||
if (original==NULL) {
|
if (original==NULL) {
|
||||||
wprintw (command_win,"Fatal error - Can\'t allocate %lu bytes!");
|
wprintw (command_win,"Fatal error - Can\'t allocate %lu bytes!");
|
||||||
refresh_command_win ();fclose (fp);return (0);
|
refresh_command_win ();fclose (fp);return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!low_read (original,length,offset)) {
|
if (!low_read (original,length,offset)) {
|
||||||
fclose (fp);return (0);
|
fclose (fp);return (0);
|
||||||
}
|
}
|
||||||
|
@ -172,17 +172,17 @@ The hex bytes are converted to text, so that they will be readable with a standa
|
||||||
if (i%16==0 && i!=0) fprintf (fp,"\n");
|
if (i%16==0 && i!=0) fprintf (fp,"\n");
|
||||||
fprintf (fp,"%02x ",original [i]);
|
fprintf (fp,"%02x ",original [i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (fp,"\n\nNew data:\n\n");
|
fprintf (fp,"\n\nNew data:\n\n");
|
||||||
|
|
||||||
for (i=0;i<length;i++) {
|
for (i=0;i<length;i++) {
|
||||||
if (i%16==0 && i!=0) fprintf (fp,"\n");
|
if (i%16==0 && i!=0) fprintf (fp,"\n");
|
||||||
fprintf (fp,"%02x ",buffer [i]);
|
fprintf (fp,"%02x ",buffer [i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (fp,"\n----- EXT2ED log end -----\n");
|
fprintf (fp,"\n----- EXT2ED log end -----\n");
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,17 +197,17 @@ Just read from the current position into type data.
|
||||||
{
|
{
|
||||||
if (device_handle==NULL) {
|
if (device_handle==NULL) {
|
||||||
printf ("Error - No device opened\n");
|
printf ("Error - No device opened\n");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_offset==-1) {
|
if (device_offset==-1) {
|
||||||
printf ("Error - No offset set\n");
|
printf ("Error - No offset set\n");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (low_read (type_data.u.buffer,EXT2_MAX_BLOCK_SIZE,device_offset)==0)
|
if (low_read (type_data.u.buffer,EXT2_MAX_BLOCK_SIZE,device_offset)==0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (current_type!=NULL)
|
if (current_type!=NULL)
|
||||||
if (strcmp (current_type->name,"ext2_dir_entry")==0)
|
if (strcmp (current_type->name,"ext2_dir_entry")==0)
|
||||||
current_type->length=type_data.u.t_ext2_dir_entry.rec_len;
|
current_type->length=type_data.u.t_ext2_dir_entry.rec_len;
|
||||||
|
@ -221,7 +221,7 @@ int write_type_data (void)
|
||||||
if (device_handle==NULL) {
|
if (device_handle==NULL) {
|
||||||
wprintw (command_win,"Error - No device opened\n");
|
wprintw (command_win,"Error - No device opened\n");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_offset==-1) {
|
if (device_offset==-1) {
|
||||||
|
@ -229,10 +229,10 @@ int write_type_data (void)
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (low_write (type_data.u.buffer,file_system_info.block_size,device_offset)==0)
|
if (low_write (type_data.u.buffer,file_system_info.block_size,device_offset)==0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ initialization phase (but is constant - 1024).
|
||||||
|
|
||||||
{
|
{
|
||||||
char buffer [80];
|
char buffer [80];
|
||||||
|
|
||||||
super_info.copy_num=0;
|
super_info.copy_num=0;
|
||||||
sprintf (buffer,"setoffset %ld",file_system_info.super_block_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset %ld",file_system_info.super_block_offset);dispatch (buffer);
|
||||||
sprintf (buffer,"settype ext2_super_block");dispatch (buffer);
|
sprintf (buffer,"settype ext2_super_block");dispatch (buffer);
|
||||||
|
@ -51,13 +51,13 @@ We implement it through dispatching to our primitive functions.
|
||||||
|
|
||||||
{
|
{
|
||||||
char temp [80],buffer [80],*ptr;
|
char temp [80],buffer [80],*ptr;
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
if (buffer [0] != '/') {
|
if (buffer [0] != '/') {
|
||||||
wprintw (command_win,"Error - Use a full pathname (begin with '/')\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - Use a full pathname (begin with '/')\n");refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ Then, we use the group's entry command to pass to another group.
|
||||||
{
|
{
|
||||||
long group_num=0;
|
long group_num=0;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
|
@ -45,14 +45,14 @@ Copyright (C) 1995 Gadi Oxman
|
||||||
#define MAX_COMMANDS_NUM 30 /* Maximum number of commands of one type */
|
#define MAX_COMMANDS_NUM 30 /* Maximum number of commands of one type */
|
||||||
#define REMEMBER_COUNT 30 /* Object memory size */
|
#define REMEMBER_COUNT 30 /* Object memory size */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The user screen consists of four parts:
|
The user screen consists of four parts:
|
||||||
|
|
||||||
1. Title window (title_win).
|
1. Title window (title_win).
|
||||||
2. Show (status) window (show_win).
|
2. Show (status) window (show_win).
|
||||||
3. Main show pad (show_pad).
|
3. Main show pad (show_pad).
|
||||||
4. Command window (command_win).
|
4. Command window (command_win).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -133,7 +133,7 @@ struct struct_file_system_info { /* Important information about the filesystem
|
||||||
struct struct_file_info { /* Used to handle files and directories */
|
struct struct_file_info { /* Used to handle files and directories */
|
||||||
|
|
||||||
struct ext2_inode *inode_ptr;
|
struct ext2_inode *inode_ptr;
|
||||||
|
|
||||||
long inode_offset;
|
long inode_offset;
|
||||||
long global_block_num,global_block_offset;
|
long global_block_num,global_block_offset;
|
||||||
long block_num,blocks_count;
|
long block_num,blocks_count;
|
||||||
|
@ -144,7 +144,7 @@ struct struct_file_info { /* Used to handle files and directories */
|
||||||
|
|
||||||
int display;
|
int display;
|
||||||
/* The following is used if the file is a directory */
|
/* The following is used if the file is a directory */
|
||||||
|
|
||||||
long dir_entry_num,dir_entries_count;
|
long dir_entry_num,dir_entries_count;
|
||||||
long dir_entry_offset;
|
long dir_entry_offset;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,9 +24,9 @@ int init_file_info (void)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct ext2_inode *ptr;
|
struct ext2_inode *ptr;
|
||||||
|
|
||||||
ptr=&type_data.u.t_ext2_inode;
|
ptr=&type_data.u.t_ext2_inode;
|
||||||
|
|
||||||
file_info.inode_ptr=ptr;
|
file_info.inode_ptr=ptr;
|
||||||
file_info.inode_offset=device_offset;
|
file_info.inode_offset=device_offset;
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ int init_file_info (void)
|
||||||
file_info.file_length=ptr->i_size;
|
file_info.file_length=ptr->i_size;
|
||||||
file_info.level=0;
|
file_info.level=0;
|
||||||
file_info.offset_in_block=0;
|
file_info.offset_in_block=0;
|
||||||
|
|
||||||
file_info.display=HEX;
|
file_info.display=HEX;
|
||||||
|
|
||||||
low_read (file_info.buffer,file_system_info.block_size,file_info.global_block_offset);
|
low_read (file_info.buffer,file_system_info.block_size,file_info.global_block_offset);
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void type_file___nextblock (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
block_offset*=atol (buffer);
|
block_offset*=atol (buffer);
|
||||||
|
@ -79,7 +79,7 @@ void type_file___nextblock (char *command_line)
|
||||||
wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_info.block_num+=block_offset;
|
file_info.block_num+=block_offset;
|
||||||
file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info);
|
file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info);
|
||||||
file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size;
|
file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size;
|
||||||
|
@ -97,17 +97,17 @@ void type_file___next (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
offset*=atol (buffer);
|
offset*=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_info.offset_in_block+offset < file_system_info.block_size) {
|
if (file_info.offset_in_block+offset < file_system_info.block_size) {
|
||||||
file_info.offset_in_block+=offset;
|
file_info.offset_in_block+=offset;
|
||||||
sprintf (buffer,"show");dispatch (buffer);
|
sprintf (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ void type_file___offset (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
offset=atol (buffer);
|
offset=atol (buffer);
|
||||||
|
@ -129,7 +129,7 @@ void type_file___offset (char *command_line)
|
||||||
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
|
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset < file_system_info.block_size) {
|
if (offset < file_system_info.block_size) {
|
||||||
file_info.offset_in_block=offset;
|
file_info.offset_in_block=offset;
|
||||||
sprintf (buffer,"show");dispatch (buffer);
|
sprintf (buffer,"show");dispatch (buffer);
|
||||||
|
@ -147,17 +147,17 @@ void type_file___prev (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
offset*=atol (buffer);
|
offset*=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_info.offset_in_block-offset >= 0) {
|
if (file_info.offset_in_block-offset >= 0) {
|
||||||
file_info.offset_in_block-=offset;
|
file_info.offset_in_block-=offset;
|
||||||
sprintf (buffer,"show");dispatch (buffer);
|
sprintf (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ void type_file___prevblock (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
block_offset*=atol (buffer);
|
block_offset*=atol (buffer);
|
||||||
|
@ -180,7 +180,7 @@ void type_file___prevblock (char *command_line)
|
||||||
wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_info.block_num-=block_offset;
|
file_info.block_num-=block_offset;
|
||||||
file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info);
|
file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info);
|
||||||
file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size;
|
file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size;
|
||||||
|
@ -198,12 +198,12 @@ void type_file___block (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
block_offset=atol (buffer);
|
block_offset=atol (buffer);
|
||||||
|
|
||||||
|
@ -226,25 +226,25 @@ void type_file___display (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0)
|
if (*ptr==0)
|
||||||
strcpy (buffer,"hex");
|
strcpy (buffer,"hex");
|
||||||
else
|
else
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
if (strcasecmp (buffer,"hex")==0) {
|
if (strcasecmp (buffer,"hex")==0) {
|
||||||
wprintw (command_win,"Display set to hex\n");wrefresh (command_win);
|
wprintw (command_win,"Display set to hex\n");wrefresh (command_win);
|
||||||
file_info.display=HEX;
|
file_info.display=HEX;
|
||||||
sprintf (buffer,"show");dispatch (buffer);
|
sprintf (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcasecmp (buffer,"text")==0) {
|
else if (strcasecmp (buffer,"text")==0) {
|
||||||
wprintw (command_win,"Display set to text\n");wrefresh (command_win);
|
wprintw (command_win,"Display set to text\n");wrefresh (command_win);
|
||||||
file_info.display=TEXT;
|
file_info.display=TEXT;
|
||||||
sprintf (buffer,"show");dispatch (buffer);
|
sprintf (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win);
|
||||||
}
|
}
|
||||||
|
@ -255,22 +255,22 @@ void file_show_hex (void)
|
||||||
{
|
{
|
||||||
long offset=0,l,i;
|
long offset=0,l,i;
|
||||||
unsigned char *ch_ptr;
|
unsigned char *ch_ptr;
|
||||||
|
|
||||||
/* device_offset and type_data points to the inode */
|
/* device_offset and type_data points to the inode */
|
||||||
|
|
||||||
show_pad_info.line=0;
|
show_pad_info.line=0;
|
||||||
|
|
||||||
wmove (show_pad,0,0);
|
wmove (show_pad,0,0);
|
||||||
ch_ptr=file_info.buffer;
|
ch_ptr=file_info.buffer;
|
||||||
for (l=0;l<file_system_info.block_size/16;l++) {
|
for (l=0;l<file_system_info.block_size/16;l++) {
|
||||||
if (file_info.file_offset+offset>file_info.file_length-1) break;
|
if (file_info.file_offset+offset>file_info.file_length-1) break;
|
||||||
wprintw (show_pad,"%08ld : ",offset);
|
wprintw (show_pad,"%08ld : ",offset);
|
||||||
for (i=0;i<16;i++) {
|
for (i=0;i<16;i++) {
|
||||||
|
|
||||||
if (file_info.file_offset+offset+i>file_info.file_length-1) {
|
if (file_info.file_offset+offset+i>file_info.file_length-1) {
|
||||||
wprintw (show_pad," ");
|
wprintw (show_pad," ");
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (file_info.offset_in_block==offset+i)
|
if (file_info.offset_in_block==offset+i)
|
||||||
wattrset (show_pad,A_REVERSE);
|
wattrset (show_pad,A_REVERSE);
|
||||||
|
@ -297,20 +297,20 @@ void file_show_hex (void)
|
||||||
wattrset (show_pad,A_NORMAL);
|
wattrset (show_pad,A_NORMAL);
|
||||||
show_pad_info.line=l-l % show_pad_info.display_lines;
|
show_pad_info.line=l-l % show_pad_info.display_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (show_pad," ");
|
wprintw (show_pad," ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (show_pad,"\n");
|
wprintw (show_pad,"\n");
|
||||||
offset+=i;
|
offset+=i;
|
||||||
ch_ptr+=i;
|
ch_ptr+=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
show_pad_info.max_line=l-1;
|
show_pad_info.max_line=l-1;
|
||||||
|
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
|
|
||||||
show_status ();
|
show_status ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ void file_show_text (void)
|
||||||
{
|
{
|
||||||
long offset=0,last_offset,l=0,cols=0;
|
long offset=0,last_offset,l=0,cols=0;
|
||||||
unsigned char *ch_ptr;
|
unsigned char *ch_ptr;
|
||||||
|
|
||||||
/* device_offset and type_data points to the inode */
|
/* device_offset and type_data points to the inode */
|
||||||
|
|
||||||
show_pad_info.line=0;
|
show_pad_info.line=0;
|
||||||
|
@ -330,14 +330,14 @@ void file_show_text (void)
|
||||||
|
|
||||||
if (file_info.file_offset+last_offset > file_info.file_length-1)
|
if (file_info.file_offset+last_offset > file_info.file_length-1)
|
||||||
last_offset=file_info.file_length-1-file_info.file_offset;
|
last_offset=file_info.file_length-1-file_info.file_offset;
|
||||||
|
|
||||||
while ( (offset <= last_offset) && l<SHOW_PAD_LINES) {
|
while ( (offset <= last_offset) && l<SHOW_PAD_LINES) {
|
||||||
|
|
||||||
if (cols==SHOW_PAD_COLS-1) {
|
if (cols==SHOW_PAD_COLS-1) {
|
||||||
wprintw (show_pad,"\n");
|
wprintw (show_pad,"\n");
|
||||||
l++;cols=0;
|
l++;cols=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (file_info.offset_in_block==offset)
|
if (file_info.offset_in_block==offset)
|
||||||
wattrset (show_pad,A_REVERSE);
|
wattrset (show_pad,A_REVERSE);
|
||||||
|
@ -354,7 +354,7 @@ void file_show_text (void)
|
||||||
|
|
||||||
else if (*ch_ptr == 0x9)
|
else if (*ch_ptr == 0x9)
|
||||||
wprintw (show_pad," ");
|
wprintw (show_pad," ");
|
||||||
|
|
||||||
else
|
else
|
||||||
wprintw (show_pad,".");
|
wprintw (show_pad,".");
|
||||||
}
|
}
|
||||||
|
@ -363,29 +363,29 @@ void file_show_text (void)
|
||||||
wattrset (show_pad,A_NORMAL);
|
wattrset (show_pad,A_NORMAL);
|
||||||
show_pad_info.line=l-l % show_pad_info.display_lines;
|
show_pad_info.line=l-l % show_pad_info.display_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
offset++;cols++;ch_ptr++;
|
offset++;cols++;ch_ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (show_pad,"\n");
|
wprintw (show_pad,"\n");
|
||||||
show_pad_info.max_line=l;
|
show_pad_info.max_line=l;
|
||||||
|
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
|
|
||||||
show_status ();
|
show_status ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_status (void)
|
void show_status (void)
|
||||||
|
|
||||||
{
|
{
|
||||||
long inode_num;
|
long inode_num;
|
||||||
|
|
||||||
werase (show_win);wmove (show_win,0,0);
|
werase (show_win);wmove (show_win,0,0);
|
||||||
wprintw (show_win,"File contents. Block %ld. ",file_info.global_block_num);
|
wprintw (show_win,"File contents. Block %ld. ",file_info.global_block_num);
|
||||||
wprintw (show_win,"File block %ld of %ld. ",file_info.block_num,file_info.blocks_count-1);
|
wprintw (show_win,"File block %ld of %ld. ",file_info.block_num,file_info.blocks_count-1);
|
||||||
wprintw (show_win,"File Offset %ld of %ld.",file_info.file_offset,file_info.file_length-1);
|
wprintw (show_win,"File Offset %ld of %ld.",file_info.file_offset,file_info.file_length-1);
|
||||||
|
|
||||||
wmove (show_win,1,0);
|
wmove (show_win,1,0);
|
||||||
inode_num=inode_offset_to_inode_num (file_info.inode_offset);
|
inode_num=inode_offset_to_inode_num (file_info.inode_offset);
|
||||||
wprintw (show_win,"File inode %ld. Indirection level %ld.",inode_num,file_info.level);
|
wprintw (show_win,"File inode %ld. Indirection level %ld.",inode_num,file_info.level);
|
||||||
|
@ -400,14 +400,14 @@ void type_file___remember (char *command_line)
|
||||||
long entry_num;
|
long entry_num;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
struct struct_descriptor *descriptor_ptr;
|
struct struct_descriptor *descriptor_ptr;
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win);
|
wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
entry_num=remember_lifo.entries_count++;
|
entry_num=remember_lifo.entries_count++;
|
||||||
|
@ -415,7 +415,7 @@ void type_file___remember (char *command_line)
|
||||||
entry_num=0;
|
entry_num=0;
|
||||||
remember_lifo.entries_count--;
|
remember_lifo.entries_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptor_ptr=first_type;
|
descriptor_ptr=first_type;
|
||||||
while (descriptor_ptr!=NULL && !found) {
|
while (descriptor_ptr!=NULL && !found) {
|
||||||
if (strcmp (descriptor_ptr->name,"ext2_inode")==0)
|
if (strcmp (descriptor_ptr->name,"ext2_inode")==0)
|
||||||
|
@ -428,7 +428,7 @@ void type_file___remember (char *command_line)
|
||||||
remember_lifo.offset [entry_num]=device_offset;
|
remember_lifo.offset [entry_num]=device_offset;
|
||||||
remember_lifo.type [entry_num]=descriptor_ptr;
|
remember_lifo.type [entry_num]=descriptor_ptr;
|
||||||
strcpy (remember_lifo.name [entry_num],buffer);
|
strcpy (remember_lifo.name [entry_num],buffer);
|
||||||
|
|
||||||
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer);
|
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer);
|
||||||
wrefresh (command_win);
|
wrefresh (command_win);
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ void type_file___set (char *command_line)
|
||||||
unsigned char tmp;
|
unsigned char tmp;
|
||||||
char *ptr,buffer [80],*ch_ptr;
|
char *ptr,buffer [80],*ch_ptr;
|
||||||
int mode=HEX;
|
int mode=HEX;
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return;
|
||||||
|
@ -492,7 +492,7 @@ void type_file___set (char *command_line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy (buffer,"show");dispatch (buffer);
|
strcpy (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ long file_block_to_global_block (long file_block,struct struct_file_info *file_i
|
||||||
|
|
||||||
{
|
{
|
||||||
long last_direct,last_indirect,last_dindirect;
|
long last_direct,last_indirect,last_dindirect;
|
||||||
|
|
||||||
last_direct=EXT2_NDIR_BLOCKS-1;
|
last_direct=EXT2_NDIR_BLOCKS-1;
|
||||||
last_indirect=last_direct+file_system_info.block_size/4;
|
last_indirect=last_direct+file_system_info.block_size/4;
|
||||||
last_dindirect=last_indirect+(file_system_info.block_size/4)*(file_system_info.block_size/4);
|
last_dindirect=last_indirect+(file_system_info.block_size/4)*(file_system_info.block_size/4);
|
||||||
|
@ -516,7 +516,7 @@ long file_block_to_global_block (long file_block,struct struct_file_info *file_i
|
||||||
file_info_ptr->level=0;
|
file_info_ptr->level=0;
|
||||||
return (file_info_ptr->inode_ptr->i_block [file_block]);
|
return (file_info_ptr->inode_ptr->i_block [file_block]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_block <= last_indirect) {
|
if (file_block <= last_indirect) {
|
||||||
file_info_ptr->level=1;
|
file_info_ptr->level=1;
|
||||||
file_block=file_block-last_direct-1;
|
file_block=file_block-last_direct-1;
|
||||||
|
@ -538,16 +538,16 @@ long return_indirect (long table_block,long block_num)
|
||||||
|
|
||||||
{
|
{
|
||||||
long block_table [EXT2_MAX_BLOCK_SIZE/4];
|
long block_table [EXT2_MAX_BLOCK_SIZE/4];
|
||||||
|
|
||||||
low_read ((char *) block_table,file_system_info.block_size,table_block*file_system_info.block_size);
|
low_read ((char *) block_table,file_system_info.block_size,table_block*file_system_info.block_size);
|
||||||
return (block_table [block_num]);
|
return (block_table [block_num]);
|
||||||
}
|
}
|
||||||
|
|
||||||
long return_dindirect (long table_block,long block_num)
|
long return_dindirect (long table_block,long block_num)
|
||||||
|
|
||||||
{
|
{
|
||||||
long f_indirect;
|
long f_indirect;
|
||||||
|
|
||||||
f_indirect=block_num/(file_system_info.block_size/4);
|
f_indirect=block_num/(file_system_info.block_size/4);
|
||||||
f_indirect=return_indirect (table_block,f_indirect);
|
f_indirect=return_indirect (table_block,f_indirect);
|
||||||
return (return_indirect (f_indirect,block_num%(file_system_info.block_size/4)));
|
return (return_indirect (f_indirect,block_num%(file_system_info.block_size/4)));
|
||||||
|
@ -557,7 +557,7 @@ long return_tindirect (long table_block,long block_num)
|
||||||
|
|
||||||
{
|
{
|
||||||
long s_indirect;
|
long s_indirect;
|
||||||
|
|
||||||
s_indirect=block_num/((file_system_info.block_size/4)*(file_system_info.block_size/4));
|
s_indirect=block_num/((file_system_info.block_size/4)*(file_system_info.block_size/4));
|
||||||
s_indirect=return_indirect (table_block,s_indirect);
|
s_indirect=return_indirect (table_block,s_indirect);
|
||||||
return (return_dindirect (s_indirect,block_num%((file_system_info.block_size/4)*(file_system_info.block_size/4))));
|
return (return_dindirect (s_indirect,block_num%((file_system_info.block_size/4)*(file_system_info.block_size/4))));
|
||||||
|
|
|
@ -33,16 +33,16 @@ void help (char *command_line)
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,argument);
|
ptr=parse_word (ptr,argument);
|
||||||
if (*argument!=0) {
|
if (*argument!=0) {
|
||||||
detailed_help (argument);
|
detailed_help (argument);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_type!=NULL) {
|
if (current_type!=NULL) {
|
||||||
|
|
||||||
wprintw (show_pad,"Type %s specific commands:\n",current_type->name);max_line++;
|
wprintw (show_pad,"Type %s specific commands:\n",current_type->name);max_line++;
|
||||||
|
|
||||||
if (current_type->type_commands.last_command==-1) {
|
if (current_type->type_commands.last_command==-1) {
|
||||||
wprintw (show_pad,"\nnone\n");max_line+=2;
|
wprintw (show_pad,"\nnone\n");max_line+=2;
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,11 @@ void help (char *command_line)
|
||||||
}
|
}
|
||||||
wprintw (show_pad,"%-13s",current_type->type_commands.names [i]);
|
wprintw (show_pad,"%-13s",current_type->type_commands.names [i]);
|
||||||
if (i%5!=4)
|
if (i%5!=4)
|
||||||
wprintw (show_pad,"; ");
|
wprintw (show_pad,"; ");
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (show_pad,"\n\n");max_line+=2;
|
wprintw (show_pad,"\n\n");max_line+=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ext2_commands.last_command != -1) {
|
if (ext2_commands.last_command != -1) {
|
||||||
wprintw (show_pad,"ext2 filesystem general commands: \n");max_line++;
|
wprintw (show_pad,"ext2 filesystem general commands: \n");max_line++;
|
||||||
|
@ -67,25 +67,25 @@ void help (char *command_line)
|
||||||
}
|
}
|
||||||
wprintw (show_pad,"%-13s",ext2_commands.names [i]);
|
wprintw (show_pad,"%-13s",ext2_commands.names [i]);
|
||||||
if (i%5!=4)
|
if (i%5!=4)
|
||||||
wprintw (show_pad,"; ");
|
wprintw (show_pad,"; ");
|
||||||
|
|
||||||
}
|
}
|
||||||
wprintw (show_pad,"\n\n");max_line+=2;
|
wprintw (show_pad,"\n\n");max_line+=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (show_pad,"General commands: \n");
|
wprintw (show_pad,"General commands: \n");
|
||||||
|
|
||||||
for (i=0;i<=general_commands.last_command;i++) {
|
for (i=0;i<=general_commands.last_command;i++) {
|
||||||
if (i%5==0) {
|
if (i%5==0) {
|
||||||
wprintw (show_pad,"\n");max_line++;
|
wprintw (show_pad,"\n");max_line++;
|
||||||
}
|
}
|
||||||
wprintw (show_pad,"%-13s",general_commands.names [i]);
|
wprintw (show_pad,"%-13s",general_commands.names [i]);
|
||||||
if (i%5!=4)
|
if (i%5!=4)
|
||||||
wprintw (show_pad,"; ");
|
wprintw (show_pad,"; ");
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (show_pad,"\n\n");max_line+=2;
|
wprintw (show_pad,"\n\n");max_line+=2;
|
||||||
|
|
||||||
wprintw (show_pad,"EXT2ED ver %s (%s)\n",E2FSPROGS_VERSION, E2FSPROGS_DATE);
|
wprintw (show_pad,"EXT2ED ver %s (%s)\n",E2FSPROGS_VERSION, E2FSPROGS_DATE);
|
||||||
wprintw (show_pad,"Copyright (C) 1995 Gadi Oxman\n");
|
wprintw (show_pad,"Copyright (C) 1995 Gadi Oxman\n");
|
||||||
wprintw (show_pad,"Reviewed 2001 Christian Bac\n");
|
wprintw (show_pad,"Reviewed 2001 Christian Bac\n");
|
||||||
|
@ -97,12 +97,12 @@ void help (char *command_line)
|
||||||
wprintw (show_pad,"with the guide of Avner Lottem and Dr. Ilana David.\n");
|
wprintw (show_pad,"with the guide of Avner Lottem and Dr. Ilana David.\n");
|
||||||
|
|
||||||
max_line+=10;
|
max_line+=10;
|
||||||
|
|
||||||
show_pad_info.line=0;show_pad_info.max_line=max_line;
|
show_pad_info.line=0;show_pad_info.max_line=max_line;
|
||||||
|
|
||||||
werase (show_win);wmove (show_win,0,0);
|
werase (show_win);wmove (show_win,0,0);
|
||||||
wprintw (show_win,"EXT2ED help");
|
wprintw (show_win,"EXT2ED help");
|
||||||
|
|
||||||
refresh_show_win ();
|
refresh_show_win ();
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ void detailed_help (char *text)
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (current_type != NULL)
|
if (current_type != NULL)
|
||||||
for (i=0;i<=current_type->type_commands.last_command;i++) {
|
for (i=0;i<=current_type->type_commands.last_command;i++) {
|
||||||
if (strcmp (current_type->type_commands.names [i],text)==0) {
|
if (strcmp (current_type->type_commands.names [i],text)==0) {
|
||||||
|
@ -149,20 +149,20 @@ void set_device (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
char *ptr,new_device [80];
|
char *ptr,new_device [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,new_device);
|
ptr=parse_word (command_line,new_device);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Device name not specified\n");
|
wprintw (command_win,"Error - Device name not specified\n");
|
||||||
refresh_command_win ();return;
|
refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
parse_word (ptr,new_device);
|
parse_word (ptr,new_device);
|
||||||
check_mounted (new_device);
|
check_mounted (new_device);
|
||||||
if (mounted && !AllowMountedRead) {
|
if (mounted && !AllowMountedRead) {
|
||||||
wprintw (command_win,"Error - Filesystem is mounted, aborting\n");
|
wprintw (command_win,"Error - Filesystem is mounted, aborting\n");
|
||||||
wprintw (command_win,"You may wish to use the AllowMountedRead on configuration option\n");
|
wprintw (command_win,"You may wish to use the AllowMountedRead on configuration option\n");
|
||||||
refresh_command_win ();return;
|
refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounted && AllowMountedRead) {
|
if (mounted && AllowMountedRead) {
|
||||||
wprintw (command_win,"Warning - Filesystem is mounted. Displayed data may be unreliable.\n");
|
wprintw (command_win,"Warning - Filesystem is mounted. Displayed data may be unreliable.\n");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
|
@ -170,7 +170,7 @@ void set_device (char *command_line)
|
||||||
|
|
||||||
if (device_handle!=NULL)
|
if (device_handle!=NULL)
|
||||||
fclose (device_handle);
|
fclose (device_handle);
|
||||||
|
|
||||||
if ( (device_handle=fopen (new_device,"rb"))==NULL) {
|
if ( (device_handle=fopen (new_device,"rb"))==NULL) {
|
||||||
wprintw (command_win,"Error - Can not open device %s\n",new_device);refresh_command_win ();
|
wprintw (command_win,"Error - Can not open device %s\n",new_device);refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
|
@ -204,14 +204,14 @@ void set_offset (char *command_line)
|
||||||
long mult=1;
|
long mult=1;
|
||||||
long new_offset;
|
long new_offset;
|
||||||
char *ptr,new_offset_buffer [80];
|
char *ptr,new_offset_buffer [80];
|
||||||
|
|
||||||
if (device_handle==NULL) {
|
if (device_handle==NULL) {
|
||||||
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
|
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr=parse_word (command_line,new_offset_buffer);
|
ptr=parse_word (command_line,new_offset_buffer);
|
||||||
|
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();
|
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
|
@ -246,7 +246,7 @@ void set_offset (char *command_line)
|
||||||
}
|
}
|
||||||
new_offset=device_offset+atol (new_offset_buffer+1)*mult;
|
new_offset=device_offset+atol (new_offset_buffer+1)*mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (new_offset_buffer [0]=='-') {
|
else if (new_offset_buffer [0]=='-') {
|
||||||
if (device_offset==-1) {
|
if (device_offset==-1) {
|
||||||
wprintw (command_win,"Error - Select a fixed offset first\n");refresh_command_win ();
|
wprintw (command_win,"Error - Select a fixed offset first\n");refresh_command_win ();
|
||||||
|
@ -255,10 +255,10 @@ void set_offset (char *command_line)
|
||||||
new_offset=device_offset-atol (new_offset_buffer+1)*mult;
|
new_offset=device_offset-atol (new_offset_buffer+1)*mult;
|
||||||
if (new_offset<0) new_offset=0;
|
if (new_offset<0) new_offset=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
new_offset=atol (new_offset_buffer)*mult;
|
new_offset=atol (new_offset_buffer)*mult;
|
||||||
|
|
||||||
if ( (fseek (device_handle,new_offset,SEEK_SET))==-1) {
|
if ( (fseek (device_handle,new_offset,SEEK_SET))==-1) {
|
||||||
wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",new_offset,device_name);
|
wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",new_offset,device_name);
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
|
@ -362,7 +362,7 @@ void set (char *command_line)
|
||||||
unsigned long *long_ptr,offset=0;
|
unsigned long *long_ptr,offset=0;
|
||||||
int i,len, found=0;
|
int i,len, found=0;
|
||||||
char *ptr,buffer [80],variable [80],value [80];
|
char *ptr,buffer [80],variable [80],value [80];
|
||||||
|
|
||||||
if (device_handle==NULL) {
|
if (device_handle==NULL) {
|
||||||
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
|
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
|
@ -389,7 +389,7 @@ void set (char *command_line)
|
||||||
if (current_type==NULL) {
|
if (current_type==NULL) {
|
||||||
wprintw (command_win,"Sorry, not yet supported\n");refresh_command_win ();return;
|
wprintw (command_win,"Sorry, not yet supported\n");refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<current_type->fields_num && !found;i++) {
|
for (i=0;i<current_type->fields_num && !found;i++) {
|
||||||
if (strcmp (current_type->field_names [i],variable)==0) {
|
if (strcmp (current_type->field_names [i],variable)==0) {
|
||||||
found=1;
|
found=1;
|
||||||
|
@ -429,7 +429,7 @@ void hex_set (char *command_line)
|
||||||
unsigned char tmp;
|
unsigned char tmp;
|
||||||
char *ptr,buffer [80],*ch_ptr;
|
char *ptr,buffer [80],*ch_ptr;
|
||||||
int mode=HEX;
|
int mode=HEX;
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return;
|
||||||
|
@ -482,7 +482,7 @@ void hex_set (char *command_line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy (buffer,"show");dispatch (buffer);
|
strcpy (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,14 +500,14 @@ void set_type (char *command_line)
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
parse_word (ptr,buffer);
|
parse_word (ptr,buffer);
|
||||||
|
|
||||||
if (strcmp (buffer,"none")==0 || strcmp (buffer,"hex")==0) {
|
if (strcmp (buffer,"none")==0 || strcmp (buffer,"hex")==0) {
|
||||||
wprintw (command_win,"Data will be shown as hex dump\n");refresh_command_win ();
|
wprintw (command_win,"Data will be shown as hex dump\n");refresh_command_win ();
|
||||||
current_type=NULL;
|
current_type=NULL;
|
||||||
sprintf (tmp_buffer,"show");dispatch (tmp_buffer);
|
sprintf (tmp_buffer,"show");dispatch (tmp_buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptor_ptr=first_type;
|
descriptor_ptr=first_type;
|
||||||
while (descriptor_ptr!=NULL && !found) {
|
while (descriptor_ptr!=NULL && !found) {
|
||||||
if (strcmp (descriptor_ptr->name,buffer)==0)
|
if (strcmp (descriptor_ptr->name,buffer)==0)
|
||||||
|
@ -523,7 +523,7 @@ void set_type (char *command_line)
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - %s is not a valid type\n",buffer);refresh_command_win ();
|
wprintw (command_win,"Error - %s is not a valid type\n",buffer);refresh_command_win ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_int(short len, void *ptr)
|
void show_int(short len, void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -584,7 +584,7 @@ void show_char(short len, void *ptr)
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
wprintw(show_pad, "\"");
|
wprintw(show_pad, "\"");
|
||||||
|
|
||||||
for (i=0; i < len; i++) {
|
for (i=0; i < len; i++) {
|
||||||
ch = *cp++;
|
ch = *cp++;
|
||||||
if (ch == 0) {
|
if (ch == 0) {
|
||||||
|
@ -604,17 +604,17 @@ void show_char(short len, void *ptr)
|
||||||
}
|
}
|
||||||
wprintw(show_pad, "%c", ch);
|
wprintw(show_pad, "%c", ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw(show_pad, "\"\n");
|
wprintw(show_pad, "\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void show (char *command_line)
|
void show (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned int i,l,len,temp_int;
|
unsigned int i,l,len,temp_int;
|
||||||
unsigned long offset=0,temp_long;
|
unsigned long offset=0,temp_long;
|
||||||
unsigned char temp_char,*ch_ptr;
|
unsigned char temp_char,*ch_ptr;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ void show (char *command_line)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
show_pad_info.line=0;
|
show_pad_info.line=0;
|
||||||
|
|
||||||
if (current_type==NULL) {
|
if (current_type==NULL) {
|
||||||
wmove (show_pad,0,0);
|
wmove (show_pad,0,0);
|
||||||
ch_ptr=type_data.u.buffer;
|
ch_ptr=type_data.u.buffer;
|
||||||
|
@ -631,7 +631,7 @@ void show (char *command_line)
|
||||||
for (i=0;i<16;i++) {
|
for (i=0;i<16;i++) {
|
||||||
if (type_data.offset_in_block==offset+i)
|
if (type_data.offset_in_block==offset+i)
|
||||||
wattrset (show_pad,A_REVERSE);
|
wattrset (show_pad,A_REVERSE);
|
||||||
|
|
||||||
if (ch_ptr [i]>=' ' && ch_ptr [i]<='z')
|
if (ch_ptr [i]>=' ' && ch_ptr [i]<='z')
|
||||||
wprintw (show_pad,"%c",ch_ptr [i]);
|
wprintw (show_pad,"%c",ch_ptr [i]);
|
||||||
else
|
else
|
||||||
|
@ -643,7 +643,7 @@ void show (char *command_line)
|
||||||
for (i=0;i<16;i++) {
|
for (i=0;i<16;i++) {
|
||||||
if (type_data.offset_in_block==offset+i)
|
if (type_data.offset_in_block==offset+i)
|
||||||
wattrset (show_pad,A_REVERSE);
|
wattrset (show_pad,A_REVERSE);
|
||||||
|
|
||||||
wprintw (show_pad,"%02x",ch_ptr [i]);
|
wprintw (show_pad,"%02x",ch_ptr [i]);
|
||||||
|
|
||||||
if (type_data.offset_in_block==offset+i) {
|
if (type_data.offset_in_block==offset+i) {
|
||||||
|
@ -696,12 +696,12 @@ void next (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
offset*=atol (buffer);
|
offset*=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_type!=NULL) {
|
if (current_type!=NULL) {
|
||||||
sprintf (buffer,"setoffset type +%ld",offset);
|
sprintf (buffer,"setoffset type +%ld",offset);
|
||||||
dispatch (buffer);
|
dispatch (buffer);
|
||||||
|
@ -712,7 +712,7 @@ void next (char *command_line)
|
||||||
type_data.offset_in_block+=offset;
|
type_data.offset_in_block+=offset;
|
||||||
sprintf (buffer,"show");dispatch (buffer);
|
sprintf (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
@ -725,12 +725,12 @@ void prev (char *command_line)
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
offset*=atol (buffer);
|
offset*=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_type!=NULL) {
|
if (current_type!=NULL) {
|
||||||
sprintf (buffer,"setoffset type -%ld",offset);
|
sprintf (buffer,"setoffset type -%ld",offset);
|
||||||
dispatch (buffer);
|
dispatch (buffer);
|
||||||
|
@ -741,13 +741,13 @@ void prev (char *command_line)
|
||||||
type_data.offset_in_block-=offset;
|
type_data.offset_in_block-=offset;
|
||||||
sprintf (buffer,"show");dispatch (buffer);
|
sprintf (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pgdn (char *commnad_line)
|
void pgdn (char *commnad_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
show_pad_info.line+=show_pad_info.display_lines;
|
show_pad_info.line+=show_pad_info.display_lines;
|
||||||
|
@ -773,19 +773,19 @@ void remember (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_num;
|
long entry_num;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
if (device_handle==NULL) {
|
if (device_handle==NULL) {
|
||||||
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
|
wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
|
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
entry_num=remember_lifo.entries_count++;
|
entry_num=remember_lifo.entries_count++;
|
||||||
|
@ -793,16 +793,16 @@ void remember (char *command_line)
|
||||||
entry_num=0;
|
entry_num=0;
|
||||||
remember_lifo.entries_count--;
|
remember_lifo.entries_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
remember_lifo.offset [entry_num]=device_offset;
|
remember_lifo.offset [entry_num]=device_offset;
|
||||||
remember_lifo.type [entry_num]=current_type;
|
remember_lifo.type [entry_num]=current_type;
|
||||||
strcpy (remember_lifo.name [entry_num],buffer);
|
strcpy (remember_lifo.name [entry_num],buffer);
|
||||||
|
|
||||||
if (current_type!=NULL)
|
if (current_type!=NULL)
|
||||||
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",current_type->name,device_offset,buffer);
|
wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",current_type->name,device_offset,buffer);
|
||||||
else
|
else
|
||||||
wprintw (command_win,"Offset %ld remembered as %s\n",device_offset,buffer);
|
wprintw (command_win,"Offset %ld remembered as %s\n",device_offset,buffer);
|
||||||
|
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,17 +821,17 @@ void recall (char *command_line)
|
||||||
|
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
|
wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
|
|
||||||
for (entry_num=remember_lifo.entries_count-1;entry_num>=0;entry_num--) {
|
for (entry_num=remember_lifo.entries_count-1;entry_num>=0;entry_num--) {
|
||||||
if (strcmp (remember_lifo.name [entry_num],buffer)==0)
|
if (strcmp (remember_lifo.name [entry_num],buffer)==0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry_num==-1) {
|
if (entry_num==-1) {
|
||||||
wprintw (command_win,"Error - Can not recall %s\n",buffer);refresh_command_win ();
|
wprintw (command_win,"Error - Can not recall %s\n",buffer);refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
|
@ -839,13 +839,13 @@ void recall (char *command_line)
|
||||||
|
|
||||||
sprintf (buffer,"setoffset %ld",remember_lifo.offset [entry_num]);dispatch (buffer);
|
sprintf (buffer,"setoffset %ld",remember_lifo.offset [entry_num]);dispatch (buffer);
|
||||||
if (remember_lifo.type [entry_num] != NULL) {
|
if (remember_lifo.type [entry_num] != NULL) {
|
||||||
sprintf (buffer,"settype %s",remember_lifo.type [entry_num]->name);dispatch (buffer);
|
sprintf (buffer,"settype %s",remember_lifo.type [entry_num]->name);dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
sprintf (buffer,"settype none");dispatch (buffer);
|
sprintf (buffer,"settype none");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw (command_win,"Object %s in Offset %ld recalled\n",current_type->name,device_offset);
|
wprintw (command_win,"Object %s in Offset %ld recalled\n",current_type->name,device_offset);
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
@ -864,12 +864,12 @@ void enable_write (char *command_line)
|
||||||
wprintw (command_win,"Sorry, write access is not allowed\n");
|
wprintw (command_win,"Sorry, write access is not allowed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
wprintw (command_win,"Error - Filesystem is mounted\n");
|
wprintw (command_win,"Error - Filesystem is mounted\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (fp=fopen (device_name,"r+b"))==NULL) {
|
if ( (fp=fopen (device_name,"r+b"))==NULL) {
|
||||||
wprintw (command_win,"Error - Can not open device %s for reading and writing\n",device_name);refresh_command_win ();
|
wprintw (command_win,"Error - Can not open device %s for reading and writing\n",device_name);refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
|
@ -893,7 +893,7 @@ void disable_write (char *command_line)
|
||||||
wprintw (command_win,"Error - Can not open device %s\n",device_name);refresh_command_win ();
|
wprintw (command_win,"Error - Can not open device %s\n",device_name);refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (device_handle);
|
fclose (device_handle);
|
||||||
device_handle=fp;write_access=0;
|
device_handle=fp;write_access=0;
|
||||||
wprintw (command_win,"Write access disabled\n");refresh_command_win ();
|
wprintw (command_win,"Write access disabled\n");refresh_command_win ();
|
||||||
|
|
|
@ -19,11 +19,11 @@ Copyright (C) 1995 Gadi Oxman
|
||||||
#include "ext2ed.h"
|
#include "ext2ed.h"
|
||||||
|
|
||||||
void type_ext2_group_desc___next (char *command_line)
|
void type_ext2_group_desc___next (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
long entry_offset=1;
|
long entry_offset=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
@ -39,7 +39,7 @@ void type_ext2_group_desc___prev (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_offset=1;
|
long entry_offset=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
@ -55,7 +55,7 @@ void type_ext2_group_desc___entry (char *command_line)
|
||||||
{
|
{
|
||||||
long group_num;
|
long group_num;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
||||||
|
@ -63,11 +63,11 @@ void type_ext2_group_desc___entry (char *command_line)
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
group_num=atol (buffer);
|
group_num=atol (buffer);
|
||||||
|
|
||||||
if (group_num < 0 || group_num >= file_system_info.groups_count) {
|
if (group_num < 0 || group_num >= file_system_info.groups_count) {
|
||||||
wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
|
device_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
|
||||||
|
|
||||||
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
|
||||||
|
@ -81,7 +81,7 @@ void type_ext2_group_desc___gocopy (char *command_line)
|
||||||
{
|
{
|
||||||
unsigned long copy_num,offset;
|
unsigned long copy_num,offset;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
||||||
|
@ -89,12 +89,12 @@ void type_ext2_group_desc___gocopy (char *command_line)
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
copy_num=atol (buffer);
|
copy_num=atol (buffer);
|
||||||
|
|
||||||
offset=file_system_info.first_group_desc_offset+copy_num*file_system_info.super_block.s_blocks_per_group*file_system_info.block_size;
|
offset=file_system_info.first_group_desc_offset+copy_num*file_system_info.super_block.s_blocks_per_group*file_system_info.block_size;
|
||||||
|
|
||||||
if (offset > file_system_info.file_system_size) {
|
if (offset > file_system_info.file_system_size) {
|
||||||
wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
group_info.copy_num=copy_num;
|
group_info.copy_num=copy_num;
|
||||||
device_offset=offset+group_info.group_num*sizeof (struct ext2_group_desc);
|
device_offset=offset+group_info.group_num*sizeof (struct ext2_group_desc);
|
||||||
|
@ -108,12 +108,12 @@ void type_ext2_group_desc___show (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
long group_num,temp;
|
long group_num,temp;
|
||||||
|
|
||||||
temp=(device_offset-file_system_info.first_group_desc_offset) % (file_system_info.super_block.s_blocks_per_group*file_system_info.block_size);
|
temp=(device_offset-file_system_info.first_group_desc_offset) % (file_system_info.super_block.s_blocks_per_group*file_system_info.block_size);
|
||||||
group_num=temp/sizeof (struct ext2_group_desc);
|
group_num=temp/sizeof (struct ext2_group_desc);
|
||||||
|
|
||||||
show (command_line);
|
show (command_line);
|
||||||
|
|
||||||
wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0);
|
wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0);
|
||||||
wprintw (show_win,"Group %ld of %ld ",group_num,file_system_info.groups_count-1);
|
wprintw (show_win,"Group %ld of %ld ",group_num,file_system_info.groups_count-1);
|
||||||
wprintw (show_win,"in copy %ld ",group_info.copy_num);
|
wprintw (show_win,"in copy %ld ",group_info.copy_num);
|
||||||
|
@ -136,7 +136,7 @@ void type_ext2_group_desc___inode (char *command_line)
|
||||||
{
|
{
|
||||||
long inode_offset;
|
long inode_offset;
|
||||||
char buffer [80];
|
char buffer [80];
|
||||||
|
|
||||||
inode_offset=type_data.u.t_ext2_group_desc.bg_inode_table;
|
inode_offset=type_data.u.t_ext2_group_desc.bg_inode_table;
|
||||||
sprintf (buffer,"setoffset block %ld",inode_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset block %ld",inode_offset);dispatch (buffer);
|
||||||
sprintf (buffer,"settype ext2_inode");dispatch (buffer);
|
sprintf (buffer,"settype ext2_inode");dispatch (buffer);
|
||||||
|
@ -147,10 +147,10 @@ void type_ext2_group_desc___blockbitmap (char *command_line)
|
||||||
{
|
{
|
||||||
long block_bitmap_offset;
|
long block_bitmap_offset;
|
||||||
char buffer [80];
|
char buffer [80];
|
||||||
|
|
||||||
block_bitmap_info.entry_num=0;
|
block_bitmap_info.entry_num=0;
|
||||||
block_bitmap_info.group_num=group_info.group_num;
|
block_bitmap_info.group_num=group_info.group_num;
|
||||||
|
|
||||||
block_bitmap_offset=type_data.u.t_ext2_group_desc.bg_block_bitmap;
|
block_bitmap_offset=type_data.u.t_ext2_group_desc.bg_block_bitmap;
|
||||||
sprintf (buffer,"setoffset block %ld",block_bitmap_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset block %ld",block_bitmap_offset);dispatch (buffer);
|
||||||
sprintf (buffer,"settype block_bitmap");dispatch (buffer);
|
sprintf (buffer,"settype block_bitmap");dispatch (buffer);
|
||||||
|
@ -161,10 +161,10 @@ void type_ext2_group_desc___inodebitmap (char *command_line)
|
||||||
{
|
{
|
||||||
long inode_bitmap_offset;
|
long inode_bitmap_offset;
|
||||||
char buffer [80];
|
char buffer [80];
|
||||||
|
|
||||||
inode_bitmap_info.entry_num=0;
|
inode_bitmap_info.entry_num=0;
|
||||||
inode_bitmap_info.group_num=group_info.group_num;
|
inode_bitmap_info.group_num=group_info.group_num;
|
||||||
|
|
||||||
inode_bitmap_offset=type_data.u.t_ext2_group_desc.bg_inode_bitmap;
|
inode_bitmap_offset=type_data.u.t_ext2_group_desc.bg_inode_bitmap;
|
||||||
sprintf (buffer,"setoffset block %ld",inode_bitmap_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset block %ld",inode_bitmap_offset);dispatch (buffer);
|
||||||
sprintf (buffer,"settype inode_bitmap");dispatch (buffer);
|
sprintf (buffer,"settype inode_bitmap");dispatch (buffer);
|
||||||
|
@ -174,7 +174,7 @@ void type_ext2_group_desc___setactivecopy (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct ext2_group_desc gd;
|
struct ext2_group_desc gd;
|
||||||
|
|
||||||
gd=type_data.u.t_ext2_group_desc;
|
gd=type_data.u.t_ext2_group_desc;
|
||||||
dispatch ("gocopy 0");
|
dispatch ("gocopy 0");
|
||||||
type_data.u.t_ext2_group_desc=gd;
|
type_data.u.t_ext2_group_desc=gd;
|
||||||
|
|
|
@ -48,12 +48,12 @@ int init (void)
|
||||||
|
|
||||||
{
|
{
|
||||||
printf ("Initializing ...\n");
|
printf ("Initializing ...\n");
|
||||||
|
|
||||||
if (!process_configuration_file ()) {
|
if (!process_configuration_file ()) {
|
||||||
fprintf (stderr,"Error - Unable to complete configuration. Quitting.\n");
|
fprintf (stderr,"Error - Unable to complete configuration. Quitting.\n");
|
||||||
return (0);
|
return (0);
|
||||||
};
|
};
|
||||||
|
|
||||||
general_commands.last_command=-1; /* No commands whatsoever meanwhile */
|
general_commands.last_command=-1; /* No commands whatsoever meanwhile */
|
||||||
ext2_commands.last_command=-1;
|
ext2_commands.last_command=-1;
|
||||||
add_general_commands (); /* Add the general commands, aviable always */
|
add_general_commands (); /* Add the general commands, aviable always */
|
||||||
|
@ -62,12 +62,12 @@ int init (void)
|
||||||
current_type=NULL; /* No filesystem specific types yet */
|
current_type=NULL; /* No filesystem specific types yet */
|
||||||
|
|
||||||
remember_lifo.entries_count=0; /* Object memory is empty */
|
remember_lifo.entries_count=0; /* Object memory is empty */
|
||||||
|
|
||||||
init_windows (); /* Initialize the NCURSES interface */
|
init_windows (); /* Initialize the NCURSES interface */
|
||||||
init_readline (); /* Initialize the READLINE interface */
|
init_readline (); /* Initialize the READLINE interface */
|
||||||
init_signals (); /* Initialize the signal handlers */
|
init_signals (); /* Initialize the signal handlers */
|
||||||
write_access=0; /* Write access disabled */
|
write_access=0; /* Write access disabled */
|
||||||
|
|
||||||
strcpy (last_command_line,"help"); /* Show the help screen to the user */
|
strcpy (last_command_line,"help"); /* Show the help screen to the user */
|
||||||
dispatch ("help");
|
dispatch ("help");
|
||||||
return (1); /* Success */
|
return (1); /* Success */
|
||||||
|
@ -109,26 +109,26 @@ int set_struct_descriptors (char *file_name)
|
||||||
char current_line [500],current_word [50],*ch;
|
char current_line [500],current_word [50],*ch;
|
||||||
char variable_name [50],variable_type [20];
|
char variable_name [50],variable_type [20];
|
||||||
struct struct_descriptor *current_descriptor;
|
struct struct_descriptor *current_descriptor;
|
||||||
|
|
||||||
if ( (fp=fopen (file_name,"rt"))==NULL) {
|
if ( (fp=fopen (file_name,"rt"))==NULL) {
|
||||||
wprintw (command_win,"Error - Failed to open descriptors file %s\n",file_name);
|
wprintw (command_win,"Error - Failed to open descriptors file %s\n",file_name);
|
||||||
refresh_command_win (); return (0);
|
refresh_command_win (); return (0);
|
||||||
};
|
};
|
||||||
|
|
||||||
while (!feof (fp)) {
|
while (!feof (fp)) {
|
||||||
fgets (current_line,500,fp);
|
fgets (current_line,500,fp);
|
||||||
if (feof (fp)) break;
|
if (feof (fp)) break;
|
||||||
ch=parse_word (current_line,current_word);
|
ch=parse_word (current_line,current_word);
|
||||||
if (strcmp (current_word,"struct")==0) {
|
if (strcmp (current_word,"struct")==0) {
|
||||||
ch=parse_word (ch,current_word);
|
ch=parse_word (ch,current_word);
|
||||||
current_descriptor=add_new_descriptor (current_word);
|
current_descriptor=add_new_descriptor (current_word);
|
||||||
|
|
||||||
while (strchr (current_line,'{')==NULL) {
|
while (strchr (current_line,'{')==NULL) {
|
||||||
fgets (current_line,500,fp);
|
fgets (current_line,500,fp);
|
||||||
if (feof (fp)) break;
|
if (feof (fp)) break;
|
||||||
};
|
};
|
||||||
if (feof (fp)) break;
|
if (feof (fp)) break;
|
||||||
|
|
||||||
fgets (current_line,500,fp);
|
fgets (current_line,500,fp);
|
||||||
|
|
||||||
while (strchr (current_line,'}')==NULL) {
|
while (strchr (current_line,'}')==NULL) {
|
||||||
|
@ -147,9 +147,9 @@ int set_struct_descriptors (char *file_name)
|
||||||
add_new_variable (current_descriptor,variable_type,variable_name);
|
add_new_variable (current_descriptor,variable_type,variable_name);
|
||||||
fgets (current_line,500,fp);
|
fgets (current_line,500,fp);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ void free_struct_descriptors (void)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct struct_descriptor *ptr,*next;
|
struct struct_descriptor *ptr,*next;
|
||||||
|
|
||||||
ptr=first_type;
|
ptr=first_type;
|
||||||
while (ptr!=NULL) {
|
while (ptr!=NULL) {
|
||||||
next=ptr->next;
|
next=ptr->next;
|
||||||
|
@ -173,12 +173,12 @@ void free_user_commands (struct struct_commands *ptr)
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0;i<=ptr->last_command;i++) {
|
for (i=0;i<=ptr->last_command;i++) {
|
||||||
free (ptr->names [i]);
|
free (ptr->names [i]);
|
||||||
free (ptr->descriptions [i]);
|
free (ptr->descriptions [i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr->last_command=-1;
|
ptr->last_command=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ struct struct_descriptor *add_new_descriptor (char *name)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct struct_descriptor *ptr;
|
struct struct_descriptor *ptr;
|
||||||
|
|
||||||
ptr = malloc (sizeof (struct struct_descriptor));
|
ptr = malloc (sizeof (struct struct_descriptor));
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
printf ("Error - Can not allocate memory - Quitting\n");
|
printf ("Error - Can not allocate memory - Quitting\n");
|
||||||
|
@ -232,7 +232,7 @@ void add_new_variable (struct struct_descriptor *ptr,char *v_type,char *v_name)
|
||||||
short len=1;
|
short len=1;
|
||||||
char field_type=FIELD_TYPE_INT;
|
char field_type=FIELD_TYPE_INT;
|
||||||
struct type_table *p;
|
struct type_table *p;
|
||||||
|
|
||||||
strcpy (ptr->field_names [ptr->fields_num],v_name);
|
strcpy (ptr->field_names [ptr->fields_num],v_name);
|
||||||
ptr->field_positions [ptr->fields_num]=ptr->length;
|
ptr->field_positions [ptr->fields_num]=ptr->length;
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ void add_new_variable (struct struct_descriptor *ptr,char *v_type,char *v_name)
|
||||||
ptr->field_types [ptr->fields_num] = field_type;
|
ptr->field_types [ptr->fields_num] = field_type;
|
||||||
|
|
||||||
ptr->length+=len;
|
ptr->length+=len;
|
||||||
ptr->fields_num++;
|
ptr->fields_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_type_commands (struct struct_descriptor *ptr)
|
void fill_type_commands (struct struct_descriptor *ptr)
|
||||||
|
@ -294,7 +294,7 @@ Set specific type user commands.
|
||||||
add_user_command (&ptr->type_commands,"file","Display file data of the current inode",type_ext2_inode___file);
|
add_user_command (&ptr->type_commands,"file","Display file data of the current inode",type_ext2_inode___file);
|
||||||
add_user_command (&ptr->type_commands,"dir","Display directory data of the current inode",type_ext2_inode___dir);
|
add_user_command (&ptr->type_commands,"dir","Display directory data of the current inode",type_ext2_inode___dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp ((ptr->name),"dir")==0) {
|
if (strcmp ((ptr->name),"dir")==0) {
|
||||||
add_user_command (&ptr->type_commands,"show","Shows current directory data",type_dir___show);
|
add_user_command (&ptr->type_commands,"show","Shows current directory data",type_dir___show);
|
||||||
add_user_command (&ptr->type_commands,"inode","Returns to the inode of the current directory",type_dir___inode);
|
add_user_command (&ptr->type_commands,"inode","Returns to the inode of the current directory",type_dir___inode);
|
||||||
|
@ -307,7 +307,7 @@ Set specific type user commands.
|
||||||
add_user_command (&ptr->type_commands,"writedata","Writes the current entry to the disk",type_dir___writedata);
|
add_user_command (&ptr->type_commands,"writedata","Writes the current entry to the disk",type_dir___writedata);
|
||||||
add_user_command (&ptr->type_commands,"set","Changes a variable in the current directory entry",type_dir___set);
|
add_user_command (&ptr->type_commands,"set","Changes a variable in the current directory entry",type_dir___set);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp ((ptr->name),"ext2_super_block")==0) {
|
if (strcmp ((ptr->name),"ext2_super_block")==0) {
|
||||||
add_user_command (&ptr->type_commands,"show","Displays the super block data",type_ext2_super_block___show);
|
add_user_command (&ptr->type_commands,"show","Displays the super block data",type_ext2_super_block___show);
|
||||||
add_user_command (&ptr->type_commands,"gocopy","Move to another backup copy of the superblock",type_ext2_super_block___gocopy);
|
add_user_command (&ptr->type_commands,"gocopy","Move to another backup copy of the superblock",type_ext2_super_block___gocopy);
|
||||||
|
@ -343,30 +343,30 @@ Set specific type user commands.
|
||||||
add_user_command (&ptr->type_commands,"allocate","Allocates the current inode",type_ext2_inode_bitmap___allocate);
|
add_user_command (&ptr->type_commands,"allocate","Allocates the current inode",type_ext2_inode_bitmap___allocate);
|
||||||
add_user_command (&ptr->type_commands,"deallocate","Deallocates the current inode",type_ext2_inode_bitmap___deallocate);
|
add_user_command (&ptr->type_commands,"deallocate","Deallocates the current inode",type_ext2_inode_bitmap___deallocate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_user_command (struct struct_commands *ptr,char *name,char *description,PF callback)
|
void add_user_command (struct struct_commands *ptr,char *name,char *description,PF callback)
|
||||||
|
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
num=ptr->last_command;
|
num=ptr->last_command;
|
||||||
if (num+1==MAX_COMMANDS_NUM) {
|
if (num+1==MAX_COMMANDS_NUM) {
|
||||||
printf ("Internal Error - Can't add command %s\n",name);
|
printf ("Internal Error - Can't add command %s\n",name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr->last_command=++num;
|
ptr->last_command=++num;
|
||||||
|
|
||||||
ptr->names [num]=(char *) malloc (strlen (name)+1);
|
ptr->names [num]=(char *) malloc (strlen (name)+1);
|
||||||
strcpy (ptr->names [num],name);
|
strcpy (ptr->names [num],name);
|
||||||
|
|
||||||
if (*description!=0) {
|
if (*description!=0) {
|
||||||
ptr->descriptions [num]=(char *) malloc (strlen (description)+1);
|
ptr->descriptions [num]=(char *) malloc (strlen (description)+1);
|
||||||
strcpy (ptr->descriptions [num],description);
|
strcpy (ptr->descriptions [num],description);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr->callback [num]=callback;
|
ptr->callback [num]=callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ int set_file_system_info (void)
|
||||||
{
|
{
|
||||||
int ext2_detected=0;
|
int ext2_detected=0;
|
||||||
struct ext2_super_block *sb;
|
struct ext2_super_block *sb;
|
||||||
|
|
||||||
file_system_info.super_block_offset=1024;
|
file_system_info.super_block_offset=1024;
|
||||||
file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize;
|
file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize;
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ int set_file_system_info (void)
|
||||||
|
|
||||||
sb=&file_system_info.super_block;
|
sb=&file_system_info.super_block;
|
||||||
|
|
||||||
if (sb->s_magic == EXT2_SUPER_MAGIC)
|
if (sb->s_magic == EXT2_SUPER_MAGIC)
|
||||||
ext2_detected=1;
|
ext2_detected=1;
|
||||||
|
|
||||||
if (ext2_detected)
|
if (ext2_detected)
|
||||||
|
@ -403,7 +403,7 @@ int set_file_system_info (void)
|
||||||
|
|
||||||
if (ForceExt2 && !ext2_detected)
|
if (ForceExt2 && !ext2_detected)
|
||||||
wprintw (command_win,"Forcing extended 2 filesystem\n");
|
wprintw (command_win,"Forcing extended 2 filesystem\n");
|
||||||
|
|
||||||
if (ForceDefault || !ext2_detected)
|
if (ForceDefault || !ext2_detected)
|
||||||
wprintw (command_win,"Forcing default parameters\n");
|
wprintw (command_win,"Forcing default parameters\n");
|
||||||
|
|
||||||
|
@ -414,17 +414,17 @@ int set_file_system_info (void)
|
||||||
if (!set_struct_descriptors (Ext2Descriptors))
|
if (!set_struct_descriptors (Ext2Descriptors))
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ForceDefault && ext2_detected) {
|
if (!ForceDefault && ext2_detected) {
|
||||||
|
|
||||||
file_system_info.block_size=EXT2_MIN_BLOCK_SIZE << sb->s_log_block_size;
|
file_system_info.block_size=EXT2_MIN_BLOCK_SIZE << sb->s_log_block_size;
|
||||||
if (file_system_info.block_size == EXT2_MIN_BLOCK_SIZE)
|
if (file_system_info.block_size == EXT2_MIN_BLOCK_SIZE)
|
||||||
file_system_info.first_group_desc_offset=2*EXT2_MIN_BLOCK_SIZE;
|
file_system_info.first_group_desc_offset=2*EXT2_MIN_BLOCK_SIZE;
|
||||||
else
|
else
|
||||||
file_system_info.first_group_desc_offset=file_system_info.block_size;
|
file_system_info.first_group_desc_offset=file_system_info.block_size;
|
||||||
file_system_info.groups_count = div_ceil(sb->s_blocks_count,
|
file_system_info.groups_count = div_ceil(sb->s_blocks_count,
|
||||||
sb->s_blocks_per_group);
|
sb->s_blocks_per_group);
|
||||||
|
|
||||||
file_system_info.inodes_per_block=file_system_info.block_size/sizeof (struct ext2_inode);
|
file_system_info.inodes_per_block=file_system_info.block_size/sizeof (struct ext2_inode);
|
||||||
file_system_info.blocks_per_group=sb->s_inodes_per_group/file_system_info.inodes_per_block;
|
file_system_info.blocks_per_group=sb->s_inodes_per_group/file_system_info.inodes_per_block;
|
||||||
file_system_info.no_blocks_in_group=sb->s_blocks_per_group;
|
file_system_info.no_blocks_in_group=sb->s_blocks_per_group;
|
||||||
|
@ -433,10 +433,10 @@ int set_file_system_info (void)
|
||||||
|
|
||||||
else {
|
else {
|
||||||
file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize;
|
file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize;
|
||||||
file_system_info.block_size=DefaultBlockSize;
|
file_system_info.block_size=DefaultBlockSize;
|
||||||
file_system_info.no_blocks_in_group=DefaultBlocksInGroup;
|
file_system_info.no_blocks_in_group=DefaultBlocksInGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_system_info.file_system_size > 2147483647) {
|
if (file_system_info.file_system_size > 2147483647) {
|
||||||
wprintw (command_win,"Sorry, filesystems bigger than 2 GB are currently not supported\n");
|
wprintw (command_win,"Sorry, filesystems bigger than 2 GB are currently not supported\n");
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -458,17 +458,17 @@ void init_signals (void)
|
||||||
signal (SIGWINCH, signal_SIGWINCH_handler); /* Catch SIGWINCH */
|
signal (SIGWINCH, signal_SIGWINCH_handler); /* Catch SIGWINCH */
|
||||||
signal (SIGTERM, signal_SIGTERM_handler);
|
signal (SIGTERM, signal_SIGTERM_handler);
|
||||||
signal (SIGSEGV, signal_SIGSEGV_handler);
|
signal (SIGSEGV, signal_SIGSEGV_handler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void signal_SIGWINCH_handler (int sig_num)
|
void signal_SIGWINCH_handler (int sig_num)
|
||||||
|
|
||||||
{
|
{
|
||||||
redraw_request=1; /* We will handle it in main.c */
|
redraw_request=1; /* We will handle it in main.c */
|
||||||
|
|
||||||
/* Reset signal handler */
|
/* Reset signal handler */
|
||||||
signal (SIGWINCH, signal_SIGWINCH_handler);
|
signal (SIGWINCH, signal_SIGWINCH_handler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void signal_SIGTERM_handler (int sig_num)
|
void signal_SIGTERM_handler (int sig_num)
|
||||||
|
@ -496,12 +496,12 @@ int process_configuration_file (void)
|
||||||
|
|
||||||
strcpy (buffer, ETC_DIR);
|
strcpy (buffer, ETC_DIR);
|
||||||
strcat (buffer,"/ext2ed.conf");
|
strcat (buffer,"/ext2ed.conf");
|
||||||
|
|
||||||
if ((fp=fopen (buffer,"rt"))==NULL) {
|
if ((fp=fopen (buffer,"rt"))==NULL) {
|
||||||
fprintf (stderr,"Error - Unable to open configuration file %s\n",buffer);
|
fprintf (stderr,"Error - Unable to open configuration file %s\n",buffer);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (get_next_option (fp,option,value)) {
|
while (get_next_option (fp,option,value)) {
|
||||||
if (strcasecmp (option,"Ext2Descriptors")==0) {
|
if (strcasecmp (option,"Ext2Descriptors")==0) {
|
||||||
strcpy (Ext2Descriptors,value);
|
strcpy (Ext2Descriptors,value);
|
||||||
|
@ -581,7 +581,7 @@ int process_configuration_file (void)
|
||||||
fclose (fp);return (0);
|
fclose (fp);return (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
fprintf (stderr,"Error - Unknown option: %s\n",option);
|
fprintf (stderr,"Error - Unknown option: %s\n",option);
|
||||||
fclose (fp);return (0);
|
fclose (fp);return (0);
|
||||||
|
@ -598,13 +598,13 @@ int get_next_option (FILE *fp,char *option,char *value)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char buffer [600];
|
char buffer [600];
|
||||||
|
|
||||||
if (feof (fp)) return (0);
|
if (feof (fp)) return (0);
|
||||||
do{
|
do{
|
||||||
if (feof (fp)) return (0);
|
if (feof (fp)) return (0);
|
||||||
fgets (buffer,500,fp);
|
fgets (buffer,500,fp);
|
||||||
} while (buffer [0]=='#' || buffer [0]=='\n');
|
} while (buffer [0]=='#' || buffer [0]=='\n');
|
||||||
|
|
||||||
ptr=parse_word (buffer,option);
|
ptr=parse_word (buffer,option);
|
||||||
ptr=parse_word (ptr,value);
|
ptr=parse_word (ptr,value);
|
||||||
return (1);
|
return (1);
|
||||||
|
@ -618,15 +618,15 @@ void check_mounted (char *name)
|
||||||
char current_line [500],current_word [200];
|
char current_line [500],current_word [200];
|
||||||
|
|
||||||
mounted=0;
|
mounted=0;
|
||||||
|
|
||||||
if ( (fp=fopen ("/etc/mtab","rt"))==NULL) {
|
if ( (fp=fopen ("/etc/mtab","rt"))==NULL) {
|
||||||
wprintw (command_win,"Error - Failed to open /etc/mtab. Assuming filesystem is mounted.\n");
|
wprintw (command_win,"Error - Failed to open /etc/mtab. Assuming filesystem is mounted.\n");
|
||||||
refresh_command_win ();mounted=1;return;
|
refresh_command_win ();mounted=1;return;
|
||||||
};
|
};
|
||||||
|
|
||||||
while (!feof (fp)) {
|
while (!feof (fp)) {
|
||||||
fgets (current_line,500,fp);
|
fgets (current_line,500,fp);
|
||||||
if (feof (fp)) break;
|
if (feof (fp)) break;
|
||||||
ptr=parse_word (current_line,current_word);
|
ptr=parse_word (current_line,current_word);
|
||||||
if (strcasecmp (current_word,name)==0) {
|
if (strcasecmp (current_word,name)==0) {
|
||||||
mounted=1;fclose (fp);return;
|
mounted=1;fclose (fp);return;
|
||||||
|
@ -634,6 +634,6 @@ void check_mounted (char *name)
|
||||||
};
|
};
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ void type_ext2_inode___prev (char *command_line)
|
||||||
if (entry_num-mult+1>0) {
|
if (entry_num-mult+1>0) {
|
||||||
device_offset-=sizeof (struct ext2_inode)*mult;
|
device_offset-=sizeof (struct ext2_inode)*mult;
|
||||||
entry_num-=mult;
|
entry_num-=mult;
|
||||||
|
|
||||||
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
|
||||||
strcpy (buffer,"show");dispatch (buffer);
|
strcpy (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void type_ext2_inode___prev (char *command_line)
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win ();
|
wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry_num==0) {
|
if (entry_num==0) {
|
||||||
wprintw (command_win,"Reached first inode in current group descriptor\n");
|
wprintw (command_win,"Reached first inode in current group descriptor\n");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
|
@ -77,7 +77,7 @@ void type_ext2_inode___next (char *command_line)
|
||||||
struct ext2_group_desc desc;
|
struct ext2_group_desc desc;
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
|
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
mult=atol (buffer);
|
mult=atol (buffer);
|
||||||
|
@ -99,7 +99,7 @@ void type_ext2_inode___next (char *command_line)
|
||||||
if (entry_num+mult-1<last_entry) {
|
if (entry_num+mult-1<last_entry) {
|
||||||
device_offset+=sizeof (struct ext2_inode)*mult;
|
device_offset+=sizeof (struct ext2_inode)*mult;
|
||||||
entry_num+=mult;
|
entry_num+=mult;
|
||||||
|
|
||||||
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer);
|
||||||
strcpy (buffer,"show");dispatch (buffer);
|
strcpy (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ void type_ext2_inode___next (char *command_line)
|
||||||
else {
|
else {
|
||||||
wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win ();
|
wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry_num==last_entry) {
|
if (entry_num==last_entry) {
|
||||||
wprintw (command_win,"Reached last inode in current group descriptor\n");
|
wprintw (command_win,"Reached last inode in current group descriptor\n");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
|
@ -119,10 +119,10 @@ void type_ext2_inode___show (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct ext2_inode *inode_ptr;
|
struct ext2_inode *inode_ptr;
|
||||||
|
|
||||||
unsigned short temp;
|
unsigned short temp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
long group_num,group_offset,entry_num,block_num,first_entry,last_entry,inode_num;
|
long group_num,group_offset,entry_num,block_num,first_entry,last_entry,inode_num;
|
||||||
struct ext2_group_desc desc;
|
struct ext2_group_desc desc;
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ void type_ext2_inode___show (char *command_line)
|
||||||
wprintw (show_pad,"r");
|
wprintw (show_pad,"r");
|
||||||
else
|
else
|
||||||
wprintw (show_pad,"-");
|
wprintw (show_pad,"-");
|
||||||
|
|
||||||
if (temp & 2)
|
if (temp & 2)
|
||||||
wprintw (show_pad,"w");
|
wprintw (show_pad,"w");
|
||||||
else
|
else
|
||||||
|
@ -168,7 +168,7 @@ void type_ext2_inode___show (char *command_line)
|
||||||
|
|
||||||
wmove (show_pad,10,40);
|
wmove (show_pad,10,40);
|
||||||
temp=inode_ptr->i_flags;
|
temp=inode_ptr->i_flags;
|
||||||
|
|
||||||
if (temp & EXT2_SECRM_FL)
|
if (temp & EXT2_SECRM_FL)
|
||||||
wprintw (show_pad,"s");
|
wprintw (show_pad,"s");
|
||||||
else
|
else
|
||||||
|
@ -204,14 +204,14 @@ void type_ext2_inode___show (char *command_line)
|
||||||
wprintw (show_pad,"d");
|
wprintw (show_pad,"d");
|
||||||
else
|
else
|
||||||
wprintw (show_pad,"-");
|
wprintw (show_pad,"-");
|
||||||
|
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
|
|
||||||
wmove (show_win,1,0);
|
wmove (show_win,1,0);
|
||||||
|
|
||||||
wprintw (show_win,"Inode %ld of %ld. Entry %ld of %ld in group descriptor %ld.\n"
|
wprintw (show_win,"Inode %ld of %ld. Entry %ld of %ld in group descriptor %ld.\n"
|
||||||
,inode_num,file_system_info.super_block.s_inodes_count,entry_num,last_entry,group_num);
|
,inode_num,file_system_info.super_block.s_inodes_count,entry_num,last_entry,group_num);
|
||||||
|
|
||||||
wprintw (show_win,"Inode type: ");
|
wprintw (show_win,"Inode type: ");
|
||||||
|
|
||||||
if (inode_num < EXT2_GOOD_OLD_FIRST_INO) {
|
if (inode_num < EXT2_GOOD_OLD_FIRST_INO) {
|
||||||
|
@ -241,7 +241,7 @@ void type_ext2_inode___show (char *command_line)
|
||||||
}
|
}
|
||||||
if (type_data.u.t_ext2_inode.i_mode==0)
|
if (type_data.u.t_ext2_inode.i_mode==0)
|
||||||
wprintw (show_win,"Free. ");
|
wprintw (show_win,"Free. ");
|
||||||
|
|
||||||
if (S_ISREG (type_data.u.t_ext2_inode.i_mode))
|
if (S_ISREG (type_data.u.t_ext2_inode.i_mode))
|
||||||
wprintw (show_win,"File. ");
|
wprintw (show_win,"File. ");
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ void type_ext2_inode___show (char *command_line)
|
||||||
if (inode_ptr->i_size <= 60)
|
if (inode_ptr->i_size <= 60)
|
||||||
wprintw (show_pad,"-> %s",(char *) &type_data.u.t_ext2_inode.i_block [0]);
|
wprintw (show_pad,"-> %s",(char *) &type_data.u.t_ext2_inode.i_block [0]);
|
||||||
else
|
else
|
||||||
wprintw (show_pad,"Slow symbolic link\n");
|
wprintw (show_pad,"Slow symbolic link\n");
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ void type_ext2_inode___show (char *command_line)
|
||||||
wprintw (show_win,"Block device. ");
|
wprintw (show_win,"Block device. ");
|
||||||
|
|
||||||
wprintw (show_win,"\n");refresh_show_win ();
|
wprintw (show_win,"\n");refresh_show_win ();
|
||||||
|
|
||||||
if (entry_num==last_entry) {
|
if (entry_num==last_entry) {
|
||||||
wprintw (command_win,"Reached last inode in current group descriptor\n");
|
wprintw (command_win,"Reached last inode in current group descriptor\n");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
|
@ -305,7 +305,7 @@ void type_ext2_inode___entry (char *command_line)
|
||||||
sprintf (buffer,"next %ld",wanted_entry-entry_num);
|
sprintf (buffer,"next %ld",wanted_entry-entry_num);
|
||||||
dispatch (buffer);
|
dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (wanted_entry < entry_num) {
|
else if (wanted_entry < entry_num) {
|
||||||
sprintf (buffer,"prev %ld",entry_num-wanted_entry);
|
sprintf (buffer,"prev %ld",entry_num-wanted_entry);
|
||||||
dispatch (buffer);
|
dispatch (buffer);
|
||||||
|
@ -316,12 +316,12 @@ void type_ext2_inode___group (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
char buffer [80];
|
char buffer [80];
|
||||||
|
|
||||||
long group_num,group_offset;
|
long group_num,group_offset;
|
||||||
|
|
||||||
group_num=inode_offset_to_group_num (device_offset);
|
group_num=inode_offset_to_group_num (device_offset);
|
||||||
group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
|
group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
|
||||||
|
|
||||||
sprintf (buffer,"setoffset %ld",group_offset);dispatch (buffer);
|
sprintf (buffer,"setoffset %ld",group_offset);dispatch (buffer);
|
||||||
sprintf (buffer,"settype ext2_group_desc");dispatch (buffer);
|
sprintf (buffer,"settype ext2_group_desc");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
@ -330,17 +330,17 @@ void type_ext2_inode___file (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
char buffer [80];
|
char buffer [80];
|
||||||
|
|
||||||
if (!S_ISREG (type_data.u.t_ext2_inode.i_mode)) {
|
if (!S_ISREG (type_data.u.t_ext2_inode.i_mode)) {
|
||||||
wprintw (command_win,"Error - Inode type is not file\n");refresh_command_win ();
|
wprintw (command_win,"Error - Inode type is not file\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!init_file_info ()) {
|
if (!init_file_info ()) {
|
||||||
wprintw (command_win,"Error - Unable to show file\n");refresh_command_win ();
|
wprintw (command_win,"Error - Unable to show file\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (buffer,"settype file");dispatch (buffer);
|
sprintf (buffer,"settype file");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,21 +348,21 @@ void type_ext2_inode___dir (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
char buffer [80];
|
char buffer [80];
|
||||||
|
|
||||||
if (!S_ISDIR (type_data.u.t_ext2_inode.i_mode)) {
|
if (!S_ISDIR (type_data.u.t_ext2_inode.i_mode)) {
|
||||||
wprintw (command_win,"Error - Inode type is not directory\n");refresh_command_win ();
|
wprintw (command_win,"Error - Inode type is not directory\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It is very important to init first_file_info first, as search_dir_entries relies on it */
|
/* It is very important to init first_file_info first, as search_dir_entries relies on it */
|
||||||
|
|
||||||
if (!init_dir_info (&first_file_info)) {
|
if (!init_dir_info (&first_file_info)) {
|
||||||
wprintw (command_win,"Error - Unable to show directory\n");refresh_command_win ();
|
wprintw (command_win,"Error - Unable to show directory\n");refresh_command_win ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_info=first_file_info;
|
file_info=first_file_info;
|
||||||
|
|
||||||
sprintf (buffer,"settype dir");dispatch (buffer);
|
sprintf (buffer,"settype dir");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,9 +371,9 @@ long inode_offset_to_group_num (long inode_offset)
|
||||||
{
|
{
|
||||||
int found=0;
|
int found=0;
|
||||||
struct ext2_group_desc desc;
|
struct ext2_group_desc desc;
|
||||||
|
|
||||||
long block_num,group_offset,group_num;
|
long block_num,group_offset,group_num;
|
||||||
|
|
||||||
block_num=inode_offset/file_system_info.block_size;
|
block_num=inode_offset/file_system_info.block_size;
|
||||||
|
|
||||||
group_offset=file_system_info.first_group_desc_offset;
|
group_offset=file_system_info.first_group_desc_offset;
|
||||||
|
@ -387,14 +387,14 @@ long inode_offset_to_group_num (long inode_offset)
|
||||||
group_offset+=sizeof (struct ext2_group_desc);
|
group_offset+=sizeof (struct ext2_group_desc);
|
||||||
group_num=(group_offset-file_system_info.first_group_desc_offset)/sizeof (struct ext2_group_desc);
|
group_num=(group_offset-file_system_info.first_group_desc_offset)/sizeof (struct ext2_group_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
return (group_num);
|
return (group_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
long int inode_offset_to_inode_num (long inode_offset)
|
long int inode_offset_to_inode_num (long inode_offset)
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ long int inode_offset_to_inode_num (long inode_offset)
|
||||||
first_entry=0;last_entry=file_system_info.super_block.s_inodes_per_group-1;
|
first_entry=0;last_entry=file_system_info.super_block.s_inodes_per_group-1;
|
||||||
inode_num=group_num*file_system_info.super_block.s_inodes_per_group+1;
|
inode_num=group_num*file_system_info.super_block.s_inodes_per_group+1;
|
||||||
inode_num+=entry_num;
|
inode_num+=entry_num;
|
||||||
|
|
||||||
return (inode_num);
|
return (inode_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ long int inode_num_to_inode_offset (long inode_num)
|
||||||
struct ext2_group_desc desc;
|
struct ext2_group_desc desc;
|
||||||
|
|
||||||
inode_num--;
|
inode_num--;
|
||||||
|
|
||||||
group_num=inode_num/file_system_info.super_block.s_inodes_per_group;
|
group_num=inode_num/file_system_info.super_block.s_inodes_per_group;
|
||||||
inode_entry=inode_num%file_system_info.super_block.s_inodes_per_group;
|
inode_entry=inode_num%file_system_info.super_block.s_inodes_per_group;
|
||||||
group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
|
group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc);
|
||||||
|
|
|
@ -28,7 +28,7 @@ void type_ext2_inode_bitmap___entry (char *command_line)
|
||||||
{
|
{
|
||||||
unsigned long entry_num;
|
unsigned long entry_num;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
||||||
|
@ -36,11 +36,11 @@ void type_ext2_inode_bitmap___entry (char *command_line)
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
entry_num=atol (buffer);
|
entry_num=atol (buffer);
|
||||||
|
|
||||||
if (entry_num >= file_system_info.super_block.s_inodes_per_group) {
|
if (entry_num >= file_system_info.super_block.s_inodes_per_group) {
|
||||||
wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inode_bitmap_info.entry_num=entry_num;
|
inode_bitmap_info.entry_num=entry_num;
|
||||||
strcpy (buffer,"show");dispatch (buffer);
|
strcpy (buffer,"show");dispatch (buffer);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ void type_ext2_inode_bitmap___next (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_offset=1;
|
long entry_offset=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
@ -66,7 +66,7 @@ void type_ext2_inode_bitmap___prev (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_offset=1;
|
long entry_offset=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
@ -82,24 +82,24 @@ void type_ext2_inode_bitmap___allocate (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_num,num=1;
|
long entry_num,num=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
num=atol (buffer);
|
num=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_num=inode_bitmap_info.entry_num;
|
entry_num=inode_bitmap_info.entry_num;
|
||||||
if (num > file_system_info.super_block.s_inodes_per_group-entry_num) {
|
if (num > file_system_info.super_block.s_inodes_per_group-entry_num) {
|
||||||
wprintw (command_win,"Error - There aren't that much inodes in the group\n");
|
wprintw (command_win,"Error - There aren't that much inodes in the group\n");
|
||||||
refresh_command_win ();return;
|
refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (num) {
|
while (num) {
|
||||||
allocate_inode (entry_num);
|
allocate_inode (entry_num);
|
||||||
num--;entry_num++;
|
num--;entry_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch ("show");
|
dispatch ("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,24 +108,24 @@ void type_ext2_inode_bitmap___deallocate (char *command_line)
|
||||||
{
|
{
|
||||||
long entry_num,num=1;
|
long entry_num,num=1;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr!=0) {
|
if (*ptr!=0) {
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
num=atol (buffer);
|
num=atol (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_num=inode_bitmap_info.entry_num;
|
entry_num=inode_bitmap_info.entry_num;
|
||||||
if (num > file_system_info.super_block.s_inodes_per_group-entry_num) {
|
if (num > file_system_info.super_block.s_inodes_per_group-entry_num) {
|
||||||
wprintw (command_win,"Error - There aren't that much inodes in the group\n");
|
wprintw (command_win,"Error - There aren't that much inodes in the group\n");
|
||||||
refresh_command_win ();return;
|
refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (num) {
|
while (num) {
|
||||||
deallocate_inode (entry_num);
|
deallocate_inode (entry_num);
|
||||||
num--;entry_num++;
|
num--;entry_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch ("show");
|
dispatch ("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void allocate_inode (long entry_num)
|
||||||
{
|
{
|
||||||
unsigned char bit_mask=1;
|
unsigned char bit_mask=1;
|
||||||
int byte_offset,j;
|
int byte_offset,j;
|
||||||
|
|
||||||
byte_offset=entry_num/8;
|
byte_offset=entry_num/8;
|
||||||
for (j=0;j<entry_num%8;j++)
|
for (j=0;j<entry_num%8;j++)
|
||||||
bit_mask*=2;
|
bit_mask*=2;
|
||||||
|
@ -147,12 +147,12 @@ void deallocate_inode (long entry_num)
|
||||||
{
|
{
|
||||||
unsigned char bit_mask=1;
|
unsigned char bit_mask=1;
|
||||||
int byte_offset,j;
|
int byte_offset,j;
|
||||||
|
|
||||||
byte_offset=entry_num/8;
|
byte_offset=entry_num/8;
|
||||||
for (j=0;j<entry_num%8;j++)
|
for (j=0;j<entry_num%8;j++)
|
||||||
bit_mask*=2;
|
bit_mask*=2;
|
||||||
bit_mask^=0xff;
|
bit_mask^=0xff;
|
||||||
|
|
||||||
type_data.u.buffer [byte_offset] &= bit_mask;
|
type_data.u.buffer [byte_offset] &= bit_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void type_ext2_inode_bitmap___show (char *command_line)
|
||||||
|
|
||||||
ptr=type_data.u.buffer;
|
ptr=type_data.u.buffer;
|
||||||
show_pad_info.line=0;show_pad_info.max_line=-1;
|
show_pad_info.line=0;show_pad_info.max_line=-1;
|
||||||
|
|
||||||
wmove (show_pad,0,0);
|
wmove (show_pad,0,0);
|
||||||
for (i=0,entry_num=0;i<file_system_info.super_block.s_inodes_per_group/8;i++,ptr++) {
|
for (i=0,entry_num=0;i<file_system_info.super_block.s_inodes_per_group/8;i++,ptr++) {
|
||||||
for (j=1;j<=128;j*=2) {
|
for (j=1;j<=128;j*=2) {
|
||||||
|
@ -190,13 +190,13 @@ void type_ext2_inode_bitmap___show (char *command_line)
|
||||||
show_pad_info.max_line++;
|
show_pad_info.max_line++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i%8!=7) {
|
if (i%8!=7) {
|
||||||
wprintw (show_pad,"\n");
|
wprintw (show_pad,"\n");
|
||||||
show_pad_info.max_line++;
|
show_pad_info.max_line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
show_info ();
|
show_info ();
|
||||||
wmove (show_win,1,0);wprintw (show_win,"Inode bitmap of block group %ld\n",inode_bitmap_info.group_num);
|
wmove (show_win,1,0);wprintw (show_win,"Inode bitmap of block group %ld\n",inode_bitmap_info.group_num);
|
||||||
|
|
||||||
|
|
102
ext2ed/main.c
102
ext2ed/main.c
|
@ -71,7 +71,7 @@ char device_name [80]; /* The location of the filesystem */
|
||||||
FILE *device_handle=NULL; /* This is passed to the fopen / fread ... commands */
|
FILE *device_handle=NULL; /* This is passed to the fopen / fread ... commands */
|
||||||
long device_offset; /* The current position in the filesystem */
|
long device_offset; /* The current position in the filesystem */
|
||||||
/* Note that we have a 2 GB limitation */
|
/* Note that we have a 2 GB limitation */
|
||||||
|
|
||||||
int mounted=0; /* This is set when we find that the filesystem is mounted */
|
int mounted=0; /* This is set when we find that the filesystem is mounted */
|
||||||
|
|
||||||
struct struct_commands general_commands,ext2_commands; /* Used to define the general and ext2 commands */
|
struct struct_commands general_commands,ext2_commands; /* Used to define the general and ext2 commands */
|
||||||
|
@ -98,7 +98,7 @@ int main (int argc, char **argv)
|
||||||
int write_priv = 0;
|
int write_priv = 0;
|
||||||
int c;
|
int c;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (!init ())
|
if (!init ())
|
||||||
return (1);
|
return (1);
|
||||||
while ((c = getopt (argc, argv, "w")) != EOF) {
|
while ((c = getopt (argc, argv, "w")) != EOF) {
|
||||||
|
@ -119,7 +119,7 @@ int main (int argc, char **argv)
|
||||||
set_device(buf);
|
set_device(buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
if (write_priv) {
|
if (write_priv) {
|
||||||
wprintw (command_win,"\n");
|
wprintw (command_win,"\n");
|
||||||
enable_write("enable_write");
|
enable_write("enable_write");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ int command_read_key()
|
||||||
key = 0;
|
key = 0;
|
||||||
kill(getpid(), SIGTSTP);
|
kill(getpid(), SIGTSTP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_NPAGE:
|
case KEY_NPAGE:
|
||||||
pgdn("");
|
pgdn("");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
|
@ -161,7 +161,7 @@ int command_read_key()
|
||||||
case ERR:
|
case ERR:
|
||||||
key = 0;
|
key = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
key = '\b';
|
key = '\b';
|
||||||
}
|
}
|
||||||
|
@ -203,10 +203,10 @@ void parser (void)
|
||||||
cbreak();
|
cbreak();
|
||||||
keypad(command_win, 1);
|
keypad(command_win, 1);
|
||||||
wtimeout(command_win, 100);
|
wtimeout(command_win, 100);
|
||||||
|
|
||||||
rl_getc_function = rl_getc_replacement;
|
rl_getc_function = rl_getc_replacement;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
/* Terminal screen size has changed */
|
/* Terminal screen size has changed */
|
||||||
if (redraw_request) {
|
if (redraw_request) {
|
||||||
|
@ -228,7 +228,7 @@ void parser (void)
|
||||||
* time.
|
* time.
|
||||||
*/
|
*/
|
||||||
mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0);
|
mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0);
|
||||||
|
|
||||||
/* echo (); */
|
/* echo (); */
|
||||||
ptr=readline ("ext2ed > ");
|
ptr=readline ("ext2ed > ");
|
||||||
/* noecho (); */
|
/* noecho (); */
|
||||||
|
@ -239,15 +239,15 @@ void parser (void)
|
||||||
* XXX WHY???
|
* XXX WHY???
|
||||||
*/
|
*/
|
||||||
strcpy (command_line,ptr);
|
strcpy (command_line,ptr);
|
||||||
free (ptr);
|
free (ptr);
|
||||||
|
|
||||||
if (*command_line != 0)
|
if (*command_line != 0)
|
||||||
add_history (command_line);
|
add_history (command_line);
|
||||||
|
|
||||||
/* If only enter was pressed, recall the last command */
|
/* If only enter was pressed, recall the last command */
|
||||||
if (*command_line==0)
|
if (*command_line==0)
|
||||||
strcpy (command_line,last_command_line);
|
strcpy (command_line,last_command_line);
|
||||||
|
|
||||||
/* Emulate readline's actions for ncurses */
|
/* Emulate readline's actions for ncurses */
|
||||||
mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0);
|
mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0);
|
||||||
werase (command_win);
|
werase (command_win);
|
||||||
|
@ -261,7 +261,7 @@ void parser (void)
|
||||||
|
|
||||||
/* And call dispatch to do the actual job */
|
/* And call dispatch to do the actual job */
|
||||||
quit=dispatch (command_line);
|
quit=dispatch (command_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void read_line(char * foo) {
|
void read_line(char * foo) {
|
||||||
|
@ -321,13 +321,13 @@ void parser (void)
|
||||||
if (*command_line==0)
|
if (*command_line==0)
|
||||||
strcpy (command_line,last_command_line);
|
strcpy (command_line,last_command_line);
|
||||||
|
|
||||||
mvcur (-1,-1,LINES-COMMAND_WIN_LINES + 1,0);
|
mvcur (-1,-1,LINES-COMMAND_WIN_LINES + 1,0);
|
||||||
|
|
||||||
strcpy (last_command_line,command_line); /* Save this command in our tiny cache */
|
strcpy (last_command_line,command_line); /* Save this command in our tiny cache */
|
||||||
|
|
||||||
/* And call dispatch to do the actual job */
|
/* And call dispatch to do the actual job */
|
||||||
quit=dispatch (command_line);
|
quit=dispatch (command_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -335,35 +335,35 @@ void parser (void)
|
||||||
/*
|
/*
|
||||||
* This is a very important function. Its task is to recieve a command
|
* This is a very important function. Its task is to recieve a command
|
||||||
* name and link it to a C function. There are three types of commands:
|
* name and link it to a C function. There are three types of commands:
|
||||||
*
|
*
|
||||||
* 1. General commands - Always available and accessed through
|
* 1. General commands - Always available and accessed through
|
||||||
* general_commands.
|
* general_commands.
|
||||||
* 2. Ext2 specific commands - Available when editing an ext2
|
* 2. Ext2 specific commands - Available when editing an ext2
|
||||||
* filesystem, accessed through ext2_commands.
|
* filesystem, accessed through ext2_commands.
|
||||||
* 3. Type specific commands - Those are changing according to the
|
* 3. Type specific commands - Those are changing according to the
|
||||||
* current type. The global variable current_type points to the
|
* current type. The global variable current_type points to the
|
||||||
* current object definition (of type struct_descriptor). In it, the
|
* current object definition (of type struct_descriptor). In it, the
|
||||||
* struct_commands entry contains the type specific commands links.
|
* struct_commands entry contains the type specific commands links.
|
||||||
*
|
*
|
||||||
* Overriding is an important feature - Much like in C++ : The same
|
* Overriding is an important feature - Much like in C++ : The same
|
||||||
* command name can dispatch to different functions. The overriding
|
* command name can dispatch to different functions. The overriding
|
||||||
* priority is 3,2,1; That is - A type specific command will always
|
* priority is 3,2,1; That is - A type specific command will always
|
||||||
* override a general command. This is used through the program to
|
* override a general command. This is used through the program to
|
||||||
* allow fine tuned operation.
|
* allow fine tuned operation.
|
||||||
*
|
*
|
||||||
* When an handling function is found, it is called along with the
|
* When an handling function is found, it is called along with the
|
||||||
* command line that was passed to us. The handling function is then
|
* command line that was passed to us. The handling function is then
|
||||||
* free to interpert the arguments in its own style.
|
* free to interpert the arguments in its own style.
|
||||||
*/
|
*/
|
||||||
int dispatch (char *command_line)
|
int dispatch (char *command_line)
|
||||||
{
|
{
|
||||||
int i,found=0;
|
int i,found=0;
|
||||||
|
|
||||||
char command [80];
|
char command [80];
|
||||||
|
|
||||||
parse_word (command_line,command);
|
parse_word (command_line,command);
|
||||||
|
|
||||||
if (strcasecmp (command,"quit")==0) return (1);
|
if (strcasecmp (command,"quit")==0) return (1);
|
||||||
|
|
||||||
/* 1. Search for type specific commands FIRST - Allows
|
/* 1. Search for type specific commands FIRST - Allows
|
||||||
overriding of a general command */
|
overriding of a general command */
|
||||||
|
@ -388,9 +388,9 @@ int dispatch (char *command_line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 3. If not found, search the general commands */
|
/* 3. If not found, search the general commands */
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
for (i=0;i<=general_commands.last_command && !found;i++) {
|
for (i=0;i<=general_commands.last_command && !found;i++) {
|
||||||
if (strcasecmp (command,general_commands.names [i])==0) {
|
if (strcasecmp (command,general_commands.names [i])==0) {
|
||||||
|
@ -400,18 +400,18 @@ int dispatch (char *command_line)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4. If not found, issue an error message and return */
|
/* 4. If not found, issue an error message and return */
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
wprintw (command_win,"Error: Unknown command\n");
|
wprintw (command_win,"Error: Unknown command\n");
|
||||||
refresh_command_win ();
|
refresh_command_win ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* This function copies the next word in source to the variable dest,
|
* This function copies the next word in source to the variable dest,
|
||||||
* ignoring whitespaces. It returns a pointer to the next word in
|
* ignoring whitespaces. It returns a pointer to the next word in
|
||||||
* source. It is used to split the command line into command and arguments.
|
* source. It is used to split the command line into command and arguments.
|
||||||
|
@ -419,12 +419,12 @@ int dispatch (char *command_line)
|
||||||
char *parse_word (char *source,char *dest)
|
char *parse_word (char *source,char *dest)
|
||||||
{
|
{
|
||||||
char ch,*source_ptr,*target_ptr;
|
char ch,*source_ptr,*target_ptr;
|
||||||
|
|
||||||
if (*source==0) {
|
if (*source==0) {
|
||||||
*dest=0;
|
*dest=0;
|
||||||
return (source);
|
return (source);
|
||||||
};
|
};
|
||||||
|
|
||||||
source_ptr=source;target_ptr=dest;
|
source_ptr=source;target_ptr=dest;
|
||||||
do {
|
do {
|
||||||
ch=*source_ptr++;
|
ch=*source_ptr++;
|
||||||
|
@ -432,7 +432,7 @@ char *parse_word (char *source,char *dest)
|
||||||
|
|
||||||
while (ch>' ' && ch<='z') {
|
while (ch>' ' && ch<='z') {
|
||||||
*target_ptr++=ch;
|
*target_ptr++=ch;
|
||||||
ch=*source_ptr++;
|
ch=*source_ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*target_ptr=0;
|
*target_ptr=0;
|
||||||
|
@ -448,23 +448,23 @@ char *parse_word (char *source,char *dest)
|
||||||
/*
|
/*
|
||||||
* text is the partial command entered by the user; We assume that it
|
* text is the partial command entered by the user; We assume that it
|
||||||
* is a part of a command - I didn't write code for smarter completion.
|
* is a part of a command - I didn't write code for smarter completion.
|
||||||
*
|
*
|
||||||
* The state variable is an index which tells us how many possible
|
* The state variable is an index which tells us how many possible
|
||||||
* completions we already returned to readline.
|
* completions we already returned to readline.
|
||||||
*
|
*
|
||||||
* We return only one possible completion or (char *) NULL if there
|
* We return only one possible completion or (char *) NULL if there
|
||||||
* are no more completions. This function will be called by readline
|
* are no more completions. This function will be called by readline
|
||||||
* over and over until we tell it to stop.
|
* over and over until we tell it to stop.
|
||||||
*
|
*
|
||||||
* While scanning for possible completions, we use the same priority
|
* While scanning for possible completions, we use the same priority
|
||||||
* definition which was used in dispatch.
|
* definition which was used in dispatch.
|
||||||
*/
|
*/
|
||||||
#if HAVE_READLINE
|
#if HAVE_READLINE
|
||||||
char *complete_command (char *text,int state)
|
char *complete_command (char *text,int state)
|
||||||
{
|
{
|
||||||
int state_index=-1;
|
int state_index=-1;
|
||||||
int i,len;
|
int i,len;
|
||||||
|
|
||||||
len=strlen (text);
|
len=strlen (text);
|
||||||
|
|
||||||
/* Is the command type specific ? */
|
/* Is the command type specific ? */
|
||||||
|
@ -480,7 +480,7 @@ char *complete_command (char *text,int state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No, pehaps ext2 specific command then ? */
|
/* No, pehaps ext2 specific command then ? */
|
||||||
|
|
||||||
for (i=0;i<=ext2_commands.last_command;i++) {
|
for (i=0;i<=ext2_commands.last_command;i++) {
|
||||||
if (strncmp (ext2_commands.names [i],text,len)==0) {
|
if (strncmp (ext2_commands.names [i],text,len)==0) {
|
||||||
state_index++;
|
state_index++;
|
||||||
|
@ -489,9 +489,9 @@ char *complete_command (char *text,int state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Check for a general command */
|
/* Check for a general command */
|
||||||
|
|
||||||
for (i=0;i<=general_commands.last_command;i++) {
|
for (i=0;i<=general_commands.last_command;i++) {
|
||||||
if (strncmp (general_commands.names [i],text,len)==0) {
|
if (strncmp (general_commands.names [i],text,len)==0) {
|
||||||
state_index++;
|
state_index++;
|
||||||
|
@ -501,27 +501,27 @@ char *complete_command (char *text,int state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* quit is handled differently */
|
/* quit is handled differently */
|
||||||
|
|
||||||
if (strncmp ("quit",text,len)==0) {
|
if (strncmp ("quit",text,len)==0) {
|
||||||
state_index++;
|
state_index++;
|
||||||
if (state==state_index)
|
if (state==state_index)
|
||||||
return (dupstr ("quit"));
|
return (dupstr ("quit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No more completions */
|
/* No more completions */
|
||||||
|
|
||||||
return ((char *) NULL);
|
return ((char *) NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Nothing special - Just allocates enough space and copy the string.
|
* Nothing special - Just allocates enough space and copy the string.
|
||||||
*/
|
*/
|
||||||
char *dupstr (char *src)
|
char *dupstr (char *src)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
ptr=(char *) malloc (strlen (src)+1);
|
ptr=(char *) malloc (strlen (src)+1);
|
||||||
strcpy (ptr,src);
|
strcpy (ptr,src);
|
||||||
return (ptr);
|
return (ptr);
|
||||||
|
@ -531,13 +531,13 @@ char *dupstr (char *src)
|
||||||
/*
|
/*
|
||||||
* This function reports an internal error. It is almost not used. One
|
* This function reports an internal error. It is almost not used. One
|
||||||
* place in which I do check for internal errors is disk.c.
|
* place in which I do check for internal errors is disk.c.
|
||||||
*
|
*
|
||||||
* We just report the error, and try to continue ...
|
* We just report the error, and try to continue ...
|
||||||
*/
|
*/
|
||||||
void internal_error (char *description,char *source_name,char *function_name)
|
void internal_error (char *description,char *source_name,char *function_name)
|
||||||
{
|
{
|
||||||
wprintw (command_win,"Internal error - Found by source: %s.c , function: %s\n",source_name,function_name);
|
wprintw (command_win,"Internal error - Found by source: %s.c , function: %s\n",source_name,function_name);
|
||||||
wprintw (command_win,"\t%s\n",description);
|
wprintw (command_win,"\t%s\n",description);
|
||||||
wprintw (command_win,"Press enter to (hopefully) continue\n");
|
wprintw (command_win,"Press enter to (hopefully) continue\n");
|
||||||
refresh_command_win ();getch ();werase (command_win);
|
refresh_command_win ();getch ();werase (command_win);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,14 @@ void type_ext2_super_block___show (char *command_line)
|
||||||
{
|
{
|
||||||
struct ext2_super_block *super;
|
struct ext2_super_block *super;
|
||||||
super=&type_data.u.t_ext2_super_block;
|
super=&type_data.u.t_ext2_super_block;
|
||||||
|
|
||||||
show (command_line);
|
show (command_line);
|
||||||
|
|
||||||
if (super->s_blocks_count != 0) {
|
if (super->s_blocks_count != 0) {
|
||||||
wmove (show_pad,2,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_r_blocks_count/ (float) super->s_blocks_count);
|
wmove (show_pad,2,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_r_blocks_count/ (float) super->s_blocks_count);
|
||||||
wmove (show_pad,3,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_blocks_count/ (float) super->s_blocks_count);
|
wmove (show_pad,3,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_blocks_count/ (float) super->s_blocks_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (super->s_inodes_count != 0) {
|
if (super->s_inodes_count != 0) {
|
||||||
wmove (show_pad,4,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_inodes_count/ (float) super->s_inodes_count);
|
wmove (show_pad,4,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_inodes_count/ (float) super->s_inodes_count);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ void type_ext2_super_block___show (char *command_line)
|
||||||
wprintw (show_pad,"Unknown");
|
wprintw (show_pad,"Unknown");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wmove (show_pad,16,40);
|
wmove (show_pad,16,40);
|
||||||
if (type_data.u.t_ext2_super_block.s_state & 0x1)
|
if (type_data.u.t_ext2_super_block.s_state & 0x1)
|
||||||
wprintw (show_pad,"clean ");
|
wprintw (show_pad,"clean ");
|
||||||
|
@ -71,9 +71,9 @@ void type_ext2_super_block___show (char *command_line)
|
||||||
wprintw (show_pad,"with errors ");
|
wprintw (show_pad,"with errors ");
|
||||||
else
|
else
|
||||||
wprintw (show_pad,"with no errors");
|
wprintw (show_pad,"with no errors");
|
||||||
|
|
||||||
wmove (show_pad,17,40);
|
wmove (show_pad,17,40);
|
||||||
|
|
||||||
switch (type_data.u.t_ext2_super_block.s_errors) {
|
switch (type_data.u.t_ext2_super_block.s_errors) {
|
||||||
case EXT2_ERRORS_CONTINUE:
|
case EXT2_ERRORS_CONTINUE:
|
||||||
wprintw (show_pad,"Continue");
|
wprintw (show_pad,"Continue");
|
||||||
|
@ -90,7 +90,7 @@ void type_ext2_super_block___show (char *command_line)
|
||||||
}
|
}
|
||||||
|
|
||||||
wmove (show_pad,21,40);
|
wmove (show_pad,21,40);
|
||||||
|
|
||||||
switch (type_data.u.t_ext2_super_block.s_creator_os) {
|
switch (type_data.u.t_ext2_super_block.s_creator_os) {
|
||||||
|
|
||||||
case EXT2_OS_LINUX:
|
case EXT2_OS_LINUX:
|
||||||
|
@ -105,7 +105,7 @@ void type_ext2_super_block___show (char *command_line)
|
||||||
wprintw (show_pad,"Unknown");
|
wprintw (show_pad,"Unknown");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh_show_pad ();
|
refresh_show_pad ();
|
||||||
|
|
||||||
wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0);
|
wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0);
|
||||||
|
@ -121,7 +121,7 @@ void type_ext2_super_block___gocopy (char *command_line)
|
||||||
{
|
{
|
||||||
unsigned long copy_num,offset;
|
unsigned long copy_num,offset;
|
||||||
char *ptr,buffer [80];
|
char *ptr,buffer [80];
|
||||||
|
|
||||||
ptr=parse_word (command_line,buffer);
|
ptr=parse_word (command_line,buffer);
|
||||||
if (*ptr==0) {
|
if (*ptr==0) {
|
||||||
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return;
|
||||||
|
@ -129,12 +129,12 @@ void type_ext2_super_block___gocopy (char *command_line)
|
||||||
ptr=parse_word (ptr,buffer);
|
ptr=parse_word (ptr,buffer);
|
||||||
|
|
||||||
copy_num=atol (buffer);
|
copy_num=atol (buffer);
|
||||||
|
|
||||||
offset=file_system_info.super_block_offset+copy_num*file_system_info.no_blocks_in_group*file_system_info.block_size;
|
offset=file_system_info.super_block_offset+copy_num*file_system_info.no_blocks_in_group*file_system_info.block_size;
|
||||||
|
|
||||||
if (offset > file_system_info.file_system_size) {
|
if (offset > file_system_info.file_system_size) {
|
||||||
wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return;
|
wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return;
|
||||||
}
|
}
|
||||||
|
|
||||||
super_info.copy_num=copy_num;
|
super_info.copy_num=copy_num;
|
||||||
device_offset=offset;
|
device_offset=offset;
|
||||||
|
@ -147,7 +147,7 @@ void type_ext2_super_block___setactivecopy (char *command_line)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct ext2_super_block sb;
|
struct ext2_super_block sb;
|
||||||
|
|
||||||
sb=type_data.u.t_ext2_super_block;
|
sb=type_data.u.t_ext2_super_block;
|
||||||
dispatch ("gocopy 0");
|
dispatch ("gocopy 0");
|
||||||
type_data.u.t_ext2_super_block=sb;
|
type_data.u.t_ext2_super_block=sb;
|
||||||
|
|
18
ext2ed/win.c
18
ext2ed/win.c
|
@ -30,7 +30,7 @@ Copyright (C) 1995 Gadi Oxman
|
||||||
struct struct_pad_info show_pad_info;
|
struct struct_pad_info show_pad_info;
|
||||||
WINDOW *title_win,*show_win,*command_win,*mt_win1,*mt_win2,*show_pad;
|
WINDOW *title_win,*show_win,*command_win,*mt_win1,*mt_win2,*show_pad;
|
||||||
|
|
||||||
/* to remember configuration after initscr
|
/* to remember configuration after initscr
|
||||||
* and modify it
|
* and modify it
|
||||||
*/
|
*/
|
||||||
struct termios termioInit, termioCurrent;
|
struct termios termioInit, termioCurrent;
|
||||||
|
@ -56,7 +56,7 @@ void setup_show_win(void)
|
||||||
show_pad_info.display_cols=COLS;
|
show_pad_info.display_cols=COLS;
|
||||||
show_pad_info.max_line=show_pad_info.display_lines-1;show_pad_info.max_col=show_pad_info.display_cols-1;
|
show_pad_info.max_line=show_pad_info.display_lines-1;show_pad_info.max_col=show_pad_info.display_cols-1;
|
||||||
show_pad_info.disable_output=0;
|
show_pad_info.disable_output=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_windows (void)
|
void init_windows (void)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ void init_windows (void)
|
||||||
termioCurrent = termioInit;
|
termioCurrent = termioInit;
|
||||||
termioCurrent.c_lflag |= ECHO; /* set echo on */
|
termioCurrent.c_lflag |= ECHO; /* set echo on */
|
||||||
tcsetattr(0,TCSANOW,&termioCurrent);
|
tcsetattr(0,TCSANOW,&termioCurrent);
|
||||||
|
|
||||||
if (LINES<TITLE_WIN_LINES+SHOW_WIN_LINES+COMMAND_WIN_LINES+3) {
|
if (LINES<TITLE_WIN_LINES+SHOW_WIN_LINES+COMMAND_WIN_LINES+3) {
|
||||||
printf ("Sorry, your terminal screen is too small\n");
|
printf ("Sorry, your terminal screen is too small\n");
|
||||||
printf ("Error - Can not initialize windows\n");
|
printf ("Error - Can not initialize windows\n");
|
||||||
|
@ -105,7 +105,7 @@ void refresh_title_win (void)
|
||||||
void refresh_show_win (void)
|
void refresh_show_win (void)
|
||||||
{
|
{
|
||||||
int current_page,total_pages;
|
int current_page,total_pages;
|
||||||
|
|
||||||
current_page=show_pad_info.line/show_pad_info.display_lines+1;
|
current_page=show_pad_info.line/show_pad_info.display_lines+1;
|
||||||
if (show_pad_info.line%show_pad_info.display_lines)
|
if (show_pad_info.line%show_pad_info.display_lines)
|
||||||
current_page++;
|
current_page++;
|
||||||
|
@ -123,10 +123,10 @@ void refresh_show_pad (void)
|
||||||
|
|
||||||
{
|
{
|
||||||
int left,top,right,bottom,i;
|
int left,top,right,bottom,i;
|
||||||
|
|
||||||
if (show_pad_info.disable_output)
|
if (show_pad_info.disable_output)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (show_pad_info.max_line < show_pad_info.display_lines-1) {
|
if (show_pad_info.max_line < show_pad_info.display_lines-1) {
|
||||||
for (i=show_pad_info.max_line+1;i<show_pad_info.display_lines;i++) {
|
for (i=show_pad_info.max_line+1;i<show_pad_info.display_lines;i++) {
|
||||||
wmove (show_pad,i,0);wprintw (show_pad,"\n");
|
wmove (show_pad,i,0);wprintw (show_pad,"\n");
|
||||||
|
@ -157,19 +157,19 @@ void close_windows (void)
|
||||||
{
|
{
|
||||||
// echo ();
|
// echo ();
|
||||||
tcsetattr(0,TCSANOW,&termioInit);
|
tcsetattr(0,TCSANOW,&termioInit);
|
||||||
|
|
||||||
delwin (title_win);
|
delwin (title_win);
|
||||||
delwin (command_win);
|
delwin (command_win);
|
||||||
delwin (show_win);
|
delwin (show_win);
|
||||||
delwin (show_pad);
|
delwin (show_pad);
|
||||||
|
|
||||||
endwin ();
|
endwin ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_info (void)
|
void show_info (void)
|
||||||
{
|
{
|
||||||
int block_num,block_offset;
|
int block_num,block_offset;
|
||||||
|
|
||||||
block_num=device_offset/file_system_info.block_size;
|
block_num=device_offset/file_system_info.block_size;
|
||||||
block_offset=device_offset%file_system_info.block_size;
|
block_offset=device_offset%file_system_info.block_size;
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ __inline struct group * getgrnam(char* g){return 0;}
|
||||||
|
|
||||||
struct group
|
struct group
|
||||||
{
|
{
|
||||||
char *gr_name;
|
char *gr_name;
|
||||||
char *gr_passwd;
|
char *gr_passwd;
|
||||||
__gid_t gr_gid;
|
__gid_t gr_gid;
|
||||||
char **gr_mem;
|
char **gr_mem;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define getgrgid(i) NULL
|
#define getgrgid(i) NULL
|
||||||
|
|
|
@ -9,13 +9,13 @@ __inline struct passwd* getpwnam (char* g){return 0;}
|
||||||
|
|
||||||
struct passwd
|
struct passwd
|
||||||
{
|
{
|
||||||
char *pw_name;
|
char *pw_name;
|
||||||
char *pw_passwd;
|
char *pw_passwd;
|
||||||
__uid_t pw_uid;
|
__uid_t pw_uid;
|
||||||
__gid_t pw_gid;
|
__gid_t pw_gid;
|
||||||
char *pw_gecos;
|
char *pw_gecos;
|
||||||
char *pw_dir;
|
char *pw_dir;
|
||||||
char *pw_shell;
|
char *pw_shell;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define getpwuid(i) NULL
|
#define getpwuid(i) NULL
|
||||||
|
|
|
@ -164,7 +164,7 @@ pop (int x)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct loaded_l10nfile *
|
struct loaded_l10nfile *
|
||||||
_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
||||||
const char *dirlist, size_t dirlist_len,
|
const char *dirlist, size_t dirlist_len,
|
||||||
|
@ -359,7 +359,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Normalize codeset name. There is no standard for the codeset
|
/* Normalize codeset name. There is no standard for the codeset
|
||||||
names. Normalization allows the user to use any of the common
|
names. Normalization allows the user to use any of the common
|
||||||
names. The return value is dynamically allocated and has to be
|
names. The return value is dynamically allocated and has to be
|
||||||
|
|
|
@ -223,8 +223,8 @@ static const short yyrline[] =
|
||||||
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
|
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
|
||||||
static const char *const yytname[] =
|
static const char *const yytname[] =
|
||||||
{
|
{
|
||||||
"$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
|
"$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
|
||||||
"ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
|
"ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
|
||||||
"start", "exp", 0
|
"start", "exp", 0
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -556,7 +556,7 @@ int yydebug;
|
||||||
#ifndef YYMAXDEPTH
|
#ifndef YYMAXDEPTH
|
||||||
# define YYMAXDEPTH 10000
|
# define YYMAXDEPTH 10000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef YYERROR_VERBOSE
|
#ifdef YYERROR_VERBOSE
|
||||||
|
|
||||||
# ifndef yystrlen
|
# ifndef yystrlen
|
||||||
|
@ -608,7 +608,7 @@ yystpcpy (yydest, yysrc)
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#line 315 "/usr/local/share/bison/bison.simple"
|
#line 315 "/usr/local/share/bison/bison.simple"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1081,7 +1081,7 @@ case 12:
|
||||||
|
|
||||||
#line 705 "/usr/local/share/bison/bison.simple"
|
#line 705 "/usr/local/share/bison/bison.simple"
|
||||||
|
|
||||||
|
|
||||||
yyvsp -= yylen;
|
yyvsp -= yylen;
|
||||||
yyssp -= yylen;
|
yyssp -= yylen;
|
||||||
#if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
|
|
|
@ -90,7 +90,7 @@ extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev);
|
||||||
extern int blkid_tag_next(blkid_tag_iterate iterate,
|
extern int blkid_tag_next(blkid_tag_iterate iterate,
|
||||||
const char **type, const char **value);
|
const char **type, const char **value);
|
||||||
extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
|
extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
|
||||||
extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
|
extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
|
||||||
const char *value);
|
const char *value);
|
||||||
extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
|
extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
|
||||||
const char *type,
|
const char *type,
|
||||||
|
|
|
@ -100,14 +100,14 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
|
||||||
|
|
||||||
if (filename && !strlen(filename))
|
if (filename && !strlen(filename))
|
||||||
filename = 0;
|
filename = 0;
|
||||||
if (!filename)
|
if (!filename)
|
||||||
filename = safe_getenv("BLKID_FILE");
|
filename = safe_getenv("BLKID_FILE");
|
||||||
if (!filename)
|
if (!filename)
|
||||||
filename = BLKID_CACHE_FILE;
|
filename = BLKID_CACHE_FILE;
|
||||||
cache->bic_filename = blkid_strdup(filename);
|
cache->bic_filename = blkid_strdup(filename);
|
||||||
|
|
||||||
blkid_read_cache(cache);
|
blkid_read_cache(cache);
|
||||||
|
|
||||||
*ret_cache = cache;
|
*ret_cache = cache;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ void blkid_put_cache(blkid_cache cache)
|
||||||
(void) blkid_flush_cache(cache);
|
(void) blkid_flush_cache(cache);
|
||||||
|
|
||||||
DBG(DEBUG_CACHE, printf("freeing cache struct\n"));
|
DBG(DEBUG_CACHE, printf("freeing cache struct\n"));
|
||||||
|
|
||||||
/* DBG(DEBUG_CACHE, blkid_debug_dump_cache(cache)); */
|
/* DBG(DEBUG_CACHE, blkid_debug_dump_cache(cache)); */
|
||||||
|
|
||||||
while (!list_empty(&cache->bic_devs)) {
|
while (!list_empty(&cache->bic_devs)) {
|
||||||
|
@ -137,7 +137,7 @@ void blkid_put_cache(blkid_cache cache)
|
||||||
|
|
||||||
while (!list_empty(&tag->bit_names)) {
|
while (!list_empty(&tag->bit_names)) {
|
||||||
blkid_tag bad = list_entry(tag->bit_names.next,
|
blkid_tag bad = list_entry(tag->bit_names.next,
|
||||||
struct blkid_struct_tag,
|
struct blkid_struct_tag,
|
||||||
bit_names);
|
bit_names);
|
||||||
|
|
||||||
DBG(DEBUG_CACHE, printf("warning: unfreed tag %s=%s\n",
|
DBG(DEBUG_CACHE, printf("warning: unfreed tag %s=%s\n",
|
||||||
|
@ -148,7 +148,7 @@ void blkid_put_cache(blkid_cache cache)
|
||||||
}
|
}
|
||||||
if (cache->bic_filename)
|
if (cache->bic_filename)
|
||||||
free(cache->bic_filename);
|
free(cache->bic_filename);
|
||||||
|
|
||||||
free(cache);
|
free(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,12 +165,12 @@ void blkid_gc_cache(blkid_cache cache)
|
||||||
if (!p)
|
if (!p)
|
||||||
break;
|
break;
|
||||||
if (stat(dev->bid_name, &st) < 0) {
|
if (stat(dev->bid_name, &st) < 0) {
|
||||||
DBG(DEBUG_CACHE,
|
DBG(DEBUG_CACHE,
|
||||||
printf("freeing %s\n", dev->bid_name));
|
printf("freeing %s\n", dev->bid_name));
|
||||||
blkid_free_dev(dev);
|
blkid_free_dev(dev);
|
||||||
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
|
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
|
||||||
} else {
|
} else {
|
||||||
DBG(DEBUG_CACHE,
|
DBG(DEBUG_CACHE,
|
||||||
printf("Device %s exists\n", dev->bid_name));
|
printf("Device %s exists\n", dev->bid_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ void blkid_debug_dump_dev(blkid_dev dev)
|
||||||
list_for_each(p, &dev->bid_tags) {
|
list_for_each(p, &dev->bid_tags) {
|
||||||
blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
|
blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
|
||||||
if (tag)
|
if (tag)
|
||||||
printf(" tag: %s=\"%s\"\n", tag->bit_name,
|
printf(" tag: %s=\"%s\"\n", tag->bit_name,
|
||||||
tag->bit_val);
|
tag->bit_val);
|
||||||
else
|
else
|
||||||
printf(" tag: NULL\n");
|
printf(" tag: NULL\n");
|
||||||
|
@ -102,7 +102,7 @@ void blkid_debug_dump_dev(blkid_dev dev)
|
||||||
* This series of functions iterate over all devices in a blkid cache
|
* This series of functions iterate over all devices in a blkid cache
|
||||||
*/
|
*/
|
||||||
#define DEV_ITERATE_MAGIC 0x01a5284c
|
#define DEV_ITERATE_MAGIC 0x01a5284c
|
||||||
|
|
||||||
struct blkid_struct_dev_iterate {
|
struct blkid_struct_dev_iterate {
|
||||||
int magic;
|
int magic;
|
||||||
blkid_cache cache;
|
blkid_cache cache;
|
||||||
|
@ -131,7 +131,7 @@ extern int blkid_dev_set_search(blkid_dev_iterate iter,
|
||||||
{
|
{
|
||||||
char *new_type, *new_value;
|
char *new_type, *new_value;
|
||||||
|
|
||||||
if (!iter || iter->magic != DEV_ITERATE_MAGIC || !search_type ||
|
if (!iter || iter->magic != DEV_ITERATE_MAGIC || !search_type ||
|
||||||
!search_value)
|
!search_value)
|
||||||
return -1;
|
return -1;
|
||||||
new_type = malloc(strlen(search_type)+1);
|
new_type = malloc(strlen(search_type)+1);
|
||||||
|
@ -168,8 +168,8 @@ extern int blkid_dev_next(blkid_dev_iterate iter,
|
||||||
while (iter->p != &iter->cache->bic_devs) {
|
while (iter->p != &iter->cache->bic_devs) {
|
||||||
dev = list_entry(iter->p, struct blkid_struct_dev, bid_devs);
|
dev = list_entry(iter->p, struct blkid_struct_dev, bid_devs);
|
||||||
iter->p = iter->p->next;
|
iter->p = iter->p->next;
|
||||||
if (iter->search_type &&
|
if (iter->search_type &&
|
||||||
!blkid_dev_has_tag(dev, iter->search_type,
|
!blkid_dev_has_tag(dev, iter->search_type,
|
||||||
iter->search_value))
|
iter->search_value))
|
||||||
continue;
|
continue;
|
||||||
*ret_dev = dev;
|
*ret_dev = dev;
|
||||||
|
@ -220,7 +220,7 @@ int main(int argc, char **argv)
|
||||||
case 'm':
|
case 'm':
|
||||||
blkid_debug_mask = strtoul (optarg, &tmp, 0);
|
blkid_debug_mask = strtoul (optarg, &tmp, 0);
|
||||||
if (*tmp) {
|
if (*tmp) {
|
||||||
fprintf(stderr, "Invalid debug mask: %s\n",
|
fprintf(stderr, "Invalid debug mask: %s\n",
|
||||||
optarg);
|
optarg);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
|
||||||
if (strcmp(tmp->bid_name, devname))
|
if (strcmp(tmp->bid_name, devname))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DBG(DEBUG_DEVNAME,
|
DBG(DEBUG_DEVNAME,
|
||||||
printf("found devname %s in cache\n", tmp->bid_name));
|
printf("found devname %s in cache\n", tmp->bid_name));
|
||||||
dev = tmp;
|
dev = tmp;
|
||||||
break;
|
break;
|
||||||
|
@ -79,7 +79,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
|
||||||
dev = blkid_verify(cache, dev);
|
dev = blkid_verify(cache, dev);
|
||||||
if (!dev || !(dev->bid_flags & BLKID_BID_FL_VERIFIED))
|
if (!dev || !(dev->bid_flags & BLKID_BID_FL_VERIFIED))
|
||||||
return dev;
|
return dev;
|
||||||
/*
|
/*
|
||||||
* If the device is verified, then search the blkid
|
* If the device is verified, then search the blkid
|
||||||
* cache for any entries that match on the type, uuid,
|
* cache for any entries that match on the type, uuid,
|
||||||
* and label, and verify them; if a cache entry can
|
* and label, and verify them; if a cache entry can
|
||||||
|
@ -192,7 +192,7 @@ static void probe_one(blkid_cache cache, const char *ptname,
|
||||||
dev->bid_devno == devno)
|
dev->bid_devno == devno)
|
||||||
goto set_pri;
|
goto set_pri;
|
||||||
|
|
||||||
if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) &&
|
if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) &&
|
||||||
st.st_rdev == devno) {
|
st.st_rdev == devno) {
|
||||||
devname = blkid_strdup(device);
|
devname = blkid_strdup(device);
|
||||||
break;
|
break;
|
||||||
|
@ -309,7 +309,7 @@ static void lvm_probe_all(blkid_cache cache, int only_if_new)
|
||||||
DBG(DEBUG_DEVNAME, printf("LVM dev %s: devno 0x%04X\n",
|
DBG(DEBUG_DEVNAME, printf("LVM dev %s: devno 0x%04X\n",
|
||||||
lvm_device,
|
lvm_device,
|
||||||
(unsigned int) dev));
|
(unsigned int) dev));
|
||||||
probe_one(cache, lvm_device, dev, BLKID_PRI_LVM,
|
probe_one(cache, lvm_device, dev, BLKID_PRI_LVM,
|
||||||
only_if_new);
|
only_if_new);
|
||||||
free(lvm_device);
|
free(lvm_device);
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ static int probe_all(blkid_cache cache, int only_if_new)
|
||||||
ptname, (unsigned int) devs[which]));
|
ptname, (unsigned int) devs[which]));
|
||||||
|
|
||||||
if (sz > 1)
|
if (sz > 1)
|
||||||
probe_one(cache, ptname, devs[which], 0,
|
probe_one(cache, ptname, devs[which], 0,
|
||||||
only_if_new);
|
only_if_new);
|
||||||
lens[which] = 0; /* mark as checked */
|
lens[which] = 0; /* mark as checked */
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list,
|
||||||
path, *devname));
|
path, *devname));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (list && S_ISDIR(st.st_mode) && !lstat(path, &st) &&
|
if (list && S_ISDIR(st.st_mode) && !lstat(path, &st) &&
|
||||||
S_ISDIR(st.st_mode))
|
S_ISDIR(st.st_mode))
|
||||||
add_to_dirlist(path, list);
|
add_to_dirlist(path, list);
|
||||||
}
|
}
|
||||||
|
@ -175,13 +175,13 @@ char *blkid_devno_to_devname(dev_t devno)
|
||||||
|
|
||||||
if (!devname) {
|
if (!devname) {
|
||||||
DBG(DEBUG_DEVNO,
|
DBG(DEBUG_DEVNO,
|
||||||
printf("blkid: couldn't find devno 0x%04lx\n",
|
printf("blkid: couldn't find devno 0x%04lx\n",
|
||||||
(unsigned long) devno));
|
(unsigned long) devno));
|
||||||
} else {
|
} else {
|
||||||
DBG(DEBUG_DEVNO,
|
DBG(DEBUG_DEVNO,
|
||||||
printf("found devno 0x%04llx as %s\n", (long long)devno, devname));
|
printf("found devno 0x%04llx as %s\n", (long long)devno, devname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return devname;
|
return devname;
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ int main(int argc, char **argv)
|
||||||
perror(argv[0]);
|
perror(argv[0]);
|
||||||
|
|
||||||
bytes = blkid_get_dev_size(fd);
|
bytes = blkid_get_dev_size(fd);
|
||||||
printf("Device %s has %Ld 1k blocks.\n", argv[1],
|
printf("Device %s has %Ld 1k blocks.\n", argv[1],
|
||||||
(unsigned long long) bytes >> 10);
|
(unsigned long long) bytes >> 10);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -47,7 +47,7 @@ static int figure_label_len(const unsigned char *label, int len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *get_buffer(struct blkid_probe *pr,
|
static unsigned char *get_buffer(struct blkid_probe *pr,
|
||||||
blkid_loff_t off, size_t len)
|
blkid_loff_t off, size_t len)
|
||||||
{
|
{
|
||||||
ssize_t ret_read;
|
ssize_t ret_read;
|
||||||
|
@ -96,7 +96,7 @@ static int check_mdraid(int fd, unsigned char *ret_uuid)
|
||||||
struct mdp_superblock_s *md;
|
struct mdp_superblock_s *md;
|
||||||
blkid_loff_t offset;
|
blkid_loff_t offset;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -BLKID_ERR_PARAM;
|
return -BLKID_ERR_PARAM;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ static void get_ext2_info(blkid_dev dev, struct blkid_magic *id,
|
||||||
struct ext2_super_block *es = (struct ext2_super_block *) buf;
|
struct ext2_super_block *es = (struct ext2_super_block *) buf;
|
||||||
const char *label = 0;
|
const char *label = 0;
|
||||||
|
|
||||||
DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n",
|
DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n",
|
||||||
blkid_le32(es->s_feature_compat),
|
blkid_le32(es->s_feature_compat),
|
||||||
blkid_le32(es->s_feature_incompat),
|
blkid_le32(es->s_feature_incompat),
|
||||||
blkid_le32(es->s_feature_ro_compat)));
|
blkid_le32(es->s_feature_ro_compat)));
|
||||||
|
@ -307,7 +307,7 @@ static int probe_ext4(struct blkid_probe *probe, struct blkid_magic *id,
|
||||||
es = (struct ext2_super_block *)buf;
|
es = (struct ext2_super_block *)buf;
|
||||||
|
|
||||||
/* Distinguish from jbd */
|
/* Distinguish from jbd */
|
||||||
if (blkid_le32(es->s_feature_incompat) &
|
if (blkid_le32(es->s_feature_incompat) &
|
||||||
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)
|
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)
|
||||||
return -BLKID_ERR_PARAM;
|
return -BLKID_ERR_PARAM;
|
||||||
|
|
||||||
|
@ -419,13 +419,13 @@ static unsigned char *search_fat_label(struct vfat_dir_entry *dir, int count)
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
if (dir[i].name[0] == 0x00)
|
if (dir[i].name[0] == 0x00)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ((dir[i].name[0] == FAT_ENTRY_FREE) ||
|
if ((dir[i].name[0] == FAT_ENTRY_FREE) ||
|
||||||
(dir[i].cluster_high != 0 || dir[i].cluster_low != 0) ||
|
(dir[i].cluster_high != 0 || dir[i].cluster_low != 0) ||
|
||||||
((dir[i].attr & FAT_ATTR_MASK) == FAT_ATTR_LONG_NAME))
|
((dir[i].attr & FAT_ATTR_MASK) == FAT_ATTR_LONG_NAME))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) ==
|
if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) ==
|
||||||
FAT_ATTR_VOLUME_ID) {
|
FAT_ATTR_VOLUME_ID) {
|
||||||
return dir[i].name;
|
return dir[i].name;
|
||||||
}
|
}
|
||||||
|
@ -436,7 +436,7 @@ static unsigned char *search_fat_label(struct vfat_dir_entry *dir, int count)
|
||||||
/* FAT label extraction from the root directory taken from Kay
|
/* FAT label extraction from the root directory taken from Kay
|
||||||
* Sievers's volume_id library */
|
* Sievers's volume_id library */
|
||||||
static int probe_fat(struct blkid_probe *probe,
|
static int probe_fat(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct vfat_super_block *vs = (struct vfat_super_block *) buf;
|
struct vfat_super_block *vs = (struct vfat_super_block *) buf;
|
||||||
|
@ -484,11 +484,11 @@ static int probe_fat(struct blkid_probe *probe,
|
||||||
if (ms->ms_fat_length) {
|
if (ms->ms_fat_length) {
|
||||||
/* the label may be an attribute in the root directory */
|
/* the label may be an attribute in the root directory */
|
||||||
root_start = (reserved + fat_size) * sector_size;
|
root_start = (reserved + fat_size) * sector_size;
|
||||||
root_dir_entries = vs->vs_dir_entries[0] +
|
root_dir_entries = vs->vs_dir_entries[0] +
|
||||||
(vs->vs_dir_entries[1] << 8);
|
(vs->vs_dir_entries[1] << 8);
|
||||||
|
|
||||||
buf_size = root_dir_entries * sizeof(struct vfat_dir_entry);
|
buf_size = root_dir_entries * sizeof(struct vfat_dir_entry);
|
||||||
dir = (struct vfat_dir_entry *) get_buffer(probe, root_start,
|
dir = (struct vfat_dir_entry *) get_buffer(probe, root_start,
|
||||||
buf_size);
|
buf_size);
|
||||||
if (dir)
|
if (dir)
|
||||||
vol_label = search_fat_label(dir, root_dir_entries);
|
vol_label = search_fat_label(dir, root_dir_entries);
|
||||||
|
@ -497,7 +497,7 @@ static int probe_fat(struct blkid_probe *probe,
|
||||||
vol_label = ms->ms_label;
|
vol_label = ms->ms_label;
|
||||||
vol_serno = ms->ms_serno;
|
vol_serno = ms->ms_serno;
|
||||||
|
|
||||||
blkid_set_tag(probe->dev, "SEC_TYPE", "msdos",
|
blkid_set_tag(probe->dev, "SEC_TYPE", "msdos",
|
||||||
sizeof("msdos"));
|
sizeof("msdos"));
|
||||||
} else {
|
} else {
|
||||||
/* Search the FAT32 root dir for the label attribute */
|
/* Search the FAT32 root dir for the label attribute */
|
||||||
|
@ -511,10 +511,10 @@ static int probe_fat(struct blkid_probe *probe,
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
next_sect_off = (next - 2) * vs->vs_cluster_size;
|
next_sect_off = (next - 2) * vs->vs_cluster_size;
|
||||||
next_off = (start_data_sect + next_sect_off) *
|
next_off = (start_data_sect + next_sect_off) *
|
||||||
sector_size;
|
sector_size;
|
||||||
|
|
||||||
dir = (struct vfat_dir_entry *)
|
dir = (struct vfat_dir_entry *)
|
||||||
get_buffer(probe, next_off, buf_size);
|
get_buffer(probe, next_off, buf_size);
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
break;
|
break;
|
||||||
|
@ -526,7 +526,7 @@ static int probe_fat(struct blkid_probe *probe,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* get FAT entry */
|
/* get FAT entry */
|
||||||
fat_entry_off = (reserved * sector_size) +
|
fat_entry_off = (reserved * sector_size) +
|
||||||
(next * sizeof(__u32));
|
(next * sizeof(__u32));
|
||||||
buf = get_buffer(probe, fat_entry_off, buf_size);
|
buf = get_buffer(probe, fat_entry_off, buf_size);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
|
@ -563,7 +563,7 @@ static int probe_fat(struct blkid_probe *probe,
|
||||||
* [7-Jul-2005, Karel Zak <kzak@redhat.com>]
|
* [7-Jul-2005, Karel Zak <kzak@redhat.com>]
|
||||||
*/
|
*/
|
||||||
static int probe_fat_nomagic(struct blkid_probe *probe,
|
static int probe_fat_nomagic(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct msdos_super_block *ms;
|
struct msdos_super_block *ms;
|
||||||
|
@ -574,7 +574,7 @@ static int probe_fat_nomagic(struct blkid_probe *probe,
|
||||||
if (ms->ms_heads == 0)
|
if (ms->ms_heads == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* cluster size check*/
|
/* cluster size check*/
|
||||||
if (ms->ms_cluster_size == 0 ||
|
if (ms->ms_cluster_size == 0 ||
|
||||||
(ms->ms_cluster_size & (ms->ms_cluster_size-1)))
|
(ms->ms_cluster_size & (ms->ms_cluster_size-1)))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -604,7 +604,7 @@ static int probe_fat_nomagic(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_ntfs(struct blkid_probe *probe,
|
static int probe_ntfs(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct ntfs_super_block *ns;
|
struct ntfs_super_block *ns;
|
||||||
|
@ -631,7 +631,7 @@ static int probe_ntfs(struct blkid_probe *probe,
|
||||||
if (ns->cluster_per_mft_record < 0)
|
if (ns->cluster_per_mft_record < 0)
|
||||||
mft_record_size = 1 << (0-ns->cluster_per_mft_record);
|
mft_record_size = 1 << (0-ns->cluster_per_mft_record);
|
||||||
else
|
else
|
||||||
mft_record_size = ns->cluster_per_mft_record *
|
mft_record_size = ns->cluster_per_mft_record *
|
||||||
sectors_per_cluster * bytes_per_sector;
|
sectors_per_cluster * bytes_per_sector;
|
||||||
nr_clusters = blkid_le64(ns->number_of_sectors) / sectors_per_cluster;
|
nr_clusters = blkid_le64(ns->number_of_sectors) / sectors_per_cluster;
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ static int probe_ntfs(struct blkid_probe *probe,
|
||||||
(blkid_le64(ns->mft_mirror_cluster_location) > nr_clusters))
|
(blkid_le64(ns->mft_mirror_cluster_location) > nr_clusters))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
off = blkid_le64(ns->mft_mirror_cluster_location) *
|
off = blkid_le64(ns->mft_mirror_cluster_location) *
|
||||||
bytes_per_sector * sectors_per_cluster;
|
bytes_per_sector * sectors_per_cluster;
|
||||||
|
|
||||||
buf_mft = get_buffer(probe, off, mft_record_size);
|
buf_mft = get_buffer(probe, off, mft_record_size);
|
||||||
|
@ -649,7 +649,7 @@ static int probe_ntfs(struct blkid_probe *probe,
|
||||||
if (memcmp(buf_mft, "FILE", 4))
|
if (memcmp(buf_mft, "FILE", 4))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
off = blkid_le64(ns->mft_cluster_location) * bytes_per_sector *
|
off = blkid_le64(ns->mft_cluster_location) * bytes_per_sector *
|
||||||
sectors_per_cluster;
|
sectors_per_cluster;
|
||||||
|
|
||||||
buf_mft = get_buffer(probe, off, mft_record_size);
|
buf_mft = get_buffer(probe, off, mft_record_size);
|
||||||
|
@ -672,7 +672,7 @@ static int probe_ntfs(struct blkid_probe *probe,
|
||||||
|
|
||||||
attr_off = blkid_le16(mft->attrs_offset);
|
attr_off = blkid_le16(mft->attrs_offset);
|
||||||
label_str[0] = 0;
|
label_str[0] = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
attr = (struct file_attribute *) (buf_mft + attr_off);
|
attr = (struct file_attribute *) (buf_mft + attr_off);
|
||||||
attr_len = blkid_le16(attr->len);
|
attr_len = blkid_le16(attr->len);
|
||||||
|
@ -712,7 +712,7 @@ static int probe_ntfs(struct blkid_probe *probe,
|
||||||
|
|
||||||
|
|
||||||
static int probe_xfs(struct blkid_probe *probe,
|
static int probe_xfs(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct xfs_super_block *xs;
|
struct xfs_super_block *xs;
|
||||||
|
@ -756,7 +756,7 @@ static int probe_reiserfs(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_reiserfs4(struct blkid_probe *probe,
|
static int probe_reiserfs4(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct reiser4_super_block *rs4 = (struct reiser4_super_block *) buf;
|
struct reiser4_super_block *rs4 = (struct reiser4_super_block *) buf;
|
||||||
|
@ -765,14 +765,14 @@ static int probe_reiserfs4(struct blkid_probe *probe,
|
||||||
if (strlen((char *) rs4->rs4_label))
|
if (strlen((char *) rs4->rs4_label))
|
||||||
label = rs4->rs4_label;
|
label = rs4->rs4_label;
|
||||||
set_uuid(probe->dev, rs4->rs4_uuid, 0);
|
set_uuid(probe->dev, rs4->rs4_uuid, 0);
|
||||||
blkid_set_tag(probe->dev, "LABEL", (const char *) label,
|
blkid_set_tag(probe->dev, "LABEL", (const char *) label,
|
||||||
sizeof(rs4->rs4_label));
|
sizeof(rs4->rs4_label));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_jfs(struct blkid_probe *probe,
|
static int probe_jfs(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct jfs_super_block *js;
|
struct jfs_super_block *js;
|
||||||
|
@ -825,7 +825,7 @@ static int probe_luks(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_romfs(struct blkid_probe *probe,
|
static int probe_romfs(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct romfs_super_block *ros;
|
struct romfs_super_block *ros;
|
||||||
|
@ -840,7 +840,7 @@ static int probe_romfs(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_cramfs(struct blkid_probe *probe,
|
static int probe_cramfs(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct cramfs_super_block *csb;
|
struct cramfs_super_block *csb;
|
||||||
|
@ -888,7 +888,7 @@ static int probe_swap1(struct blkid_probe *probe,
|
||||||
/* arbitrary sanity check.. is there any garbage down there? */
|
/* arbitrary sanity check.. is there any garbage down there? */
|
||||||
if (sws->sws_pad[32] == 0 && sws->sws_pad[33] == 0) {
|
if (sws->sws_pad[32] == 0 && sws->sws_pad[33] == 0) {
|
||||||
if (sws->sws_volume[0])
|
if (sws->sws_volume[0])
|
||||||
blkid_set_tag(probe->dev, "LABEL", sws->sws_volume,
|
blkid_set_tag(probe->dev, "LABEL", sws->sws_volume,
|
||||||
sizeof(sws->sws_volume));
|
sizeof(sws->sws_volume));
|
||||||
if (sws->sws_uuid[0])
|
if (sws->sws_uuid[0])
|
||||||
set_uuid(probe->dev, sws->sws_uuid, 0);
|
set_uuid(probe->dev, sws->sws_uuid, 0);
|
||||||
|
@ -897,7 +897,7 @@ static int probe_swap1(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_iso9660(struct blkid_probe *probe,
|
static int probe_iso9660(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct iso_volume_descriptor *iso;
|
struct iso_volume_descriptor *iso;
|
||||||
|
@ -906,7 +906,7 @@ static int probe_iso9660(struct blkid_probe *probe,
|
||||||
iso = (struct iso_volume_descriptor *) buf;
|
iso = (struct iso_volume_descriptor *) buf;
|
||||||
label = iso->volume_id;
|
label = iso->volume_id;
|
||||||
|
|
||||||
blkid_set_tag(probe->dev, "LABEL", (const char *) label,
|
blkid_set_tag(probe->dev, "LABEL", (const char *) label,
|
||||||
figure_label_len(label, 32));
|
figure_label_len(label, 32));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -917,7 +917,7 @@ static const char
|
||||||
"NSR03", "TEA01", 0 };
|
"NSR03", "TEA01", 0 };
|
||||||
|
|
||||||
static int probe_udf(struct blkid_probe *probe,
|
static int probe_udf(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf __BLKID_ATTR((unused)))
|
unsigned char *buf __BLKID_ATTR((unused)))
|
||||||
{
|
{
|
||||||
int j, bs;
|
int j, bs;
|
||||||
|
@ -927,7 +927,7 @@ static int probe_udf(struct blkid_probe *probe,
|
||||||
/* determine the block size by scanning in 2K increments
|
/* determine the block size by scanning in 2K increments
|
||||||
(block sizes larger than 2K will be null padded) */
|
(block sizes larger than 2K will be null padded) */
|
||||||
for (bs = 1; bs < 16; bs++) {
|
for (bs = 1; bs < 16; bs++) {
|
||||||
isosb = (struct iso_volume_descriptor *)
|
isosb = (struct iso_volume_descriptor *)
|
||||||
get_buffer(probe, bs*2048+32768, sizeof(isosb));
|
get_buffer(probe, bs*2048+32768, sizeof(isosb));
|
||||||
if (!isosb)
|
if (!isosb)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -938,8 +938,8 @@ static int probe_udf(struct blkid_probe *probe,
|
||||||
/* Scan up to another 64 blocks looking for additional VSD's */
|
/* Scan up to another 64 blocks looking for additional VSD's */
|
||||||
for (j = 1; j < 64; j++) {
|
for (j = 1; j < 64; j++) {
|
||||||
if (j > 1) {
|
if (j > 1) {
|
||||||
isosb = (struct iso_volume_descriptor *)
|
isosb = (struct iso_volume_descriptor *)
|
||||||
get_buffer(probe, j*bs*2048+32768,
|
get_buffer(probe, j*bs*2048+32768,
|
||||||
sizeof(isosb));
|
sizeof(isosb));
|
||||||
if (!isosb)
|
if (!isosb)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -960,7 +960,7 @@ static int probe_udf(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_ocfs(struct blkid_probe *probe,
|
static int probe_ocfs(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct ocfs_volume_header ovh;
|
struct ocfs_volume_header ovh;
|
||||||
|
@ -975,7 +975,7 @@ static int probe_ocfs(struct blkid_probe *probe,
|
||||||
blkid_set_tag(probe->dev,"SEC_TYPE","ocfs1",sizeof("ocfs1"));
|
blkid_set_tag(probe->dev,"SEC_TYPE","ocfs1",sizeof("ocfs1"));
|
||||||
else if (major >= 9)
|
else if (major >= 9)
|
||||||
blkid_set_tag(probe->dev,"SEC_TYPE","ntocfs",sizeof("ntocfs"));
|
blkid_set_tag(probe->dev,"SEC_TYPE","ntocfs",sizeof("ntocfs"));
|
||||||
|
|
||||||
blkid_set_tag(probe->dev, "LABEL", ovl.label, ocfslabellen(ovl));
|
blkid_set_tag(probe->dev, "LABEL", ovl.label, ocfslabellen(ovl));
|
||||||
blkid_set_tag(probe->dev, "MOUNT", ovh.mount, ocfsmountlen(ovh));
|
blkid_set_tag(probe->dev, "MOUNT", ovh.mount, ocfsmountlen(ovh));
|
||||||
set_uuid(probe->dev, ovl.vol_id, 0);
|
set_uuid(probe->dev, ovl.vol_id, 0);
|
||||||
|
@ -983,7 +983,7 @@ static int probe_ocfs(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_ocfs2(struct blkid_probe *probe,
|
static int probe_ocfs2(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct ocfs2_super_block *osb;
|
struct ocfs2_super_block *osb;
|
||||||
|
@ -996,7 +996,7 @@ static int probe_ocfs2(struct blkid_probe *probe,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_oracleasm(struct blkid_probe *probe,
|
static int probe_oracleasm(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id __BLKID_ATTR((unused)),
|
struct blkid_magic *id __BLKID_ATTR((unused)),
|
||||||
unsigned char *buf)
|
unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct oracle_asm_disk_label *dl;
|
struct oracle_asm_disk_label *dl;
|
||||||
|
@ -1018,9 +1018,9 @@ static int probe_gfs(struct blkid_probe *probe,
|
||||||
|
|
||||||
if (blkid_be32(sbd->sb_fs_format) == GFS_FORMAT_FS &&
|
if (blkid_be32(sbd->sb_fs_format) == GFS_FORMAT_FS &&
|
||||||
blkid_be32(sbd->sb_multihost_format) == GFS_FORMAT_MULTI)
|
blkid_be32(sbd->sb_multihost_format) == GFS_FORMAT_MULTI)
|
||||||
{
|
{
|
||||||
blkid_set_tag(probe->dev, "UUID", 0, 0);
|
blkid_set_tag(probe->dev, "UUID", 0, 0);
|
||||||
|
|
||||||
if (strlen(sbd->sb_locktable))
|
if (strlen(sbd->sb_locktable))
|
||||||
label = sbd->sb_locktable;
|
label = sbd->sb_locktable;
|
||||||
blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable));
|
blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable));
|
||||||
|
@ -1040,9 +1040,9 @@ static int probe_gfs2(struct blkid_probe *probe,
|
||||||
|
|
||||||
if (blkid_be32(sbd->sb_fs_format) == GFS2_FORMAT_FS &&
|
if (blkid_be32(sbd->sb_fs_format) == GFS2_FORMAT_FS &&
|
||||||
blkid_be32(sbd->sb_multihost_format) == GFS2_FORMAT_MULTI)
|
blkid_be32(sbd->sb_multihost_format) == GFS2_FORMAT_MULTI)
|
||||||
{
|
{
|
||||||
blkid_set_tag(probe->dev, "UUID", 0, 0);
|
blkid_set_tag(probe->dev, "UUID", 0, 0);
|
||||||
|
|
||||||
if (strlen(sbd->sb_locktable))
|
if (strlen(sbd->sb_locktable))
|
||||||
label = sbd->sb_locktable;
|
label = sbd->sb_locktable;
|
||||||
blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable));
|
blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable));
|
||||||
|
@ -1051,7 +1051,7 @@ static int probe_gfs2(struct blkid_probe *probe,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unicode_16be_to_utf8(unsigned char *str, int out_len,
|
static void unicode_16be_to_utf8(unsigned char *str, int out_len,
|
||||||
const unsigned char *buf, int in_len)
|
const unsigned char *buf, int in_len)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -1138,7 +1138,7 @@ static int probe_hfsplus(struct blkid_probe *probe,
|
||||||
(memcmp(sbd->embed_sig, "HX", 2) != 0))
|
(memcmp(sbd->embed_sig, "HX", 2) != 0))
|
||||||
/* This must be an HFS volume, so fail */
|
/* This must be an HFS volume, so fail */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
alloc_block_size = blkid_be32(sbd->al_blk_size);
|
alloc_block_size = blkid_be32(sbd->al_blk_size);
|
||||||
alloc_first_block = blkid_be16(sbd->al_bl_st);
|
alloc_first_block = blkid_be16(sbd->al_bl_st);
|
||||||
embed_first_block = blkid_be16(sbd->embed_startblock);
|
embed_first_block = blkid_be16(sbd->embed_startblock);
|
||||||
|
@ -1431,7 +1431,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
|
||||||
|
|
||||||
if ((now >= dev->bid_time) &&
|
if ((now >= dev->bid_time) &&
|
||||||
(st.st_mtime <= dev->bid_time) &&
|
(st.st_mtime <= dev->bid_time) &&
|
||||||
((diff < BLKID_PROBE_MIN) ||
|
((diff < BLKID_PROBE_MIN) ||
|
||||||
(dev->bid_flags & BLKID_BID_FL_VERIFIED &&
|
(dev->bid_flags & BLKID_BID_FL_VERIFIED &&
|
||||||
diff < BLKID_PROBE_INTERVAL)))
|
diff < BLKID_PROBE_INTERVAL)))
|
||||||
return dev;
|
return dev;
|
||||||
|
@ -1444,7 +1444,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
|
||||||
|
|
||||||
if ((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) {
|
if ((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) {
|
||||||
DBG(DEBUG_PROBE, printf("blkid_verify: error %s (%d) while "
|
DBG(DEBUG_PROBE, printf("blkid_verify: error %s (%d) while "
|
||||||
"opening %s\n", strerror(errno), errno,
|
"opening %s\n", strerror(errno), errno,
|
||||||
dev->bid_name));
|
dev->bid_name));
|
||||||
goto open_err;
|
goto open_err;
|
||||||
}
|
}
|
||||||
|
@ -1454,12 +1454,12 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
|
||||||
probe.sbbuf = 0;
|
probe.sbbuf = 0;
|
||||||
probe.buf = 0;
|
probe.buf = 0;
|
||||||
probe.buf_max = 0;
|
probe.buf_max = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the type array. If we already know the type,
|
* Iterate over the type array. If we already know the type,
|
||||||
* then try that first. If it doesn't work, then blow away
|
* then try that first. If it doesn't work, then blow away
|
||||||
* the type information, and try again.
|
* the type information, and try again.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
try_again:
|
try_again:
|
||||||
type = 0;
|
type = 0;
|
||||||
|
@ -1530,7 +1530,7 @@ found_type:
|
||||||
free(probe.sbbuf);
|
free(probe.sbbuf);
|
||||||
if (probe.buf)
|
if (probe.buf)
|
||||||
free(probe.buf);
|
free(probe.buf);
|
||||||
if (probe.fd >= 0)
|
if (probe.fd >= 0)
|
||||||
close(probe.fd);
|
close(probe.fd);
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
|
@ -1574,7 +1574,7 @@ int main(int argc, char **argv)
|
||||||
printf("LABEL='%s'\n", dev->bid_label);
|
printf("LABEL='%s'\n", dev->bid_label);
|
||||||
if (dev->bid_uuid)
|
if (dev->bid_uuid)
|
||||||
printf("UUID='%s'\n", dev->bid_uuid);
|
printf("UUID='%s'\n", dev->bid_uuid);
|
||||||
|
|
||||||
blkid_free_dev(dev);
|
blkid_free_dev(dev);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct blkid_probe {
|
||||||
size_t buf_max;
|
size_t buf_max;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*blkid_probe_t)(struct blkid_probe *probe,
|
typedef int (*blkid_probe_t)(struct blkid_probe *probe,
|
||||||
struct blkid_magic *id, unsigned char *buf);
|
struct blkid_magic *id, unsigned char *buf);
|
||||||
|
|
||||||
struct blkid_magic {
|
struct blkid_magic {
|
||||||
|
@ -347,7 +347,7 @@ struct ocfs_volume_header {
|
||||||
|
|
||||||
struct ocfs_volume_label {
|
struct ocfs_volume_label {
|
||||||
unsigned char disk_lock[48];
|
unsigned char disk_lock[48];
|
||||||
char label[64];
|
char label[64];
|
||||||
unsigned char label_len[2];
|
unsigned char label_len[2];
|
||||||
unsigned char vol_id[16];
|
unsigned char vol_id[16];
|
||||||
unsigned char vol_id_len[2];
|
unsigned char vol_id_len[2];
|
||||||
|
@ -432,15 +432,15 @@ struct gfs2_sb {
|
||||||
__u32 sb_fs_format;
|
__u32 sb_fs_format;
|
||||||
__u32 sb_multihost_format;
|
__u32 sb_multihost_format;
|
||||||
__u32 __pad0; /* Was superblock flags in gfs1 */
|
__u32 __pad0; /* Was superblock flags in gfs1 */
|
||||||
|
|
||||||
__u32 sb_bsize;
|
__u32 sb_bsize;
|
||||||
__u32 sb_bsize_shift;
|
__u32 sb_bsize_shift;
|
||||||
__u32 __pad1; /* Was journal segment size in gfs1 */
|
__u32 __pad1; /* Was journal segment size in gfs1 */
|
||||||
|
|
||||||
struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
|
struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
|
||||||
struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
|
struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
|
||||||
struct gfs2_inum sb_root_dir;
|
struct gfs2_inum sb_root_dir;
|
||||||
|
|
||||||
char sb_lockproto[GFS_LOCKNAME_LEN];
|
char sb_lockproto[GFS_LOCKNAME_LEN];
|
||||||
char sb_locktable[GFS_LOCKNAME_LEN];
|
char sb_locktable[GFS_LOCKNAME_LEN];
|
||||||
/* In gfs1, quota and license dinodes followed */
|
/* In gfs1, quota and license dinodes followed */
|
||||||
|
@ -686,7 +686,7 @@ _INLINE_ __u64 blkid_swab64(__u64 val)
|
||||||
return (blkid_swab32(val >> 32) |
|
return (blkid_swab32(val >> 32) |
|
||||||
(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
|
(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,7 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Some tags are stored directly in the device struct */
|
/* Some tags are stored directly in the device struct */
|
||||||
if (!strcmp(name, "DEVNO"))
|
if (!strcmp(name, "DEVNO"))
|
||||||
dev->bid_devno = STRTOULL(value, 0, 0);
|
dev->bid_devno = STRTOULL(value, 0, 0);
|
||||||
else if (!strcmp(name, "PRI"))
|
else if (!strcmp(name, "PRI"))
|
||||||
dev->bid_pri = strtol(value, 0, 0);
|
dev->bid_pri = strtol(value, 0, 0);
|
||||||
|
@ -401,7 +401,7 @@ void blkid_read_cache(blkid_cache cache)
|
||||||
cache->bic_filename));
|
cache->bic_filename));
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(DEBUG_CACHE, printf("reading cache file %s\n",
|
DBG(DEBUG_CACHE, printf("reading cache file %s\n",
|
||||||
cache->bic_filename));
|
cache->bic_filename));
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ static void debug_dump_dev(blkid_dev dev)
|
||||||
list_for_each(p, &dev->bid_tags) {
|
list_for_each(p, &dev->bid_tags) {
|
||||||
blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
|
blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
|
||||||
if (tag)
|
if (tag)
|
||||||
printf(" tag: %s=\"%s\"\n", tag->bit_name,
|
printf(" tag: %s=\"%s\"\n", tag->bit_name,
|
||||||
tag->bit_val);
|
tag->bit_val);
|
||||||
else
|
else
|
||||||
printf(" tag: NULL\n");
|
printf(" tag: NULL\n");
|
||||||
|
|
|
@ -68,7 +68,7 @@ char *blkid_get_devname(blkid_cache cache, const char *token,
|
||||||
|
|
||||||
if (!token)
|
if (!token)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
if (blkid_get_cache(&c, NULL) < 0)
|
if (blkid_get_cache(&c, NULL) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -126,7 +126,7 @@ int main(int argc, char **argv)
|
||||||
fprintf(stderr, "Couldn't get blkid cache\n");
|
fprintf(stderr, "Couldn't get blkid cache\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[2]) {
|
if (argv[2]) {
|
||||||
value = blkid_get_tag_value(cache, argv[1], argv[2]);
|
value = blkid_get_tag_value(cache, argv[1], argv[2]);
|
||||||
printf("%s has tag %s=%s\n", argv[2], argv[1],
|
printf("%s has tag %s=%s\n", argv[2], argv[1],
|
||||||
|
|
|
@ -181,7 +181,7 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
cache->bic_filename = blkid_strdup(argv[1]);
|
cache->bic_filename = blkid_strdup(argv[1]);
|
||||||
|
|
||||||
if ((ret = blkid_flush_cache(cache)) < 0) {
|
if ((ret = blkid_flush_cache(cache)) < 0) {
|
||||||
fprintf(stderr, "error (%d) saving cache\n", ret);
|
fprintf(stderr, "error (%d) saving cache\n", ret);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -83,7 +83,7 @@ blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
|
extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
blkid_tag tag;
|
blkid_tag tag;
|
||||||
|
@ -125,7 +125,7 @@ static blkid_tag blkid_find_head_cache(blkid_cache cache, const char *type)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set a tag on an existing device.
|
* Set a tag on an existing device.
|
||||||
*
|
*
|
||||||
* If value is NULL, then delete the tagsfrom the device.
|
* If value is NULL, then delete the tagsfrom the device.
|
||||||
*/
|
*/
|
||||||
int blkid_set_tag(blkid_dev dev, const char *name,
|
int blkid_set_tag(blkid_dev dev, const char *name,
|
||||||
|
@ -141,7 +141,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
|
||||||
if (!(val = blkid_strndup(value, vlength)) && value)
|
if (!(val = blkid_strndup(value, vlength)) && value)
|
||||||
return -BLKID_ERR_MEM;
|
return -BLKID_ERR_MEM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Certain common tags are linked directly to the device struct
|
* Certain common tags are linked directly to the device struct
|
||||||
* We need to know what they are before we do anything else because
|
* We need to know what they are before we do anything else because
|
||||||
* the function name parameter might get freed later on.
|
* the function name parameter might get freed later on.
|
||||||
|
@ -174,7 +174,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
|
||||||
t->bit_dev = dev;
|
t->bit_dev = dev;
|
||||||
|
|
||||||
list_add_tail(&t->bit_tags, &dev->bid_tags);
|
list_add_tail(&t->bit_tags, &dev->bid_tags);
|
||||||
|
|
||||||
if (dev->bid_cache) {
|
if (dev->bid_cache) {
|
||||||
head = blkid_find_head_cache(dev->bid_cache,
|
head = blkid_find_head_cache(dev->bid_cache,
|
||||||
t->bit_name);
|
t->bit_name);
|
||||||
|
@ -194,11 +194,11 @@ int blkid_set_tag(blkid_dev dev, const char *name,
|
||||||
list_add_tail(&t->bit_names, &head->bit_names);
|
list_add_tail(&t->bit_names, &head->bit_names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Link common tags directly to the device struct */
|
/* Link common tags directly to the device struct */
|
||||||
if (dev_var)
|
if (dev_var)
|
||||||
*dev_var = val;
|
*dev_var = val;
|
||||||
|
|
||||||
if (dev->bid_cache)
|
if (dev->bid_cache)
|
||||||
dev->bid_cache->bic_flags |= BLKID_BIC_FL_CHANGED;
|
dev->bid_cache->bic_flags |= BLKID_BIC_FL_CHANGED;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -274,7 +274,7 @@ errout:
|
||||||
* This series of functions iterate over all tags in a device
|
* This series of functions iterate over all tags in a device
|
||||||
*/
|
*/
|
||||||
#define TAG_ITERATE_MAGIC 0x01a5284c
|
#define TAG_ITERATE_MAGIC 0x01a5284c
|
||||||
|
|
||||||
struct blkid_struct_tag_iterate {
|
struct blkid_struct_tag_iterate {
|
||||||
int magic;
|
int magic;
|
||||||
blkid_dev dev;
|
blkid_dev dev;
|
||||||
|
@ -301,7 +301,7 @@ extern int blkid_tag_next(blkid_tag_iterate iter,
|
||||||
const char **type, const char **value)
|
const char **type, const char **value)
|
||||||
{
|
{
|
||||||
blkid_tag tag;
|
blkid_tag tag;
|
||||||
|
|
||||||
*type = 0;
|
*type = 0;
|
||||||
*value = 0;
|
*value = 0;
|
||||||
if (!iter || iter->magic != TAG_ITERATE_MAGIC ||
|
if (!iter || iter->magic != TAG_ITERATE_MAGIC ||
|
||||||
|
@ -342,9 +342,9 @@ extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
blkid_read_cache(cache);
|
blkid_read_cache(cache);
|
||||||
|
|
||||||
DBG(DEBUG_TAG, printf("looking for %s=%s in cache\n", type, value));
|
DBG(DEBUG_TAG, printf("looking for %s=%s in cache\n", type, value));
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
pri = -1;
|
pri = -1;
|
||||||
dev = 0;
|
dev = 0;
|
||||||
|
@ -352,7 +352,7 @@ try_again:
|
||||||
|
|
||||||
if (head) {
|
if (head) {
|
||||||
list_for_each(p, &head->bit_names) {
|
list_for_each(p, &head->bit_names) {
|
||||||
blkid_tag tmp = list_entry(p, struct blkid_struct_tag,
|
blkid_tag tmp = list_entry(p, struct blkid_struct_tag,
|
||||||
bit_names);
|
bit_names);
|
||||||
|
|
||||||
if (!strcmp(tmp->bit_val, value) &&
|
if (!strcmp(tmp->bit_val, value) &&
|
||||||
|
@ -395,7 +395,7 @@ extern int optind;
|
||||||
void usage(char *prog)
|
void usage(char *prog)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device "
|
fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device "
|
||||||
"[type value]\n",
|
"[type value]\n",
|
||||||
prog);
|
prog);
|
||||||
fprintf(stderr, "\tList all tags for a device and exit\n");
|
fprintf(stderr, "\tList all tags for a device and exit\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -423,7 +423,7 @@ int main(int argc, char **argv)
|
||||||
case 'm':
|
case 'm':
|
||||||
blkid_debug_mask = strtoul (optarg, &tmp, 0);
|
blkid_debug_mask = strtoul (optarg, &tmp, 0);
|
||||||
if (*tmp) {
|
if (*tmp) {
|
||||||
fprintf(stderr, "Invalid debug mask: %s\n",
|
fprintf(stderr, "Invalid debug mask: %s\n",
|
||||||
optarg);
|
optarg);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -448,14 +448,14 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
dev = blkid_get_dev(cache, devname, flags);
|
dev = blkid_get_dev(cache, devname, flags);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
fprintf(stderr, "%s: Can not find device in blkid cache\n",
|
fprintf(stderr, "%s: Can not find device in blkid cache\n",
|
||||||
devname);
|
devname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (search_type) {
|
if (search_type) {
|
||||||
found = blkid_dev_has_tag(dev, search_type, search_value);
|
found = blkid_dev_has_tag(dev, search_type, search_value);
|
||||||
printf("Device %s: (%s, %s) %s\n", blkid_dev_devname(dev),
|
printf("Device %s: (%s, %s) %s\n", blkid_dev_devname(dev),
|
||||||
search_type, search_value ? search_value : "NULL",
|
search_type, search_value ? search_value : "NULL",
|
||||||
found ? "FOUND" : "NOT FOUND");
|
found ? "FOUND" : "NOT FOUND");
|
||||||
return(!found);
|
return(!found);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This testing program makes sure the blkid_types header file
|
* This testing program makes sure the blkid_types header file
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 by Theodore Ts'o.
|
* Copyright (C) 2006 by Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
|
|
|
@ -40,7 +40,7 @@ const char *e2p_feature2string(int compat, unsigned int mask);
|
||||||
int e2p_string2feature(char *string, int *compat, unsigned int *mask);
|
int e2p_string2feature(char *string, int *compat, unsigned int *mask);
|
||||||
int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array);
|
int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array);
|
||||||
int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
||||||
__u32 *clear_ok_array, int *type_err,
|
__u32 *clear_ok_array, int *type_err,
|
||||||
unsigned int *mask_err);
|
unsigned int *mask_err);
|
||||||
|
|
||||||
int e2p_is_null_uuid(void *uu);
|
int e2p_is_null_uuid(void *uu);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* feature.c --- convert between features and strings
|
* feature.c --- convert between features and strings
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu>
|
* Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu>
|
||||||
*
|
*
|
||||||
* This file can be redistributed under the terms of the GNU Library General
|
* This file can be redistributed under the terms of the GNU Library General
|
||||||
* Public License
|
* Public License
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -251,11 +251,11 @@ static char *skip_over_word(char *cp)
|
||||||
/*
|
/*
|
||||||
* Edit a feature set array as requested by the user. The ok_array,
|
* Edit a feature set array as requested by the user. The ok_array,
|
||||||
* if set, allows the application to limit what features the user is
|
* if set, allows the application to limit what features the user is
|
||||||
* allowed to set or clear using this function. If clear_ok_array is set,
|
* allowed to set or clear using this function. If clear_ok_array is set,
|
||||||
* then use it tell whether or not it is OK to clear a filesystem feature.
|
* then use it tell whether or not it is OK to clear a filesystem feature.
|
||||||
*/
|
*/
|
||||||
int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
||||||
__u32 *clear_ok_array, int *type_err,
|
__u32 *clear_ok_array, int *type_err,
|
||||||
unsigned int *mask_err)
|
unsigned int *mask_err)
|
||||||
{
|
{
|
||||||
char *cp, *buf, *next;
|
char *cp, *buf, *next;
|
||||||
|
@ -280,7 +280,7 @@ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
||||||
neg = 0;
|
neg = 0;
|
||||||
cp = skip_over_blanks(cp);
|
cp = skip_over_blanks(cp);
|
||||||
next = skip_over_word(cp);
|
next = skip_over_word(cp);
|
||||||
|
|
||||||
if (*next == 0)
|
if (*next == 0)
|
||||||
next = 0;
|
next = 0;
|
||||||
else
|
else
|
||||||
|
@ -307,11 +307,11 @@ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (neg) {
|
if (neg) {
|
||||||
if (clear_ok_array &&
|
if (clear_ok_array &&
|
||||||
!(clear_ok_array[compat_type] & mask)) {
|
!(clear_ok_array[compat_type] & mask)) {
|
||||||
rc = 1;
|
rc = 1;
|
||||||
if (type_err)
|
if (type_err)
|
||||||
*type_err = (compat_type |
|
*type_err = (compat_type |
|
||||||
E2P_FEATURE_NEGATE_FLAG);
|
E2P_FEATURE_NEGATE_FLAG);
|
||||||
if (mask_err)
|
if (mask_err)
|
||||||
*mask_err = mask;
|
*mask_err = mask;
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
|
|
||||||
#include "e2p.h"
|
#include "e2p.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deal with lame glibc's that define this function without actually
|
* Deal with lame glibc's that define this function without actually
|
||||||
* implementing it. Can you say "attractive nuisance", boys and girls?
|
* implementing it. Can you say "attractive nuisance", boys and girls?
|
||||||
* I knew you could!
|
* I knew you could!
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,7 +51,7 @@ int getflags (int fd, unsigned long * flags)
|
||||||
#else
|
#else
|
||||||
#if HAVE_EXT2_IOCTLS
|
#if HAVE_EXT2_IOCTLS
|
||||||
int r, f;
|
int r, f;
|
||||||
|
|
||||||
if (!fstat(fd, &buf) &&
|
if (!fstat(fd, &buf) &&
|
||||||
!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode))
|
!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode))
|
||||||
goto notsupp;
|
goto notsupp;
|
||||||
|
|
|
@ -25,7 +25,7 @@ int getversion (int fd, unsigned long * version)
|
||||||
{
|
{
|
||||||
#if HAVE_EXT2_IOCTLS
|
#if HAVE_EXT2_IOCTLS
|
||||||
int r, ver;
|
int r, ver;
|
||||||
|
|
||||||
r = ioctl (fd, EXT2_IOC_GETVERSION, &ver);
|
r = ioctl (fd, EXT2_IOC_GETVERSION, &ver);
|
||||||
*version = ver;
|
*version = ver;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* feature.c --- convert between features and strings
|
* feature.c --- convert between features and strings
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu>
|
* Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu>
|
||||||
*
|
*
|
||||||
* This file can be redistributed under the terms of the GNU Library General
|
* This file can be redistributed under the terms of the GNU Library General
|
||||||
* Public License
|
* Public License
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -29,7 +29,7 @@ int iterate_on_dir (const char * dir_name,
|
||||||
struct dirent *de, *dep;
|
struct dirent *de, *dep;
|
||||||
int max_len = -1, len, ret = 0;
|
int max_len = -1, len, ret = 0;
|
||||||
|
|
||||||
#if HAVE_PATHCONF && defined(_PC_NAME_MAX)
|
#if HAVE_PATHCONF && defined(_PC_NAME_MAX)
|
||||||
max_len = pathconf(dir_name, _PC_NAME_MAX);
|
max_len = pathconf(dir_name, _PC_NAME_MAX);
|
||||||
#endif
|
#endif
|
||||||
if (max_len == -1) {
|
if (max_len == -1) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Universite Pierre et Marie Curie (Paris VI)
|
* Universite Pierre et Marie Curie (Paris VI)
|
||||||
*
|
*
|
||||||
* Copyright (C) 1995, 1996, 1997 Theodore Ts'o <tytso@mit.edu>
|
* Copyright (C) 1995, 1996, 1997 Theodore Ts'o <tytso@mit.edu>
|
||||||
*
|
*
|
||||||
* This file can be redistributed under the terms of the GNU Library General
|
* This file can be redistributed under the terms of the GNU Library General
|
||||||
* Public License
|
* Public License
|
||||||
*/
|
*/
|
||||||
|
@ -227,7 +227,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
|
||||||
fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb));
|
fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb));
|
||||||
fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb));
|
fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb));
|
||||||
if (sb->s_reserved_gdt_blocks)
|
if (sb->s_reserved_gdt_blocks)
|
||||||
fprintf(f, "Reserved GDT blocks: %u\n",
|
fprintf(f, "Reserved GDT blocks: %u\n",
|
||||||
sb->s_reserved_gdt_blocks);
|
sb->s_reserved_gdt_blocks);
|
||||||
fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group);
|
fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group);
|
||||||
fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group);
|
fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group);
|
||||||
|
@ -275,10 +275,10 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
|
||||||
fprintf(f, "First inode: %d\n", sb->s_first_ino);
|
fprintf(f, "First inode: %d\n", sb->s_first_ino);
|
||||||
fprintf(f, "Inode size: %d\n", sb->s_inode_size);
|
fprintf(f, "Inode size: %d\n", sb->s_inode_size);
|
||||||
if (sb->s_min_extra_isize)
|
if (sb->s_min_extra_isize)
|
||||||
fprintf(f, "Required extra isize: %d\n",
|
fprintf(f, "Required extra isize: %d\n",
|
||||||
sb->s_min_extra_isize);
|
sb->s_min_extra_isize);
|
||||||
if (sb->s_want_extra_isize)
|
if (sb->s_want_extra_isize)
|
||||||
fprintf(f, "Desired extra isize: %d\n",
|
fprintf(f, "Desired extra isize: %d\n",
|
||||||
sb->s_want_extra_isize);
|
sb->s_want_extra_isize);
|
||||||
}
|
}
|
||||||
if (!e2p_is_null_uuid(sb->s_journal_uuid))
|
if (!e2p_is_null_uuid(sb->s_journal_uuid))
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* mountopts.c --- convert between default mount options and strings
|
* mountopts.c --- convert between default mount options and strings
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Theodore Ts'o <tytso@mit.edu>
|
* Copyright (C) 2002 Theodore Ts'o <tytso@mit.edu>
|
||||||
*
|
*
|
||||||
* This file can be redistributed under the terms of the GNU Library General
|
* This file can be redistributed under the terms of the GNU Library General
|
||||||
* Public License
|
* Public License
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const char *os_tab[] =
|
static const char *os_tab[] =
|
||||||
{ "Linux",
|
{ "Linux",
|
||||||
"Hurd",
|
"Hurd",
|
||||||
"Masix",
|
"Masix",
|
||||||
"FreeBSD",
|
"FreeBSD",
|
||||||
"Lites",
|
"Lites",
|
||||||
0 };
|
0 };
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* parse_num.c - Parse the number of blocks
|
* parse_num.c - Parse the number of blocks
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu>
|
* Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu>
|
||||||
*
|
*
|
||||||
* This file can be redistributed under the terms of the GNU Library General
|
* This file can be redistributed under the terms of the GNU Library General
|
||||||
* Public License
|
* Public License
|
||||||
*/
|
*/
|
||||||
|
@ -18,25 +18,25 @@ unsigned long parse_num_blocks(const char *arg, int log_block_size)
|
||||||
|
|
||||||
num = strtoull(arg, &p, 0);
|
num = strtoull(arg, &p, 0);
|
||||||
|
|
||||||
if (p[0] && p[1])
|
if (p[0] && p[1])
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (*p) { /* Using fall-through logic */
|
switch (*p) { /* Using fall-through logic */
|
||||||
case 'T': case 't':
|
case 'T': case 't':
|
||||||
num <<= 10;
|
num <<= 10;
|
||||||
case 'G': case 'g':
|
case 'G': case 'g':
|
||||||
num <<= 10;
|
num <<= 10;
|
||||||
case 'M': case 'm':
|
case 'M': case 'm':
|
||||||
num <<= 10;
|
num <<= 10;
|
||||||
case 'K': case 'k':
|
case 'K': case 'k':
|
||||||
num >>= log_block_size;
|
num >>= log_block_size;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
num >>= (1+log_block_size);
|
num >>= (1+log_block_size);
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* percent.c - Take percentage of a number
|
* percent.c - Take percentage of a number
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Theodore Ts'o <tytso@mit.edu>
|
* Copyright (C) 2006 Theodore Ts'o <tytso@mit.edu>
|
||||||
*
|
*
|
||||||
* This file can be redistributed under the terms of the GNU Library General
|
* This file can be redistributed under the terms of the GNU Library General
|
||||||
* Public License
|
* Public License
|
||||||
*/
|
*/
|
||||||
|
@ -23,7 +23,7 @@ unsigned int e2p_percent(int percent, unsigned int base)
|
||||||
return 0;
|
return 0;
|
||||||
if (100 % percent == 0)
|
if (100 % percent == 0)
|
||||||
return base / (100 / percent);
|
return base / (100 / percent);
|
||||||
if (mask & base)
|
if (mask & base)
|
||||||
return (base / 100) * percent;
|
return (base / 100) * percent;
|
||||||
return base * percent / 100;
|
return base * percent / 100;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ main(int argc, char **argv)
|
||||||
fprintf(stderr, "Bad percent: %s\n", argv[1]);
|
fprintf(stderr, "Bad percent: %s\n", argv[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
base = strtoul(argv[2], &p, 0);
|
base = strtoul(argv[2], &p, 0);
|
||||||
if (p[0] && p[1]) {
|
if (p[0] && p[1]) {
|
||||||
fprintf(stderr, "Bad base: %s\n", argv[2]);
|
fprintf(stderr, "Bad base: %s\n", argv[2]);
|
||||||
|
|
|
@ -41,7 +41,7 @@ static struct flags_name flags_array[] = {
|
||||||
{ EXT2_ECOMPR_FL, "E", "Compression_Error" },
|
{ EXT2_ECOMPR_FL, "E", "Compression_Error" },
|
||||||
#endif
|
#endif
|
||||||
{ EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" },
|
{ EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" },
|
||||||
{ EXT2_INDEX_FL, "I", "Indexed_direcctory" },
|
{ EXT2_INDEX_FL, "I", "Indexed_direcctory" },
|
||||||
{ EXT2_NOTAIL_FL, "t", "No_Tailmerging" },
|
{ EXT2_NOTAIL_FL, "t", "No_Tailmerging" },
|
||||||
{ EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
|
{ EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
|
||||||
{ EXT4_EXTENTS_FL, "e", "Extents" },
|
{ EXT4_EXTENTS_FL, "e", "Extents" },
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
#include "e2p.h"
|
#include "e2p.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deal with lame glibc's that define this function without actually
|
* Deal with lame glibc's that define this function without actually
|
||||||
* implementing it. Can you say "attractive nuisance", boys and girls?
|
* implementing it. Can you say "attractive nuisance", boys and girls?
|
||||||
* I knew you could!
|
* I knew you could!
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,7 +42,7 @@ static void e2p_unpack_uuid(void *in, struct uuid *uu)
|
||||||
tmp = *ptr++;
|
tmp = *ptr++;
|
||||||
tmp = (tmp << 8) | *ptr++;
|
tmp = (tmp << 8) | *ptr++;
|
||||||
uu->time_mid = tmp;
|
uu->time_mid = tmp;
|
||||||
|
|
||||||
tmp = *ptr++;
|
tmp = *ptr++;
|
||||||
tmp = (tmp << 8) | *ptr++;
|
tmp = (tmp << 8) | *ptr++;
|
||||||
uu->time_hi_and_version = tmp;
|
uu->time_hi_and_version = tmp;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 1987, 1988 by MIT Student Information Processing Board.
|
* Copyright 1987, 1988 by MIT Student Information Processing Board.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software and
|
* Permission to use, copy, modify, and distribute this software and
|
||||||
* its documentation for any purpose is hereby granted, provided that
|
* its documentation for any purpose is hereby granted, provided that
|
||||||
* the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
|
* the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
|
||||||
|
|
|
@ -36,10 +36,10 @@ extern void com_err_va (const char *whoami, errcode_t code, const char *fmt,
|
||||||
|
|
||||||
extern char const *error_message (long);
|
extern char const *error_message (long);
|
||||||
extern void (*com_err_hook) (const char *, long, const char *, va_list);
|
extern void (*com_err_hook) (const char *, long, const char *, va_list);
|
||||||
extern void (*set_com_err_hook (void (*) (const char *, long,
|
extern void (*set_com_err_hook (void (*) (const char *, long,
|
||||||
const char *, va_list)))
|
const char *, va_list)))
|
||||||
(const char *, long, const char *, va_list);
|
(const char *, long, const char *, va_list);
|
||||||
extern void (*reset_com_err_hook (void)) (const char *, long,
|
extern void (*reset_com_err_hook (void)) (const char *, long,
|
||||||
const char *, va_list);
|
const char *, va_list);
|
||||||
extern int init_error_table(const char * const *msgs, long base, int count);
|
extern int init_error_table(const char * const *msgs, long base, int count);
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ extern void add_to_error_table(struct et_list *new_table);
|
||||||
|
|
||||||
/* Provided for Heimdall compatibility */
|
/* Provided for Heimdall compatibility */
|
||||||
extern const char *com_right(struct et_list *list, long code);
|
extern const char *com_right(struct et_list *list, long code);
|
||||||
extern void initialize_error_table_r(struct et_list **list,
|
extern void initialize_error_table_r(struct et_list **list,
|
||||||
const char **messages,
|
const char **messages,
|
||||||
int num_errors,
|
int num_errors,
|
||||||
long base);
|
long base);
|
||||||
extern void free_error_table(struct et_list *et);
|
extern void free_error_table(struct et_list *et);
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
/*
|
/*
|
||||||
* com_right.c -- provide Heimdall / Kerberos4kth com_err interfaces
|
* com_right.c -- provide Heimdall / Kerberos4kth com_err interfaces
|
||||||
* for backwards compatbility
|
* for backwards compatbility
|
||||||
*
|
*
|
||||||
* Copyright (c) 2003 by Theodore Ts'o
|
* Copyright (c) 2003 by Theodore Ts'o
|
||||||
*
|
*
|
||||||
* Taken from lib/com_err/error.c from Kerberos4kth distribution.
|
* Taken from lib/com_err/error.c from Kerberos4kth distribution.
|
||||||
*
|
*
|
||||||
* Copyright (c) 1997, 1998, 2001 Kungliga Tekniska Högskolan
|
* Copyright (c) 1997, 1998, 2001 Kungliga Tekniska Högskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -68,8 +68,8 @@ struct foobar {
|
||||||
* afoul of dependencies.
|
* afoul of dependencies.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
initialize_error_table_r(struct et_list **list,
|
initialize_error_table_r(struct et_list **list,
|
||||||
const char **messages,
|
const char **messages,
|
||||||
int num_errors,
|
int num_errors,
|
||||||
long base)
|
long base)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ initialize_error_table_r(struct et_list **list,
|
||||||
et->next = NULL;
|
et->next = NULL;
|
||||||
*end = et;
|
*end = et;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
free_error_table(struct et_list *et)
|
free_error_table(struct et_list *et)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -100,7 +100,7 @@ static check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
|
||||||
*
|
*
|
||||||
* Should have a special policy for directories.
|
* Should have a special policy for directories.
|
||||||
*/
|
*/
|
||||||
errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
|
errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
|
||||||
int mode EXT2FS_ATTR((unused)),
|
int mode EXT2FS_ATTR((unused)),
|
||||||
ext2fs_inode_bitmap map, ext2_ino_t *ret)
|
ext2fs_inode_bitmap map, ext2_ino_t *ret)
|
||||||
{
|
{
|
||||||
|
@ -109,13 +109,13 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
|
||||||
ext2_ino_t start_inode;
|
ext2_ino_t start_inode;
|
||||||
|
|
||||||
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
||||||
|
|
||||||
if (!map)
|
if (!map)
|
||||||
map = fs->inode_map;
|
map = fs->inode_map;
|
||||||
if (!map)
|
if (!map)
|
||||||
return EXT2_ET_NO_INODE_BITMAP;
|
return EXT2_ET_NO_INODE_BITMAP;
|
||||||
|
|
||||||
if (dir > 0)
|
if (dir > 0)
|
||||||
dir_group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super);
|
dir_group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super);
|
||||||
|
|
||||||
start_inode = (dir_group * EXT2_INODES_PER_GROUP(fs->super)) + 1;
|
start_inode = (dir_group * EXT2_INODES_PER_GROUP(fs->super)) + 1;
|
||||||
|
@ -134,7 +134,7 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
|
||||||
if (i > fs->super->s_inodes_count)
|
if (i > fs->super->s_inodes_count)
|
||||||
i = EXT2_FIRST_INODE(fs->super);
|
i = EXT2_FIRST_INODE(fs->super);
|
||||||
} while (i != start_inode);
|
} while (i != start_inode);
|
||||||
|
|
||||||
if (ext2fs_test_inode_bitmap(map, i))
|
if (ext2fs_test_inode_bitmap(map, i))
|
||||||
return EXT2_ET_INODE_ALLOC_FAIL;
|
return EXT2_ET_INODE_ALLOC_FAIL;
|
||||||
*ret = i;
|
*ret = i;
|
||||||
|
@ -221,7 +221,7 @@ errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
|
||||||
retval = io_channel_write_blk(fs->io, block, 1, block_buf);
|
retval = io_channel_write_blk(fs->io, block, 1, block_buf);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
ext2fs_block_alloc_stats(fs, block, +1);
|
ext2fs_block_alloc_stats(fs, block, +1);
|
||||||
*ret = block;
|
*ret = block;
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish,
|
||||||
return EXT2_ET_BLOCK_ALLOC_FAIL;
|
return EXT2_ET_BLOCK_ALLOC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ext2fs_set_alloc_block_callback(ext2_filsys fs,
|
void ext2fs_set_alloc_block_callback(ext2_filsys fs,
|
||||||
errcode_t (*func)(ext2_filsys fs,
|
errcode_t (*func)(ext2_filsys fs,
|
||||||
blk64_t goal,
|
blk64_t goal,
|
||||||
blk64_t *ret),
|
blk64_t *ret),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* alloc_sb.c --- Allocate the superblock and block group descriptors for a
|
* alloc_sb.c --- Allocate the superblock and block group descriptors for a
|
||||||
* newly initialized filesystem. Used by mke2fs when initializing a filesystem
|
* newly initialized filesystem. Used by mke2fs when initializing a filesystem
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994, 1995, 1996, 2003 Theodore Ts'o.
|
* Copyright (C) 1994, 1995, 1996, 2003 Theodore Ts'o.
|
||||||
|
@ -40,20 +40,20 @@
|
||||||
*
|
*
|
||||||
* See also the comment for ext2fs_super_and_bgd_loc()
|
* See also the comment for ext2fs_super_and_bgd_loc()
|
||||||
*/
|
*/
|
||||||
int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
|
int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
|
||||||
dgrp_t group,
|
dgrp_t group,
|
||||||
ext2fs_block_bitmap bmap)
|
ext2fs_block_bitmap bmap)
|
||||||
{
|
{
|
||||||
blk_t super_blk, old_desc_blk, new_desc_blk;
|
blk_t super_blk, old_desc_blk, new_desc_blk;
|
||||||
int j, old_desc_blocks, num_blocks;
|
int j, old_desc_blocks, num_blocks;
|
||||||
|
|
||||||
num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk,
|
num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk,
|
||||||
&old_desc_blk, &new_desc_blk, 0);
|
&old_desc_blk, &new_desc_blk, 0);
|
||||||
|
|
||||||
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
|
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
|
||||||
old_desc_blocks = fs->super->s_first_meta_bg;
|
old_desc_blocks = fs->super->s_first_meta_bg;
|
||||||
else
|
else
|
||||||
old_desc_blocks =
|
old_desc_blocks =
|
||||||
fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
|
fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
|
||||||
|
|
||||||
if (super_blk || (group == 0))
|
if (super_blk || (group == 0))
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
* License.
|
* License.
|
||||||
* %End-Header%
|
* %End-Header%
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -73,7 +73,7 @@ void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse)
|
||||||
(fs->block_alloc_stats)(fs, (blk64_t) blk, inuse);
|
(fs->block_alloc_stats)(fs, (blk64_t) blk, inuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs,
|
void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs,
|
||||||
void (*func)(ext2_filsys fs,
|
void (*func)(ext2_filsys fs,
|
||||||
blk64_t blk,
|
blk64_t blk,
|
||||||
int inuse),
|
int inuse),
|
||||||
|
|
|
@ -101,7 +101,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||||
if (last_grp > fs->group_desc_count)
|
if (last_grp > fs->group_desc_count)
|
||||||
last_grp = fs->group_desc_count;
|
last_grp = fs->group_desc_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate the block and inode bitmaps, if necessary
|
* Allocate the block and inode bitmaps, if necessary
|
||||||
*/
|
*/
|
||||||
|
@ -130,7 +130,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||||
if (!fs->group_desc[group].bg_block_bitmap) {
|
if (!fs->group_desc[group].bg_block_bitmap) {
|
||||||
retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
|
retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
|
||||||
1, bmap, &new_blk);
|
1, bmap, &new_blk);
|
||||||
if (retval == EXT2_ET_BLOCK_ALLOC_FAIL)
|
if (retval == EXT2_ET_BLOCK_ALLOC_FAIL)
|
||||||
retval = ext2fs_get_free_blocks(fs, group_blk,
|
retval = ext2fs_get_free_blocks(fs, group_blk,
|
||||||
last_blk, 1, bmap, &new_blk);
|
last_blk, 1, bmap, &new_blk);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
@ -158,7 +158,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||||
if (!fs->group_desc[group].bg_inode_bitmap) {
|
if (!fs->group_desc[group].bg_inode_bitmap) {
|
||||||
retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
|
retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
|
||||||
1, bmap, &new_blk);
|
1, bmap, &new_blk);
|
||||||
if (retval == EXT2_ET_BLOCK_ALLOC_FAIL)
|
if (retval == EXT2_ET_BLOCK_ALLOC_FAIL)
|
||||||
retval = ext2fs_get_free_blocks(fs, group_blk,
|
retval = ext2fs_get_free_blocks(fs, group_blk,
|
||||||
last_blk, 1, bmap, &new_blk);
|
last_blk, 1, bmap, &new_blk);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* badblocks.c --- routines to manipulate the bad block structure
|
* badblocks.c --- routines to manipulate the bad block structure
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
|
* Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
|
@ -34,7 +34,7 @@ static errcode_t make_u32_list(int size, int num, __u32 *list,
|
||||||
{
|
{
|
||||||
ext2_u32_list bb;
|
ext2_u32_list bb;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list), &bb);
|
retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list), &bb);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -54,7 +54,7 @@ static errcode_t make_u32_list(int size, int num, __u32 *list,
|
||||||
*ret = bb;
|
*ret = bb;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This procedure creates an empty u32 list.
|
* This procedure creates an empty u32 list.
|
||||||
|
@ -79,7 +79,7 @@ errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size)
|
||||||
errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest)
|
errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest)
|
||||||
{
|
{
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
retval = make_u32_list(src->size, src->num, src->list, dest);
|
retval = make_u32_list(src->size, src->num, src->list, dest);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -271,11 +271,11 @@ int ext2fs_u32_list_iterate(ext2_u32_iterate iter, __u32 *blk)
|
||||||
|
|
||||||
if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
|
if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (iter->ptr < bb->num) {
|
if (iter->ptr < bb->num) {
|
||||||
*blk = bb->list[iter->ptr++];
|
*blk = bb->list[iter->ptr++];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*blk = 0;
|
*blk = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue