summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-07-19 02:37:41 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-07-19 02:37:41 -0400
commitdb0bdb49f49fc3dd14c12439d934a3403a3be9f1 (patch)
treeebbdc877184df5896a89d291193029d730aadd85
parentefe0b401465a3ee836180614b5b435acbb84fc27 (diff)
parent58384b8fa81ce01221414a3603591b63e487609b (diff)
downloade2fsprogs-db0bdb49f49fc3dd14c12439d934a3403a3be9f1.tar.gz
Merge branch 'maint' into next
Conflicts: resize/extent.c
-rw-r--r--debian/control.in2
-rw-r--r--debian/initrd-tools.e2fsprogs31
-rw-r--r--debian/initrd.ext3-add-journal27
-rwxr-xr-xdebian/rules11
-rw-r--r--debugfs/set_fields.c5
-rw-r--r--e2fsck/ea_refcount.c7
-rw-r--r--e2fsck/iscan.c2
-rw-r--r--e2fsck/unix.c4
-rw-r--r--lib/e2p/ls.c42
-rw-r--r--lib/ext2fs/Makefile.in6
-rw-r--r--lib/ext2fs/ext2_fs.h23
-rw-r--r--lib/ext2fs/swapfs.c6
-rw-r--r--lib/ext2fs/tst_super_size.c119
-rw-r--r--misc/e2freefrag.c4
-rw-r--r--resize/extent.c7
-rw-r--r--resize/main.c3
-rw-r--r--resize/resize2fs.8.in2
-rw-r--r--tests/progs/test_rel.c2
18 files changed, 220 insertions, 83 deletions
diff --git a/debian/control.in b/debian/control.in
index 0e1f195e..3c8cf84e 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -243,7 +243,7 @@ Description: ext2/ext3/ext4 file system utilities
hard disks on Debian and other Linux systems.
.
This package contains programs for creating, checking, and maintaining
- ext-based file systems, and the generic fsck wrapper.
+ ext2/3/4-based file systems.
Package: e2fsprogs-dbg
Section: debug
diff --git a/debian/initrd-tools.e2fsprogs b/debian/initrd-tools.e2fsprogs
deleted file mode 100644
index ed49db41..00000000
--- a/debian/initrd-tools.e2fsprogs
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-#
-# /usr/share/initrd-tools/scripts/e2fsprogs
-#
-cp /usr/share/e2fsprogs/initrd.ext3-add-journal \
- $INITRDDIR/scripts/ext3-add-journal.sh
-cp /sbin/tune2fs $INITRDDIR/sbin
-cp /usr/lib/e2initrd_helper $INITRDDIR/bin/e2initrd_helper
-
-case "$VERSION" in
- 2.4.*)
- case "uname -r" in
- 2.4.*) : ;;
- *) LD_ASSUME_KERNEL=2.4.1
- export LD_ASSUME_KERNEL
- ;;
- esac
- ;;
-esac
-
-PROGS="/sbin/tune2fs /usr/lib/e2initrd_helper"
-LIBS=`unset LD_LIBRARY_PATH LD_PRELOAD; ldd $PROGS | \
- grep -vE 'linux-gate.so|linux-vdso.so' | sort -u | awk '{print $3}'`
-for i in $LIBS
-do
- if test -f /etc/ld.so.preload && grep -s ^$i\$ /etc/ld.so.preload; then
- continue
- fi
- mkdir -p `dirname $INITRDDIR/$i`
- cp $i $INITRDDIR/$i
-done
diff --git a/debian/initrd.ext3-add-journal b/debian/initrd.ext3-add-journal
deleted file mode 100644
index 4def7b18..00000000
--- a/debian/initrd.ext3-add-journal
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-#
-# /usr/share/e2fsprogs/initrd.ext3-add-journal
-#
-cd /
-mount -nt proc proc proc
-rootdev=$(cat proc/sys/kernel/real-root-dev)
-cmdline=$(cat /proc/cmdline)
-umount -n proc
-if [ $rootdev != 256 -a $rootdev != 255 ]; then
- mount -nt tmpfs tmpfs /dev2
- get_device
- roottype=`/bin/e2initrd_helper -r /dev2/root2`
- if test -n "$roottype" ; then
- mount -nt tmpfs tmpfs /etc
- echo >> /etc/fstab
- echo >> /etc/mtab
- if test "$roottype" = "ext3" ; then
- /sbin/tune2fs -O has_journal /dev2/root2 > /dev/null 2>&1
- else
- /sbin/tune2fs -O ^has_journal /dev2/root2 > /dev/null 2>&1
- fi
- umount -n /etc
- fi
- umount -n /dev2
- umount -n /proc > /dev/null 2>&1
-fi
diff --git a/debian/rules b/debian/rules
index 495c8571..9fe59e63 100755
--- a/debian/rules
+++ b/debian/rules
@@ -385,17 +385,6 @@ binary-arch: install install-udeb
$(INSTALL) -m 0644 -D -p debian/$$i ${debdir}/$${pkg}/usr/share/lintian/overrides/$${pkg} ;\
done
- # mkinitrd script
- mkdir -p debian/e2fsprogs/usr/share/initrd-tools/scripts
- $(INSTALL) -p -o root -g root -m 0755 debian/initrd-tools.e2fsprogs \
- debian/e2fsprogs/usr/share/initrd-tools/scripts/e2fsprogs
-
- # initrd script
- mkdir -p debian/e2fsprogs/usr/share/e2fsprogs
- $(INSTALL) -p -o root -g root -m 0755 debian/initrd.ext3-add-journal \
- debian/e2fsprogs/usr/share/e2fsprogs/initrd.ext3-add-journal
-
-
# symlinks to prepare dh_installdocs run
ifneq ($(UTIL_LINUX_NG),yes)
diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c
index 88cf411a..34eb505f 100644
--- a/debugfs/set_fields.c
+++ b/debugfs/set_fields.c
@@ -135,6 +135,11 @@ static struct field_set_info super_fields[] = {
{ "raid_stripe_width", &set_sb.s_raid_stripe_width, 4, parse_uint },
{ "log_groups_per_flex", &set_sb.s_log_groups_per_flex, 1, parse_uint },
{ "kbytes_written", &set_sb.s_kbytes_written, 8, parse_uint },
+ { "snapshot_inum", &set_sb.s_snapshot_inum, 4, parse_uint },
+ { "snapshot_id", &set_sb.s_snapshot_id, 4, parse_uint },
+ { "snapshot_r_blocks_count", &set_sb.s_snapshot_r_blocks_count, 8,
+ parse_uint },
+ { "snapshot_list", &set_sb.s_snapshot_list, 4, parse_uint },
{ 0, 0, 0, 0 }
};
diff --git a/e2fsck/ea_refcount.c b/e2fsck/ea_refcount.c
index 39f2db7f..b10cfffa 100644
--- a/e2fsck/ea_refcount.c
+++ b/e2fsck/ea_refcount.c
@@ -196,9 +196,14 @@ retry:
range = 0;
else if (blk > highval)
range = 1;
- else
+ else {
range = ((float) (blk - lowval)) /
(highval - lowval);
+ if (range > 0.9)
+ range = 0.9;
+ if (range < 0.1)
+ range = 0.1;
+ }
mid = low + ((int) (range * (high-low)));
}
#endif
diff --git a/e2fsck/iscan.c b/e2fsck/iscan.c
index e9fa0763..84e2cc17 100644
--- a/e2fsck/iscan.c
+++ b/e2fsck/iscan.c
@@ -51,7 +51,7 @@ static void usage(void)
static void PRS(int argc, char *argv[])
{
int flush = 0;
- char c;
+ int c;
#ifdef MTRACE
extern void *mallwatch;
#endif
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index bae3b38c..6cb2214b 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1061,6 +1061,8 @@ restart:
orig_retval = retval;
retval = try_open_fs(ctx, flags, io_ptr, &fs);
if ((orig_retval == 0) && retval != 0) {
+ if (fs)
+ ext2fs_close(fs);
com_err(ctx->program_name, retval,
"when using the backup blocks");
printf(_("%s: going back to original "
@@ -1448,6 +1450,8 @@ no_journal:
sb->s_mnt_count = 0;
if (!(ctx->flags & E2F_FLAG_TIME_INSANE))
sb->s_lastcheck = ctx->now;
+ memset(((char *) sb) + EXT4_S_ERR_START, 0,
+ EXT4_S_ERR_LEN);
ext2fs_mark_super_dirty(fs);
}
}
diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c
index bc80e647..6964519d 100644
--- a/lib/e2p/ls.c
+++ b/lib/e2p/ls.c
@@ -350,6 +350,48 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
fprintf(f, "type %u\n", sb->s_jnl_backup_type);
}
}
+ if (sb->s_snapshot_inum) {
+ fprintf(f, "Snapshot inode: %u\n",
+ sb->s_snapshot_inum);
+ fprintf(f, "Snapshot ID: %u\n",
+ sb->s_snapshot_id);
+ fprintf(f, "Snapshot reserved blocks: %llu\n",
+ sb->s_snapshot_r_blocks_count);
+ }
+ if (sb->s_snapshot_list)
+ fprintf(f, "Snapshot list head: %u\n",
+ sb->s_snapshot_list);
+ if (sb->s_error_count)
+ fprintf(f, "FS Error count: %u\n",
+ sb->s_error_count);
+ if (sb->s_first_error_time) {
+ tm = sb->s_first_error_time;
+ fprintf(f, "First error time: %s", ctime(&tm));
+ memset(buf, 0, sizeof(buf));
+ strncpy(buf, sb->s_first_error_func,
+ sizeof(sb->s_first_error_func));
+ fprintf(f, "First error function: %s\n", buf);
+ fprintf(f, "First error line #: %u\n",
+ sb->s_first_error_line);
+ fprintf(f, "First error inode #: %u\n",
+ sb->s_first_error_ino);
+ fprintf(f, "First error block #: %llu\n",
+ sb->s_first_error_block);
+ }
+ if (sb->s_last_error_time) {
+ tm = sb->s_last_error_time;
+ fprintf(f, "Last error time: %s", ctime(&tm));
+ memset(buf, 0, sizeof(buf));
+ strncpy(buf, sb->s_last_error_func,
+ sizeof(sb->s_last_error_func));
+ fprintf(f, "Last error function: %s\n", buf);
+ fprintf(f, "Last error line #: %u\n",
+ sb->s_last_error_line);
+ fprintf(f, "Last error inode #: %u\n",
+ sb->s_last_error_ino);
+ fprintf(f, "Last error block #: %llu\n",
+ sb->s_last_error_block);
+ }
}
void list_super (struct ext2_super_block * s)
diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in
index 7e29b64d..f25c0b7a 100644
--- a/lib/ext2fs/Makefile.in
+++ b/lib/ext2fs/Makefile.in
@@ -245,11 +245,15 @@ tst_getsectsize: tst_getsectsize.o $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(Q) $(CC) -o tst_sectgetsize tst_getsectsize.o \
$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
+tst_types.o: $(srcdir)/tst_types.c ext2_types.h
+
tst_types: tst_types.o ext2_types.h
$(E) " LD $@"
$(Q) $(CC) -o tst_types tst_types.o
-tst_super_size: tst_super_size.o ext2_fs.h
+tst_super_size.o: $(srcdir)/tst_super_size.c $(srcdir)/ext2_fs.h
+
+tst_super_size: tst_super_size.o
$(E) " LD $@"
$(Q) $(CC) -o tst_super_size tst_super_size.o
diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index 7a093603..fa256e55 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -504,6 +504,12 @@ struct ext2_inode_large {
#define EXT2_ERRORS_PANIC 3 /* Panic */
#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
+#if (__GNUC__ >= 4)
+#define ext4_offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER)
+#else
+#define ext4_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
/*
* Structure of the super block
*/
@@ -597,9 +603,24 @@ struct ext2_super_block {
__u64 s_snapshot_r_blocks_count; /* reserved blocks for active
snapshot's future use */
__u32 s_snapshot_list; /* inode number of the head of the on-disk snapshot list */
- __u32 s_reserved[155]; /* Padding to the end of the block */
+#define EXT4_S_ERR_START ext4_offsetof(struct ext2_super_block, s_error_count)
+ __u32 s_error_count; /* number of fs errors */
+ __u32 s_first_error_time; /* first time an error happened */
+ __u32 s_first_error_ino; /* inode involved in first error */
+ __u64 s_first_error_block; /* block involved of first error */
+ __u8 s_first_error_func[32]; /* function where the error happened */
+ __u32 s_first_error_line; /* line number where error happened */
+ __u32 s_last_error_time; /* most recent time of an error */
+ __u32 s_last_error_ino; /* inode involved in last error */
+ __u32 s_last_error_line; /* line number where error happened */
+ __u64 s_last_error_block; /* block involved of last error */
+ __u8 s_last_error_func[32]; /* function where the error happened */
+#define EXT4_S_ERR_END ext4_offsetof(struct ext2_super_block, s_error_count)
+ __u32 s_reserved[128]; /* Padding to the end of the block */
};
+#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
+
/*
* Codes for operating systems
*/
diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index 9dd2d4bc..619bd2d5 100644
--- a/lib/ext2fs/swapfs.c
+++ b/lib/ext2fs/swapfs.c
@@ -71,6 +71,12 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
sb->s_want_extra_isize = ext2fs_swab16(sb->s_want_extra_isize);
sb->s_flags = ext2fs_swab32(sb->s_flags);
sb->s_kbytes_written = ext2fs_swab64(sb->s_kbytes_written);
+ sb->s_snapshot_inum = ext2fs_swab32(sb->s_snapshot_inum);
+ sb->s_snapshot_id = ext2fs_swab32(s_snapshot_id);
+ sb->s_snapshot_r_blocks_count =
+ ext2fs_swab64(sb->s_snapshot_r_blocks_count);
+ sb->s_snapshot_list = ext2fs_swab32(sb->s_snapshot_list);
+
for (i=0; i < 4; i++)
sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
diff --git a/lib/ext2fs/tst_super_size.c b/lib/ext2fs/tst_super_size.c
index 49a561ff..606479ca 100644
--- a/lib/ext2fs/tst_super_size.c
+++ b/lib/ext2fs/tst_super_size.c
@@ -15,14 +15,127 @@
#include "ext2_fs.h"
+#define sb_struct ext2_super_block
+#define sb_struct_name "ext2_super_block"
+
+struct sb_struct sb;
+
+int verbose = 0;
+
+#define offsetof(type, member) __builtin_offsetof (type, member)
+#define check_field(x) cur_offset = do_field(#x, sizeof(sb.x), \
+ offsetof(struct sb_struct, x), \
+ cur_offset)
+
+static int do_field(const char *field, size_t size, int offset, int cur_offset)
+{
+ if (offset != cur_offset) {
+ printf("Warning! Unexpected offset at %s\n", field);
+ exit(1);
+ }
+ printf("%8d %-30s %3u\n", offset, field, (unsigned) size);
+ return offset + size;
+}
+
+void check_superblock_fields()
+{
+#if (__GNUC__ >= 4)
+ int cur_offset = 0;
+
+ printf("%8s %-30s %3s\n", "offset", "field", "size");
+ check_field(s_inodes_count);
+ check_field(s_blocks_count);
+ check_field(s_r_blocks_count);
+ check_field(s_free_blocks_count);
+ check_field(s_free_inodes_count);
+ check_field(s_first_data_block);
+ check_field(s_log_block_size);
+ check_field(s_log_frag_size);
+ check_field(s_blocks_per_group);
+ check_field(s_frags_per_group);
+ check_field(s_inodes_per_group);
+ check_field(s_mtime);
+ check_field(s_wtime);
+ check_field(s_mnt_count);
+ check_field(s_max_mnt_count);
+ check_field(s_magic);
+ check_field(s_state);
+ check_field(s_errors);
+ check_field(s_minor_rev_level);
+ check_field(s_lastcheck);
+ check_field(s_checkinterval);
+ check_field(s_creator_os);
+ check_field(s_rev_level);
+ check_field(s_def_resuid);
+ check_field(s_def_resgid);
+ check_field(s_first_ino);
+ check_field(s_inode_size);
+ check_field(s_block_group_nr);
+ check_field(s_feature_compat);
+ check_field(s_feature_incompat);
+ check_field(s_feature_ro_compat);
+ check_field(s_uuid);
+ check_field(s_volume_name);
+ check_field(s_last_mounted);
+ check_field(s_algorithm_usage_bitmap);
+ check_field(s_prealloc_blocks);
+ check_field(s_prealloc_dir_blocks);
+ check_field(s_reserved_gdt_blocks);
+ check_field(s_journal_uuid);
+ check_field(s_journal_inum);
+ check_field(s_journal_dev);
+ check_field(s_last_orphan);
+ check_field(s_hash_seed);
+ check_field(s_def_hash_version);
+ check_field(s_jnl_backup_type);
+ check_field(s_desc_size);
+ check_field(s_default_mount_opts);
+ check_field(s_first_meta_bg);
+ check_field(s_mkfs_time);
+ check_field(s_jnl_blocks);
+ check_field(s_blocks_count_hi);
+ check_field(s_r_blocks_count_hi);
+ check_field(s_free_blocks_hi);
+ check_field(s_min_extra_isize);
+ check_field(s_want_extra_isize);
+ check_field(s_flags);
+ check_field(s_raid_stride);
+ check_field(s_mmp_interval);
+ check_field(s_mmp_block);
+ check_field(s_raid_stripe_width);
+ check_field(s_log_groups_per_flex);
+ check_field(s_reserved_char_pad);
+ check_field(s_reserved_pad);
+ check_field(s_kbytes_written);
+ check_field(s_snapshot_inum);
+ check_field(s_snapshot_id);
+ check_field(s_snapshot_r_blocks_count);
+ check_field(s_snapshot_list);
+ check_field(s_error_count);
+ check_field(s_first_error_time);
+ check_field(s_first_error_ino);
+ check_field(s_first_error_block);
+ check_field(s_first_error_func);
+ check_field(s_first_error_line);
+ check_field(s_last_error_time);
+ check_field(s_last_error_ino);
+ check_field(s_last_error_line);
+ check_field(s_last_error_block);
+ check_field(s_last_error_func);
+ check_field(s_reserved);
+ printf("Ending offset is %d\n\n", cur_offset);
+#endif
+}
+
+
int main(int argc, char **argv)
{
- int s = sizeof(struct ext2_super_block);
+ int s = sizeof(struct sb_struct);
- printf("Size of struct ext2_super_block is %d\n", s);
+ check_superblock_fields();
+ printf("Size of struct %s is %d\n", sb_struct_name, s);
if (s != 1024) {
exit(1);
}
exit(0);
}
-
diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c
index edbe0bb0..b827a494 100644
--- a/misc/e2freefrag.c
+++ b/misc/e2freefrag.c
@@ -177,6 +177,7 @@ errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info)
printf("\nMin. free extent: %lu KB \nMax. free extent: %lu KB\n"
"Avg. free extent: %lu KB\n", info->min, info->max, info->avg);
+ printf("Num. free extent: %lu\n", info->real_free_chunks);
printf("\nHISTOGRAM OF FREE EXTENT SIZES:\n");
printf("%s : %12s %12s %7s\n", "Extent Size Range", "Free extents",
@@ -258,7 +259,8 @@ int main(int argc, char *argv[])
ext2_filsys fs = NULL;
char *device_name;
char *progname;
- char c, *end;
+ char *end;
+ int c;
add_error_table(&et_ext2_error_table);
progname = argv[0];
diff --git a/resize/extent.c b/resize/extent.c
index 0da8df6d..94eb689c 100644
--- a/resize/extent.c
+++ b/resize/extent.c
@@ -167,9 +167,14 @@ __u64 ext2fs_extent_translate(ext2_extent extent, __u64 old_loc)
range = 0;
else if (old_loc > highval)
range = 1;
- else
+ else {
range = ((float) (old_loc - lowval)) /
(highval - lowval);
+ if (range > 0.9)
+ range = 0.9;
+ if (range < 0.1)
+ range = 0.1;
+ }
mid = low + ((__u64) (range * (high-low)));
}
#endif
diff --git a/resize/main.c b/resize/main.c
index 7c4f4dda..7d8b287c 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -345,8 +345,7 @@ int main (int argc, char ** argv)
min_size = calculate_minimum_resize_size(fs);
if (print_min_size) {
- if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
- (fs->super->s_state & EXT2_ERROR_FS) ||
+ if (!force && ((fs->super->s_state & EXT2_ERROR_FS) ||
((fs->super->s_state & EXT2_VALID_FS) == 0))) {
fprintf(stderr,
_("Please run 'e2fsck -f %s' first.\n\n"),
diff --git a/resize/resize2fs.8.in b/resize/resize2fs.8.in
index 3ea7a630..09770e18 100644
--- a/resize/resize2fs.8.in
+++ b/resize/resize2fs.8.in
@@ -31,7 +31,7 @@ enlarge or shrink an unmounted file system located on
If the filesystem is mounted, it can be used to expand the size of the
mounted filesystem, assuming the kernel supports on-line resizing. (As
of this writing, the Linux 2.6 kernel supports on-line resize for
-filesystems mounted using ext3 only.).
+filesystems mounted using ext3 and ext4.).
.PP
The
.I size
diff --git a/tests/progs/test_rel.c b/tests/progs/test_rel.c
index e6997b65..954a7221 100644
--- a/tests/progs/test_rel.c
+++ b/tests/progs/test_rel.c
@@ -713,7 +713,7 @@ void main(int argc, char **argv)
int retval;
int sci_idx;
const char *usage = "Usage: test_rel [-R request] [-f cmd_file]";
- char c;
+ int c;
char *request = 0;
int exit_status = 0;
char *cmd_file = 0;