History log of /external/e2fsprogs/lib/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d25948b9b4a9e361ef071dc8175df0407f60b7e0 21-Nov-2014 JP Abgrall <jpa@google.com> tune2fs: Allow building it as a static lib

This allows getting all of tune2fs as a static library.
The entry point is
int tune2fs_main(int argc, char **argv).
It requires passing argv[0]="tune2fs" to get tune2fs behavior.

Bug: 18430740
Change-Id: I7bf8d96c53066a4da37778c0d67383b0b820e2ff
lkid/Android.mk
2p/Android.mk
t/Android.mk
xt2fs/Android.mk
uota/Android.mk
a9e24fdeb275a2afc964f511583795052801ad65 12-Jun-2014 JP Abgrall <jpa@google.com> lib/uuid: make a static library also

Change-Id: Idb36204f2d8cadb9564db445d5301f705ce4d043
Signed-off-by: JP Abgrall <jpa@google.com>
uid/Android.mk
6c6a75dc1ed760f80417dd52a2a7b570fb738a0a 20-Mar-2014 JP Abgrall <jpa@google.com> llseek: setup the correct seek for ext2fs_llseek

After
http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/commit/lib/ext2fs/llseek.c?id=274d46e1d35af423d0292d63c4d0ad7a03be82ba

with
__linux__
defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE)
SIZEOF_OFF_T >= SIZEOF_LONG_LONG
it leads to ext2fs_llseek() doing a "return lseek(fd, offset, origin);"
Which fails for offsets > 32bit.

Also, with
__linux__
!(defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE))
defined(HAVE_LLSEEK)
SIZEOF_OFF_T == SIZEOF_LONG_LONG
my_llseek is not defined at all. And there is no need to define
llseek as lseek, as llseek is never used.
Luckily ext2fs_llseek() then does "return lseek(...);"
It would seem that my_llseek should be used in both places.

Bug: 13340735
Change-Id: Ie7330300c9c1ca103eaaef97536dcf10adbbba02
Signed-off-by: JP Abgrall <jpa@google.com>
xt2fs/llseek.c
e0ed7404719a9ddd2ba427a80db5365c8bad18c0 20-Mar-2014 JP Abgrall <jpa@google.com> Switch back to 1.42.9 now that there is a fix

Revert "Revert changes that moved from 1.41.14 to 1.42.9"

This reverts commit 65f0aab98b20b5994a726ab90d355248bcddfffd.
akefile.bsd-lib
akefile.elf-lib
akefile.solaris-lib
lkid/Android.mk
lkid/MODULE_LICENSE_LGPL
lkid/Makefile.in
lkid/blkid.pc.in
lkid/blkid_types.h
lkid/blkid_types.h.in
lkid/cache.c
lkid/getsize.c
lkid/list.h
lkid/probe.c
lkid/probe.h
onfig.h.in
irpaths.h.in
2p/MODULE_LICENSE_LGPL
2p/Makefile.in
2p/e2p.h
2p/e2p.pc.in
2p/feature.c
2p/fgetflags.c
2p/fsetflags.c
2p/getflags.c
2p/getversion.c
2p/ls.c
2p/mntopts.c
2p/parse_num.c
2p/pf.c
2p/setflags.c
t/MODULE_LICENSE_MIT
t/Makefile.in
t/com_err.c
t/com_err.h
t/com_err.pc.in
t/com_err.texinfo
t/error_message.c
t/error_table.h
t/et_c.awk
t/et_name.c
t/test_cases/continuation.c
t/test_cases/heimdal.c
t/test_cases/heimdal2.c
t/test_cases/heimdal3.c
t/test_cases/imap_err.c
t/test_cases/simple.c
t/texinfo.tex
xt2fs/Android.mk
xt2fs/MODULE_LICENSE_LGPL
xt2fs/Makefile.in
xt2fs/Makefile.pq
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/badblocks.c
xt2fs/bb_inode.c
xt2fs/bitmaps.c
xt2fs/bitops.c
xt2fs/bitops.h
xt2fs/blkmap64_ba.c
xt2fs/blkmap64_rb.c
xt2fs/blknum.c
xt2fs/block.c
xt2fs/bmap.c
xt2fs/bmap64.h
xt2fs/bmove.c
xt2fs/brel.h
xt2fs/brel_ma.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/crc32c.c
xt2fs/crc32c_defs.h
xt2fs/csum.c
xt2fs/dblist.c
xt2fs/dblist_dir.c
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/dirhash.c
xt2fs/dupfs.c
xt2fs/e2image.h
xt2fs/expanddir.c
xt2fs/ext2_err.c
xt2fs/ext2_err.et.in
xt2fs/ext2_err.h
xt2fs/ext2_fs.h
xt2fs/ext2_io.h
xt2fs/ext2_types.h
xt2fs/ext2_types.h.in
xt2fs/ext2fs.h
xt2fs/ext2fs.pc.in
xt2fs/ext2fsP.h
xt2fs/ext_attr.c
xt2fs/extent.c
xt2fs/extent_dbg.ct
xt2fs/fiemap.h
xt2fs/fileio.c
xt2fs/finddev.c
xt2fs/flushb.c
xt2fs/freefs.c
xt2fs/gen_bitmap.c
xt2fs/gen_bitmap64.c
xt2fs/gen_crc32ctable.c
xt2fs/get_pathname.c
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/i_block.c
xt2fs/icount.c
xt2fs/imager.c
xt2fs/initialize.c
xt2fs/inline.c
xt2fs/inode.c
xt2fs/inode_io.c
xt2fs/io_manager.c
xt2fs/irel.h
xt2fs/ismounted.c
xt2fs/kernel-jbd.h
xt2fs/kernel-list.h
xt2fs/link.c
xt2fs/llseek.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/mmp.c
xt2fs/namei.c
xt2fs/newdir.c
xt2fs/nt_io.c
xt2fs/openfs.c
xt2fs/progress.c
xt2fs/punch.c
xt2fs/qcow2.c
xt2fs/qcow2.h
xt2fs/rbtree.c
xt2fs/rbtree.h
xt2fs/read_bb.c
xt2fs/read_bb_file.c
xt2fs/res_gdt.c
xt2fs/rw_bitmaps.c
xt2fs/sparse.c
xt2fs/swapfs.c
xt2fs/symlink.c
xt2fs/tdb.c
xt2fs/tdb.h
xt2fs/test_io.c
xt2fs/tst_badblocks.c
xt2fs/tst_bitmaps.c
xt2fs/tst_bitmaps_cmd.ct
xt2fs/tst_bitmaps_cmds
xt2fs/tst_bitmaps_exp
xt2fs/tst_bitops.c
xt2fs/tst_fs_struct.c
xt2fs/tst_inode_size.c
xt2fs/tst_iscan.c
xt2fs/tst_super_size.c
xt2fs/undo_io.c
xt2fs/unix_io.c
xt2fs/valid_blk.c
uota/Android.mk
uota/Makefile.in
uota/common.h
uota/dqblk_v2.h
uota/mkquota.c
uota/mkquota.h
uota/quota.pc.in
uota/quotaio.c
uota/quotaio.h
uota/quotaio_tree.c
uota/quotaio_tree.h
uota/quotaio_v2.c
uota/quotaio_v2.h
s/MODULE_LICENSE_MIT
s/Makefile.in
s/error.c
s/execute_cmd.c
s/help.c
s/invocation.c
s/list_rqs.c
s/pager.c
s/parse.c
s/request_tbl.c
s/ss.h
s/ss.pc.in
s/ss_internal.h
uid/MODULE_LICENSE_BSD_LIKE
uid/Makefile.in
uid/gen_uuid.c
uid/tst_uuid.c
uid/uuid.pc.in
uid/uuid_time.c
65f0aab98b20b5994a726ab90d355248bcddfffd 06-Mar-2014 JP Abgrall <jpa@google.com> Revert changes that moved from 1.41.14 to 1.42.9

Revert "e2fsck: Don't use e2fsck_global_ctx unless HAVE_SIGNAL_H"
commit e80e74c41d85ff93f3d212ba6512340f48054a93.

Revert "Merge remote-tracking branch 'linaro/linaro-1.42.9' into aosp_master"
This reverts commit e97b2b6fc82f840e84dfc631b87f21be44ff2421, reversing
changes made to 7e2fb9d09c245eba70ee008b78007315e9c0f1df.

Revert "Prepare for upstream 1.42.9"
This reverts commit 7e2fb9d09c245eba70ee008b78007315e9c0f1df.

Bug: 13340735
Change-Id: If48b153a95ef5f69f7cdccb00e23524abff3c5a8
Signed-off-by: JP Abgrall <jpa@google.com>
akefile.bsd-lib
akefile.elf-lib
akefile.solaris-lib
lkid/Android.mk
lkid/MODULE_LICENSE_LGPL
lkid/Makefile.in
lkid/blkid.pc.in
lkid/blkid_types.h
lkid/blkid_types.h.in
lkid/cache.c
lkid/getsize.c
lkid/list.h
lkid/probe.c
lkid/probe.h
onfig.h.in
irpaths.h.in
2p/MODULE_LICENSE_LGPL
2p/Makefile.in
2p/e2p.h
2p/e2p.pc.in
2p/feature.c
2p/fgetflags.c
2p/fsetflags.c
2p/getflags.c
2p/getversion.c
2p/ls.c
2p/mntopts.c
2p/parse_num.c
2p/pf.c
2p/setflags.c
t/MODULE_LICENSE_MIT
t/Makefile.in
t/com_err.c
t/com_err.h
t/com_err.pc.in
t/com_err.texinfo
t/error_message.c
t/error_table.h
t/et_c.awk
t/et_name.c
t/test_cases/continuation.c
t/test_cases/heimdal.c
t/test_cases/heimdal2.c
t/test_cases/heimdal3.c
t/test_cases/imap_err.c
t/test_cases/simple.c
t/texinfo.tex
xt2fs/Android.mk
xt2fs/MODULE_LICENSE_LGPL
xt2fs/Makefile.in
xt2fs/Makefile.pq
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/badblocks.c
xt2fs/bb_inode.c
xt2fs/bitmaps.c
xt2fs/bitops.c
xt2fs/bitops.h
xt2fs/blkmap64_ba.c
xt2fs/blkmap64_rb.c
xt2fs/blknum.c
xt2fs/block.c
xt2fs/bmap.c
xt2fs/bmap64.h
xt2fs/bmove.c
xt2fs/brel.h
xt2fs/brel_ma.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/crc32c.c
xt2fs/crc32c_defs.h
xt2fs/csum.c
xt2fs/dblist.c
xt2fs/dblist_dir.c
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/dirhash.c
xt2fs/dupfs.c
xt2fs/e2image.h
xt2fs/expanddir.c
xt2fs/ext2_err.c
xt2fs/ext2_err.et.in
xt2fs/ext2_err.h
xt2fs/ext2_fs.h
xt2fs/ext2_io.h
xt2fs/ext2_types.h
xt2fs/ext2_types.h.in
xt2fs/ext2fs.h
xt2fs/ext2fs.pc.in
xt2fs/ext2fsP.h
xt2fs/ext_attr.c
xt2fs/extent.c
xt2fs/extent_dbg.ct
xt2fs/fiemap.h
xt2fs/fileio.c
xt2fs/finddev.c
xt2fs/flushb.c
xt2fs/freefs.c
xt2fs/gen_bitmap.c
xt2fs/gen_bitmap64.c
xt2fs/gen_crc32ctable.c
xt2fs/get_pathname.c
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/i_block.c
xt2fs/icount.c
xt2fs/imager.c
xt2fs/initialize.c
xt2fs/inline.c
xt2fs/inode.c
xt2fs/inode_io.c
xt2fs/io_manager.c
xt2fs/irel.h
xt2fs/ismounted.c
xt2fs/kernel-jbd.h
xt2fs/kernel-list.h
xt2fs/link.c
xt2fs/llseek.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/mmp.c
xt2fs/namei.c
xt2fs/newdir.c
xt2fs/nt_io.c
xt2fs/openfs.c
xt2fs/progress.c
xt2fs/punch.c
xt2fs/qcow2.c
xt2fs/qcow2.h
xt2fs/rbtree.c
xt2fs/rbtree.h
xt2fs/read_bb.c
xt2fs/read_bb_file.c
xt2fs/res_gdt.c
xt2fs/rw_bitmaps.c
xt2fs/sparse.c
xt2fs/swapfs.c
xt2fs/symlink.c
xt2fs/tdb.c
xt2fs/tdb.h
xt2fs/test_io.c
xt2fs/tst_badblocks.c
xt2fs/tst_bitmaps.c
xt2fs/tst_bitmaps_cmd.ct
xt2fs/tst_bitmaps_cmds
xt2fs/tst_bitmaps_exp
xt2fs/tst_bitops.c
xt2fs/tst_fs_struct.c
xt2fs/tst_inode_size.c
xt2fs/tst_iscan.c
xt2fs/tst_super_size.c
xt2fs/undo_io.c
xt2fs/unix_io.c
xt2fs/valid_blk.c
uota/Android.mk
uota/Makefile.in
uota/common.h
uota/dqblk_v2.h
uota/mkquota.c
uota/mkquota.h
uota/quota.pc.in
uota/quotaio.c
uota/quotaio.h
uota/quotaio_tree.c
uota/quotaio_tree.h
uota/quotaio_v2.c
uota/quotaio_v2.h
s/MODULE_LICENSE_MIT
s/Makefile.in
s/error.c
s/execute_cmd.c
s/help.c
s/invocation.c
s/list_rqs.c
s/pager.c
s/parse.c
s/request_tbl.c
s/ss.h
s/ss.pc.in
s/ss_internal.h
uid/MODULE_LICENSE_BSD_LIKE
uid/Makefile.in
uid/gen_uuid.c
uid/tst_uuid.c
uid/uuid.pc.in
uid/uuid_time.c
9f9a0502c08474b18ab6084f0c251672eb8543d7 17-Oct-2013 Jeff Sharkey <jsharkey@android.com> Fix blkid time diff bug, build binary.

When calculating time diffs, use difftime() instead of risking
integer overflow. Also build a "blkid" binary.

Bug: 11175082
Change-Id: I23521f45204574bb32f152926401c2cbad93175b
lkid/probe.c
18a1444b4f1e6a0948fd38fa0de382d86cfe04de 31-Dec-2013 Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> Add files that would normally be generated by the e2fsprogs build system

Android doesn't run ./configure and friends, so it has to rely on
pre-populated versions of the autogenerated files.

This is somewhat bogus (e.g. hardcoded little-endian reference in
lib/ext2fs/ext2_types.h) and should at some point be fixed, but it's
what Android has always done, not a regression from the 1.41.14 branch.

Also, don't #include config.h which we don't generate (we pass what it
usually contains as -D parameters from Android.mk) anywhere.

Add a new Android.mk file for the quota library.

Change-Id: I162c6327fee5bd06261d9cdcc34bda10f04a6f21
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
lkid/blkid.h
lkid/blkid_types.h
lkid/cache.c
lkid/dev.c
lkid/devname.c
lkid/devno.c
lkid/getsize.c
lkid/llseek.c
lkid/probe.c
lkid/read.c
lkid/resolve.c
lkid/save.c
lkid/tag.c
lkid/tst_types.c
lkid/version.c
2p/feature.c
2p/fgetflags.c
2p/fgetversion.c
2p/fsetflags.c
2p/fsetversion.c
2p/getflags.c
2p/getversion.c
2p/hashstr.c
2p/iod.c
2p/ls.c
2p/mntopts.c
2p/ostype.c
2p/parse_num.c
2p/pe.c
2p/percent.c
2p/pf.c
2p/ps.c
2p/setflags.c
2p/setversion.c
2p/uuid.c
t/com_err.c
t/com_right.c
t/error_message.c
t/et_name.c
t/init_et.c
t/vfprintf.c
xt2fs/Android.mk
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/badblocks.c
xt2fs/bb_compat.c
xt2fs/bb_inode.c
xt2fs/bitmaps.c
xt2fs/bitops.c
xt2fs/blkmap64_ba.c
xt2fs/blknum.c
xt2fs/block.c
xt2fs/bmap.c
xt2fs/bmove.c
xt2fs/brel_ma.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/crc16.c
xt2fs/crc32c.c
xt2fs/csum.c
xt2fs/dblist.c
xt2fs/dblist_dir.c
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/dirhash.c
xt2fs/dosio.c
xt2fs/dupfs.c
xt2fs/expanddir.c
xt2fs/ext2_err.c
xt2fs/ext2_err.h
xt2fs/ext2_types.h
xt2fs/ext_attr.c
xt2fs/extent.c
xt2fs/fileio.c
xt2fs/finddev.c
xt2fs/flushb.c
xt2fs/freefs.c
xt2fs/gen_bitmap.c
xt2fs/gen_bitmap64.c
xt2fs/get_pathname.c
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/i_block.c
xt2fs/icount.c
xt2fs/imager.c
xt2fs/ind_block.c
xt2fs/initialize.c
xt2fs/inline.c
xt2fs/inode.c
xt2fs/inode_io.c
xt2fs/io_manager.c
xt2fs/irel_ma.c
xt2fs/ismounted.c
xt2fs/link.c
xt2fs/llseek.c
xt2fs/lookup.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/mmp.c
xt2fs/namei.c
xt2fs/native.c
xt2fs/newdir.c
xt2fs/nt_io.c
xt2fs/openfs.c
xt2fs/progress.c
xt2fs/punch.c
xt2fs/qcow2.c
xt2fs/read_bb.c
xt2fs/read_bb_file.c
xt2fs/res_gdt.c
xt2fs/rw_bitmaps.c
xt2fs/swapfs.c
xt2fs/symlink.c
xt2fs/tdb.c
xt2fs/tdbtool.c
xt2fs/test_io.c
xt2fs/tst_badblocks.c
xt2fs/tst_bitmaps.c
xt2fs/tst_bitops.c
xt2fs/tst_byteswap.c
xt2fs/tst_getsectsize.c
xt2fs/tst_getsize.c
xt2fs/tst_inode_size.c
xt2fs/tst_iscan.c
xt2fs/tst_super_size.c
xt2fs/tst_types.c
xt2fs/undo_io.c
xt2fs/unix_io.c
xt2fs/unlink.c
xt2fs/valid_blk.c
xt2fs/version.c
xt2fs/write_bb_file.c
popen.c
uota/Android.mk
uota/mkquota.c
uota/quotaio.c
uota/quotaio_tree.c
uota/quotaio_v2.c
s/data.c
s/error.c
s/execute_cmd.c
s/get_readline.c
s/help.c
s/invocation.c
s/list_rqs.c
s/listen.c
s/pager.c
s/parse.c
s/prompt.c
s/request_tbl.c
s/requests.c
s/test_ss.c
uid/clear.c
uid/compare.c
uid/copy.c
uid/gen_uuid.c
uid/gen_uuid_nt.c
uid/isnull.c
uid/pack.c
uid/parse.c
uid/tst_uuid.c
uid/unpack.c
uid/unparse.c
uid/uuid.h
uid/uuid_time.c
uid/uuid_types.h
5fe0b41dba699fa14432a633c863ea8cb7bf3f5d 31-Dec-2013 Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> Re-add Android makefiles from AOSP master

Change-Id: I6c6dbe11baa395442f4cf845ad39801f1c426129
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
ndroid.mk
lkid/Android.mk
2p/Android.mk
t/Android.mk
xt2fs/Android.mk
uid/Android.mk
b79e338d2ca2d148164deff2129d33eac665ac6c 28-Dec-2013 Theodore Ts'o <tytso@mit.edu> Use makeinfo --html instead of texi2html

The texi2html utility from the texi2html ceased being developed
upstream in 2011, and upstream has declared it superseded by the
makeinfo utility from the texinfo package.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/Makefile.in
t/com_err.texinfo
aa2c743331f392e49d5b168b5e3d8c8a8084b8b4 25-Dec-2013 Theodore Ts'o <tytso@mit.edu> e2image: only skip writing zero blocks when writing to a new file

The e2image progam was originally intended to create image files.
However, some people have started using e2image to copy a file system
from one block device to another, since it is more efficient than
using dd because it only copies the blocks which are in use. If we
are doing this, however, we must not skip writing blocks which are all
zero in the source device, since they may not be zero in the
destination device.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Phillip Susi <psusi@ubuntu.com>
xt2fs/e2image.h
b3c2a638139b5da7f63f7ebe450860918d297a39 25-Dec-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: checksum bg descriptors larger than 64 bytes

Currently the ext4 block group descriptor is 64 bytes. In case we
need to support larger block group descriptors in the future, teach
ext2fs_group_desc_csum() to checksum parts of the block group
descriptors that libext2fs doesn't yet understand.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
2bc30417541deffca795db8ec4e7f7ccb616dc3f 23-Dec-2013 Andreas Dilger <adilger@dilger.ca> debugfs, e2fsck: fix s_desc_size handling

The s_desc_size in the superblock specifies the group descriptor
size in bytes, but in various places the EXT4_FEATURE_INCOMPAT_64BIT
flag implies that the descriptor size is EXT2_MIN_DESC_SIZE_64BIT
(64 bytes) instead of checking the actual size. In other places,
the s_desc_size field is used without checking for INCOMPAT_64BIT.

In the case of ext2fs_group_desc() the s_desc_size was being ignored,
and assumed to be sizeof(struct ext4_group_desc), which would result
in garbage for any but the first group descriptor. Similarly, in
ext2fs_group_desc_csum() and print_csum() they assumed that the
maximum group descriptor size was sizeof(struct ext4_group_desc).
Fix these functions to use the actual superblock s_desc_size if
INCOMPAT_64BIT.

Conversely, in ext2fs_swap_group_desc2() s_desc_size was used
without checking for INCOMPAT_64BIT being set.

The e2fsprogs behaviour is different than that of the kernel,
which always checks INCOMPAT_64BIT, and only uses s_desc_size to
determine the offset of group descriptors and what range of bytes
to checksum.

Allow specifying the s_desc_size field at mke2fs time with the
"-E desc_size=NNN" option. Allow a power-of-two s_desc_size
value up to s_blocksize if INCOMPAT_64BIT is specified. This
is not expected to be used by regular users at this time, so it
is not currently documented in the mke2fs usage or man page.

Add m_desc_size_128, f_desc_size_128, and f_desc_bad test cases to
verify mke2fs and e2fsck handling of larger group descriptor sizes.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/blknum.c
xt2fs/csum.c
xt2fs/initialize.c
xt2fs/swapfs.c
11d1116a7c0b833af317249d12025413fecbcd70 23-Dec-2013 Andreas Dilger <adilger@dilger.ca> e2fsck: verify s_desc_size is power-of-two value

Add a LOG2_CHECK mode for check_super_value() so that it is easy
to verify values that are supposed to be power-of-two values
(s_desc_size and s_inode_size so far). In ext2fs_check_desc()
also check for a power-of-two s_desc_size.

Print out s_desc_size in debugfs "stats" and dumpe2fs output, if
it is non-zero.

It turns out that the s_desc_size validation in check_super_block()
is not currently used by e2fsck, because the group descriptors are
verified earlier by ext2fs_check_desc(), and even without an
explicit check of s_desc_size the group descriptors fail to align
correctly on disk. It makes sense to keep the check_super_block()
regardless, in case the code changes at some point in the future.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/ext2_fs.h
f404167dda29a59d2be2882328aeb074b9899669 17-Dec-2013 Theodore Ts'o <tytso@mit.edu> Clean up sparse warnings

Mostly by adding static and removing excess extern qualifiers. Also
convert a few remaining non-ANSI function declarations to ANSI.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/com_err.c
t/error_message.c
t/error_table.h
t/et_name.c
xt2fs/Makefile.in
xt2fs/bmap.c
xt2fs/dblist.c
xt2fs/dir_iterate.c
xt2fs/extent.c
xt2fs/fileio.c
xt2fs/mmp.c
xt2fs/punch.c
s/error.c
s/execute_cmd.c
s/help.c
s/invocation.c
s/pager.c
s/parse.c
s/request_tbl.c
s/ss_internal.h
fbabd5c44c2303501ad79b0e0386fe6436e0e147 16-Dec-2013 Kazuya Mio <k-mio@sx.jp.nec.com> mke2fs: disallow creating FS on a loop mounted file with no option

When /etc/mtab is a symlink of /proc/mounts, mke2fs without -FF option
can create a filesystem on the image file that is mounted.
According to mke2fs man page, we should specify -FF option in this case.

This patch protects filesystem from unintended mke2fs caused by human error.

How to reproduce:
# mke2fs -t ext4 -Fq fs.img
# mount -o loop fs.img /mnt/mp1
# mke2fs -t ext4 -Fq fs.img && echo "mke2fs success"
mke2fs success

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ismounted.c
230272c15a71edfd53bc805adf560d0386dddff3 16-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: don't update the summary counts when doing implied cluster allocation

When we're appending a block to a directory file or the journal file,
and the new block is part of a cluster that has already been allocated
to the file (implied cluster allocation), don't update the bitmap or
the summary counts because that was performed when the cluster was
allocated.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/expanddir.c
xt2fs/mkjournal.c
84397754250d13e8596dd68c157c4c9863800079 16-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: only punch complete clusters

When bigalloc is enabled, using ext2fs_block_alloc_stats2() to free
any block in a cluster has the effect of freeing the entire cluster.
This is problematic if a caller instructs us to punch, say, blocks
12-15 of a 16-block cluster, because blocks 0-11 now point to a "free"
cluster.

The naive way to solve this problem is to see if any of the other
blocks in this logical cluster map to a physical cluster. If so, then
we know that the cluster is still in use and it mustn't be freed.
Otherwise, we are punching the last mapped block in this cluster, so
we can free the cluster.

The implementation given only does the rigorous checks for the partial
clusters at the beginning and end of the punching range.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
xt2fs/ext2fs.h
xt2fs/punch.c
eaf4403561c5822d3cdcc93092039d49d1c0375e 16-Dec-2013 Andreas Dilger <adilger@dilger.ca> ext2fs,blkid: delete unused LIST_HEAD() macro

The LIST_HEAD() macro conflicts with the <sys/queue.h> declaration
of the same name. Delete the unused LIST_HEAD() macro from the
libext2fs and libblkid headers to avoid compiler warnings. It can
be replaced by INIT_LIST_HEAD() or LIST_HEAD_INIT() if needed.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/list.h
xt2fs/kernel-list.h
269da3b8068ecb0bdf8077b0f7b27f164203cb35 16-Dec-2013 Andreas Dilger <adilger@dilger.ca> ext2fs: quiet compiler warnings

Include ext2fsP.h in fileio.c for ext2fs_file_block_offset_too_big()
declaration. Fix up the declaration to mark it extern in the header.

Include <strings.h> header for strcasecmp() in tune2fs.c if available,
as described in the strcasecmp(3) man page, instead of doing this
indirectly by declaring _BSD_SOURCE and getting it from <string.h>.

If CONFIG_QUOTA is undefined, parse_quota_opts() is unused in
tune2fs.c so #ifdef it out.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fsP.h
xt2fs/fileio.c
45ff69ffeb700012a7c052f5e45882557a40be7e 16-Dec-2013 Andreas Dilger <adilger@dilger.ca> build: quiet LLVM non-literal string format warning

Compiling with LLVM generates a large number of warnings due
to the use of _() for wrapping strings for i18n:

warning: format string is not a string literal
(potentially insecure) [-Wformat-security]
./nls-enable.h:4:14: note: expanded from macro '_'
#define _(a) (gettext (a))
^~~~~~~~~~~~

These warnings are fixed by using "%s" as the format string,
and then _() is used as the string argument.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/getsize.c
3a941bef3b9036ca3db9d510c71bcae801ea4dd1 16-Dec-2013 Andreas Dilger <adilger@dilger.ca> build: use long long for __u64 by default

Don't print a verbose configure error in parse-types.h if
<asm/types.h> missing and __[SU]*_TYPEDEF is unset. This is
always the case for non-Linux builds.

The printf formatting strings all use "%llu" for printing 64-bit
values and this it produces a large number of warnings if __u64
is defined as "unsigned long". If __U64_TYPEDEF isn't set use
"unsigned long long" for __u64 in ext2-types.h and blkid-types.h
by default instead of using "unsigned long".

Fix a few places where "%d" or "%u" or "%Lu" were used to print a
64-bit value, by converting them to use "%lld" or "%llu" instead.

Fix a few places where "%lu" was used to print .tv_usec, by casting
the variable to "(long)" since .tv_usec is "int" on some systems.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/blkid_types.h.in
xt2fs/ext2_types.h.in
uid/gen_uuid.c
uid/tst_uuid.c
uid/uuid_time.c
a9825cfe945e6dc6e300f89e7e613b80afde0189 15-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: use ext2fs_punch() to truncate quota file

Use the new ext2fs_punch() call to truncate the quota file. This also
eliminates the need to fix it to work with bigalloc.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/quotaio.c
4c6fd9c20a3473db3fe419d613244e26c4a92b7b 15-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: clamp block-map punch range end to 2^32 blocks

In the ^extent case, passing ~0ULL as the 'end' parameter to
ext2fs_punch() causes the (end - start + 1) calculation to overflow to
zero. Since the old-style mapped block files cannot have more than
2^32 blocks, just clamp it to ~0U.

This fixes a regression in t_quota_2off with the patch "libext2fs: use
ext2fs_punch() to truncate quota file" applied.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/punch.c
299cc61755f72311df002cc99dae13f469e0a198 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: zero block contents past EOF when setting size

When we set the file size, find the block containing EOF, and zero
everything in that block past EOF so that we can't return stale data
if we ever use fallocate or truncate to lengthen the file.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fileio.c
042a0f52ec79e448fd798df7757c6addeb00aede 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: don't error out when punching a totally sparse file

If we're asked to punch a file with no data blocks mapped to it and a
non-zero length, we don't need to do any work in ext2fs_punch_extent()
and can return success. Unfortunately, the extent_get() function
returns "no current node" because it (correctly) failed to find any
extents, which is bubbled up to callers. Since no extents being found
is not an error in this corner case, fix up ext2fs_punch_extent() to
return 0 to callers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/punch.c
dc9673abcf8e00f2b2e6e346b6312ef3745ac543 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix punching extents when there are no left extents

When deleting an entire extent, we cannot always slip to the previous
leaf extent because there might not /be/ a previous extent.
Attempting to correct for that error by asking for the 'current' leaf
extent also doesn't work, because the failed attempt to change to the
previous extent leaves us with no current extent.

Fix this problem by recording the lblk of the next extent before
deleting the current extent and _goto()ing to the next extent after
the deletion.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/punch.c
8a86bbb19714c135aef07095d0b3c1d7e4f7a155 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fail fileio write if we can't allocate a block

If we're using ext2fs_file_write() to write to a hole in a file,
ensure that we can actually allocate the block before updating i_size.
In other words, don't update i_size and don't return success if we hit
an error while allocating space.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fileio.c
13b48a0ae1b4556fdddbc3742022137302498300 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix a broken close() test

Zero is a valid file descriptor, so close it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkjournal.c
6a26b38ac46a0489bd477832dcaebd276c2f489b 11-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix memory leaks (on error paths)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/gen_bitmap64.c
xt2fs/mkjournal.c
xt2fs/newdir.c
xt2fs/qcow2.c
8d74ab767d0f97258fed40f2f2d862227545bcea 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: check return values

Fix up a few places where we ignore return values.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/flushb.c
xt2fs/icount.c
xt2fs/imager.c
xt2fs/mkjournal.c
xt2fs/punch.c
b2778bcb8c37705ea97fee58199446d83dbda927 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libquota: fix memory leak (on error path)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/mkquota.c
e46c187aa6ee1ad6f38f0fb9c39da5e2bb6ceeb9 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libss: fix memory handling errors

Fix memory allocation calculations and check for NULL pointer returns.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/invocation.c
s/parse.c
s/request_tbl.c
dc9da630d6f3d6c7284df97f5015e32329da3307 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libss: fix fd error handling

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/help.c
s/list_rqs.c
85b8f7affa5fadb1972e82e04cc3d1828966b238 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> debugfs: don't leak mmp_s memory (on error path)

ext2fs_free_mem() takes a pointer to a pointer, similar to
ext2fs_get_mem(). Improve the documentation, and fix debugfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
56fa48879641603f2a3814fbe130ab2a29dcf411 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fileio should use 64bit io routines

When reading or writing file blocks, use the IO manager routines that
can handle 64bit block numbers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fileio.c
62f17f36031102a2a40fac338e063c556f73b94a 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: make symlinks safe for 64bit blocks and extents

If we have to create a big symlink (i.e. one that doesn't fit into
i_block[]), we are not 64bit block safe and the namei code does not
handle extents at all. Fix both.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/namei.c
xt2fs/symlink.c
ba0230f885af90185d00e7e3702e35c656b47ea1 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix "a" vs "an" in the error catalog

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_err.et.in
1e7451493ed67ae94ba5c1d2bed059527bc9848d 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: don't allow ridiculously large logical block numbers

Forbid clients from trying to map logical block numbers that are
larger than the lblk->pblk data structures are capable of handling.
While we're at it, don't let clients set the file size to a number
that's beyond what can be mapped.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
xt2fs/ext2fsP.h
xt2fs/fileio.c
3b6c0938ec5aa401c7ae6c95e94e5ad30a7b8562 11-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix tests that set LARGE_FILE

For each site where we test for a large file (> 2GB) and set the
LARGE_FILE feature, use a helper function to make the size test
consistent with the test that's in e2fsck. This fixes the fsck
complaints when we try to create a 2GB journal (not so hard with 64k
block size) and fixes the incorrect test in fileio.c.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/fileio.c
xt2fs/mkjournal.c
341bc5e368f7a768482f041971fb3c4b156d6ed9 12-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: don't overflow when punching indirect blocks with large blocks

On a FS with a rather large blockize (> 4K), the old block map
structure can construct a fat enough "tree" (or whatever we call that
lopsided thing) that (at least in theory) one could create mappings
for logical blocks higher than 32 bits. In practice this doesn't
happen, but the 'max' and 'iter' variables that the punch helpers use
will overflow because the BLOCK_SIZE_BITS shifts are too large to fit
a 32-bit variable. The current variable declarations also cause punch
to fail on TIND-mapped blocks even if the file is < 16T. So enlarge
the fields to fit.

Yes, this is an obscure corner case, but it seems a little silly if we
can't punch a file's block 300,000,000 on a 64k-block filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/punch.c
2fe2d408a4e231eb5d2342b7f3dbd155563aa755 04-Dec-2013 Andreas Dilger <adilger@dilger.ca> mmp: fix 64-bit handling of s_mmp_block

Fix the checking of s_mmp_block in e2fsck_pass1() and
ext2fs_mmp_read() to handle the high 32 bits of s_blocks_count.
Remove redundant check of s_mmp_block in do_dump_mmp() right before
ext2fs_mmp_read() is called.

Also fix s_blocks_count_hi in check_backup_super_block(), since it
cannot use the ext2fs_blocks_count() helper easily.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mmp.c
17abb05f515d72c78667108a95c904ef65bcc6aa 03-Dec-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix function declarations to match definition

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
144f4e8ca511ef699570bc0426d5969d2b903d77 03-Dec-2013 Eric Whitney <enwlinux@gmail.com> libext2fs: fix printf conversion spec in tst_iscan.c

A recent patch to fix blk_t to blk64_t assignment mismatches in
e2fsprogs (commit 4dbfd79d1458ce1259b951377e341aeb6197f8c1) created
a printf conversion spec / argument type mismatch in tst_iscan.c.
Fix this to avoid truncation of the printed value and to silence
a compiler warning seen when "make check" is run.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tst_iscan.c
15a668c4b57f0d38776a0eac23e884e084a1be87 03-Dec-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: add explicit casts to bitops.h

Add some explicit casts to silence some -Wconversion noise.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
b70483742b7ad993b574fbfb96ce77f5c05c84f9 03-Dec-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: add explicit casts to ext2fs.h

Add some explicit casts to silence some -Wconversion noise.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
496220309337863b45d9ee6173ff431919fb51f5 02-Dec-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: fix some memory leaks with image file handling

These memory leaks were discovered by using "valgrind
--leak-check=full" while running "e2image -I bar.img foo.e2i"

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/freefs.c
xt2fs/openfs.c
8b3c52fb8115c8c37835d74455619f380acbc833 02-Dec-2013 Kit Westneat <kwestneat@ddn.com> libext2fs: set the fs block size to new_io in ext2fs_rewrite_to_io()

e2image manually opens a new IO channel, and then sets the file system
to use this new IO channel via ext2fs_rewrite+to_io(). We need to
make sure the IO channel is set to the file system's block size to
avoid some nasty buffer overruns.

[ Modified by tytso to use io_channel_set_blksize() ]

Signed-off-by: Kit Westneat <kwestneat@ddn.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
xt2fs/openfs.c
d87f198ca3250c9dff6a4002cd2bbbb5ab6f113a 24-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: reject 64bit badblocks numbers

Don't accept block numbers larger than 2^32 for the badblocks list,
and don't run badblocks on them either.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/read_bb_file.c
d36e027f9ce175f2437dcf681479935e185755a0 18-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: stop iterating dirents when done linking

When we've succesfully linked an inode into a directory, we can stop
iterating the directory.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/link.c
43075b42bdff509cc567bd870a32072edf05d04c 14-Oct-2013 Niu Yawei <niu@whamcloud.com> quota: fix disabling quota, add quota tests

Update all superblock copies when disabling the quota feature.

Added basic tests for the quota feature.

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/mkquota.c
832cb612f8c1c10525fe438206d4fe5c6d38a4e7 12-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> e2fsprogs: add (optional) sparse checking to the build

Run sparse against source files when building e2fsprogs with 'make C=1'. If
instead C=2, it configures basic ext2 types for bitwise checking with sparse,
which can help find the (many many) spots where conversion errors are
(possibly) happening.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/Makefile.in
2p/Makefile.in
t/Makefile.in
xt2fs/Makefile.in
xt2fs/ext2fs.h
uota/Makefile.in
s/Makefile.in
uid/Makefile.in
57bde59a067c21ed924de4194344948f3c3ecb9a 12-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: openfs() musn't allow bigalloc without EXT2_FLAGS_64BITS

Currently, only the new 64-bit bitmap implementation supports the
block<->cluster conversions that bigalloc requires. Therefore, if we
have a bigalloc filesystem, require EXT2_FLAGS_64BITS be passed in to
ext2fs_open(). This does not mean that bigalloc file systems have to
be 64-bits; just that the userspace utilities have to be able to use
the new 64-bit capable library functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
xt2fs/openfs.c
2a091427bcbff1fd1cf3f0bccf00da98d52b8f16 08-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: search all possible blocks in implied_cluster_alloc()

implied_cluster_alloc() is written such that if the the user passes in
a logical block that is the zeroth block in a logical cluster (lblk %
cluster_ratio == 0), then it will assume that there is no physical
cluster mapped to any other part of the logical cluster.

This is not true if we happen to be allocating logical blocks in
reverse order. Therefore, search the whole cluster, except for the
lblk that we passed in.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
4605a35d1ef573dc166a73ed910d0ee7b02489cb 08-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix off-by-one error in file truncation

When told to truncate a file, ext2fs_file_set_size2() should start with
the first block past the end of the file. The current calculation
jumps one more block ahead, with the result that it fails to hack off
the last block. Adding blocksize-1 and dividing is sufficient to find
the last block.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fileio.c
470ca046b1e682c419d50efc8d4941db1b8601d9 08-Oct-2013 Niu Yawei <yawei.niu@gmail.com> libext2fs: update i_size in ext2fs_file_write()

ext2fs_file_write() needs to update i_size on successful write,
otherwise, ext2fs_file_read() in same open/close cycle will not
be able to read the just written data.

This fixes a bug which results in the the problem of quotacheck
triggered on 'tune2fs -O quota' failed to write back multiple
users/groups accounting information.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fileio.c
a25487cbaf0e340144cb4673d52136abdb3eb2cf 07-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> e2fsprogs: fix inode and block relocation functions to use blk64_t

The inode and block relocation functions aren't currently compiled in
(so we don't need to worry about breaking ABI compatibility). They
were originally intended for use by resize2fs, but we never ended up
using them, so (wisely) they weren't ever included in libext2fs as an
exported interface (they're not even compiled by the Makefile).

Fix them so that in case we ever use them, so that in places where raw
data types (int, long, etc.) stood in for blk_t and blk64_t. Also fix
some sites where we should probably be using blk64_t.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/brel.h
xt2fs/brel_ma.c
xt2fs/irel.h
4dbfd79d1458ce1259b951377e341aeb6197f8c1 07-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> e2fsprogs: fix blk_t <- blk64_t assignment mismatches

Fix all the places where we should be using a blk64_t instead of a
blk_t. These fixes are more severe because 64bit values could be
truncated silently.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/ext2fsP.h
xt2fs/fileio.c
xt2fs/inode.c
xt2fs/punch.c
xt2fs/tst_iscan.c
581646b94f3b57a461105968b49105a1357216ea 07-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: ind_punch() must not stop examining blocks prematurely

When we're iterating the main loop in ind_punch(), "offset" tracks how
far we've progressed into the block map, "start" tells us where to
start punching, and "count" tells us how many blocks we are to punch
after "start". Therefore, we would like to break out of the loop once
the "offset" that we're looking at has progressed past the end of the
punch range. Unfortunately, if start !=0, the if-break clause in the
loop causes us to break out of the loop early.

Therefore, change the breakout test to terminate the loop at the
correct time.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/punch.c
4ee4ad80dcceb42b1e5cfd2d4067a38b99b9fa95 07-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: allow callers to punch a single block

The range of blocks to punch is treated as an inclusive range on both
ends, i.e. if start=1 and end=2, both blocks 1 and 2 are punched out.
Thus, start == end means that the caller wishes to punch a single
block. Remove the check that prevents us from punching a single
block.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/punch.c
5d494038eede1bb538441dedf4207529629154b3 07-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: rewind extent pointer when totally deleting an extent

During a punch operation, if we decide to delete an extent out of the
extent tree, the subsequent extents are moved on top of the current
extent (that is to say, they're memmmove'd down one slot). Therefore
it is not correct to advance to the next leaf because that means we
miss half the extents in the range! Rereading the current pointer
should be fine.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/punch.c
580d8a0933e9fe390a445c50358af852345c0a47 07-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix a minor grammatical error in the error catalog

'an block' should be 'a block'.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2_err.et.in
92a7b0d2e3f7e0ea190477c82edf57fb85eed95c 01-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: set the large_file feature flag when setting i_size > 2GB

If someone tries to write a file that is larger than 2GB, we need to
set the large_file feature flag to affirm that i_size_hi can hold
meaningful contents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/fileio.c
7320cb7106e5f5a552d07432e9322e1059c02bf3 01-Oct-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: only link an inode into a directory once

The ext2fs_link helper function link_proc does not check the value of
ls->done, which means that if the function finds multiple empty spaces
that will fit the new directory entry, it will create a directory
entry in each of the spaces. Instead of doing that, check the done
value and don't do anything more if we've already added the directory
entry.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/link.c
8ab395524b95875818505a497428cab73e80c0d5 05-Aug-2013 Zheng Liu <wenqing.lz@taobao.com> libext2fs: fix a coding style for EXT2_NO_MTAB_FILE

When we define an error in lib/ext2fs/ext2_err.et.in, we will always use
EXT2_ET_* prefix for a new error. But EXT2_NO_MTAB_FILE doesn't obey
this rule. So fix it.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_err.et.in
xt2fs/ismounted.c
a88c2fb508e42be997512732085a2ed887155b9f 09-Sep-2013 Eric Sandeen <sandeen@redhat.com> resize2fs: fix interior extent node corruption

If we have an extent tree like this (from debuge2fs's "ex" command):

Level Entries Logical Physical Length Flags
...
2/ 2 60/ 63 13096 - 13117 650024 - 650045 22
2/ 2 61/ 63 13134 - 13142 650062 - 650070 9
2/ 2 62/ 63 13193 - 13194 650121 - 650122 2
2/ 2 63/ 63 13227 - 13227 650155 - 650155 1 A)
1/ 2 4/ 14 13228 - 17108 655367 3881 B)
2/ 2 1/117 13228 - 13251 650156 - 650179 24 C)
2/ 2 2/117 13275 - 13287 650203 - 650215 13
2/ 2 3/117 13348 - 13353 650276 - 650281 6
...

and we resize the fs in such a way that all of those blocks must
be moved down, we do them one at a time. Eventually we move 1-block
extent A) to a lower block, and then follow it with the other
blocks in the next logical offsets from extent C) in the next
interior node B).

The userspace extent code tries to merge, so when it finds that
logical 13228 can be merged with logical 13227 into a single extent,
it does. And so on, all through extent C), up to block 13250 (why
not 13251? [1]), and eventually move the node block as well.
So we end up with this when all the blocks are moved post-resize:

Level Entries Logical Physical Length Flags
...
2/ 2 120/122 13193 - 13193 33220 - 33220 1
2/ 2 121/122 13194 - 13194 33221 - 33221 1
2/ 2 122/122 13227 - 13250 33222 - 33245 24 D)
1/ 2 5/ 19 13228 - 17108 34676 3881 E) ***
2/ 2 1/222 13251 - 13251 33246 - 33246 1 F)
2/ 2 2/222 13275 - 13286 33247 - 33258 12
...

All those adjacent blocks got moved into extent D), which is nice -
but the next interior node E) was never updated to reflect its new
starting point - it says the leaf extents beneath it start at 13228,
when in fact they start at 13251.

So as we move blocks one by one out of original extent C) above, we
need to keep updating C)'s parent node B) for a proper starting point.
fix_parents() does this.

Once the tree is corrupted like this, more corruption can
ensue post-resize, because we traverse the tree by interior nodes,
relying on their start block to know where we are in the tree.
If it gets off, we'll end up inserting blocks into the wrong part
of the tree, etc.

I have a testcase using fsx to create a complex extent tree which
is then moved during resize; it hit this corruption quite easily,
and with this fix, it succeeds.

Note the first hunk in the commit is for going the other way,
moving the last block of an extent to the extent after it; this
needs the same sort of fix-up, although I haven't seen it in
practice.

[1] We leave the last block because a single-block extent is its
own case, and there is no merging code in that case. \o/

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
816d2c9cf7fb17fe808a081e076cb558f44ec30d 09-Sep-2013 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: ext2fs_dup_handle should not alias MMP buffers

It turns out that resize2fs uses ext2fs_dup_handle to duplicate fs handles. If
MMP is enabled, this causes both handles to share MMP buffers, which is bad
news when it comes time to free both handles. Change the code to (we hope) fix
this. This prevents resize2fs from failing with a double-free error when
handed a MMP filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dupfs.c
42b61c50e5af99a10fc56975ecd08ab71e4f00e8 08-Jul-2013 Theodore Ts'o <tytso@mit.edu> libext2fs, tests: allow /etc/mtab file to be missing

The environment variable EXT2FS_NO_MTAB_OK will suppress the error
code EXT2_NO_MTAB_FILE when the /etc/mtab file can not be found. This
allows the e2fsprogs regression test suite to be run in chroots which
might not have an /etc/mtab file.

By default will still want to complain if the /etc/mtab file is
missing, since we really don't want to discourage distributions and
purveyors of embedded systems from running without an /etc/mtab file.
But if it's missing it only results in a missing sanity check that
might cause file system corruption if the file system is mounted when
programs such as e2fsck, tune2fs, or resize2fs is running, so there is
no potential security problems that might result if this environment
variable is set inappropriately.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ismounted.c
b49d67ddd8af9568bd5eee319af0479f042db4fd 17-Jun-2013 Theodore Ts'o <tytso@mit.edu> Use ext2fs_cpu_to_be32() instead of cpu_to_be32() in kernel-jbd.h

Avoid compatibility problems by using the byte swapping functions
defined by e2fsprogs, instead of the ones defined in the system header
files. We use them everywhere else, so we should use them in
kernel-jbd.h too.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/kernel-jbd.h
3df6014a3d216d19be7d2286de24e8ee106f18ad 16-Jun-2013 Theodore Ts'o <tytso@mit.edu> Work around Debian Bug #712530

Add a test to see if the backtrace() function requires linking in a
library in /usr/lib.

Addresses-Debian-Bug: #708307

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
1ad3174af5213fa7029944cc19723cda08f221d3 16-Jun-2013 Theodore Ts'o <tytso@mit.edu> Try to use secure_getenv() in preference to __secure_getenv()

If secure_getenv() use it in preference to __secure_getenv().
Starting with (e)glibc version 2.17, secure_getenv() exists, while
__secure_getenv() only works with shared library links (where it is a
weak symbol), but not for static links with /lib/libc.a

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/cache.c
onfig.h.in
t/error_message.c
xt2fs/test_io.c
s/pager.c
4718395120454ad7c193c76258ef5359f2ab3f2f 16-Jun-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: optimize ext2fs_bg_has_super()

Reduce the CPU time needed when checking whether a block group has a
sparse superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/ext2fs.h
3ac420165c0ad6cf2aa6450095e55975f4571a3f 10-Jun-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: remove lib/ext2fs/sparse.c

This file was never getting compiled, and there is no user of
ext2fs_list_backups() in the e2fsprogs sources. So remove it as a
clean up.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/sparse.c
577c773a60fa7d167f5aaf717fadd20fe507fb97 20-May-2013 Theodore Ts'o <tytso@mit.edu> misc: fix gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/quotaio.h
uota/quotaio_tree.c
e48bf256e99e4923c6193ff78000af18c700d93d 20-May-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: fix gcc -Wall warnings

Primarily signed vs unsigned and const warnings.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.c
xt2fs/bitops.h
xt2fs/blkmap64_rb.c
xt2fs/block.c
xt2fs/crc32c.c
xt2fs/gen_bitmap64.c
xt2fs/mmp.c
xt2fs/rbtree.c
xt2fs/rbtree.h
xt2fs/rw_bitmaps.c
xt2fs/symlink.c
572ef60b8923dc072e2644f706b25c3c92cb4bb6 22-Apr-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: only use override function when reading an 128 byte inode

The ext2fs_read_inode_full() function should not use fs->read_inode()
if the caller has requested more than the base 128 byte inode
structure and the inode size is greater than 128 bytes. Otherwise the
caller won't get all of the bytes that they were asking for, since
there's no way for the fs->read_inode override function can know what
the size of the buffer passed to ext2fs_read_inode_full().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
8034d9fa0f9a06f5caeab431fe226423dc5dc7d9 22-Apr-2013 Tomas Racek <tracek@redhat.com> e2image: fix flag settings in e2image.h

This prevents from SIGSEGV when -s options is used.

Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
xt2fs/e2image.h
871ad942641b604631a9d33a7008e073ba946a9e 13-Mar-2013 Theodore Ts'o <tytso@mit.edu> blkid: remove no-op statement which caused a clang warning

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
5084088215242e5839fa482dd25e06a127aba311 25-Feb-2013 Jan Kara <jack@suse.cz> libext2fs: Provide prototype for ext2fs_symlink()

New function ext2fs_symlink() doesn't have a prototype in ext2fs.h and
thus debugfs compilation gives warning:

debugfs.c:2219:2: warning: implicit declaration of function 'ext2fs_symlink'

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
9e20cf223ad6e44536f7e3116413cc8a445618c7 25-Feb-2013 Jan Kara <jack@suse.cz> e2p: Fix 's' handling in parse_num_blocks2()

parse_num_blocks2() wrongly did:
num << 1;
when log_block_size < 0. That is obviously wrong as such statement has
no effect (and the compiler properly warns about it). Callers expect
returned value to be in bytes when log_block_size < 0 so fix the
statement accordingly.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/parse_num.c
0d89e5acea99fc00d9b834eab6d228c47a71920a 28-Jan-2013 Philipp Thomas <pth@suse.de> Fix warnings about functions not returning a value

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/gen_bitmap64.c
b55705e0ba83147f16a3abb955f3761f78b7db94 28-Jan-2013 Andreas Dilger <adilger@dilger.ca> build: quiet build warnings for "gcc -Wall"

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_sb.c
274d46e1d35af423d0292d63c4d0ad7a03be82ba 24-Jan-2013 Phillip Susi <psusi@ubuntu.com> libext2fs: fix ext2fs_llseek on i386

ext2fs_llseek() was using lseek instead of lseek64. The
only time it would use lseek64 is if passed an offset that
overflowed 32 bits. This works for SEEK_SET, but not
SEEK_CUR, which can apply a small offset to move the file
pointer past the 32 bit limit.

The code has been changed to instead try lseek64 first, and
fall back to lseek if that fails. It also was doing a
runtime check of the size of off_t. This has been moved to
compile time.

This fixes a problem which would cause e2image when built for
x86-32 to bomb out when used with large file systems.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
xt2fs/llseek.c
3e1816b8cc9086354453bd75aaaeade558f98b3e 20-Jan-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: teach the ext2fs_*_block_bitmap_range2() about clusters

The ext2fs_{mark,unmark,test}_block_bitmap2() functions understand
about clusters, and will take block numbers and convert them to
clusters before checking the bitmap. The
ext2fs_*_block_bitmap_range2() functions did not do this, which made
them inconsistent. Fortunately, nothing has depended on this
incorrect behavior, and in fact most of the usage of these functions
have only recently been added, and only for optimizations that were
only enabled for non-bigalloc file systems.

So this is a change in previously exported functions, but (a) it
doesn't change the behavior at all for non-bigalloc file systems, and
(b) the change is more likely to fix bugs for bigalloc file systems.
For example, this change fixes a problem with resize2fs and bigalloc
file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/gen_bitmap64.c
f01c1a6bce5e6674cbfa5260db1691bca01a4410 04-Jan-2013 Darren Hart <dvhart@infradead.org> libext2fs: add the ext2fs_symlink() function

Creating symlinks is a complex affair when accounting for slowlinks.

Create a new function, ext2fs_symlink(), modeled after ext2fs_mkdir().
Like ext2fs_mkdir(), ext2fs_symlink() takes on the task of allocating a
new inode and block (for slowlinks), setting up sane default values in
the inode, copying the target path to either the inode (for fastlinks)
or to the first block (for slowlinks), and accounting for the inode and
block stats. Disallow link targets longer than blocksize as the Linux
kernel prevents this.

It does not attempt to expand the parent directory, instead returning
EXT2_ET_DIR_NO_SPACE and leaving it to the caller to expand just as
ext2fs_mkdir() does. Ideally, I think both of these functions should
make a single attempt to expand the directory.

[ Fixed a few bugs discovered when creating a test case for ext2fs_symlink() ]

Signed-off-by: Darren Hart <dvhart@infradead.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Andreas Dilger <adilger@dilger.ca>
xt2fs/Makefile.in
xt2fs/ext2_err.et.in
xt2fs/symlink.c
53f2a1eaf051b9ef8a2927cdd7d6de281c8d5a03 16-Jan-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: add error codes from 1.43.x development branch

To maintain the error codes numbering, we need to pull in the changes
from the 1.43.x development branch for the libext2's error table.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_err.et.in
dd4f565d5ac3b1f37100291fb1cd067dd0d55d05 15-Jan-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: avoid 32-bit overflow in ext2fs_initialize with a 512M cluster size

If the user attemps to create a 512MB cluster, we need to adjust the
defaults to avoid a 32-bit overflow of s_blocks_per_group. Also check
to make sure that the caller of ext2fs_initialize() has not given a
value of s_clusters_per_group that would result in an overflow of
s_blocks_per_group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
xt2fs/initialize.c
35d886b67947dcb802da09306b6a85f1e9f99865 15-Jan-2013 Theodore Ts'o <tytso@mit.edu> libe2p: teach parse_num_blocks2() to return bytes if log_block_size < 0

Previously the behavior of parse_num_block2 was undefined if
log_block_size was less than zero. It will now return a number in
units of bytes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
2p/parse_num.c
f0257d8891c602cabc7358a5ca826444a172ccf5 09-Jan-2013 Theodore Ts'o <tytso@mit.edu> libext2fs: ext2fs_open2() should not set ret_fs after a MMP failure

The addition of MMP code was added in the wrong place, so ret_fs could
get set (and EXT2_FLAG_NOFREE_ON_ERROR was cleared as well, which
could confuse e2fsck which depends on this flag being cleared if
ext2fs_open2() succeeded.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
027b0577d4e5081a4d28dff9289559d38a36d533 03-Jan-2013 Theodore Ts'o <tytso@mit.edu> Fix 32-bit overflow problems: dgrp_t * s_blocks_per_group

There are a number of places where we multiply a dgrp_t with
s_blocks_per_group expecting that we will get a blk64_t. This
requires a cast, or using the convenience function
ext2fs_group_first_block2().

This audit was suggested by Eric Sandeen.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
xt2fs/alloc.c
xt2fs/extent.c
xt2fs/mkjournal.c
a0ba54ec00abce6ce9e7e5f2d5f6e0899559ebb8 03-Jan-2013 Theodore Ts'o <tytso@mit.edu> resize2fs: use [un]mark_block_range bitmap functions to reduce CPU usage

Use ext2fs_[un]mark_block_range2() functions to reduce the CPU
overhead of resizing large file systems by 45%, primarily by
reducing the time spent in fix_uninit_block_bitmaps().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_sb.c
ccfedb17b110d8eec6343a1c3a6a2437fea4dbc2 02-Jan-2013 Theodore Ts'o <tytso@mit.edu> Clean up texinfo files

Fix up the com_err.texinfo file so it will produce a valid printed
output, by cleaning up some errors in the texinfo file, and updating
texinfo.tex to be consistent with the version in the doc subdirectory.

Also add rules so we can generate pdf and ps files from
com_err.texinfo and libext2fs.texinfo.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/Makefile.in
t/com_err.texinfo
t/texinfo.tex
e3507739e4185bdb2394928eb6479e48f4e690a8 01-Jan-2013 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall nits

This fixes the last set of gcc -Wall complaints.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/getversion.c
xt2fs/blkmap64_rb.c
xt2fs/imager.c
xt2fs/openfs.c
0ce0172984c807d3366e8db6e2a2b6ecae314832 29-Nov-2012 Andreas Dilger <adilger@dilger.ca> libquota: quiet log_err() bad format warnings

The macro for log_err() was written so that it needed to always
have an argument, but GCC was unhappy to have an argument when
none was specified in the format string. Use the CPP "##" to
eat the preceeding comma if no argument is specified.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/common.h
uota/mkquota.c
uota/quotaio.c
uota/quotaio_tree.c
uota/quotaio_v2.c
00eb0eee0addfd3b7ede98b85e00dff1547838a0 29-Nov-2012 Andreas Dilger <adilger@dilger.ca> build: quiet some "gcc -Wall" compiler warnings

Quiet a number of simple compiler warnings:
- pointers not initialized by ext2fs_get_mem()
- return without value in non-void function
- dereferencing type-punned pointers
- unused variables

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
xt2fs/crc32c.c
xt2fs/dblist.c
xt2fs/qcow2.c
xt2fs/tst_bitmaps.c
uota/mkquota.c
1d6fd6d0c3766a8165e69284c75812574a29c804 29-Nov-2012 Andreas Dilger <adilger@dilger.ca> misc: cleanup unused variables on MacOS

Clean up unused variables found by GCC on MacOS.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/blkmap64_rb.c
xt2fs/bmap.c
xt2fs/ismounted.c
xt2fs/mkjournal.c
xt2fs/rw_bitmaps.c
xt2fs/unix_io.c
uota/quotaio.c
uid/gen_uuid.c
f797cf3e37b476aac593fe9a9f4630448d335332 29-Nov-2012 Andreas Dilger <adilger@dilger.ca> tests: don't consider "make check" a compiler error

In a number of places, the output format from "make check" is
incorrectly interpreted as compiler warning output (triggered by
the presence of colons and parenthesis in the output). Convert
these lines to similar output that does not trigger false build
warnings.

In the case of the tst_uuid.c program, the "ctime()" output was
difficult to change, but in fact it is better to actually compare
the time-based UUID against wallclock time instead of just printing
the formatted time as a string, so this test is improved.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/csum.c
xt2fs/inline.c
uid/tst_uuid.c
068136c31e6fb7d6508d59190eeab6257340075c 23-Dec-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: link the test programs with static libraries

Force the use of the static libraries when linking the test program so
that "make check" works when the shared libraries have not been
installed, and so that we test against the version of the libraries in
the source tree.

Reported-by: g.esp@free.fr
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
bee7b67ce92bb912fccc0dcce3c71c186c2a988b 23-Dec-2012 Theodore Ts'o <tytso@mit.edu> debugfs: add the ability to manipulate the extent tree directly

This commit adds the functionality which had previously only been in
the tst_extents command to debugfs. The debugfs command extent_open
will open extent tree of a particular inode, and enables a series of
commands which will allow the user to interact with the extent tree
directly. Once the extent tree is closed via extent_open(), these
additional commands will be disabled again.

This commit exports two new functions from lib/ext2fs/extent.c which
had previously been statically defined: ext2fs_extent_node_split() and
ext2fs_extent_goto2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/ext2fs.h
xt2fs/extent.c
xt2fs/extent_dbg.ct
eacf6a0878a92836231ee69813cb8764d21140f9 21-Dec-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: ext2fs_extents_fix_parents() should not modify the handle location

Previously, ext2fs_extent_fix_parents() would only avoid modifying the
cursor location associated with the extent handle the cursor was
pointed at a leaf node in the extent tree. This is because it saved
the starting logical block number of the current extent, but not the
"level" of the extent (where level 0 is the leaf node, level 1 is the
interior node which points at blocks containing leaf nodes, etc.)

Fix ext2fs_extent_fix_parents() so it is guaranteed to not change the
current extent in the handle even if the current extent is not at the
bottom of the tree.

Also add a fix_extent command to the tst_extents program to make it
easier to test this function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
xt2fs/extent_dbg.ct
789bd401c3bce85d3c2ae4504ca62509aa0a8b88 20-Dec-2012 Eric Sandeen <sandeen@redhat.com> e2fsck: fix incorrect interior node logical start values

An index node's logical start (ei_block) should
match the logical start of the first node (index
or leaf) below it. If we find a node whose start
does not match its parent, fix all of its parents
accordingly.

If it finds such a problem, we'll see:

Pass 1: Checking inodes, blocks, and sizes
Interior extent node level 0 of inode 274258:
Logical start 3666 does not match logical start 4093 at next level. Fix<y>?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/extent.c
dbe5c43b2e6fcc8fe831a134fbc3dda1f5dd0733 17-Dec-2012 Mikael Pettersson <mikpe@it.uu.se> libext2fs: remove m68k-specific bitops code

The current m68k code was buggy for multiple reasons; first the bfset,
et. al commands interpret the bit number as a signed number, not an
unsigned number. Secondly, there were missing memory clobbers. Since
there is no real benefit in using explicit asm's at this point (gcc is
smart enough to optimize the generic C code to use the set/clear/test
bit m68k instruction) fix this bug by removing the m68k specific asm
versions of these functions.

Tested on m68k-linux with e2fsprogs-1.42.6 and gcc-4.6.3 as before.
All tests pass and the debug output looks sane.

I compared the e2fsck binaries from the previous build with this
one. They had identical .text sizes, and almost the same number
of bit field instructions (obviously compiler-generated), so this
change should have no serious performance implications.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Schwab <schwab@linux-m68k.org>
xt2fs/bitops.h
4e0bb5eb745009decac4c5836671ff4bef21ce2a 17-Dec-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: fix memory and fd leak in error path of unix_open()

Fix a potential memory leak reported by Li Xi. In addition, there
were possible error cases where the file descriptor would not be
properly closed, so fix those as well while we're at it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Li Xi <pkuelelixi@gmail.com>
xt2fs/unix_io.c
1564150d3111f95317073ebc853b79aa5307cff5 17-Oct-2012 Gregoire Pichon <gregoire.pichon@bull.net> mke2fs: fix handling of mmp_update_interval option

Make sure the s_mmp_update_interval super block field is set
from the file system parameters block which is passed into the
ext2fs_initialize() function.

Addresses-Lustre-Bug: LU-1888

Signed-off-by: Gregoire Pichon <gregoire.pichon@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/initialize.c
b65ccfc7a4e36d152c8ab8af57da783eca965a4c 25-Nov-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: optimize rb_get_bmap_range() for mostly allocated bmaps

This optimizies the CPU utilization of the rb_get_bmap_range()
function when most of the bitmap is allocated.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
xt2fs/blkmap64_rb.c
c3f9641eaf959b4222aa145477e6f0f8811244d8 25-Nov-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: optimize rb_get_bmap_range()

This simplifies the rb_get_bmap_range() function and speeds it up for
the case where most of the bitmap is zero.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
xt2fs/blkmap64_rb.c
c6b006ea6c9fec7f3f33347a52efc396063bcd26 24-Nov-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: add ext2fs_bitcount() function

This function efficiently counts the number of bits in a block of
memory.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
xt2fs/bitops.c
xt2fs/bitops.h
xt2fs/tst_bitmaps.c
xt2fs/tst_bitmaps_cmds
xt2fs/tst_bitmaps_exp
fc8ea52033fffccfd8aeece9babf77c61c38aed9 24-Nov-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: optimize rb_set_bmap_range()

This speeds up reading bitmaps from disk for very large (and full)
disks by significant amounts (i.e., up to two CPU minutes for a 4T
file system).

Addresses-Google-Bug: #7534813

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
xt2fs/blkmap64_rb.c
3e554cc116a55c9fffe17f4e819d5f2ecf8ad0af 23-Nov-2012 Andreas Dilger <adilger@dilger.ca> ext2fs, blkid: localize environment-specific variables

Restructure the ext2fs_get_device_size() and blkid_get_dev_size()
code to localize the variables used for different device probing
methods. This at least reduces the #ifdef mess to only one part
of the code for each method, and avoids "unused variable" compiler
warnings added when variables are declared without being #ifdef'd.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/getsize.c
xt2fs/getsize.c
ab00fdac7c5345d06d936640c12e1d24c7fdb6b2 22-Nov-2012 Andreas Dilger <adilger@whamcloud.com> libext2fs: change mmp.c to LGPL to match other files

Change the license of the mmp.c file to LGPL to match the license
of other files in the libext2fs library.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/mmp.c
fb129bba73868a41df74fec87773abd0c6c6cd4a 06-Oct-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: further optimize rb_test_bit

Profiling shows that rb_test_bit() is now calling ext2fs_rb_next() a
lot, and this function is now the hot spot when running e2freefrag.
If we cache the results of ext2fs_rb_next(), we can eliminate those
extra calls, which further speeds up both e2freefrag and e2fsck by
reducing the amount of CPU time spent in userspace.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/blkmap64_rb.c
0bcba36f3f90488d2ef7502bd3c4f4920f2c4251 06-Oct-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: remove pointless indirection in rbtree bitmaps

The code was previously allocating a single 4 or 8 byte pointer for
the rcursor and wcursor fields in the ext2fs_rb_private structure;
this added two extra memory allocations (which could fail), and extra
indirections, for no good reason. Removing the extra indirection also
makes the code more readable, so it's all upside and no downside.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
xt2fs/blkmap64_rb.c
547a59a821df1cffcd0ca2c763be9ef319cb980b 05-Oct-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: optimize rb_test_bit

Optimize testing for a bit in an rbtree-based bitmap for the case
where the calling application is scanning through the bitmap
sequentially. Previously, we did this for a set of bits which were
inside an allocated extent, but we did not optimize the case where
there was a large number of bits after an allocated extents which were
not in use.

1111111111111110000000000000000000
^ optimized ^not optimized

In my tests of a roughly half-filled file system, the run time of
e2freefrag was halved, and the cpu time spent in userspace was during
e2fsck's pass 5 was reduced by a factor of 30%.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
xt2fs/blkmap64_rb.c
c498cb11d3e72e41af760bd882675f44db8b77e7 23-Sep-2012 Theodore Ts'o <tytso@mit.edu> mke2fs: fix progress suppression to make regression tests reliable

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/progress.c
b2f5ce5516a0b6d261876884139043c8e6579f0a 21-Sep-2012 Theodore Ts'o <tytso@mit.edu> mke2fs: throttle allocating groups progress as well

Throttle updates for the "Allocating Groups" progress updates to once
a second as well. We now do this throttling in libext2fs, so we don't
have to do this for each of mke2fs's progress updates, and because the
updates from ext2fs_allocate_tables() come from within libext2fs
anyway.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/progress.c
ab3f5c5aad6310be1d1891c05f1bc8cf7ccf0cef 10-Sep-2012 Theodore Ts'o <tytso@mit.edu> Allow e2fsprogs to be built using the clang (LLVM) frontend

Since clang uses C99 semantics by default, the main changes required
to allow clang to build e2fsprogs was to add support the C99 inline
semantics, while still allowing us to be built when the legacy (but
still default for gcc) GNU C89 inline semantics are in force.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/bitops.h
xt2fs/ext2fs.h
xt2fs/tst_bitmaps.c
xt2fs/tst_inode_size.c
xt2fs/tst_super_size.c
321649c9f491c2012f5e1a20337fd276bc5290f0 30-Aug-2012 Akira Fujita <a-fujita@rs.jp.nec.com> mke2fs: recalculate the reserved blocks when the last BG is dropped

mke2fs -m option can set reserved blocks ratio up to 50%. But if the
last block group is not big enough to support the necessary data
structures, it gets dropped, we have to recalculate the number of
reserved blocks so that the reserved blocks matches the requested
percentage.

It also avoids a problem where if the user specifies a reserved blocks
of 50%, and after the last partial block group was dropped, if the
number of reserved blocks is greater than 50%, e2fsck will complain.

Steps to reproduce:

1. Create a FS which has the overhead for the last BG
and specify 50 % for reserved blocks ratio
# mke2fs -m 50 -t ext4 DEV 1025M

mke2fs 1.42.5 (29-Jul-2012)
warning: 256 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
656640 inodes, 2621440 blocks
1310848 blocks (50.00%) reserved for the super user
~~~~~~~ <-- Reserved blocks exceed 50% of FS blocks count!

2. e2fsck outputs filesystem corruption
# e2fsck DEV

e2fsck 1.42.5 (29-Jul-2012)
Corruption found in superblock. (r_blocks_count = 1310848).

The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 32768 <device>

Signed-off-by: Akira Fujita <a-fujita@rs.jp.ne.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/initialize.c
d5aa6a82b37a0e78d8882601e6ad9da9d9dcb4da 04-Aug-2012 Theodore Ts'o <tytso@mit.edu> Put ELF_OTHER_LIBS in the right place for the linker

Commit a7c17431b9 attempted to fix a problem where the system
libraries might get used instead of local libraries for things like
-lcom_err. It tried to accomplish this by moving $(ELF_OTHER_LIBS) to
before $(LDFLAGS).

Unfortunately, this was the wrong fix; $(ELF_OTHER_LIBS) *MUST* be
after the object files, or the linker might not pull in the necessary
library and not include it into the DT_NEEDED section of the shared
library. The proper fix is to add a -L$(LIB) before $(LDFLAGS), and
then remove the -L option from all of the ELF_OTHER_LIBS definitions
in the library Makefiles.

Addresses-Sourceforge-Bug: #3554345

Cc: Olivier Blin <olivier.blin@softathome.com>
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.elf-lib
akefile.solaris-lib
lkid/Makefile.in
xt2fs/Makefile.in
uota/Makefile.in
s/Makefile.in
3aa8f60aaedd2e467cae690274c70c3d9835802b 29-Jul-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: fix uninit block calculation when inodes_per_block < first_ino

The following commands:

dd if=/dev/zero of=/tmp/foo count=1 ibs=$(( 256 * 1024 * 1024 ))
mke2fs -N 256 -t ext4 /tmp/foo

... will cause mke2fs to write until it fills the device. The cause
for this is that the explicit request for 256 inodes causes the number
of inodes per block group to be 8. The ext2fs_initialize() function
assumed that all of the reserved inodes would be in the first block
group, which is not true in this case. This caused the number of
uninitialized inodes in the first block group to be negative, which
then resulted in mke2fs trying to zero out a very large number of
blocks. Oops.

Addresses-Sourceforge-Bug: #3528892

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
a7c17431b9fbf767235d614cfe2e4f22ee0d6771 29-Jul-2012 Olivier Blin <olivier.blin@softathome.com> Link shared libraries with local libraries instead of system ones

ELF_OTHER_LIBS usually contains local search dirs (-L ../..), but it
was added in link command after system search dirs from LDFLAGS.

Libraries and executables were linked with the system libraries if
present, and possibly using static archives instead of shared
libraries.

It could also make final executable link to fail when shared libraries
are enabled: if libext2fs.so is linked with a static libcom_err.a from
system, build system would attempt to link without -lpthread.

This fixes the issue by moving ELF_OTHER_LIBS before LDFLAGS in the
link command.

Addresses-Sourceforge-Bug: #3542572

Reported-by: Olivier Blin <blino@users.sourceforge.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
akefile.elf-lib
akefile.solaris-lib
ad64902b70282cc0d3453237b39a1d1388906509 14-Jul-2012 Aditya Kali <adityakali@google.com> libquota: fix quota_inode_truncate()

We failed to clear EXT2_FLAG_SUPER_ONLY after deleting the
quota inode and so, the updated block bitmap was not written
back. This caused fsck to complain after running
'tune2fs -O ^quota <dev>'. Clear this flag so that updated
block bitmap gets written. Also, avoid truncating the quota
inode if it is not hidden.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/quotaio.c
5027751530980c61e313d265b1367fee90589cf4 14-Jul-2012 Aditya Kali <adityakali@google.com> tune2fs/quota: always create hidden quota files

Currently 'tune2fs -O quota <dev>' will try to use existing
quota files and write their inode numbers in the superblock.
Next e2fsck run then converts these into hidden quota inodes
(ino #3 & #4). But this approach has problems:
1) Before e2fsck run, the inodes are visible to the user and
might get corrupted or removed or replaced by the user.
2) Since these are user visible, we have to include
their block usage in the quota accounting. But once
these inodes are hidden, e2fsck will have to decrement
their usage from the quota accounting (which e2fsck
currently doesn't do and instead reports error).
(the following used to give e2fsck error previously:
# assume <dev> has aquota.user & aquota.group files
$ tune2fs -O quota <dev> # stores ino# of quota files in
# ext4 superblock
$ e2fsck -f <dev> # hides quota files, but now quota
# usage is incorrect.
<< quota errors >>
Instead of making e2fsck complicated, this patch creates the
hidden quota inodes at 'tune2fs -O quota' time iteself. The
usage is computed freshly and limits are copied from the
aquota.user and aquota.group files as earlier.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/mkquota.c
uota/mkquota.h
c1986ecb6fc68427db7579d409929939117e45ff 13-Jun-2012 Theodore Ts'o <tytso@mit.edu> Fix blhc (Build Log Hardening Check) warnings

The Build Log Hardening Check is a debian tool which scans the output
of a package build making sure that the security hardening flags are
used when compiling and linking all of binaries in a package.

For the most part we were passing CFLAGS, CPPFLAGS, and LDFLAGS down
to the compiler and link commands, but there there were one or two
exceptions. In addition, there where a few places in "make install"
where the V=1 option was not being honored, which triggered blhc
warnings since it couldn't analyze those commands.

The e2fsck.static was the only binary that was not getting built and
packaged with the hardening flags, but I've fixed all of the blhc
warnings so in the future it will be obvious if we regress.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
uid/Makefile.in
8f00911a21f4e95de84c60e09cc4df173e5b6701 13-Jun-2012 Theodore Ts'o <tytso@mit.edu> libquota: remove unneeded #include of <sys/quota.h>

The attempted inclusion of sys/quota.h is causing failures in when
building on the hurd and freebsd platforms for Debian. It's not
necessary any more, so just remove the #include.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/quotaio.c
0796e660859724f304155e094b6cf5739a610ae4 12-Jun-2012 Theodore Ts'o <tytso@mit.edu> lsattr, chattr: add support for btrfs's No_COW flag

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/pf.c
xt2fs/ext2_fs.h
beb388a473bc12fa874743a7b9f97ec3094bb9d1 12-Jun-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: fix block iterator for extents when truncating inodes

When e2fsck uses the block iterator to release the blocks in an
extent-mapped inode, when the last block in an extent is removed, the
current extent has been removed and the extent cursor is now pointing
at the next inode. But the block iterator code doesn't know that. So
when it tries to go the next extent, it will end up skipping an
extent, and so the inode will be incompletely truncated.

The fix is to go to the next extent before calling the callback
function for the current extent. This way, regardless of whether the
current extent gets removed, the extent cursor is still pointing at
the right place.

Reported-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
e0e2c7db4d753aa0192a4a78974fb01bee8a2fb4 11-Jun-2012 Aditya Kali <adityakali@google.com> libext2fs: fix i_blocks for extent leaf create/delete with bigalloc

When libext2fs allocates/deletes an extent leaf, the i_blocks
value is incremented/decremented by fs->blocksize / 512. This
is incorrect in case of bigalloc. The correct way here is to
use cluster_size / 512.

The problem is seen if we try to create a large inode using
libext2fs (say using ext2fs_block_iterate3()) on a bigalloc
filesystem. fsck catches this and complains.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
2ae58b6d5c73e044f3d498feea5d81892af2671f 04-Jun-2012 Jan Kara <jack@suse.cz> libquota: remove unnecessary definitions

Quite some definitions in quota library are not necessary. Remove them.
Also fold quota.h file into quotaio.h since it didn't contain that many
definitions.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/Makefile.in
uota/dqblk_v2.h
uota/mkquota.c
uota/mkquota.h
uota/quota.h
uota/quotaio.c
uota/quotaio.h
uota/quotaio_tree.h
uota/quotaio_v2.c
uota/quotaio_v2.h
182acd17bef0cf8dcb66568448a528abb1dfcd71 28-May-2012 Andreas Dilger <adilger@whamcloud.com> libext2fs: don't inline ext2fs_open_file() and ext2fs_stat()

The creation of inline wrappers ext2fs_open_file() and ext2fs_stat()
in commit c859cb1de0d624caa0779fb17d1a53766143136e in ext2fs.h caused
difficulties with the use of headers, since the headers for open64()
and stat64() may already be included (and skip the declaration of the
64-bit variants) before ext2fs.h is ever read. There is no real way
to solve the missing prototypes and resulting compiler warnings inside
ext2fs.h.

Since ext2fs_open_file() and ext2fs_stat() are not performance
critical operations, they do not need to be inline functions at all,
and the needed function headers can be handled properly in one file.

Similarly, posix_memalloc() was having difficulties with headers, and
was being defined in ext2fs.h, but it is now only being used by a
single file, so move the required header there.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/inline.c
xt2fs/unix_io.c
3b802e43d9276a13cbc75144087cbf017672ca6c 28-May-2012 Theodore Ts'o <tytso@mit.edu> libquota: remove quota_is_on() which was the last user of quotactl()

The quotactl() system call was being used without the use of a
function prototype. On closer examination, it turns out the one user
of that system call was the quota_is_on() function, which is not used
by e2fsprogs at all. Since libquota is an e2fsprogs-internal library,
and not one that we plan to export any time soon, the simplest thing
to do is to simply remove quota_is_on(), which in turn allows us to
remove all of the infrastructure around using the Linux-specific
quotactl() system call.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
uota/mkquota.c
uota/mkquota.h
uota/quota.h
88f8f33cef74f64ff8b4d69381d5a0cf276dd04f 28-May-2012 Mike Frysinger <vapier@gentoo.org> libquota: add missing time.h include

This code uses time() but doesn't include time.h leading to:
quotaio.c:89:2: warning: implicit declaration of function 'time'

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/quotaio.c
918eeb32e9bd1d053bafc9d3c70ef420c21eeda9 28-May-2012 Eric Sandeen <sandeen@redhat.com> libext2fs: fix rbtree backend for extent lengths greater than 2^32

For a completely full filesystem with more than 2^32 blocks, the
rbtree bitmap backend can assemble an extent of used blocks which is
longer than 2^32. If it does, it will overflow ->count, and corrupt
the rbtree for the bitmaps.

Discovered by completely filling a 32T filesystem using fallocate, and
then observing debugfs, dumpe2fs, and e2fsck all behaving badly.

(Note that filling with only 31 x 1T files did not show the problem,
because freespace was fragmented enough that there was no sufficiently
long range of used blocks.)

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/blkmap64_rb.c
8c778b3acd885c79d76d94b4ba0b7fad7b031607 21-May-2012 Theodore Ts'o <tytso@mit.edu> libe2p: teach e2p_jrnl_feature2string() about the 64-bit journal feature

This will allow dumpe2fs to correctly display the 64-bit journal
feature, if it is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
ae06582867e1a30d3f8ac2641e9f4cca8091b385 14-May-2012 Theodore Ts'o <tytso@mit.edu> Change pkg-config files so that both <et/com_err.h> and <com_err.h> work

Change the include path in the Cflags field so that #include
<lib/foo.h> and <foo.h> will work. We had originally used a C flags
which allowed <foo.h> to work, but many applications (especially those
not using pkg-config) had been using the <lob/foo.h> formulation which
didn't require an explicit -I{$includedir} option to the C compiler.

If those applications then converted over to pkg-config, and the
e2fsprogs libraries were installed with a prefix other than /usr, so
that the header files were in some directory such as
/usr/local/include, a program that used #include <lib/foo.h> would
fail to compile.

So change the pkg-config files to include both -I{$includedir} and
-I{$includir}/lib.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/blkid.pc.in
2p/e2p.pc.in
t/com_err.pc.in
xt2fs/ext2fs.pc.in
uota/quota.pc.in
s/ss.pc.in
uid/uuid.pc.in
40024fdbafdf3875a0950e8fee5dd8bf69ea6b6c 14-May-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: fix bug in unix_io corrupted > 16TB file systems on 32-bit systems

The code was assuming that "unsigned long" was 64-bit, which of course
it isn't on 32-bit systems. This caused blocks to get written to the
wrong place.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/unix_io.c
183c73b02615acc33fc22e89b8cc7fdc5f22ee0e 13-May-2012 Theodore Ts'o <tytso@mit.edu> Teach build system to install relative symlinks if requested

Add a configure option, --enable-relative-symlinks, which will use
relative symlinks for the ELF shared library files.

Addresses-Sourceforge-Bug: #3520767

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.elf-lib
e366e42392d3bc762a71e038081960adfdc9d587 12-May-2012 Theodore Ts'o <tytso@mit.edu> Include LDFLAGS when building BSD libraries

Addresses-Sourceforge-Bug: #3517272

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.bsd-lib
58b3d8d3aec9398b8c0fdedd23434a885f037c02 12-May-2012 Matthias Andree <matthias.andree@gmx.de> Fix parallel (make -j) build

Add a few dependencies where needed, so that "make -j17 check" now
works.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uid/Makefile.in
660b4c3b3fd78d0da408643b9c09b47becb5521a 12-May-2012 Theodore Ts'o <tytso@mit.edu> Reserve the codepoints for the INCOMPAT features LARGEDATA and INLINEDATA

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
xt2fs/ext2_fs.h
d71520751ecfb9e0196ff154122f54f2e0f12d0f 02-May-2012 Theodore Ts'o <tytso@mit.edu> Support systems without posix_memalign() and memalign()

MacOS 10.5 doesn't have posix_memalign() nor memalign(), but it does
have valloc(). The Android SDK would like to be built on MacOS 10.5,
so I've added support for a good-enough emulation of memalign()'s
functionality using valloc(), with an explicit test to make sure
valloc() is returning a pointer which is sufficiently aligned given
the requested alignment. This won't work if you try to operate on a
file system with a 16k blocksize using an e2fsprogs built on MacOS
10.5 system, but it is good enough for the common case of 4k
blocksize file systems, and we will let the memory allocation fail in
the alignment is not good enough.

I've also added a unit test for ext2fs_get_memalign() so we can be
sure it's working as expected. I've tested the code paths with
HAVE_POSIX_MEMALIGN defined, HAVE_POSIX_MEMALIGN undefined, and
HAVE_POSIX_MEMALIGN and HAVE_MEMALIGN undefined on an x86 Linux
system, and so I know the valloc() code path works OK. The simplistic
(and less safe) patch at:

https://trac.macports.org/attachment/ticket/33692/patch-lib-ext2fs-inline.c.diff

Shows that using valloc() apparently works OK for MacOS 10.5 (but if
it doesn't the unit test will catch a problem).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/inline.c
fd1c5a0622a9578b86f695d2f60df7d4f8b21875 07-May-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: factor out I/O buffer allocation

Create a new function, io_channel_alloc_buf() which allocates I/O
buffers with appropriate alignment if we are using direct I/O. The
original code was sometimes using a larger alignment factor than
necessary, and would always request an aligned memory buffer even when
it was not necessary since the block device was not opened with
O_DIRECT.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_io.h
xt2fs/inode.c
xt2fs/io_manager.c
xt2fs/openfs.c
xt2fs/rw_bitmaps.c
xt2fs/unix_io.c
07d120848d143c40feb55be31f0f0bb1ad1ec6f9 07-May-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: make read_bitmaps() more efficient when using direct I/O

Read in a full block for each allocation bitmap, to avoid using a
kernel bounce buffer when using direct I/O.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/rw_bitmaps.c
dd0a2679ddd0a9bf53e32efc0f67a7e7a5ea5f00 07-May-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: refactor Direct I/O alignment requirement calculations

Create a new function, ext2fs_get_dio_alignment(), which returns the
alignment requirements for direct I/O. This way we can factor out the
code from MMP and the Unix I/O manager. The two modules weren't
consistently calculating the alignment factors, and in particular MMP
would sometimes use a larger alignment factor than was strictly
necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/getsectsize.c
xt2fs/mmp.c
xt2fs/unix_io.c
0a05b90330d8b505469c72143964b954776be232 07-May-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: move the alignment field from unix_io to the io_manager

The align field which indicated the required data alignment of data
buffers was stored in a field specific to the unix_io manager. Move
it to the top-level io_channel structure so it can be better
generalized.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_io.h
xt2fs/test_io.c
xt2fs/unix_io.c
7943ccf5f2fa76f1dc164ddd1ffd5044a1dca31a 24-Apr-2012 Aditya Kali <adityakali@google.com> e2fsck,libquota: Update quota only if its inconsistent

Currently fsck recomputes quotas and overwrites quota files
whenever its run. This causes unnecessary modification of
filesystem even when quotas were never inconsistent. We also
lose the limits information because of this. With this patch,
e2fsck compares the computed quotas to the on-disk quotas
(while updating the in-memory limits) and writes out the
quota inode only if it is inconsistent.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/mkquota.c
uota/mkquota.h
f6243c10db64ae46beb6a90fccf771f9c9f3d2f8 10-Apr-2012 Daniel Norberg <dano@spotify.com> com_err.pc: correct include path

compile_et puts #include <et/com_err.h> in
generated header files so pkg-config --cflags
com_err should provide the path to the directory
containing et/.
t/com_err.pc.in
46f100707c3cd07e271b0c6f5523ec6ca1ac4416 06-Apr-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: improve testing coverage of tst_bitmaps

Improve the test coverage of tst_bitmaps by:

(a) adding the ability to test the legacy (32-bit) bitmap code
(b) adding tests for ext2fs_find_first_zero_inode_bitmap2() and
ext2fs_find_first_zero_block_bitmap2()

The recent regressions caused by the addition (and use) of
ext2fs_find_first_zero_inode_bitmap2() would have been caught if we
had added these tests first. (Another object lesson in why unit tests
are critically important!)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/tst_bitmaps.c
xt2fs/tst_bitmaps_cmd.ct
xt2fs/tst_bitmaps_cmds
xt2fs/tst_bitmaps_exp
38792ca78bd4df44cb615bed04512f21945a150a 06-Apr-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: use correct types in ext2fs_find_first_zero_block_bitmap2()

Fortunately nothing was using this inline function, so we'll just fix
the types in its function signature, which were nonsensical (this was
caused by a cut-and-paste error).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
664c332612a0ef86df5c67286155ea895ed88ee3 06-Apr-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: add 32-bit compat code for ext2fs_find_first_zero_generic_bmap()

The lack of 32-bit support was causing febootstrap to crash since it
wasn't passing EXT2_FLAG_64BITS when opening the file system, so we
were still using the legacy bitmaps.

Also add support for bigalloc bitmap into the ffz functions.

Addresses-Red-Hat-Bugzilla: #808421

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/gen_bitmap.c
xt2fs/gen_bitmap64.c
b24efa218794b567c27ad99db319b4bd5d696958 06-Apr-2012 Theodore Ts'o <tytso@mit.edu> Don't assume that the presence of mntent.h means that setmntent() exists

Change autoconf to test for setmntent() and use that to decide whether
to use getmntent() and setmntent(), since some systems don't have
setmntent() but they do have the mntent.h header file.

Also, remove the includes of mntent.h from e2fsck and mke2fs and other
places where it is not needed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
xt2fs/ismounted.c
25ff7725cc934fff9bca44add76b5557c71e4a4a 06-Apr-2012 Theodore Ts'o <tytso@mit.edu> e2fsck: add portability fallback in case getpwuid_r is not present

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
304e11c2c1878ef392095d10bf5e93f7ea7131e4 05-Apr-2012 Theodore Ts'o <tytso@mit.edu> mke2fs: don't fail creating the journal if /etc/mtab is missing

The ext2fs_add_journal_inode() function calls
ext2fs_check_mount_point(), which can fail if /etc/mtab is missing.
This causes mke2fs to fail in the middle of the file system format
process; mke2fs calls ext2fs_check_mount_point() already (and has
appropriate fallbacks that calls fails), so add a flag so that mke2fs
can request ext2fs_add_journal_inode() to skip trying to call
e2fsck_check_mount_point().

Addresses-Sourceforge-Bug: #3509398

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/mkjournal.c
e64e6761aa22f31123a91206a5686526f7b9c6c0 05-Apr-2012 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall nitpicks

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/blkmap64_rb.c
xt2fs/crc32c.c
xt2fs/ext2fs.h
xt2fs/gen_bitmap64.c
xt2fs/get_pathname.c
xt2fs/icount.c
xt2fs/rbtree.h
70d7281dcbf3180d291ade48296982dcda356877 28-Mar-2012 Theodore Ts'o <tytso@mit.edu> Update Release Notes, Changelogs, version.h, etc. for 1.42.2 release

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
3a6db9bbc8a5aa85c200e66fc0563a1e87417efe 27-Mar-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: fix ext2fs_get_memalign when posix_memalign() doesn't exist

Reported by: Gianluigi Tiesi <sherpya@netfarm.it>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inline.c
11f359f7660f0194ac1752ea83a704e6db1d5f9f 10-Mar-2012 Sami Liedes <sami.liedes@iki.fi> libext2fs: implement fast find_first_zero() for bitarray bitmaps.

With this change the CPU time needed to shrink a 100G filesystem drops
to 0.8% of the original (17 CPU seconds instead of 2057).

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/blkmap64_ba.c
538eb8784a2c6cac28c539f545fa3bf6fea3246f 26-Mar-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: update dirty flags if the uninit flags are cleared

Update the block group descriptor checksum and mark the superblock and
allocation bitmaps as dirty in check_inode_uninit() and
check_block_uninit().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
c1a1e7fc24d6e37f931bbb8eeb29c90243f0a55d 10-Mar-2012 Sami Liedes <sami.liedes@iki.fi> libext2fs: Implement ext2fs_find_first_zero_generic_bmap().

This function searches a bitmap for the first zero bit within a range.
It checks if there is a bitmap backend specific implementation
available (if the relevant field in bitmap_ops is non-NULL). If not,
it uses a generic and slow method by repeatedly calling test_bmap() in
a loop. Also change ext2fs_new_inode() to use this new function.

This change in itself does not result in a large speedup, rather it
refactors the code in preparation for the introduction of a faster
find_first_zero() for bitarray based bitmaps.

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/bitops.h
xt2fs/bmap64.h
xt2fs/gen_bitmap64.c
5f7c04972fefa8198c34f231a9e8a5430705b4ab 23-Mar-2012 Sami Liedes <sami.liedes@iki.fi> libext2fs: document EXT2_FLAG_64BITS in ext2fs_open2()

From 5c7302de65d689ad84427649aab4d361b21270df Mon Sep 17 00:00:00 2001
From: Sami Liedes <sami.liedes@iki.fi>
Date: Sat, 10 Mar 2012 22:25:55 +0200
Subject: [PATCH] libext2fs: Document EXT2_FLAG_64BITS in ext2fs_open2().

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/openfs.c
75556776d315e67e411b983cdcdb05eb74b803a9 23-Mar-2012 Sami Liedes <sami.liedes@iki.fi> libext2fs: move a modulo operation out of a hot loop.

Filesystem shrinking in particular is a heavy user of this loop in
ext2fs_new_inode(). This change makes resize2fs use 24% less CPU time
for shrinking a 100G filesystem.

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/alloc.c
010dc7b90d97b93907cbf57b3b44f1c1cad234f6 23-Mar-2012 Lukas Czerner <lczerner@redhat.com> e2fsck: remove EXT4_EOFBLOCKS_FL flag handling

We've decided to remove EOFBLOCKS_FL from the ext4 file system entirely,
because it is not actually very useful and it is causing more problems
than it solves. We're going to remove it from e2fsprogs first and then
after the new e2fsprogs version is common enough we can remove the
kernel part as well.

This commit changes e2fsck to not check for EOFBLOCKS_FL. Instead we
simply search for initialized extents past the i_size as this should not
happen. Uninitialized extents can be past the i_size as we can do
fallocate with KEEP_SIZE flag.

Also remove the EXT4_EOFBLOCKS_FL from lib/ext2fs/ext2_fs.h since it is
no longer needed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2_fs.h
37c8db7b2078d0310e5676404e21cc143d8e4d56 22-Mar-2012 Theodore Ts'o <tytso@mit.edu> mke2fs: add option to use direct I/O (mke2fs -D)

This can be useful when using mke2fs on loaded servers, since
otherwise mke2fs can dirty a huge amount of memory very quickly,
leading to other applications not being happy at all.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
963d0f1a9458396c18d0aa030601f29cc1e25f30 20-Mar-2012 Andreas Dilger <adilger@whamcloud.com> tests: add field sizes to inode/super struct tests

In addition to validating the ordering of fields within the inode
and superblock structures, also validate the field sizes. Otherwise
it is possible to incorrectly change the size of one of these fields
without getting any kind of error from these tests. Failures would
only show up later in the test image checks if the field that is
changed is before another in-use field.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/tst_inode_size.c
xt2fs/tst_super_size.c
87141781aabb4dc01359428d2feecdc7f43eeac0 15-Mar-2012 Theodore Ts'o <tytso@mit.edu> dumpe2fs: print the expected block group checksum if it is incorrect

This helps to diagnose problems caused by incorrect block group
checksums.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
xt2fs/ext2fs.h
800766ee4a2bcdc0a32442d093d20da6ea3815ab 07-Mar-2012 Mike Frysinger <vapier@gentoo.org> libext2fs: check for fallocate symbol before using it

If we have newer kernel headers which define FALLOC_FL_PUNCH_HOLE, but we
are on an older glibc which lacks fallocate, we end up trying to use the
func anyways. Check the ifdef that autoconf already set up for us.

Reported-by: Ortwin Glueck <odi@odi.ch>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/unix_io.c
677fc9169c2802f74ec15e16041baba01fec8335 07-Mar-2012 Mike Frysinger <vapier@gentoo.org> configure: sort the lists for AC_CHECK_FUNCS and AC_CHECK_HEADERS

By using m4_flatten, should be easier to maintain these lists.

Regen configure and config.h.in after doing this.

(Modified by tytso to use m4_flatten for the list of header files
checked by AC_CHECK_HEADERS)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
7270fbe7fa51cbce01a07d031f03872f314206d1 24-Feb-2012 Andreas Dilger <adilger@whamcloud.com> build: fix compile warnings on OSX

Clean up some compile warnings related to fstat64(), which is
verbosely deprecated on OSX.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/getsize.c
xt2fs/getsize.c
0df8a27bbaf51b55c0e8c3a533ef4c2ff9d79c9f 24-Feb-2012 Andreas Dilger <adilger@whamcloud.com> libquota: don't include system quota.h header

Don't use the system <sys/quota.h> header in mkquota.c, since there
is a local e2fsprogs version of quota.h that is already included and
has the desired quota constants, and avoids symbol conflicts with the
system <sys/quota.h> on other platforms (in particular OSX).

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/mkquota.c
997a0cf34e26c4af1cf18f2e61d8d1ad346e8e2f 27-Feb-2012 Mike Frysinger <vapier@gentoo.org> libext2fs: include config.h for HAVE_xxx defines

We check HAVE_UNISTD_H but haven't included config.h yet, so we end up
hitting warnings about missing prototypes for close/read/etc... funcs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/mmp.c
b96365f8c2e48b714332d038c6360f9993ac17e0 27-Feb-2012 Mike Frysinger <vapier@gentoo.org> libext2fs: include sys/time.h for gettimeofday()

Building on my glibc-2.15 system hits a warning:
gen_bitmap64.c: In function 'ext2fs_alloc_generic_bmap':
gen_bitmap64.c:127:2: warning: implicit declaration of function
'gettimeofday' [-Wimplicit-function-declaration]

Include sys/time.h if it's available for the prototype.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap64.c
d9a5d37535794842358e1cfe4faa4a89804ed209 21-Feb-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: support O_DIRECT functionality for Mac OS X

Darwin uses fcntl(fd, F_NOCACHE, 1) instead of the O_DIRECT flag.

Addresses-SourceForge-Bug: #3140289

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/unix_io.c
48b89108202172268dd4a12645bece26c51d56fa 21-Feb-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: don't mark the superblock as dirty if the fs was opened r/o

If the file system is read/only opened with a backup superblock, and
the file system has uninit_bg enabled, the super block must not be
marked as dirty; otherwise, ext2fs_close() will call ext2fs_flush(),
which will fail, since the file descriptor for the block device was
opened read/only, and then the file descriptor won't actually be
closed.

This is normally not a problem since most of the time the program will
exit shortly after calling ext2fs_close(), and many programs don't
bother checking the error return from ext2fs_close(), especially if
the file system was opened read/only.

A big exception to this is e2fsck, since it opens and close the file
systems during its startup, and to make matters worse, registers an
error handler which will noisly complain about the failed writes
caused by ext2fs_flush().

Fix this by not marking the superblock as dirty if the file system was
opened read/only. The changes to the block group descriptors to clear
the uninit bits will still happen, so that e2fsck -n will properly
scan the whole file system. However, those changes will get dropped
when the file system handle is closed.

Addresses-SourceForge-Bug: #3444351

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
12b25067abc29336901acb6fc36c675230fa704b 21-Feb-2012 Theodore Ts'o <tytso@mit.edu> libquota: fix invalid return in non-void function

quota_inode_truncate() returns an errcode_t, not void.

Addresses-SourceForge-Bug: #3468423

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/quotaio.c
991211f676f49c6cf30af368dade2f81287f1fa8 17-Feb-2012 Theodore Ts'o <tytso@mit.edu> libext2fs, libe2p: Reserve RO_COMPAT_REPLICA feature

The replica is a feature which stores multiple copies of the key
metadata blocks so a single block failure in failure-prone media
(read: certain types of flash storage) doesn't take out the entire
file system.

Discussion on the upstream list proved not to be very positive on this
feature; the arguments were that it added complexity that wasn't
warrented, since common practice in industry is to insist on reliable
media, and if media is unreliable, you're kind of toast anyway (unless
the file system is being used as the back-end store of a cluster file
system where checksuming and data replication is happening above the
local disk file system level). So, this feature is being developed
out of tree.

We reserve the code points so that other people won't accidentally
step on them. Since it's not upstream, it's a soft reservation, but
it's not like we have any shortage of RO_COMPAT features. We are a
bit more tight on reserved inodes, but EXT2_BOOT_LOADER_INO and
EXT2_UNDEL_DIR_INO are not currently used anywhere, and
EXT2_EXCLUDE_INO is a reservation for another out-of-tree feature.
There are no features currently being discussed which require a
reserved inode, but if a need were to arise, we can claw back code
point reservations that were never used or not in tree, as those will
always be considered lower priority than in-tree features.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
3ae682bb0a5e025963b25ff5ac5d53e2115483f2 17-Feb-2012 Darrick J. Wong <djwong@us.ibm.com> libext2fs: Add ext2fs_file_get_inode_num call (for fuse2fs)

Add a function to return the inode number of an open file.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/fileio.c
a204236eafb47e3cd4e9dbc0e810bccd8c9173cc 15-Feb-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: fix BLOCK_ABORT handling in the block iterator for extents

When processing files that contain extents, the block iterator
functions were not properly handling the BLOCK_ABORT bit. This could
cause problems such as ext2fs_link() adding a directory entry multiple
times.

Thanks to Darrick Wong <djwong@us.ibm.com> for reporting this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
9e89dbbd462b389b6406eb9f02eb63ca997b0e8a 15-Feb-2012 Darrick J. Wong <djwong@us.ibm.com> libext2fs: when truncating file, punch out blocks at end

Currently, ext2fs_file_set_size2 punches out data blocks between the
end of the file and infinity when truncate_block <= old_truncate
(i.e. when you've made the file longer). This is not a useful
behavior, particularly since it *fails* to punch out the data blocks
when the file is shortened (i.e. truncate_block < old_truncate). This
seems to be the result of the test being backwards, so fix the code to
punch only when the file is getting shorter.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/fileio.c
8a1da3c5ae5d042c272fbcf5ea222ca561f566a5 14-Feb-2012 Theodore Ts'o <tytso@mit.edu> debugfs: use ss_safe_getenv() instead of getenv()

In the case where debugfs (or rdebugfs) is installed setgid disk, or
some such, we need to disable the use of environment variables for the
obvious reasons.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/ss.h
454ac9d56acb643c48222c71f2b0e63926783b17 08-Feb-2012 Andreas Dilger <adilger@whamcloud.com> libext2fs: quiet spurious group checksum errors

If we have to read the backup group descriptor checksums, the UNINIT
flags are cleared to ensure that all of the inodes in the filesystem
are scanned. However, the code that reset the UNINIT flags did not
reset the group checksum, and this produced many spurious error
messages in e2fsck.

Group descriptor 0 checksum is invalid. FIXED.
Group descriptor 1 checksum is invalid. FIXED.
:
:

Recompute checksums after modifying group descriptors to avoid these
error messages. Remove expected error messages in f_illitable_flexbg.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/openfs.c
1f572d1f88628c1e0dc88cb8cfaf2bb480b81e4f 17-Jan-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: display partial path if fs corrupted in ext2fs_get_pathname()

The function ext2fs_get_pathname() used to return EXT2_ET_NO_DIRECTORY
if one of the directories in an inode's pathname is not a directory.
This is not very useful in an emergency, when the file system is
corrupted. This commit will cause ext2fs_get_pathname() to return a
partial pathname, which should help system administrators trying to
use debugfs to investigate a corrupted file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/get_pathname.c
24d364fc43601ea3d2e01cc506633302fa091d8f 10-Jan-2012 Mike Frysinger <vapier@gentoo.org> libext2fs: change getpagesize to sysconf

Newer versions of glibc no longer export the getpagesize() prototype when
using recent versions of POSIX (_XOPEN_SOURCE). So building tdb.c gives
use implicit function declaration warnings. Fix the issue by using the
portable sysconf() function which returns the same answer.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/tdb.c
9288e3be665bb8d5657d7f710687a50fad859acf 16-Dec-2011 Lukas Czerner <lczerner@redhat.com> libext2fs: add bitmap statistics

This feature is especially useful for better understanding how e2fsprogs
tools (mainly e2fsck) treats bitmaps and what bitmap backend can be most
suitable for particular bitmap. Backend itself (if implemented) can
provide statistics of its own as well.

[ Changed to provide basic statistics when enabled with the
E2FSPROGS_BITMAPS_STATS environment variable -- tytso]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/blkmap64_ba.c
xt2fs/blkmap64_rb.c
xt2fs/bmap64.h
xt2fs/ext2fs.h
xt2fs/gen_bitmap64.c
xt2fs/icount.c
4a61d17c7c4c09ce3bb5f77bdb9b90eb9f10e8c3 17-Dec-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: adjust the description when copying a bitmap

Label the copy of a bitmap as "copy of ..." so that the bitmap's
description is more descriptive.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/gen_bitmap64.c
830b44f4385eb255d08fe0c8b200f8d8e3e97a8d 16-Dec-2011 Theodore Ts'o <tytso@mit.edu> e2fsck: use different bitmap types as appropriate

Now that we have multiple backend implementations of the bitmap code,
this commit teaches e2fsck to use either the most appropriate backend
for each use case.

Since we don't know for sure if we will get it all right, the default
choices can be overridden via e2fsck.conf. The various definitions
are shown here, with the current defaults (which may change as we add
more bitmap implementations and as learn what works better).

; EXT2FS_BAMP64_BITARRAY is 1
; EXT2FS_BMAP64_RBTREE is 2
; EXT2FS_BMAP64_AUTODIR is 3
[bitmaps]
inode_used_map = 2 ; pass1
inode_dir_map = 3 ; pass1
inode_reg_map = 2 ; pass1
block_found_map = 2 ; pass1
inode_bad_map = 2 ; pass1
inode_imagic_map = 2 ; pass1
block_dup_map = 2 ; pass1
block_ea_map = 2 ; pass1
inode_link_info = 2 ; pass1
inode_dup_map = 2 ; pass1b
inode_done_map = 3 ; pass3
inode_loop_detect = 3 ; pass3
fs_bitmaps = 2

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
0ff7bf30074d8a449ba389e9f088d356447105de 16-Dec-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: use the rbtree bitmap by default when initializing a file system

This change causes the max resident memory of mke2fs, as reported by
/usr/bin/time, to drop from 9296k to 5328k when formatting a 25
gig volume.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
d182831a15dfa4d36979be10fdfd4ec06bdd65b9 18-Dec-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: add pseudo bitmap backend type EXT2FS_BMAP64_AUTODIR

This backend type will automatically switch between the bitarray and
the rbtree backend based on the number of directories in the file
system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/ext2fs.h
xt2fs/gen_bitmap64.c
c1359d91958cadfbc0987921ee5b4db717852e90 18-Dec-2011 Lukas Czerner <lczerner@redhat.com> libext2fs: add a bitmap implementation using rbtree's

For a long time we had a bitarray backend for storing filesystem
metadata bitmaps, however today this approach might hit its limits with
todays huge data storage devices, because of its memory utilization.

Bitarrays stores bitmaps as ..well, as bitmaps. But this is in most
cases highly unefficient because we need to allocate memory even for the
big parts of bitmaps we will never use, resulting in high memory
utilization especially for huge filesystem, when bitmaps might occupy
gigabytes of space.

This commit adds another backend to store bitmaps. It is based on
rbtrees and it stores just used extents of bitmaps. It means that it can
be more memory efficient in most cases.

I have done some limited benchmarking and it shows that rbtree backend
consumes approx 65% less memory that bitarray on 312GB filesystem aged
with Impression (default config). This number may grow significantly
with the filesystem size, but also it may be a lot lower (even negative)
if the inodes are very fragmented (need more benchmarking).

This commit itself does not enable the use of rbtree backend.

[ Simplified the code by avoiding unneeded memory allocation and
deallocation of del_ext. In addition, fixed a bug discovered by the
tst_bitmaps tests: rb_unamrk_bmap() must return true if the bit was
previously set in bitmap, and zero otherwise -- tytso ]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/blkmap64_rb.c
xt2fs/bmap64.h
xt2fs/ext2fs.h
xt2fs/gen_bitmap64.c
5db745a2836fd480d6be1b7cf388b0aad6b786ad 16-Dec-2011 Lukas Czerner <lczerner@redhat.com> libext2fs: add rbtree library

This commit adds rbtree library into e2fsprogs so it can be used for
various internal data structures. The rbtree implementation is ripped of
kernel rbtree implementation with small changes needed for it to work
outside kernel.

[ I prefixed the exported symbols and interface with ext2fs_ to keep
avoid pulluting the namespace exported by the libext2fs shared
library. -- tytso ]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/rbtree.c
xt2fs/rbtree.h
b8ad88b3e746b0c37dfb61e0fe7ad7a7636f9537 18-Dec-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: add tests for the bitmap functions

These tests allow us to be sure that the new bitmap backends are
correctly implemented.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/tst_bitmaps.c
xt2fs/tst_bitmaps_cmd.ct
xt2fs/tst_bitmaps_cmds
xt2fs/tst_bitmaps_exp
67861e5bf3ae177b14d34846218fcdfdeee805a6 16-Dec-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: add default_bitmap_type to the ext2_filsys structure

This allows a program to control the bitmap backend implementation
that will get used without needing to change the current library API.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitmaps.c
xt2fs/ext2fs.h
xt2fs/ext2fsP.h
xt2fs/gen_bitmap64.c
ba37bb704f4ab2631a39c32b35d6bb339e17b293 05-Dec-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: don't break when ext2fs_clear_generic_bmap() for 32-bit bitmaps

This is only an issue for programs compiled against e2fsprogs 1.41
that manipulate bitmaps directly. Fortunately there are very few
programs which do that, especially those that try to clear a bitmap.

Addresses-Sourceforge-Bugs: #3451486

Reported-by: robi6@users.sourceforge.net
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/gen_bitmap64.c
499d5ec5582209279bb0cf86672770d77b047871 29-Nov-2011 Theodore Ts'o <tytso@mit.edu> Update Release Notes, Changelogs, version.h, etc. for 1.42 release

Also fixed depfix.sed

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/Makefile.in
xt2fs/Makefile.in
uid/Makefile.in
4e523bbe00cfa0240b4581eeca0c097b05c9fe3e 29-Nov-2011 Theodore Ts'o <tytso@mit.edu> e2fsck: speed up runs when using tdb for large atypical filesystems

Optimize how the tdb library so that running with [scratch_files] in
/etc/e2fsck.conf is more efficient. Use a better hash function,
supplied by Rogier Wolff, and supply an estimate of the size of the
hash table to tdb_open instead of using the default (which is way too
small in most cases). Also, disable the tdb locking and fsync calls,
since it's not necessary for our use in this case (which is
essentially as cheap swap space; the tdb files do not contain
persistent data.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/icount.c
xt2fs/tdb.c
db40c20e3fd66d90d29a41bef9eb20d1e0745906 28-Nov-2011 Theodore Ts'o <tytso@mit.edu> configure: check for msync() for portability reasons

Turns out the Hurd defines MS_SYNC but doesn't define msync(). Go
figure. So check for both.

Reported by Svante Signell.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tdb.c
2f7d855c632a5dd507669abc90ec452635a4a248 28-Nov-2011 Theodore Ts'o <tytso@mit.edu> libquota: remove use of PATH_MAX and replace it with QUOTA_NAME_LEN

PATH_MAX is not portable (for example, it doesn't exist on the Hurd).
So replace it with a new define, which defines the maximum length of
the base quota name. As it turns out, this is substantially smaller
than PATH_MAX.

Also move the definitions relating to quotaio.c from mkquota.h to
quotaio.h, as a cleanup.

Addresses-Debian-Bug: #649689

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/mkquota.h
uota/quotaio.c
uota/quotaio.h
5fff8636e54f762fcfe7312ec7c0428924ff7292 26-Nov-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: move mmp fields to preserve structure layout of ext2_filsys

This helps provide better ABI compatibility for e2fsprogs 1.42.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
930d7a7fb777c4558b5417ae00a4cf57b10169a2 26-Nov-2011 Theodore Ts'o <tytso@mit.edu> tst_fs_struct: add program to help check ABI compatibility of ext2fs_filsys

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/tst_fs_struct.c
08ae93a2eda03817deabf08d4da9015a283ed56b 20-Nov-2011 Niu Yawei <niu@whamcloud.com> libext2fs: enforce a max nested link count in ext2fs_find_block_device()

Define EXT2FS_MAX_NESTED_LINKS as 8, and check the link count to make
sure we don't exceed it in ext2fs_find_block_device() and
follow_link(). This fixes a potential infinite loop in
ext2fs_find_block_device() if there are symbolic loop links in the
device directory.

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fsP.h
xt2fs/finddev.c
xt2fs/namei.c
c4ab66c526c2f9bdff2e9abb817287b585e2e95d 17-Nov-2011 Theodore Ts'o <tytso@mit.edu> debugfs: add filefrag command

Add the ability to report on the fragmentation of a file on a file
system opened using debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
5e96c5721d58acfbf9d76b62214f6ae421fe4e6b 15-Nov-2011 Theodore Ts'o <tytso@mit.edu> debugfs: add the freefrag command

The freefrag command provides the functionality of e2freefrag on the
currently open file system in debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
2b8d68391957dfb681931da42c42416a9525b395 14-Nov-2011 Theodore Ts'o <tytso@mit.edu> libquota: log an error message if ext2fs_file_open() fails

This also fixes a format string type compiler warning.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/quotaio.c
1527d99d378a4a45f1e36b197bed628ce28d73ee 14-Nov-2011 Niu Yawei <niu@whamcloud.com> libquota: fix get_dq()

The dq_id should be set on newly created dqout.

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/mkquota.c
7bed9a78828e56ddb687cf2b5f1d6ec1f5e5ecc6 14-Nov-2011 Niu <niu@whamcloud.com> libquota: fix quota usage compute

In quota_compute_usage(), the space usage should be in bytes but
not quota block.

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/mkquota.c
198d20fc74a6124548b96e4c14c38ff8d5a95ae5 14-Nov-2011 Niu <niu@whamcloud.com> libquota: quota file read support

This patch adds read quota file support, which includes:
- Improve scan dquot APIs & fix defects in scan dquot functions;
- Implement quota_file_open();
- Introduce quota_update_inode() to update usage in old quota file,
and keep the limits unchanged.

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/mkquota.c
uota/mkquota.h
uota/quotaio.c
uota/quotaio.h
uota/quotaio_tree.c
uota/quotaio_tree.h
uota/quotaio_v2.c
a86d55da8bf41335aa2fc5ec16ca63859d918e81 14-Nov-2011 Aditya Kali <adityakali@google.com> libquota: cleanup libquota code

This patch cleans up the quota code as suggested in previous reviews. This
includes
* remove BUG_ON()s and 'exit()' calls from library code
* remove calls to malloc/free and instead use ext2fs_get/free_mem functions.
* lib/quota/common.c file in not needed anymore and is removed.
* rename exported functions to start with quota_
(ex: init_quota_context --> quota_init_context)
* better error handling in quota library

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/Makefile.in
uota/common.c
uota/common.h
uota/mkquota.c
uota/mkquota.h
uota/quotaio.c
uota/quotaio.h
uota/quotaio_tree.c
uota/quotaio_v2.c
7becb2065ffd5c4b403546d577c2421b4a840c3c 14-Nov-2011 Theodore Ts'o <tytso@mit.edu> Make quota support disabled by support

Quota support can be enabled using --enable-quota. There are still
some buglets that we need to fix up before it can be considered 100%
supported, so let's disable it for the 1.42 release.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
xt2fs/ext2fs.h
df7a86d404e293465b8e5f39859c0916e84ba35a 12-Nov-2011 Eric Sandeen <sandeen@redhat.com> libext2fs: fix write size in ext2fs_mmp_write

Without this change, we will write data past the end of the
mmp buf. Valgrind catches this:

==6373== Syscall param write(buf) points to unaddressable byte(s)
==6373== at 0x362260E470: __write_nocancel (in /lib64/libpthread-2.12.2.so)
==6373== by 0x41CF83: raw_write_blk (unix_io.c:255)
==6373== by 0x41D2BC: unix_write_blk64 (unix_io.c:757)
==6373== by 0x41A05D: ext2fs_mmp_write (mmp.c:130)
==6373== by 0x40B0C9: do_set_mmp_value (set_fields.c:806)
==6373== by 0x421B61: really_execute_command (execute_cmd.c:108)
==6373== by 0x421C54: ss_execute_line (execute_cmd.c:234)
==6373== by 0x403743: main (debugfs.c:2339)
==6373== Address 0x63f000 is not stack'd, malloc'd or (recently) free'd

and in my testing it led to silent failures while writing the mmp
block in debugfs:

write(3, "xV4\22PMM\342\325V\274N\0\0\0\0host.name."..., 4096) = -1 EFAULT (Bad address)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/mmp.c
a9f46078c4313a466c7014c733dc3a4daa8fdec4 10-Nov-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: use HAVE_FSTAT64 instead of HAVE_STAT64 for ext2fs_stat()

Commit 6b56f3d92d introduced the use of HAVE_STAT64 without arranging
that it be defined in configure.in. Previously ext4.h used
HAVE_OPEN64, but apparently there are (broken) platforms that have
open64() but not stat64(). Go figure.

We do need to consistently use a single test for ext2fs_stat(),
ext2fs_fstat(), and struct ext2fs_struct_stat, or we could end up
passing a struct stat64 to a fstat() system call, or some such. I've
elected to use HAVE_FSTAT64 because: (a) it's already defined in the
configure script, and (b) if we ever come across a really broken
platform that defines fstat64() but not stat64(), we can always
emulate stat64() using open64() followed by a fstat64().

This commit fixed a bug whose symptoms were that mke2fs would not work
if given a file > 2GB on 32-bit platforms.

Addresses-Debian-Bug: #647245

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
fc4fd955f705bdbdf5512b1c739191f17d483135 10-Nov-2011 Eric Sandeen <sandeen@redhat.com> libext2: advance group in ext2fs_open2 during swapping

Without this change, we go back to getting group descriptor
"0" each time we go around the "for i" loop. It must properly
advance through the filesystem.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/openfs.c
d1b75fd60c255ebc07209a5928dff497f58cd745 05-Nov-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: don't leak tdb_null out of the shared library namespace

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tdb.c
xt2fs/tdb.h
7f21666a3da39fd335f5d4b27499d4ff76b53375 17-Oct-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: allow ext2fs_get_memalign() to compile w/o posix_memalign()

Addresses-Sourceforge-Bug: #3219173

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/inline.c
0c80c44bd08c60f3cd0ad87f12a71a75cac3bcaa 17-Oct-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: ext2fs_[set_]file_acl_block needs to check for 64-bit feature flag

The ext2fs_file_acl_block() and ext2fs_set_file_acl_block() needs to
only check i_file_acl_high if the 64-bit flag is set. This is needed
because otherwise we will run into problems on Hurd systems which
actually use that field for h_i_mode_high.

This involves an ABI change since we need to pass ext2_filsys to these
functions. Fortunately these functions were first included in the
1.42-WIP series, so it's OK for us to change them now. (This is why
we have 1.42-WIP releases. :-)

Addresses-Sourceforge-Bug: #3379227

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/blknum.c
xt2fs/bmove.c
xt2fs/ext2fs.h
xt2fs/valid_blk.c
uota/quotaio.c
3fcd8fe8acb269598390b35bbf6e4247d10bc64e 09-Oct-2011 Theodore Ts'o <tytso@mit.edu> Fix more spelling errors found by translators and add pluralization

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_err.et.in
c4012e5a7ace2e1f382c4d46f56e5749758c9a1a 06-Oct-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: make ext2fs_open_file() always use 3 arguments instead of varargs

Some architectures have narrow mode_t's which can cause some
portability warnings with varargs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/unix_io.c
b5ba6f5b9da9d4e3d6f52ef9470ec12a161b1a7f 05-Oct-2011 Theodore Ts'o <tytso@mit.edu> libquota: remove flag argument to commit_dquot()

The flag parameter wasn't being used, and using it meant that we had
to define the COMMIT_* flags, which relied on the QIF_* flags being
present. Removing this allows for increased portability.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/mkquota.c
uota/quotaio.h
uota/quotaio_v2.c
299a1e8efaab2050277a58aee4d72d8dacd439be 05-Oct-2011 Theodore Ts'o <tytso@mit.edu> libcom_err: declare com_err_gettext to be static

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/error_message.c
fd7c37fec1aec297c883998e811ee339024edf6e 05-Oct-2011 Theodore Ts'o <tytso@mit.edu> Update for e2fsprogs 1.42-WIP-1005 release

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
4259052093da329907e255b11bf3e799872828c7 05-Oct-2011 Theodore Ts'o <tytso@mit.edu> libcom_err: add set_com_err_gettext()

This function allows programs to pass in a pointer to the gettext
function so that error table strings will can be internationalized.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/com_err.h
t/error_message.c
da5a6b4317fe8939cc98a18c30668fa323641fe9 05-Oct-2011 Theodore Ts'o <tytso@mit.edu> compile_et: generate *_err.c files that have strings marked for xgettext

This allows error code strings to be internationalized.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/et_c.awk
t/test_cases/continuation.c
t/test_cases/heimdal.c
t/test_cases/heimdal2.c
t/test_cases/heimdal3.c
t/test_cases/imap_err.c
t/test_cases/simple.c
c93c1bc24becd643ea8948b33cbfd5cedacb215e 04-Oct-2011 Theodore Ts'o <tytso@mit.edu> libquota: remove NLS support

In general libraries should never (a) call exit() or (b) print output
directly to the stdout (they might be used by GUI programs. From (b)
follows (c), should never call internationalization functions
directly.

Also, since po/POTFILES.in wasn't edited, these strings weren't
getting included in e2fsprogs.pot for translation, so the _()
indirection didn't actually buy us anything.

We eventually need to nuke all of the log_fatal() and log_err() from
libquota, so best thing to do for now is remove NLS support
completely; no point whipsawing the translators with strings to
translate that will be disappearing soon anyway!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/common.h
d6120a2a5e9825557fb36cddb028fe5d4b00afec 04-Oct-2011 Theodore Ts'o <tytso@mit.edu> libquota: use ext2_loff_t instead of loff_t

The type loff_t is not portable. Use ext2_loff_t which handles this
for us.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/quotaio.c
uota/quotaio.h
uota/quotaio_tree.c
36e4e21f511423450285568ceb26b3ddb233e286 04-Oct-2011 Theodore Ts'o <tytso@mit.edu> libquota: remove get_qf_name()

The get_qf_name() function used PATH_MAX, which is non-portable.
Worse, it blindly assumed that PATH_MAX was the size of the buffer
passed to it --- which in the one and only place where it was used in
libquota, was a buffer declared to a fixed size 256 bytes.

Fix this by simply getting rid of the function altogether.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/mkquota.c
uota/mkquota.h
uota/quotaio.c
edbfd75d8fb4a13eccc2cadb12a453c3425d17d1 04-Oct-2011 Theodore Ts'o <tytso@mit.edu> libquota: clean up some gcc -Wall warnings

Remove unused variables, places where 'return' was used with no value
in a non-void function, missing function declarations, etc. Don't
assume that all systems have quotactl(), and use <sys/quota.h> if it
exists to define the quotactl interfaces.

One of the unused variables also got rid of a non-portable use of
PATH_MAX.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
onfig.h.in
xt2fs/ext2fs.h
uota/mkquota.c
uota/quota.h
uota/quotaio.c
uota/quotaio.h
uota/quotaio_v2.c
dba14293d97e61dfbeb0f2ad672ac1f3f4eb2157 04-Oct-2011 Theodore Ts'o <tytso@mit.edu> libquota: remove get_qf_path()

This function isn't used anywhere, so remove it. It also uses
PATH_MAX which is not portable.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/mkquota.h
uota/quotaio.c
00ea586fb23f88da616c27d66faf210532c12b5a 04-Oct-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix bad cast which causes problems for file systems > 512EB

If the number of block groups exceeds 2**32, a bad cast would lead to
a bogus "Not enough space to build proposed filesystem while setting
up superblock" failure.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
bfbeec0c89d44d456003770d25c70735e45c5622 04-Oct-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: Fix thinko in ext2fs_initialize bigalloc case

Surely we should be setting s_clusters_per_group, not
s_blocks_per_group, to EXT2_MAX_CLUSTERS_PER_GROUP here.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
8232f2ddaece256afd323eb5a289a5ec1b7fbd1a 04-Oct-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: move #include "ext2fs.h" from crc32c_defs.h to crc32c.c

The byte swap functions which are defined in ext2fs.h are only needed
by crc32.c, and not by gen_crc32ctable.c. The gen_crc32ctable program
needs to be compiled on the host OS, where ext2fs.h may not be
present. So move the use of the header function to crc32c.c, to avoid
compilation problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/crc32c.c
xt2fs/crc32c_defs.h
756690a29e088946129bed95066ec146f79fab89 03-Oct-2011 Theodore Ts'o <tytso@mit.edu> libext2fs, libquota: fix some makefile dependency issues

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
uota/Makefile.in
e43bb12f402c7de72113a24701fcd17024e1f25c 03-Oct-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: include headers for open() in ext2fs.h

ext2fs.h now calls open() so it should include the headers needed
for this system call as well.

Addresses-Red-Hat-Bugzilla: #742147

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
9026b3db3af838983ed81aad2b4d5e09df1013e3 30-Sep-2011 Darrick J. Wong <djwong@us.ibm.com> libext2fs: Always swab the MMP block on big-endian systems machines

The MMP code in libext2fs tries to gate MMP block swab'ing with this
test:

if (fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))

However, EXT2FS_ENABLE_SWAPFS never seems to be defined anywhere (all
possible existed, the field fs->super->s_magic is always in host
byteorder, so the test always fails. So, we can change the #ifdef to
WORDS_BIGENDIAN (which is conditionally defined on BE platforms) and
get rid of the broken if test.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mmp.c
a7a63675af85b4b636e9df4961ca44ea03bf160b 30-Sep-2011 Darrick J. Wong <djwong@us.ibm.com> libext2fs: Fix various bugs from the metadata checksum integration

Fix several minor errors in structure definitions, the byteswap code,
and Makefiles that result from merging the crc32c and initial parts of
the metadata checksumming patchset.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/ext2fs.h
xt2fs/swapfs.c
a378bd5a5a80656ad1782ee80fa301a5ecb10ecb 29-Sep-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: use ext2fs byte swap functions for portability

The functions htole32(), le32toh(), be32toh(), htobe32() aren't
defined in all environments. Use the ext2fs byte swap functions for
portability.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/crc32c_defs.h
38a420bfce58a4f32685e41104cd1dc4fd7d5013 29-Sep-2011 Theodore Ts'o <tytso@mit.edu> libquota: use ext2fs byte swapping functions for portability

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/quota.h
uota/quotaio.c
uota/quotaio_tree.c
uota/quotaio_v2.c
0f5eba7501f467f757792ee449d16c9259b994fd 24-Sep-2011 Andreas Dilger <adilger@whamcloud.com> ext2fs: add multi-mount protection (INCOMPAT_MMP)

Multi-mount protection is feature that allows mke2fs, e2fsck, and
others to detect if the filesystem is mounted on a remote node (on
SAN disks) and avoid corrupting the filesystem. For e2fsprogs this
means that it checks the MMP block to see if the filesystem is in use,
and marks the filesystem busy while e2fsck is running on the system.

This is useful on SAN disks that are shared between high-availability
servers, or accessible by multiple nodes that aren't in HA pairs. MMP
isn't intended to serve as a primary HA exclusion mechanism, but as a
failsafe to protect against user, software, or hardware errors.

There is no requirement that e2fsck updates the MMP block at regular
intervals, but e2fsck does this occasionally to provide useful
information to the sysadmin in case of a detected conflict.

For the kernel (since Linux 3.0) MMP adds a "heartbeat" mechanism to
periodically write to disk (every few seconds by default) to notify
other nodes that the filesystem is still in use and unsafe to modify.

Originally-by: Kalpak Shah <kalpak@clusterfs.com>

Signed-off-by: Johann Lombardi <johann@whamcloud.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/feature.c
2p/ls.c
xt2fs/Makefile.in
xt2fs/closefs.c
xt2fs/ext2_err.et.in
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
xt2fs/freefs.c
xt2fs/mmp.c
xt2fs/openfs.c
xt2fs/swapfs.c
xt2fs/tst_super_size.c
6b56f3d92d08806ab415e8fd883480f7f9c148e8 24-Sep-2011 Andreas Dilger <adilger@whamcloud.com> misc: quiet minor compiler errors

Several compiler errors are quieted:
- zero-length gnu_printf format string
- unused variable
- uninitalized variable (though it isn't actually used for anything)
- fixed a bug in ext2fs_stat() if stat64() does not exist

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/crc32c.c
xt2fs/ext2fs.h
xt2fs/getsize.c
uota/dqblk_v2.h
9d9a53e651fa877eb4f9df0bfd97fbcc5f514293 24-Sep-2011 Richard W.M. Jones <rjones@redhat.com> libext2fs: add flag to ext2fs_flush() and ext2fs_close() to avoid fsync

This adds new APIs: ext2fs_flush2 and ext2fs_close2 which take an
extra 'int flags' parameter.

This allows us to pass in an EXT2_FLAG_FLUSH_NO_SYNC flag which avoids
fsync'ing the filesystem when closing it. For the case we have in
mind where we are just constructing a throwaway ext2 filesystem in a
file in order to boot a VM, this saves over 5 seconds during the boot
process and avoids many unnecessary disk writes.

Existing code using ext2fs_flush and ext2fs_close remains unaffected
by this change.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/ext2fs.h
8f9d708f6afc7079842585153f000721a14dec6e 19-Sep-2011 Theodore Ts'o <tytso@mit.edu> libquota: only build a static library

Since the libquota library has namespace contamination issues, don't
build a shared library and link against it statically. Don't include
it as part of the Debian packages.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/Makefile.in
d1154eb460efe588eaed3d439c1caaca149fa362 18-Sep-2011 Theodore Ts'o <tytso@mit.edu> Shorten compile commands run by the build system

The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and
this was starting to cause some tools heartburn. It also made "make
V=1" almost useless, since trying to following the individual commands
run by make was lost in the noise of all of the defines.

So fix this by putting the configure-generated defines in lib/config.h
and the directory pathnames to lib/dirpaths.h.

In addition, clean up some vestigal defines in configure.in and in the
Makefiles to further shorten the cc command lines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/cache.c
lkid/dev.c
lkid/devname.c
lkid/devno.c
lkid/getsize.c
lkid/llseek.c
lkid/probe.c
lkid/read.c
lkid/resolve.c
lkid/save.c
lkid/tag.c
lkid/tst_types.c
lkid/version.c
onfig.h.in
irpaths.h.in
2p/Makefile.in
2p/feature.c
2p/fgetflags.c
2p/fgetversion.c
2p/fsetflags.c
2p/fsetversion.c
2p/getflags.c
2p/getversion.c
2p/hashstr.c
2p/iod.c
2p/ls.c
2p/mntopts.c
2p/ostype.c
2p/parse_num.c
2p/pe.c
2p/percent.c
2p/pf.c
2p/ps.c
2p/setflags.c
2p/setversion.c
2p/uuid.c
t/Makefile.in
t/com_err.c
t/com_right.c
t/error_message.c
t/et_name.c
t/init_et.c
t/vfprintf.c
xt2fs/Makefile.in
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/badblocks.c
xt2fs/bb_compat.c
xt2fs/bb_inode.c
xt2fs/bitmaps.c
xt2fs/bitops.c
xt2fs/blkmap64_ba.c
xt2fs/blknum.c
xt2fs/block.c
xt2fs/bmap.c
xt2fs/bmove.c
xt2fs/brel_ma.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/crc16.c
xt2fs/crc32c.c
xt2fs/csum.c
xt2fs/dblist.c
xt2fs/dblist_dir.c
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/dirhash.c
xt2fs/dosio.c
xt2fs/dupfs.c
xt2fs/expanddir.c
xt2fs/ext_attr.c
xt2fs/extent.c
xt2fs/fileio.c
xt2fs/finddev.c
xt2fs/flushb.c
xt2fs/freefs.c
xt2fs/gen_bitmap.c
xt2fs/gen_bitmap64.c
xt2fs/get_pathname.c
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/i_block.c
xt2fs/icount.c
xt2fs/imager.c
xt2fs/ind_block.c
xt2fs/initialize.c
xt2fs/inline.c
xt2fs/inode.c
xt2fs/inode_io.c
xt2fs/io_manager.c
xt2fs/irel_ma.c
xt2fs/ismounted.c
xt2fs/link.c
xt2fs/llseek.c
xt2fs/lookup.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/namei.c
xt2fs/native.c
xt2fs/newdir.c
xt2fs/openfs.c
xt2fs/progress.c
xt2fs/punch.c
xt2fs/qcow2.c
xt2fs/read_bb.c
xt2fs/read_bb_file.c
xt2fs/res_gdt.c
xt2fs/rw_bitmaps.c
xt2fs/sparse.c
xt2fs/swapfs.c
xt2fs/tdb.c
xt2fs/tdbtool.c
xt2fs/test_io.c
xt2fs/tst_badblocks.c
xt2fs/tst_bitops.c
xt2fs/tst_byteswap.c
xt2fs/tst_getsectsize.c
xt2fs/tst_getsize.c
xt2fs/tst_inode_size.c
xt2fs/tst_iscan.c
xt2fs/tst_super_size.c
xt2fs/tst_types.c
xt2fs/undo_io.c
xt2fs/unix_io.c
xt2fs/unlink.c
xt2fs/valid_blk.c
xt2fs/version.c
xt2fs/write_bb_file.c
popen.c
uota/Makefile.in
uota/common.c
uota/mkquota.c
uota/quotaio.c
uota/quotaio_tree.c
uota/quotaio_v2.c
s/Makefile.in
s/data.c
s/error.c
s/execute_cmd.c
s/get_readline.c
s/help.c
s/invocation.c
s/list_rqs.c
s/listen.c
s/pager.c
s/parse.c
s/prompt.c
s/request_tbl.c
s/requests.c
s/test_ss.c
uid/clear.c
uid/compare.c
uid/copy.c
uid/gen_uuid.c
uid/gen_uuid_nt.c
uid/isnull.c
uid/pack.c
uid/parse.c
uid/tst_uuid.c
uid/unpack.c
uid/unparse.c
uid/uuid_time.c
5ea3c825929b01739b9b876378c38846aa4b1f13 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> libext2: Fix leaks in write_bitmaps on error returns

block_buf and/or inode_buf may not be properly freed on an error
return.

Create a new errout: target to free them as needed in error conditions.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/rw_bitmaps.c
624e8ebe3058bad9af6e719b7f9e7afab7d3fe30 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: Fix some error cleanup path bugs

In inode_open(), if the allocation of &io fails, we go to cleanup
and dereference io to test io->name, which is a bug.

Similarly in undo_open() if allocation of &data fails, we
go to cleanup and dereference data to test data->real.

In the test_open() case we explicitly set retval to the only
possible error return from ext2fs_get_mem(), so remove that
for tidiness.

The other changes just make make earlier returns go through
the error goto for consistency.

In many cases we returned directly from the first error, but
"goto cleanup" etc for every subsequent error. In some
cases this leads to "impossible" tests such as:

if (ptr)
ext2fs_free_mem(&ptr)

on paths where ptr cannot be null because we would have
returned directly earlier, and Coverity flags this.

This isn't really indicative of an error in most cases, but
I think it can be clearer to always exit through the error goto
if it's used later in the function.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/dblist.c
xt2fs/inode.c
xt2fs/inode_io.c
xt2fs/test_io.c
xt2fs/undo_io.c
xt2fs/unix_io.c
06e41ddea9aa7d01c9804d0da162a00efdc42d84 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> libe2p: reach unreachable code

The EOPNOTSUPP case is unreachable, being outside a set of:
#if
...
return;
#else
...
return;
#endif

Fix this up so that if neither HAVE_CHFLAGS nor
HAVE_EXT2_IOCTLS applies, we set EOPNOTSUPP.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/setflags.c
9e30fb23ef85d6b2a58527048cc9208405a38299 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: annotate intentional fallthroughs in case statements

Using the /* fallthrough */ comment lets Coverity (and humans)
know that we really do want to fall through in these case statements.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/feature.c
2p/mntopts.c
2p/parse_num.c
xt2fs/dirhash.c
xt2fs/extent.c
665563b825ca697a2b4bdd340760a36f6263709e 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> libext2fs: Potential null ptr deref in undo_err_handler_init

In the !undo_io_backing_manager case, undo_err_handler_init
will be passed a null data->real, which will be dereferenced.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/undo_io.c
d0f196d867504d8461fb7c6958aa6a5d220d5825 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> libext2: move buf variable completely under ifdef

If !WORDS_BIGENDIAN, it is pointless to test whether buf
is NULL, because it is initialized to NULL and never changed.
This makes Coverity complain, so we can just move all handling
of "buf" under the #ifdef.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext_attr.c
bc28abc537ff49d708abd66cc70ee451fdd010fd 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> libext2: Fix EXT2_LIB_SOFTSUPP masking

EXT2_LIB_SOFTSUPP_INCOMPAT_* are supposed to be bitmasks
of features which can be opened even though they are
under development. The intent is that these are masked
out of the features list, so that they will be ignored
on open.

However, the code does a logical not vs. a bitwise not:

features &= !EXT2_LIB_SOFTSUPP_INCOMPAT;

which will not have the desired effect...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/openfs.c
ae96c678e15eda2a5d0eea7e1067b449f6604aff 16-Sep-2011 Theodore Ts'o <tytso@mit.edu> libext2s: fix swapfs.c so it builds on big endian systems

Also cleaned up ext2_fs.h, and improved the byte swapping code so the
extra fields in the large inode are properly byte swapped.

Addresses-Debian-Bug: #641838

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
xt2fs/swapfs.c
cd0b97ed9313fd61f2be31284e4894f52f65c12f 16-Sep-2011 Theodore Ts'o <tytso@mit.edu> libquota: indicate in the ELF library image that it requires libext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/Makefile.in
16c581d0e8d931f3cf0005de07481d7380ca4c0c 15-Sep-2011 Theodore Ts'o <tytso@mit.edu> debugfs: add 64-bit support to the set_field commands

The set_fields commands (set_super_value, set_inode_field,
set_block_group) now handle fields which store in split fields on
ext4's on-disk format. For example, the superblock fields
s_blocks_count and s_blocks_count_hi.

The user can either set the low or high part of the field via
"blocks_count_lo" or "blocks_count_hi", or both parts can be set via
"blocks_count".

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
xt2fs/ext2_fs.h
xt2fs/tst_super_size.c
89efc88e65136ece22708cc28ec4124a33feeecd 15-Sep-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: add metadata checksum and snapshot feature flags

Reserve EXT4_FEATURE_RO_COMPAT_METADATA_CSUM and
EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP. Also reserve fields in the
superblock and the inode for the checksums. In the block group
descriptor, reserve the exclude bitmap field for the snapshot feature,
and checksums for the inode and block allocation bitmaps.

With this commit, the metadata checksum and exclude bitmap features
should have reserved all of the fields they need in ext4's on-disk
format.

This commit also fixes an a missing byte swap for s_overhead_blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Darrick J. Wong <djwong@us.ibm.com>
Cc: Amir Goldstein <amir73il@gmail.com>
2p/feature.c
2p/ls.c
xt2fs/ext2_fs.h
xt2fs/swapfs.c
xt2fs/tst_inode_size.c
xt2fs/tst_super_size.c
f314bb0821473efcecedc450c18211e781d30a72 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> libext2fs: remove redundant last-group check in ext2fs_check_desc()

ext2fs_group_last_block2() already properly calculates
the last block in the last group, so there is no need
to special-case this after the call.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/check_desc.c
98f4547198b369bef7e41eb7ce4a16855726c393 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: add ext2fs_group_blocks_count helper

Code to count the number of blocks in the last partial
group is cut and pasted around the e2fsprogs codebase
a few times.

Making this a helper function should improve matters.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/alloc_sb.c
xt2fs/blknum.c
xt2fs/closefs.c
xt2fs/ext2fs.h
65b7a463da3b8f7ce0892be579f34ba4cf66456e 16-Sep-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix size check in tst_inode_size

Also add run tst_inode_size automaically from "make check"

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/tst_inode_size.c
75405ffde6f87f88c7172bfb431ec085c542ec1a 16-Sep-2011 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
d2bfdc7ff15ce7b6b40c087021528ce190ef43c3 16-Sep-2011 Lukas Czerner <lczerner@redhat.com> e2fsprogs: Use punch hole as "discard" on regular files

If e2fsprogs tools (mke2fs, e2fsck) is run on regular file instead of
on block device, we can use punch hole instead of regular discard
command which would not work on regular file anyway. This gives us
several advantages. First of all when e2fsck is run with '-E discard'
parameter it will punch out all ununsed space from the image, hence
trimming down the file system image. And secondly, when creating an
file system on regular file (with '-E discard' which is default), we
can use punch hole to clear the file content, hence we can skip inode
table initialization, because reads from sparse area returns zeros. This
will result in faster file system creation (without the need to specify
lazy_itable_init) and smaller images.

This commit also fixes some tests that would fail due to mke2fs showing
discard progress, hence the output would differ.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2_io.h
xt2fs/unix_io.c
c859cb1de0d624caa0779fb17d1a53766143136e 16-Sep-2011 Lukas Czerner <lczerner@redhat.com> e2fsprogs: create open() and stat() helpers

In many places we are using #ifdef HAVE_OPEN64 to determine if we can
use open64() but that's ugly. This commit creates two new helpers
ext2fs_open_file() for open() and ext2fs_stat() for stat(). Also we need
new typedef ext2fs_struct_stat for struct stat.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/unix_io.c
db8bbf27c9eeaa9c1803fb52a6cc7a60c5250c7e 16-Sep-2011 Darrick J. Wong <djwong@us.ibm.com> libext2fs: Add crc32c implementation for metadata checksumming

Add a slicing-by-8 CRC32c implementation for metadata checksumming.
Adapted from Bob Pearson's kernel patch.

Also added a self-test mechanism so we can verify that the crc32c
implementation is working correctly.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/crc32c.c
xt2fs/crc32c_defs.h
xt2fs/ext2fs.h
xt2fs/gen_crc32ctable.c
15749d7da9b6242d477801a54164b3d04c2b4102 16-Sep-2011 Amir Goldstein <amir73il@users.sf.net> libext2fs: fix the range validation in bitmap_range2 funcs

The condition ((start+num) & ~0xffffffffULL) in bitmap_range2
and generic_bmap_range funcs in get_bitmap64.c was wrong and
inconsistent with the condition (start+num-1 > bmap->real_end)
in generic_bitmap_range funcs in get_bitmap.c.

I got the following error from tune2fs on a 16TB fs:
Illegal block number passed to ext2fs_unmark_block_bitmap #4294967295
for block bitmap for 16TB.img
tune2fs: Invalid argument while reading bitmaps

Fix to condition to ((start+num-1) & ~0xffffffffULL), because
the bit (start+num) is not going to be changed by the funcs.

Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap64.c
3fbfad558e01ffbacc14e5a536c4dfec0a0af4f5 15-Sep-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix binary and source compatibility with the dump program

The dump program relies on fs->frag_size and the
EXT2_FRAGS_PER_BLOCK() macro. Kind of silly for it to do so, but it's
part of the kludgy way the dump program (which was originally written
for the BSD FFS was ported over to support ext2/3.) Given how it
makes assumptions about the ext2/3/4 file system being similar to the
BSD FFS, it's a bit of a miracle it works for ext4 --- or at least
appears to work...

Addresses-Debian-Bug: #636418

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
xt2fs/initialize.c
xt2fs/openfs.c
63165136eab4ef01dae295c8e290c2a3853c936b 15-Sep-2011 Theodore Ts'o <tytso@mit.edu> libe2p: fix bug so that MNTOPT_ options can be successfully parsed

Thanks to Israel G. Lugo for pointing this out.

Addresses-Debian-Bug: #641667

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/mntopts.c
449c87a49cdc59271eb24ad3ecd6e7857b99a160 14-Sep-2011 Theodore Ts'o <tytso@mit.edu> libquota: fix "make install" so it works in with a VPATH build directory

Also fix up the name of the header file which we are installing so it
is correct.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uota/Makefile.in
897fbaac7dfb2afe1eb67a76f3b003a8eca19199 14-Sep-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: add new test: tst_inode_size

This test makes sure the size of the ext2_inode is what we expect

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/tst_inode_size.c
9f6ba888f027ba4daf57ac61a11a6dce98e42347 14-Sep-2011 Yongqiang Yang <xiaoqiangnk@gmail.com> resize2fs: add support for new in-kernel online resize ioctl

This is needed to support online resizing for > 32-bit file systems

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
624e4a6466dba9889f5f80dc168f2bb7c2a3f5d0 20-Jul-2011 Aditya Kali <adityakali@google.com> e2fsck: add support for checking the built-in quota files

This patch adds support for doing quota accounting during full
e2fsck scan if the 'quota' feature was set on the superblock.
If user-visible quota inodes are in use, they will be hidden
and converted to the reserved quota inodes.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
f239fefc14226f655477179801c734749a04d4b4 20-Jul-2011 Aditya Kali <adityakali@google.com> e2fsprogs: add quota library to e2fsprogs

This patch adds the quota library (ported form Jan Kara's quota-tools) in
e2fsprogs in order to make quotas as a first class supported feature in Ext4.
This patch also provides interface in lib/quota/mkquota.h that will be used by
mke2fs, tune2fs, e2fsck, etc. to initialize and update quota files.
This first version of the quota library does not support reading existing quota
files. This support will be added in the near future.
Thanks to Jan Kara for his work on quota-tools. Most of the files in this patch
are taken as-is from quota tools and were simply modified to work with
libext2fs in e2fsprogs.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uota/Makefile.in
uota/common.c
uota/common.h
uota/dqblk_v2.h
uota/mkquota.c
uota/mkquota.h
uota/quota.h
uota/quota.pc.in
uota/quotaio.c
uota/quotaio.h
uota/quotaio_tree.c
uota/quotaio_tree.h
uota/quotaio_v2.c
uota/quotaio_v2.h
a4aff9ca5bcc3df76dcb3d49765674feba3d7654 31-Aug-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix binary search for the icount and badblocks stores

Remove the interpolation because there is a bug in icount which can
cause a core dump if calculated range gets turned into a NaN and then
do an out-of-bounds array access. We could fix this with some more
tests, but the complexity is such that nuking all of the interpolation
code will be faster than fixing the interpolation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/badblocks.c
xt2fs/icount.c
9c79612f2186a8ee5d8a6f2c961e4e0f63df7228 10-Aug-2011 Eric Sandeen <sandeen@redhat.com> libext2fs: copy cluster_bits in ext2fs_copy_generic_bmap

The f_lotsbad regression test was failing on some systems
with:

Restarting e2fsck from the beginning...
Pass 1: Checking inodes, blocks, and sizes
+Illegal block number passed to ext2fs_test_block_bitmap #0 for in-use block map
Pass 2: Checking directory structure
Entry 'termcap' in / (2) has deleted/unused inode 12. Clear? yes

Running with valgrind (./test_script --valgrind f_lotsbad) we
see:

+==31409== Conditional jump or move depends on uninitialised value(s)
+==31409== at 0x42927A: ext2fs_test_generic_bmap (gen_bitmap64.c:378)

among others.

Looking at gen_bitmap64.c:
376: arg >>= bitmap->cluster_bits;
377:
378: if ((arg < bitmap->start) || (arg > bitmap->end)) {

A little more debugging showed that it was actually
bitmap->cluster_bits which was uninitialized, because it never
gets copied over in ext2fs_copy_generic_bmap()

Patch below resolves the issue.

Reported-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap64.c
d8fae3cf421eb5ebc0cf8726885eb81aff0a5d1f 10-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix block iterator when the callback function modifies an extent

If the callback interator modifies a block in the middle of an extent
during a call to the block iterator, causing the extent to be split,
ext2_block_iterate3() will end up calling the callback function twice
for some number of blocks. Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
0bd0e5932046401049502ee99529b984d7cd316e 09-Jul-2011 Andreas Dilger <adilger@whamcloud.com> misc: use EXT2_I_SIZE() consistently to get size

Use the EXT2_I_SIZE() macro consistently to access the inode size.
The i_size/i_size_high combination is open coded in several places.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
xt2fs/fileio.c
81c6377d93106ccfae12b5b4f1953e97aa92b65e 08-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: don't hang in ext2fs_new_block2() on a full bigalloc file system

Prevent ext2fs_new_block2() from looping forever when a bigalloc file
system is full.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
8e8a190fa212ca28efb2e8a8b3318a24d7fc4b7a 08-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: teach ext2fs_bmap2() about bigalloc

This allows debugfs's write command to work correctly on bigalloc file
systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
551e2e46ee2fdf8cfa16e153d3c560203f0f9a5e 07-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: move ext2fs_bmap2()'s the extent handling to a separate function

Separate the extent handling to a separate function to make BMAP_ALLOC
processing more efficient.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
b98d3e8fadf32cc34b8231089a4da0a225697545 07-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: teach ext2fs_block_alloc_stats2() about bigalloc

Change ext2fs_block_alloc_stats2() so that when a cluster is
allocated, the free blocks counter in the superblock is appropriately
decremented by the cluster size.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_stats.c
c4d2d43e2dc831d5c209af3e42dffd7b5e65c1f6 07-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: replace missing flexbg initialization in flexbg_offset

Commit 25567a7b0fa9 accidentally removed the initialization for flexbg
and flexbg_size, which affected ext2fs_allocate_group_table() and
ext2fs_allocate_tables(). Replace them.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
d32c915abfb224f6f6659e9cada7e9f759b7e3d2 07-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
xt2fs/check_desc.c
xt2fs/csum.c
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
xt2fs/link.c
xt2fs/openfs.c
xt2fs/punch.c
xt2fs/unix_io.c
062cc472e6cae60a1fa43976bcc6ff39f8351ccb 06-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix 64-bit support in ext2fs_bmap2()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
41e102a4d1be1aed9bdd002e03b4d244b5446036 06-Jul-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix 64-bit support in ext2fs_{read,write}_inode_full()

This fixes a problem where reading or writing inodes located after the
4GB boundary would fail.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
25567a7b0fa98b390fd1ff0d4702b29c23a75bbb 05-Jul-2011 Theodore Ts'o <tytso@mit.edu> e2fsck, libext2fs: support for bigalloc file systems with a blocksize of 1024

Filesystems with a blocksize of 1024 have the superblock starting at
block #1. However, the first data block in the superblock is 0 to
simplify the cluster calculations. So we must compensate for this in
a number of places, mostly in the ext2fs library, but also in e2fsck.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_sb.c
xt2fs/alloc_tables.c
xt2fs/closefs.c
xt2fs/openfs.c
xt2fs/res_gdt.c
1ca87790b914a1958f3cbd8b5e1e7037f2cf30ed 20-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix makefile dependency problem

lib/ext2fs/Makefile.in had a buggy entry for blkmap64_ba.c in $(SRCS),
which caused this source file to not have a valid Makefile dependency
entry, so blkmap64_ba.o would not get rebuilt when it needed to be.

Also updated the Makefile dependency for the misc directory while
we're at it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
b2e6c86d61fccc39956c0cb8a8333f42d1569e8d 16-Jun-2011 Theodore Ts'o <tytso@mit.edu> mke2fs, e2fsck: fix i_blocks handling for bigalloc file systems

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/expanddir.c
xt2fs/i_block.c
xt2fs/mkjournal.c
fe75afbf33389f71f8588af388d0c01db0cbf753 16-Jun-2011 Theodore Ts'o <tytso@mit.edu> Fix superblock field s_blocks_count for bigalloc file systems

Treat the s_blocks_count field in the superblock as a free block count
(instead of the number of free clusters) for bigalloc file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
96367ad3bc849220651b20f41340b48e07e82b04 16-Jun-2011 Andreas Dilger <adilger@whamcloud.com> misc: quiet "unused variable" compiler warnings

Some of the newly-merged patches added "unused variable" compiler
warnings. Delete unused variables.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/alloc.c
5f2e1a81d24ca2334547edd52690378d6eb763c7 16-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: fix regression in ext2fs_new_block2() for uninit_bg file systems

Commit b0ecb787ef introduced a bug in check_block_uninit(), which is
used by ext2fs_new_block2(). This bug resulted in the block bitmap
for the block group in question not having space reserved for the file
system metadata blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
8f36e6925f817ed5086550c97796e09905fbb234 11-Jun-2011 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
388b66f727e39474a2160aa0d35402f4821aa8ae 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> ext2fs: fix error handling in ext2fs_add_dir_block

In ext2fs_add_dir_block() the dblist allocation size was changed to
grow as the number of items in the dblist increases. However, the
error handling in case of allocation failure wasn't changed to match.

Fix the error case to revert to the old allocation size on failure.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/dblist.c
6c54689fadc3fe0b0bcae2cc93946cb7a28b9f15 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> mke2fs: skip zeroing journal blocks

Add the ability to skip zeroing journal blocks on disk. This can
significantly speed up mke2fs with large journals. At worst the
uninitialized journal is only a very short-term risk (if at all),
because the journal will be overwritten on any new filesystem as
soon as any significant amount of data is written to disk, and
the new journal TID would need to match the offset/TID of an old
commit block still left on disk.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/mkjournal.c
931b58e1cb2158c1f5218059cce92e94917ef485 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> ext2fs: Handle internal journal over 2^32 bytes

The write_journal_inode() code is only setting the low 32-bit i_size
for the journal size, even though it is possible to specify a journal
up to 10M blocks in size. Trying to create a journal larger than 2GB
will succeed, but an immediate e2fsck would fail. Store i_size_high
for the journal inode when creating it, and load it upon access.

Use s_jnl_blocks[15] to store the journal i_size_high backup. This
field is currently unused, as EXT2_N_BLOCKS is 15, so it is using
s_jnl_blocks[0..14], and i_size is in s_jnl_blocks[16].

Rename the "size" argument "num_blocks" for the journal creation functions
to clarify this parameter is in units of filesystem blocks and not bytes.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/mkjournal.c
xt2fs/swapfs.c
534a4c3db58064caee4fc3e9e294251240d9d28a 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> ext2fs: don't use O_DIRECT if not available

O_DIRECT is not defined on OSX. Since direct IO is only a new
optimization and not needed for correct functionality, disable
it if O_DIRECT is unavailable.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/unix_io.c
a1a769987b0604d8836541cefe89661ec8db02c7 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> misc: fix compile warnings on OSX

The BLKFLSBUF and FDFLUSH ioctls are Linux specific, and do not
really have anything to do with __GNUC__ (which is also used on
OS/X and Solaris). Only print these warnings on Linux systems.

statfs64() is deprecated on OSX and generates a deliberate warning.
Fix some other warnings that show up on OSX builds.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/fgetflags.c
2p/fsetflags.c
2p/getflags.c
2p/setflags.c
xt2fs/flushb.c
xt2fs/getsize.c
65d05cec3d4ae02dec1b15dfec21e571cb83c9cf 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> ext2fs: fix ext2fs_warn_bitmap32() return warning

This was reported as "control reaches end of non-void function",
but comparing to other similar functions it should be a void
function. Since it is only declared in the "private" ext2fsP.h
header, it should be OK to change the function prototype.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fsP.h
xt2fs/gen_bitmap64.c
1ac2aa23ef030863f51fc77b42715e173967c44d 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> ext2fs: fix undeclared posix_memalign() warning

Older distros do not define posix_memalign() by default in the
headers. If ext2fs.h is included early in the headers, it is
possible to "#define _XOPEN_SOURCE 600" so that the stdlib.h
header will define it, but if ext2fs.h is included after stdlib.h
there is no posix_memalign() declaration.

Add a posix_memalign() declaration if stdlib.h didn't do it. This
is a bit of a hack for GNU headers, but it works on Linux and OS/X
without problems.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
cf5301d7f2c3bbed3d26600335102414cbf0c4ba 11-Jun-2011 Andreas Dilger <adilger@whamcloud.com> misc: clean up compiler warnings

Fix several types of compiler warnings (unused variables/labels),
uninitialized variables, etc that are hit with gcc -Wall.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
2p/ls.c
xt2fs/ext2fs.h
xt2fs/fileio.c
xt2fs/openfs.c
xt2fs/progress.c
xt2fs/res_gdt.c
xt2fs/unix_io.c
44fe08f1fa1e9a994ff304aa02022c53c9341519 11-Jun-2011 Theodore Ts'o <tytso@mit.edu> e2fsck: add basic bigalloc support to check (but not yet repair) file systems

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/check_desc.c
xt2fs/ext2fs.h
c6ed60cdeb1355a884f635ac8118c8f330e2ba68 11-Jun-2011 Theodore Ts'o <tytso@mit.edu> mke2fs: support creating bigalloc file systems

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
4a2a9b70c89891a146bcb9cee3f29572ca2e1370 11-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: allocate clusters to files in expand_dir.c and mkjournal.c

Teach ext2fs_expand_dir() and ext2fs_add_journal_inode() about
allocating blocks when clustered allocation is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/expanddir.c
xt2fs/mkjournal.c
b0ecb787ef9fde414791b644fa074450b28d4060 11-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: teach block allocation functions about bigalloc/clusters

Optimize ext2fs_new_block2() and ext2fs_get_free_blocks2() when
bigalloc is enabled. Also fix the uninitialized block bitmap code so
that it correctly deals clustered allocation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
94968e749b224f01fbb9009ed0285e55f6441784 10-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: teach bitmap functions about bigalloc/cluster

This patch makes the following changes:

* ext2fs_allocate_block_bitmap() now allocates a bitmap with cluster
granularity for bigalloc file systems. For mke2fs and e2fsck, a
newly added function, ext2fs_allocate_subcluster_bitmap() allocates
a bitmap with block granularity (even for bigalloc file systems).
The newly added function ext2fs_get_bitmap_granularity() will return
the number of bits (log2) of the granularity used by the bitmap.

* The ext2fs_{mark,unmark,test}_block_bitmap2() functions will shift
their passed-in argument by log2(cluster_ganularity) bits right.
This means that the arguments for the single-argument bitmap
functions will be interpreted with block granluarity, since this
minimizes code changes in the rest of the code base.

* The ext2fs_{get,set}_block_bitmap_range() functions will interpret
their arguments in cluster granularity. This is a bit inconsistent,
but the caller of those functions will need to be taught about the
subtleties of clusters for bigalloc file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitmaps.c
xt2fs/bmap64.h
xt2fs/ext2fs.h
xt2fs/gen_bitmap64.c
1afb468b9a80031b39eab37272709f45727fb221 10-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: create extent-based directories if the extents feature is enabled

This allows mke2fs to create the root and lost+found directories using
extents.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkdir.c
6a6337c3df7c982eb888764d585ec483a51af16e 05-Jun-2011 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
lib/ext2fs/bitmaps.c
lib/ext2fs/rw_bitmaps.c
misc/dumpe2fs.c
b92fbed77875b447f930fdcb5ae660c16b2ec0db 05-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: Teach block bitmap read, write, and allocation funcs about clusters

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitmaps.c
xt2fs/rw_bitmaps.c
1da5ef707904cf99300a0fb36b9ae3b29dbc8bde 04-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: change fs->clustersize to fs->cluster_ratio_bits

The log2 of the ratio of cluster size to block size is far more useful
than just storing the cluster size. So make this change, and then
define basic utility macros: EXT2FS_CLUSTER_RATIO(),
EXT2FS_CLUSTER_MASK(), EXT2FS_B2C(), EXT2FS_C2B(), and
EXT2FS_NUM_B2C().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/initialize.c
xt2fs/openfs.c
ae9e37cd114385764864518057ff854b3f335440 04-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: change EXT2_MAX_BLOCKS_PER_GROUP() to be cluster size aware

Change the EXT2_MAX_BLOCKS_PER_GROUP so that it takes the cluster size
into account. This way we can open bigalloc file systems without
ext2fs_open() thinking that they are corrupt.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
6220b6715f4900bbcfa04ef3b81ccf48b2d21825 04-Jun-2011 Theodore Ts'o <tytso@mit.edu> libext2fs: require cluster size == block_size when opening a !bigalloc fs

In ext2fs_open() check to make sure the cluster size superblock field
is the same as the block size field when the bigalloc feature is not
set. This is necessary since we will start introducing calculations
based on the cluster size field.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
1e082c62093f34432af236f35764002646f1dcfc 04-Jun-2011 Theodore Ts'o <tytso@mit.edu> libcom_err: Fix install rule if installing with hard links

If $(LINK_INSTALL_FLAGS) is -f instead of -sf, the Makefile's install
rule would not work correctly while installing com_err.h

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/Makefile.in
bf0449b1a6547a566975cb32c18a2ba5972deace 18-May-2011 Lukas Czerner <lczerner@redhat.com> e2image: Add support for qcow2 format

This commit adds support for exporting filesystem into QCOW2 image
format. Like sparse format this saves space, by writing only necessary
(metadata blocks) into image. Unlike sparse image, QCOW2 image is NOT
sparse, hence does not change its size by copying with not-sparse-aware
tools.

New options '-Q' has been added to tell the e2image to use QCOW2 as an
output image format. QCOW2 supports encryption and compression, however
e2image so far does no support such features, however you can still
scramble filenames with '-s' option.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/bitops.h
xt2fs/e2image.h
xt2fs/qcow2.c
xt2fs/qcow2.h
ffec46fea48f1f05fbe2fb863b44fd2dd718c50f 18-May-2011 Lukas Czerner <lczerner@redhat.com> e2fsprogs: Add memory allocation and zero-out helpers

Add functions ext2fs_get_memzero() which will malloc() the memory
using ext2fs_get_mem(), but it will zero the allocated memory afterwards
with memset().

Add function ext2fs_get_arrayzero() which will use calloc() for
allocating and zero-out the array.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
598d20cc3c0f71561402e13c07aaf5880b85fa37 09-May-2011 Tao Ma <boyu.mt@taobao.com> mke2fs: make s_inodes_per_group >= 8 in ext2fs_initialize

current mkfs.ext4 fails if we tried with the following parameters:

mkfs.ext4 -m 0 -N 16 -O ^has_journal,^resize_inode,^uninit_bg,extent,meta_bg -b 1024 /dev/sdb3

It will cause segfault, but it is caused by another issue. See my
patch "mke2fs: Avoid segmentation fault in
ext2fs_alloc_generic_bmap". And with that patch, the mkfs.ext4 will
fail with the error: /dev/sdb3: Memory allocation failed while setting
up superblock

The reason is that in ext2fs_initialize, we align s_inodes_per_group
to 8, but fails to consider the case that s_inodes_per_group < 8.
So make at least 8 inodes for s_inodes_per_group.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/initialize.c
5fff975431e02c2b746b023d3c5e6755e910eaa9 21-Mar-2011 Lukas Czerner <lczerner@redhat.com> e2fsprogs: fix memory leak in ext2fs_free_generic_bmap()

In ext2fs_free_generic_bmap() when we are freeing 64-bit bitmap, we do
call free_bmap() to free backend specific bitmap structures, however we
should also free ext2fs_generic_bitmap structure as well.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap64.c
ba7cb5d9d7a9415ccb611e781a3832be7259622f 21-Mar-2011 Lukas Czerner <lczerner@redhat.com> e2fsprogs: fix freeing bitmap in allocation error path

In ext2fs_alloc_generic_bmap() error path, when new bitmap allocation
fails ext2fs_generic_bitmap should be freed, however in current state it
first frees ext2fs_generic_bitmap and then
ext2fs_generic_bitmap->description which is wrong. This commit fix the
free ordering.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap64.c
5af9eeaa7d36dd6f3a434697747ba8db3434eced 18-Mar-2011 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
lib/e2p/ls.c
4df1618250349dbe71f9474c42d52d7d03cc68a0 18-Mar-2011 Theodore Ts'o <tytso@mit.edu> add new superblock field: s_overhead_blocks

It turns out that it's very hard to calculate overheads in the face of
clustered allocation (bigalloc). This is because multiple metadata
blocks from different block groups can end up in the same allocation
cluster. Calculating the exact overhead requires O(all block bitmaps)
in memory, or O(number of block groups**2) in time. So we will
calculate this at mkfs time and stash it in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
xt2fs/ext2_fs.h
xt2fs/tst_super_size.c
aa07cb79b0a38d9d8407c5631624ef8534bdde3f 28-Feb-2011 Theodore Ts'o <tytso@mit.edu> mke2fs: If the device supports discard, don't print an error message

Check to see if the device supports discard before starting the
progress bar, and then printing an error about inappropriate ioctl for
device (when creating a file system image to a file, for example).

Also, add a function signature in the ext2_io.h header file for
io_channel_discard() and fix an extra, uneeded argument in mke2fs's
call to that function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_io.h
829d9994880394e48c883510799b1536812d6efb 28-Feb-2011 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
lib/ext2fs/initialize.c
412376efff3c0e0c2fea00666c2457e6f2ae1878 26-Feb-2011 Theodore Ts'o <tytso@mit.edu> Add basic BIGALLOC support for cluster-based allocation

This adds the superblock fields needed so that dumpe2fs works and the
code points and renames the superblock fields from describing
fragments to clusters.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
2p/ls.c
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
xt2fs/initialize.c
xt2fs/openfs.c
xt2fs/swapfs.c
xt2fs/tst_super_size.c
0edcc2702106ef8ea0d4ab60ef06c0c38b0b87ee 15-Feb-2011 Aditya Kali <adityakali@google.com> e2fsprogs: reserving code points for new ext4 quota feature

This patch adds support for detecting the new 'quota' feature in ext4.
The patch reserves code points for usr and group quota inodes and also
for the feature flag EXT4_FEATURE_RO_COMPAT_QUOTA.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.h
2p/feature.c
2p/ls.c
xt2fs/ext2_fs.h
xt2fs/swapfs.c
xt2fs/tst_super_size.c
214580a339a18b0539b5998d3b47934956a30a1c 21-Feb-2011 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
misc/mke2fs.conf.5.in
6a426c97ec2de0968b4cde62e5eab3df605bde33 17-Feb-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: enable user namespace xattrs by default

User namespace xattrs are generally useful, and I think extN
is the only filesystem requiring a special mount option to
enable them, when xattrs are otherwise available. So this
change sets that mount option into the defaults, via a
mke2fs.conf option.

Note that if xattrs are config'd off, this will lead to a
mostly-harmless:

EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/initialize.c
3daf592646b668133079e2200c1e776085f2ffaf 17-Feb-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: turn off enforced fsck intervals by default

The forced fsck often comes at unexpected and inopportune moments,
and even enterprise customers are often caught by surprise when
this happens. Because a filesystem with an error condition will
be marked as requiring fsck anyway, I submit that the time-based
and mount-based checks are not particularly useful, and that
administrators can schedule fscks on their own time, or tune2fs
the enforced intervals if they so choose. This patch disables the
intervals by default, and I've added a new mkfs.conf option to
turn on the old behavior of random, unexpected, time-consuming
fscks at boot time. ;)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/initialize.c
b6d274f7c67333e9d4b191b0d27a00be6a2d723f 16-Feb-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: create com_err.h link in includedir

After debian bug #192277, debian/rules started making a symlink
to com_err.h in /usr/include. Now I have Fedora bug #550889
for the same issue, and perhaps it's time to make this link
by default, rather than fixing it up in packaging steps?

[ Changed by tytso to remove the explicit -s option; this will default
to creating a hard link by default, which slightly faster. If
people want to use symlinks for all links during the install
process, they can use configure option --enable-symlink-install.
The reason for this change is that some file systems, like AFS,
don't support symlinks, and AFS users complain when they can't build
or install into AFS. So I don't want to use symlinks
unconditionally without a way of switching things back and forth,
and it's easier if we just make all links made during the install
process to be hard links or sym links. ]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
t/Makefile.in
da2a5a4baede2a227d2da587eb74ceae66778fbc 23-Dec-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
resize/resize2fs.c
a4fdf09414e04e9ecb995aa0af2f525d335987ae 22-Dec-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Don't use the extended rec_len encoding for standard file systems

If the file system has a blocksize less than 64k, then don't use the
extended rec_len encoding, to be consistent with what the kernel will
do.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dir_iterate.c
91dc3f0db0185503083f54c7b464900c851df0aa 29-Nov-2010 Namhyung Kim <namhyung@gmail.com> libext2fs: fix possible memory leak in write_journal_inode()

ext2fs_zero_block2() allocates static buffer if needed so it
should be freed at last (call it again with 0 args).

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/mkjournal.c
58caabc37d696363330c390f77a901bbc81cda1e 22-Dec-2010 Theodore Ts'o <tytso@mit.edu> ext2fs: fix memory leak in an error case in inode_open()

Reported-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode_io.c
2150278fa25f3fe8b8f29835ccd3079b608bb825 20-Dec-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: fix potential free() of garbage in ext2fs_update_bb_inode()

There was a potential of freeing an uninitialized pointer in
rec.block_buf, which was pointed out by Namhyung Kim <namhyung@gmail.com>

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bb_inode.c
f57e64a851b417f7a8cf0ab2531ad9028ca75474 29-Nov-2010 Namhyung Kim <namhyung@gmail.com> libext2fs: fix dubious code in ext2fs_unmark_generic_bitmap()

Looks like a copy & paste problem to me.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap.c
877d1dc0ab643086bf2eafcde7d0ce2478c036ee 29-Nov-2010 Namhyung Kim <namhyung@gmail.com> libext2fs: remove unnecessary casts to ext2fs_generic_bitmap

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap64.c
3ece37ea0a4d01499568dbbacc115dfeeb8ccbbb 20-Dec-2010 Namhyung Kim <namhyung@gmail.com> libext2fs: fix dubious code in ext2fs_numeric_progress_init()

Looks like a copy & paste problem to me.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/progress.c
beb4295ca417821977688465d014143fb5955968 20-Dec-2010 Namhyung Kim <namhyung@gmail.com> libext2fs: fix potential build failure with OMIT_COM_ERR

This fixes following build failure when OMIT_COM_ERR is defined:

lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_clear_generic_bitmap’:
lib/ext2fs/gen_bitmap.c:437: error: invalid storage class for function ‘ext2fs_test_clear_generic_bitmap_range’
lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_end’:
lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_start’:
lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_unmark_generic_bitmap’:
lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_mark_generic_bitmap’:
lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_test_generic_bitmap’:
lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
make[2]: *** [gen_bitmap.o] Error 1
make[2]: Leaving directory e2fsprogs/lib/ext2fs'
make[1]: *** [all-libs-recursive] Error 1
make[1]: Leaving directory e2fsprogs'
make: *** [all] Error 2

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/gen_bitmap.c
562f264243f4d4385910b6f06872730214977736 20-Dec-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
lib/ext2fs/block.c
lib/ext2fs/csum.c
resize/main.c
9098c986b64bb65a2b7fcd2724a400ba1f451f6b 17-Dec-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix compile bug on big-endian architectures

Addresses-Sourceforge-Bug: #3138115

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/swapfs.c
94ded6c16bdcc77b43caaa151bd7afa55c5d3cf1 17-Dec-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: fix ref_offset callback with sparse files in ext2fs_block_iterate2()

Addresses-Sourceforge-Bug: 3081087

Reported-by: vmo@users.sourceforge.net
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
c816ecb204a32e67788738e050ff2b14a721672b 14-Dec-2010 Eric Sandeen <sandeen@redhat.com> e2fsprogs: fix type-punning warnings

Flags used during RHEL/Fedora builds lead to a couple type-punning
warnings:

recovery.c: In function 'do_one_pass':
recovery.c:539: warning: dereferencing type-punned pointer will break strict-aliasing rules
./csum.c: In function 'print_csum':
./csum.c:170: warning: dereferencing type-punned pointer will break strict-aliasing rules

The two changes below fix this up.

Note that the csum test binary output changes slightly, but this does
not break any tests.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/csum.c
efa1a355a1e4142b2d057be06931eb8fc0903ba3 18-Nov-2010 Lukas Czerner <lczerner@redhat.com> e2fsck: Discard free data and inode blocks.

In Pass 5 when we are checking block and inode bitmaps we have great
opportunity to discard free space and unused inodes on the device,
because bitmaps has just been verified as valid. This commit takes
advantage of this opportunity and discards both, all free space and
unused inodes.

I have added new set of options, 'nodiscard' and 'discard'. When the
underlying devices does not support discard, or discard ends with an
error, or when any kind of error occurs on the filesystem, no further
discard attempt will be made and the e2fsck will behave as it would
with nodiscard option provided.

As an addition, when there is any not-yet-zeroed inode table and
discard zeroes data, then inode table is marked as zeroed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/test_io.c
d866599ab4955858b1541f0891b1b165ba66493a 18-Nov-2010 Lukas Czerner <lczerner@redhat.com> e2fsprogs: Add CHANNEL_FLAGS_DISCARD_ZEROES flag for io_manager

When the device have discard support and simultaneously discard zeroes
data (and it is properly advertised), then we can take advantage of such
behavior in several e2fsprogs tools.

Add new flag CHANNEL_FLAGS_DISCARD_ZEROES for struct_io_channel so
each io_manager can take advantage of this. The flag is properly set
according to BLKDISCARDZEROES ioctl in unix_open.

Also remove old mke2fs_discard_zeroes_data() function and substitute it
with helper which test this flag.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2_io.h
xt2fs/unix_io.c
e90a59ed434d6c5e38dd148aa4ba5b22b8f7eb24 18-Nov-2010 Lukas Czerner <lczerner@redhat.com> e2fsprogs: Add discard function into struct_io_manager

In order to provide generic "discard" function for all e2fsprogs tools
add a discard function prototype into struct_io_manager. Specific
function for specific io managers can be crated that way.

This commit also creates unix_discard function which uses BLKDISCARD
ioctl to discard data blocks on the block device and bind it into
unit_io_manager structure to be available for all e2fsprogs tools.
Note that BLKDISCARD is still Linux specific ioctl, however other
unix systems may provide similar functionality. So far the
unix_discard() remains linux specific hence is embedded in #ifdef
__linux__ macro.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2_io.h
xt2fs/io_manager.c
xt2fs/test_io.c
xt2fs/unix_io.c
4fca2b9c07981abca16d337b2e57f78569cbbe05 22-Nov-2010 Justin Maggard <jmaggard10@gmail.com> Fix EXT4_FEATURE_RO_COMPAT_HUGE_FILE check

Creating a 4TB file on a filesystem with the 64bit flag set results in
e2fsck consistently complaining about i_blocks being wrong, with
confusing messages like this:

Inode 29818882, i_blocks is 8388608816, should be 8388608816. Fix? no

That appears to be caused by ext2fs_inode_i_blocks() checking for the
EXT4_FEATURE_RO_COMPAT_HUGE_FILE in the wrong place. Fix it.

Signed-off-by: Justin Maggard <jmaggard10@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/blknum.c
9d92a201deec7bbb1911e6e5ee98abf3c83882d4 25-Sep-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
configure
configure.in
lib/ext2fs/ext2fs.h
misc/mke2fs.c
73fbe2323af6a2b4d807c80069657bf1449b3bff 25-Sep-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Change EXT2_FLAG_DIRECT_IO to avoid conflict with devel branch

The development branch of e2fsprogs already has a code point assigned
in conflict with EXT2_FLAG_DIRECT_IO. Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
00f0b1411838db56e1e04816e4d369be332fd2b6 24-Sep-2010 Theodore Ts'o <tytso@mit.edu> ext2fs: Optimize for Direct I/O

Allocate various memory structures to be properly aligned to avoid
needing to use a bounce buffer when doing direct I/O read/writes.
This should also help on FreeBSD systems which require aligned buffers
unconditionally.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
xt2fs/openfs.c
xt2fs/rw_bitmaps.c
7f1a1fbf850f6b73b5c9c82365f01029fb250a1c 24-Sep-2010 Theodore Ts'o <tytso@mit.edu> ext2fs: Add Direct I/O support to the ext2fs library

This adds the basic support for Direct I/O to unix_io.c, and adds a
new flag EXT_FLAG_DIRECT_IO which can be passed to ext2fs_open() or
ext2fs_open2() to request Direct I/O support.

Note that device mapper devices in Linux don't support Direct I/O, and
in some circumstances using Direct I/O can actually make performance
*worse*!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/ext2_io.h
xt2fs/ext2fs.h
xt2fs/openfs.c
xt2fs/unix_io.c
faafdb765b4ed2bb33070d998426bec0cf774344 23-Sep-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix memory leak in the Unix I/O layer when changing block size

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/unix_io.c
023a1df091f9d42f826ee3737190db5de9c823b0 23-Sep-2010 Theodore Ts'o <tytso@mit.edu> ext2fs: add ext2fs_get_memalign() function

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
9345f02671fd39cad69338080b62e12e8b86671d 19-Sep-2010 Theodore Ts'o <tytso@mit.edu> tune2fs, debugfs, libext2fs: Add support for ext4 default mount options

Add support for 2.6.35's new default mount options which can be
specified in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
2p/mntopts.c
xt2fs/ext2_fs.h
xt2fs/tst_super_size.c
ccc7cf032852dd5c84b227bafb481b1d158e2b5e 31-Jul-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: fix obvious big-endian bugs introduced by 64-bit changes

These patches fix obvious bone-headed mistakes, so e2fsprogs will now
build and mostly work on powerpc. The m_meta_bg, u_mke2fs, and
u_tune2fs tests are still failing, however, so there's still work to do...

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
xt2fs/swapfs.c
27a0e958e619c3ca105e575670416a964fa2678f 22-Jul-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Add ext2fs_file_size_size2() and truncate the file if necessary

This adds a 64-bit interface for ext2fs_file_size_size() and enhances
it to trunate the file if necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/fileio.c
6dc058bd126ba2f631e38233d899f58a04e0c74f 10-Jul-2010 Renzo Davoli <renzo@cs.unibo.it> libext2fs: Add new function ext2fs_file_get_inode()

This patch adds a very simple function:

struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file);

which is useful for fuse-ext2 when it needs to read the inode of an
open file.

Signed-off-by: renzo davoli <renzo@cs.unibo.it>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/fileio.c
3adb9374fb92736e393ad64f751073b19927ec0e 22-Jul-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Add new function ext2fs_punch()

This function deallocates a range of blocks from a passed-in file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/ext2fs.h
xt2fs/punch.c
f03bb73ceb55791f7a59dbb72cfdbe121c5d204e 22-Jul-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Don't make a copy of the inode in ext2fs_extent_open2()

Previously, ext2fs_extent_open2() copied the passed-in inode structure
into the extent handle, and the extent functions modified the copy of
the inode structure if necessary due to extent splits, etc. Change
ext2fs_extent_open2() so that the extent functions use the inode
structure passed into ext2fs_extent_open2(). Otherwise the passed-in
inode structure could become out of date due to changes made by the
extent functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
47e155df575be3664493903507ac40d56c9b4e7d 21-Jul-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix ext2fs_iblk_{add,sub}_blocks() when the i_blocks_hi is non-zero

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/i_block.c
92e2d79cfbe67244eff8ded095491cba16e98dcc 20-Jul-2010 Theodore Ts'o <tytso@mit.edu> tst_extents: Fix 64-bit bugs in do_goto_block()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
db0bdb49f49fc3dd14c12439d934a3403a3be9f1 19-Jul-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
resize/extent.c
c5726f1ad7efedcdb24b3b362c84f0d0b402b337 05-Jul-2010 Theodore Ts'o <tytso@mit.edu> Enhance tst_super_size so that it checks the superblock fields as well

The test now checks to make sure the superblock fields are correctly
aligned and prints them out so they can be manually checked to make
sure they are where we expect them to be.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tst_super_size.c
993988f65527e5665181b3e4a6161f317e396489 25-Jun-2010 Theodore Ts'o <tytso@mit.edu> Add superblock fields which track first and most recent fs errors

Add superblock fields which track where and when the first and most
recent file system errors occured. These fields are displayed by
dumpe2fs and cleared by e2fsck.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
xt2fs/ext2_fs.h
8c084167ee5ea4ae28359b0d67d583eb1068465c 25-Jun-2010 Theodore Ts'o <tytso@mit.edu> Fix Makefile dependencies for test programs in lib/ext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
f5448c19acda0bae0673d17e97b8a0590c99c944 25-Jun-2010 Theodore Ts'o <tytso@mit.edu> Add support for Next3 snapshot superblock fields to dumpe2fs and debugfs

We also support for byte-swapping the Next3 fields, although the
current Next3 implementation doesn't support big-endian systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
xt2fs/swapfs.c
efe0b401465a3ee836180614b5b435acbb84fc27 14-Jun-2010 Eric Sandeen <sandeen@redhat.com> libext2fs: make fs->group_desc opaque

To prevent direct array indexing of fs->group_desc[i] (because the
group_desc may be a different size for different filesystems) make it
an opaque pointer that may only be accessed through the accessor
functions in blknum.c. The type itself is still available in a public
header; if we have a group_desc that we know is one type or another,
it's ok to access its fields directly. This change only prevents us
from indexing off fs->group_desc[i] directly.

Old-style applications who don't want to change their source code can
(as a temporary short-term hack) #define EXT2FS_OLD_32_COMPAT before
including ext2fs.h.

Change the accessors in blknum.c to use ext4fs_group_desc(), a version
of ext2fs_group_desc() which returns a ext4_group_desc pointer.

This simplifies and collapses a fair bit of code in blknum.c

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/blknum.c
xt2fs/ext2fs.h
02d6f47e9647d3155a38c8676c2da6ea773d9b68 13-Jun-2010 Jose R. Santos <jrs@us.ibm.com> mke2fs: Fix up mke2fs to be able to make 64-bit file systems

Use 64-bit interfaces in mke2fs. This should be most most of whats
needed to support creating a 64-bit filesystem.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
6d8b37fa7661484ca50a4951cffbf531ab1bccbb 13-Jun-2010 Valerie Aurora Henson <vaurora@redhat.com> libext2fs: More random 64-bit fixes, lots of block_iterate3

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmove.c
xt2fs/check_desc.c
xt2fs/expanddir.c
xt2fs/ext2fs.h
xt2fs/extent.c
xt2fs/imager.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/namei.c
xt2fs/openfs.c
xt2fs/read_bb.c
xt2fs/read_bb_file.c
xt2fs/res_gdt.c
ab13b5a9795a8c20f1d6da8fe1da340f545ec0e0 13-Jun-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Create 64-bit dblist functions

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dblist.c
xt2fs/dblist_dir.c
xt2fs/dir_iterate.c
xt2fs/ext2fs.h
xt2fs/ext2fsP.h
da3fc25bce5880c5d036d97727299ab09b415219 13-Jun-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Teach *_initialize and *_allocate_group to be 64-bit safe

This is needed to enable 64-bit mke2fs to work correctly.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
xt2fs/initialize.c
97d26ce9e3589e9f5fa17014467a9730a884d158 07-Jun-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
e2fsck/journal.c
e2fsck/pass1.c
e2fsck/pass2.c
misc/mke2fs.c
6d0ed6780285e79360353d4b06b339c00712d754 02-Jun-2010 Theodore Ts'o <tytso@mit.edu> Reserve feature flags and fields needed for the Next3 snapshot feature

The documentation is not (as of this writing) fully complete, but
there is some documentation here:

http://sourceforge.net/apps/mediawiki/next3/index.php?title=Code_documentation
http://sourceforge.net/apps/mediawiki/next3/index.php?title=On-disk_format
http://sourceforge.net/projects/next3/files/Next3_Snapshots.pdf/download

... which will hopefully be updated soon to be fully up to date with
these assignments and more details about how things work.

For now, the assignments should avoid collisions with other new work
that people might want to do on ext3/4.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
30a7610edfc0c22cb6b5ad9f76f65700fb6ffe98 02-Jun-2010 Andreas Dilger <adilger@sun.com> Reserve the EXT4_FEATURE_INCOMPAT_DIRDATA feature flag

Reserve the EXT4_FEATURE_INCOMPAT_DIRDATA feature flag for adding
extra file data in ext2_dir_entry_2 entries.

This changes the on-disk layout in the following way.

Firstly, the ext2_dir_entry_2 file_type field now has a mask: that
limits the "filetype" information to the low 4 bits of this field.
Since these values are sequentially assigned, this allows for up to 7
more filetypes to be assigned. When reading the "filetype" field, the
high 4 bits should be masked off when converting to DT_* filetypes for
userspace.

The high 4 bits of "filetype" are used as a bitmask to register up to
4 different "extended" directory entry fields. Extended data fields
are packed without alignment into the directory entry after the "name"
field in order of increasing bitmask value, for each field where bit
is set. In order to avoid the need to "understand" each of the
extended fields, the first byte of each extended data field holds the
size of that data field (including the size itself), so they can be
skipped if not understood. For fields that change the semantics of
the filesystem it is expected that a separate ROCOMPAT or INCOMPAT
field is registered.

There is a single dirent data type defined currently, for Lustre:
which holds a 128-bit file identifier. It is expected that if there
are 64-bit inode values that this will be assigned the 0x20 value.

Should a need ever arise to use all 4 of the extended dirent data
fields, it would be possible to keep the last bit (0x80) for use as a
multiplexor that stores a 1-byte aggregate data size, then a series of
"<u8_size><u8_type><data>" records in the last extended data record.
It is not expected that this will actually be needed in the lifetime
of ext4.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
cff9690f4e114d95c9031a7468c99fda0ddcb3ec 02-Jun-2010 Andreas Dilger <adilger@sun.com> Reserve the EXT4_INCOMPAT_EA_INODE feature flag

Reserve the EXT4_INCOMPAT_EA_INODE feature flag for use with
large extended attributes that are stored in a separate inode.
This changes the on-disk format in several ways:

First, replace the e_value_block field with e_value_inum, so that
an xattr entry can reference an external inode. This field is
currently unused, as all of the entries live in the same block.

struct ext2_ext_attr_entry {
__u8 e_name_len; /* length of name */
__u8 e_name_index; /* attribute name index */
__le16 e_value_offs; /* offset in disk block of value */
> __le32 e_value_inum; /* inode in which the value is stored */
__le32 e_value_size; /* size of attribute value */
__le32 e_hash; /* hash value of name and value */
char e_name[0]; /* attribute name */
}

Second, add a flag to the inode that indicates it is using a large
(external) extended attribute. This is needed so that when unlinking
an inode the xattrs will be scanned to unlink the xattr inodes
referenced by the main inode.

Third, for inodes that have a number of xattrs that are larger than
a single block, but not large enough to justify an external inode
(less than 64kB total xattr size, due to e_value_offs limitation)
the ext2_ext_attr_header->h_blocks field can grow beyond a single
block to represent a contiguous allocation of blocks for the xattr.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
effb3442419e50b6352fb13cfc8eea03bebf442e 01-Jun-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Remove #include of <linux/types.h> from fiemap.h

The system header file can end up causing type conflicts, and
including kernel header files is always dodgy/dangerous (and this case
not needed).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fiemap.h
bb1158b92ed8a12ab9e9317ca6ddd97bc12447d3 18-May-2010 Theodore Ts'o <tytso@mit.edu> mke2fs: account for physical as well as logical sector size

Some devices, notably 4k sector drives, may have a 512 logical
sector size, mapped onto a 4k physical sector size.

When mke2fs is ratcheting down the blocksize for small filesystems,
or when a blocksize is specified on the commandline, we should not
willingly go below the physical sector size of the device.

When a blocksize is specified, we -must- not go below
the logical sector size of the device.

Add a new library function, ext2fs_get_device_phys_sectsize()
to get the physical sector size if possible, and adjust the
logic in mke2fs to enforce the above rules.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/getsectsize.c
xt2fs/tst_getsectsize.c
543547a52a20cb7e69d74921b2f691078fd55d83 18-May-2010 Theodore Ts'o <tytso@mit.edu> libe2p, libext2fs: Update file copyright permission states to match COPYING

The top-level COPYING file states that the e2p and ext2fs libraries
are available under the LGPLv2. The files were incorrectly labelled.
Alex Thomas/Luster has been consulted wrt to the ext3_extents.h file;
the rest of the files were primarily authored by Theodore Ts'o.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/e2p.h
2p/feature.c
2p/fgetflags.c
2p/fgetversion.c
2p/fsetflags.c
2p/fsetversion.c
2p/getflags.c
2p/getversion.c
2p/hashstr.c
2p/iod.c
2p/ls.c
2p/mntopts.c
2p/ostype.c
2p/parse_num.c
2p/pe.c
2p/percent.c
2p/pf.c
2p/ps.c
2p/setflags.c
2p/setversion.c
2p/uuid.c
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/badblocks.c
xt2fs/bb_compat.c
xt2fs/bb_inode.c
xt2fs/bitmaps.c
xt2fs/bitops.c
xt2fs/bitops.h
xt2fs/block.c
xt2fs/bmap.c
xt2fs/bmove.c
xt2fs/brel.h
xt2fs/brel_ma.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/csum.c
xt2fs/dblist.c
xt2fs/dblist_dir.c
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/dirhash.c
xt2fs/dosio.c
xt2fs/dosio.h
xt2fs/dupfs.c
xt2fs/e2image.h
xt2fs/expanddir.c
xt2fs/ext2_io.h
xt2fs/ext2fs.h
xt2fs/ext2fsP.h
xt2fs/ext3_extents.h
xt2fs/ext_attr.c
xt2fs/extent.c
xt2fs/fileio.c
xt2fs/finddev.c
xt2fs/flushb.c
xt2fs/freefs.c
xt2fs/gen_bitmap.c
xt2fs/get_pathname.c
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/i_block.c
xt2fs/icount.c
xt2fs/imager.c
xt2fs/ind_block.c
xt2fs/initialize.c
xt2fs/inline.c
xt2fs/inode.c
xt2fs/inode_io.c
xt2fs/irel.h
xt2fs/irel_ma.c
xt2fs/ismounted.c
xt2fs/link.c
xt2fs/llseek.c
xt2fs/lookup.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/namei.c
xt2fs/native.c
xt2fs/newdir.c
xt2fs/nt_io.c
xt2fs/openfs.c
xt2fs/read_bb.c
xt2fs/read_bb_file.c
xt2fs/res_gdt.c
xt2fs/rw_bitmaps.c
xt2fs/sparse.c
xt2fs/swapfs.c
xt2fs/test_io.c
xt2fs/tst_badblocks.c
xt2fs/tst_bitops.c
xt2fs/tst_byteswap.c
xt2fs/tst_getsectsize.c
xt2fs/tst_getsize.c
xt2fs/tst_iscan.c
xt2fs/tst_super_size.c
xt2fs/tst_types.c
xt2fs/undo_io.c
xt2fs/unix_io.c
xt2fs/unlink.c
xt2fs/valid_blk.c
xt2fs/version.c
xt2fs/write_bb_file.c
4d452afe4757fdac1bd92fd6fcc09091eff181bd 18-May-2010 Theodore Ts'o <tytso@mit.edu> Always build namei.o so that building with "configure --disable-debugfs" works

namei.o is also needed by e2initrd_helper.

Long term, if we care about reduced e2fsprogs builds, we need a more
general solution for deciding what .o files are needed for a
particular build. Given that install floppies are going (gone?) the
way the dodo bird, we probably don't care, though.

Addresses-Sourceforge-Bug: #2911433

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
5aa6c3f61c0559f03b68bdeef886f34ece106757 18-May-2010 Theodore Ts'o <tytso@mit.edu> Add configure options --enable-symlink-build and --enable-symlink-install

These options allow e2fsprogs to be built using symlinks instead of
hard links, and to be installed using symlinks instead of hard links,
respectively.

Addresses-Sourceforge-Bug: #1436294

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.bsd-lib
akefile.checker
akefile.darwin-lib
akefile.elf-lib
akefile.library
akefile.profile
akefile.solaris-lib
uid/Makefile.in
822c10e84e5f57394bcad921adc560f5b032c03e 15-May-2010 Theodore Ts'o <tytso@mit.edu> libcom_err: Only output ^M when tty is in raw mode

This fixes a long-standing botch in the com_err library, and solves a
regression test problem for libss that gets tickled by source code
management systems (like Perforce) that don't preserve CRLF line
endings with fidelity.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/com_err.c
s/test_script_expected
c5b23f6c0e17503630455fb16d1b2035f844acc9 15-Mar-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
1601b10e65a55a1f8e4b262fa295cdab8cb5d98d 15-Mar-2010 Theodore Ts'o <tytso@mit.edu> libcom_err: Add support for Heimdal com_right_r function()

Addresses-Sourceforge-Bug: #2963865
Addresses-Debian-Bug: #558910

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/com_err.h
t/com_right.c
8e2399d57ac2bec1830e27deeeac66002d81001c 11-Mar-2010 Theodore Ts'o <tytso@mit.edu> ext2fs: Optimize extending an extent-mapped file using ext2fs_block_iterate2()

When ext2fs_block_iterate2() is called on an extent-mapped file with a
depth > 1, it will erroneously calling the callback function starting
all over again with an offset of logical block 0. It shouldn't do
this, and it cases mke2fs to become very slow when creating files with
very large journals.

Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
4ffafee26cf791c0c651c08d3dcefcdd363bf127 24-Feb-2010 Eric Sandeen <sandeen@redhat.com> e2fsck: don't complain about i_size for known blocks past EOF

This is the userspace side of Jiaying's EOFBLOCKS patch. With
Aneesh's patches for .33, Jiaying's patch, and this one, xfstests
013/fsstress (even with direct IO enabled) has held up through many
runs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
1d18a55c528adf997d8edee60bd8003c822c55e8 15-Feb-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix byte swapping bugs

The 64-bit patches broke compiles on big endian systems. In addition
the block group checksum test was failing, due to bugs in both the
test case and the checksum code itself. This commit addresses these
problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/csum.c
cc84d866e2f29d92b5a732fead4df2dd9f814f2b 11-Feb-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
e2fsck/pass1.c
4e79a19fe0b6dc3c2bd9cae9dfdbc5e96a3f98f8 26-Jan-2010 Eric Sandeen <sandeen@redhat.com> libss: add newer libreadline to dlopen path

Rawhide now has libreadline.so.6 ... add it to the ever-expanding
list of libs to look for.

Unfortunately without commit 06ef971be505678ee462ae1844204ed24f14aedc
this fails in a rather cryptic way.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/get_readline.c
2d07b3ad98bfe1db5fb1071f53a5338ab6c35522 31-Jan-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
configure
lib/ext2fs/alloc_tables.c
misc/mke2fs.c
c21cde9986e69756254b65b7a48974222f358a2e 31-Jan-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Add some fail-safe checks to the 32-bit bitmap code

If a 64-bit bitmap is passed to a 32-bit bitmap function, add some
checks to make sure that we print a useful error message so we can
better catch potential problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fsP.h
xt2fs/gen_bitmap.c
xt2fs/gen_bitmap64.c
bbb60e4fefdd404d8d696369804b556b404bb0c1 30-Nov-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Improve flex_bg inode table placement algorithm

When trying to find the best place for the inode table in the last
flex block group, use the true size for the flex_bg's portion of the
inode table instead of the worst case required size of the inode table
fragment if the file system is resized. This fixes a corner case
where if the size of the filesystem is just big enough that there is
only room for a single block group in the last flex_bg, and that
partial block group is too small for the full portion of the inode
table, the inode table is placed in the very first block group:

Group 64: (Blocks 2097152-2099199) [INODE_UNINIT, ITABLE_ZEROED]
Checksum 0xd305, unused inodes 8080
Block bitmap at 2097152 (+0), Inode bitmap at 2097168 (+16)
Inode table at 8626-9130 (+4292878770)
^^^^^^^^^

Thanks to Vyacheslav Dubeyko for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
4534f8bc3fb3e2fa6f8420596787fa397f525cd4 30-Nov-2009 Theodore Ts'o <tytso@mit.edu> debian: Fix FTBFS problem caused by texi2html changing its output location

Unfortunately, texi2html gratuitously changed its behavior of where
its output html files are placed when the -split_chapter is in effect.
(First it was in a subdirectory; then it was in the current directory;
now it's back to putting the output html files in a subdirectory
again.)

Support either way of doing things since the texi2html team seems to
be indecisive...

Addresses-Debian-Bug: #552934

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/Makefile.in
t/com_err.texinfo
9c9e1d5fe507d08309e9815eee50ca73e21bd2bd 29-Nov-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix SET_BMAP bugs in ext2fs_bmap() and ext2fs_bmap2()

Don't byte-swap the block number when setting i_block[x], since the
write_inode function will take of byte swapping the inode.

The phys_blk parameter contains an input parameter in the SET_BMAP
case, so it must be passed to ext2fs_bmap2() from the legacy function
ext2fs_bmap().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
4486af5b4c1b117ac88a92cd2336cb41c15107d3 16-Nov-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
misc/mke2fs.c
5f91561ae7e08d79b6a5feca167259fd7634713f 13-Oct-2009 Karel Zak <kzak@redhat.com> libext2fs: handle <=linux-2.6.19 bug in /proc/swaps

Linux <= 2.6.19 contained a bug in the /proc/swaps code where the
header would not be displayed (the first line).

This issue has been reported by Mike Frysinger for swapon(8).

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ismounted.c
6eb229dc5d212ac5897ff626b839318f4e0c57ca 10-Nov-2009 Eric Sandeen <sandeen@redhat.com> libext2fs: don't swap extent-based journal backup

The f_illitable_flexbg test was failing on ppc, because
e2fsck_move_ext3_journal is doing a direct memcmp of i_block with
s_jnl_blocks, and failing.

This is because we don't swap extent data on read from disk; rather
we do it when we access the extents. However, ext2fs_swap_super
was swapping s_jnl_blocks unconditionally, so these didn't match.

Looks like we need to treat s_jnl_blocks the same as i_block, and
swap it on access, not on read. Except for the last i_size bit...

Reviewed-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/swapfs.c
06ef971be505678ee462ae1844204ed24f14aedc 12-Nov-2009 Theodore Ts'o <tytso@mit.edu> libss: initialize function pointer for readline_shutdown()

Clear the function pointer for readline_shutdown() so that if libss is
linking against a readline library which doesn't supply a
readline_shutdown() function, ss_delete_invocation() won't seg fault.

Thanks to Solar Designer <solar@openwall.com> for reporting this
problem to me.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/invocation.c
054e5a9ccf8d65e015f2af85bfddd3fda3a0472f 26-Oct-2009 Valerie Aurora Henson <vaurora@redhat.com> Add 64bit option to known incompatible file system options

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/kernel-jbd.h
b49f78fe6e19fe63b6f989d5e1afb04f59069197 26-Oct-2009 Theodore Ts'o <tytso@mit.edu> Convert ext2fs_group_{first,last}_block() to *block2()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
xt2fs/check_desc.c
6493f8e85defc568a4ca8cdb4a53361f36fb94ba 26-Oct-2009 Theodore Ts'o <tytso@mit.edu> Convert ext2fs_group_of_blk() to ext2fs_group_of_blk2()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
xt2fs/mkjournal.c
48f23054bb8ad0506c0baa9f06ba182acc2aa88b 26-Oct-2009 Valerie Aurora Henson <vaurora@redhat.com> Convert ext2fs_block_alloc_stats() calls to block_alloc_stats2()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bb_inode.c
xt2fs/expanddir.c
xt2fs/extent.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
cf828f1a72ec1eb0c1e819307137879447c909b7 26-Oct-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Byte-swap 64-bit block group descriptors

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/csum.c
xt2fs/ext2fs.h
xt2fs/openfs.c
xt2fs/swapfs.c
d7cca6b06f366f998ed43346f9b6fca9e163692f 26-Oct-2009 Valerie Aurora Henson <vaurora@redhat.com> Convert to use block group accessor functions

Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/csum.c
xt2fs/dblist.c
xt2fs/imager.c
xt2fs/initialize.c
xt2fs/inode.c
xt2fs/mkjournal.c
xt2fs/openfs.c
xt2fs/rw_bitmaps.c
xt2fs/tst_iscan.c
cd65a24e756b8f6770a5961fd94c67eb00dd7baa 26-Oct-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Convert ext2fs_bg_flag_test() to ext2fs_bg_flags_test()

After cleaning up ext2fs_bg_flag_set() and ext2fs_bg_flag_clear(),
we're left with ext2fs_bg_flag_test(). Convert it to
ext2fs_bg_flags_test().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/blknum.c
xt2fs/ext2fs.h
xt2fs/inode.c
xt2fs/rw_bitmaps.c
e633b58ac75f2f544b7d6572e37d4b63da31e59c 26-Oct-2009 Eric Sandeen <sandeen@redhat.com> libext2fs: clean up ext2fs_bg_flags_ interfaces

The ext2fs_bg_flag* functions were confusing.

Currently we have this:

void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags);

(_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags)

and these, which can twiddle individual bits in bg_flags:

void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);

A better interface, after the patch below, is just:

ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */
ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */
ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */

and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/blknum.c
xt2fs/csum.c
xt2fs/ext2fs.h
xt2fs/initialize.c
xt2fs/openfs.c
72a729dbf962e8fba58a06ee0a11a01b15e743fc 24-Oct-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
configure
configure.in
5d10807070ae13a89c2a0cc217e30af6f061d60e 21-Oct-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix FEATURE_RO_COMPAT_HUGE_FILE && !HUGE_FILE_FL

If the RO compat HUGE_FILE feature flag is set, but the inode's
HUGE_FILE_FL flag is not set, we should still pay attention to the
high 32 bits of the i_blocks filed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/i_block.c
95bcea9fc149e349865f9eb30988ad1b4e1c1342 05-Oct-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
configure
configure.in
misc/mke2fs.c
f790bc33b20e5c1a9d357c41cb2c1b7ea486f98c 04-Oct-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Always build file_io.c

Commit 1d9b818: dumpe2fs: Print more information about the inline journal
caused dumpe2fs to use ext2fs_file_open2(). Previously the file_io
functions were only used by debugfs, so if debugfs was disabled,
file_io was not built. Now that dumpe2fs is also using file_io, we
need to build it unconditionally.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
e1f085079525c0ed4c5ab1f2abedaf9407a7b8da 04-Oct-2009 Theodore Ts'o <tytso@mit.edu> Don't use in-tree header files if using system uuid or blkid libraries

This commit forces the use of the system-provided blkid or uuid header
files if we are using the system-provided blkid or uuid libraries.
This avoids using the in-tree header files with the system libraries.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/Makefile.in
lkid/blkid.h
lkid/blkid.h.in
lkid/version.c
uid/Makefile.in
uid/tst_uuid.c
uid/uuid.h
uid/uuid.h.in
uid/uuidP.h
7822f784f1edf767cc74044e02702a6d44cee267 04-Oct-2009 Theodore Ts'o <tytso@mit.edu> blkid: Avoid a potentially error message when running "make clean"

This error isn't terribly important, but apparently it causes some
users/developers distress.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/Makefile.in
04f13d6685b57c29974e4ce2d9074679123bf8a9 09-Sep-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Add error table initialization to test programs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/ismounted.c
xt2fs/tst_badblocks.c
xt2fs/tst_getsize.c
4efbac6fed75c29d3d5f1b676b932754653a2ac5 08-Sep-2009 Valerie Aurora Henson <vaurora@redhat.com> Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/bb_inode.c
xt2fs/block.c
xt2fs/bmove.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/csum.c
xt2fs/ext_attr.c
xt2fs/icount.c
xt2fs/initialize.c
xt2fs/mkjournal.c
xt2fs/openfs.c
xt2fs/rw_bitmaps.c
xt2fs/tst_badblocks.c
a63745e81cbb476b90c75ca3ca60b9ba4be95cae 08-Sep-2009 Valerie Aurora Henson <vaurora@redhat.com> Use ext2fs_file_acl_block() instead of using .i_file_acl directly

This provides support for 48-bit file acl blocks.

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
xt2fs/valid_blk.c
c5b7b6babe658a2037af6c9d2b7a3c23208f98f1 08-Sep-2009 Valerie Aurora Henson <vaurora@redhat.com> Fix overflow in calculation of total file system blocks

Blocks per group and group desc count are both 32-bit; multiplied they
produce a 32-bit quantity which overflowed.

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitmaps.c
xt2fs/rw_bitmaps.c
51e64594919c986f87267b895504322a38ec4fac 07-Sep-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Round up the bitmap size when allocating a new bitmap

The x86 BT assembly instructure can overshoot the end of a bit array
when testing a bit at the end of the bit array, even if it never needs
to look at those memory locations. This can cause a spurious
segmentation fault. If we allocate a little extra memory, it avoids
this problem. See:

http://faydoc.tripod.com/cpu/bt.htm

This doesn't happen on Linux, probably because of the glibc's malloc()
function works, but apparently it's a major problem on the *BSD
operating systems.

Addresses-Sourceforge-Bug: #2328708

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/gen_bitmap.c
249c962ad8f2daabc403577d0c994e4c986c8f9a 23-Aug-2009 Karel Zak <kzak@redhat.com> blkid: support .ko.gz in modules.dep parser

The Linux kernel modules could be compressed, it means modules.dep
parser in libblid has to support .ko.gz extension too.

(Note, I've talked about this problem with Jon Masters and his
suggestion is to exec(/sbin/modinfo) rather than directly parse
modules.dep. BTW, the modules.dep file is deprecated.)

Address-Red-Hat-Bug: #518572
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
8bafedbf4a6889b20e119a667fc243909d283f85 25-Aug-2009 Theodore Ts'o <tytso@mit.edu> tune2fs: Fix "tune2fs -j <dev>" for extent-enabled filesystems

For filesystms that have the extent feature enabled, we need to grab
the use EXT2_IOC_GETFLAGS so that we don't accidentally end up trying
to request clearing the EXT2_EXTENT_FL, which is not supported and
causes the tune2fs -j error out.

Also fix the error returning in ext2fs_add_journal_inode() so it
returns a proper error code if the fstat() or ioctl() calls fail.

Addresses-Launchpad-bug: #416648

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkjournal.c
95fd65bb7fcf84e8d1e207f84b9d5a9f99626a38 24-Aug-2009 Valerie Aurora Henson <vaurora@redhat.com> libext2fs: create generic numeric progress meters and use them

With 64-bit file systems, mke2fs can take a long time to do things
other than write inode tables. I exported the mke2fs numeric progress
meter and used it for allocating group tables and the final file
system flush.

Signed-off-by: Valerie Aurora (Henson) <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/alloc_tables.c
xt2fs/closefs.c
xt2fs/ext2fs.h
xt2fs/ext2fsP.h
xt2fs/progress.c
732c8cd58ff30ffae0d3276c411a08920717a46c 08-Sep-2009 Theodore Ts'o <tytso@mit.edu> Use accessor functions fields for bg_flags in the block group descriptors

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/initialize.c
xt2fs/inode.c
xt2fs/openfs.c
xt2fs/rw_bitmaps.c
24a117abd0340d247befbf7687ffb70547fdf218 08-Sep-2009 Valerie Aurora Henson <vaurora@redhat.com> Convert to use io_channel_read_blk64() and io_channel_write_blk64()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bb_inode.c
xt2fs/bmove.c
xt2fs/closefs.c
xt2fs/dirblock.c
xt2fs/expanddir.c
xt2fs/extent.c
xt2fs/imager.c
xt2fs/inode.c
xt2fs/mkjournal.c
xt2fs/openfs.c
xt2fs/rw_bitmaps.c
xt2fs/undo_io.c
d62d218f118863322742093ceb938bcac6093f80 08-Sep-2009 Nick Dokos <nicholas.dokos@hp.com> libext2fs: Fix counting routines in blknum.c to take/return __u32 counts

Several routines in lib/ext2fs/blknum.c:

ext2fs_bg_free_blocks_count()
ext2fs_bg_free_inodes_count()
ext2fs_bg_used_dirs_count()
ext2fs_bg_itable_unused()

and their _set() counterparts, operate as if they are dealing with
blk64_t quantities, but they should be dealing with __u32 counts
instead.

Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/blknum.c
xt2fs/ext2fs.h
dc615a21c3c43cd9071926df2633d5b23e2e726b 07-Sep-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
f4240c8d56520b95f0a8f956ba31e204e105467e 10-Aug-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Treat uninitialized parts of bitmaps as unallocated

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/rw_bitmaps.c
8f82ef9860339039b54a324be137fbc09b762358 05-Aug-2009 Valerie Aurora Henson <vaurora@redhat.com> Convert libext2fs to 64-bit bitmap interface

(Includes fixes from Nick Dokos)

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/bb_inode.c
xt2fs/bitmaps.c
xt2fs/bmove.c
xt2fs/check_desc.c
xt2fs/csum.c
xt2fs/ext2_err.et.in
xt2fs/ext2_io.h
xt2fs/ext2fs.h
xt2fs/icount.c
xt2fs/imager.c
xt2fs/rw_bitmaps.c
xt2fs/tst_iscan.c
69365c689b7164014e539b40ef62fc8eb804a05c 22-Aug-2009 Theodore Ts'o <tytso@mit.edu> Add support for 64-bit bitmaps

Initial design was done by Theodore Ts'o; implementation was fleshed
out by Valerie Aurora Henson. Also includes some fixes from Nick Dokos.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
xt2fs/Makefile.in
xt2fs/bitops.h
xt2fs/blkmap64_ba.c
xt2fs/bmap64.h
xt2fs/ext2_err.et.in
xt2fs/ext2fs.h
xt2fs/ext2fsP.h
xt2fs/gen_bitmap.c
xt2fs/gen_bitmap64.c
1d72214658d339bd4725fe74aa42397df419e914 22-Aug-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
88fca201aca752cbb7a981e1fe1b2a875cc29833 22-Aug-2009 Theodore Ts'o <tytso@mit.edu> Move declaration of FS_IOC_FIEMAP ioctl to fiemap.h

This helps e4defrag compile on systems where the system header files
don't yet define FS_IOC_FIEMAP.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fiemap.h
baa8dbeb4e4acef9563d8aac61c01ec7c3a8c8ea 02-Aug-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
misc/Makefile.in
1451c20109608ef4925f103090dee3771aa44570 22-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Use blk_t instead of int in ext2fs_allocate_group_table

We are using a signed int to store a block number in
ext2fs_allocate_group_table. We don't actually do any computation or
comparisons using it, so it shouldn't cause any bugs, but it's
technically incorrect, and it's possible an overly clever compiler
might do something wrong with it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
8b5ed492de2584ce255cc87f054e987bf4e9c5f3 20-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Avoid creating unneeded new extents in ext2fs_extent_set_bmap()

Avoiding inserting a new extent if it is possible to merge the new
block to the beginning or the end of the previous or next extent.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
64cb68b3eab55f532a1b07e3778b75631e85f44a 20-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Improve debugging printf's in extent.c

Comment out less common debugging printf's, and fix some type
warnings. Add high-level debugging printf's for ext2fs_extent_goto(),
ext2fs_extent_insert(), ext2fs_extent_delete(), ext2fs_extent_replace()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
16e470e65010ba3f0516cf9cdf1bd6c98f064e3f 20-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix regression in ext2fs_extent_set_bmap()

Commit 0dc291611 introduced a regression when unmapping the first
block in an extent. This caused e2fsck -fD to corrupt large
directories if the directory has to shrink by more than one block.
The problem was set_bmap should only go to a next leaf when setting a
first block in an extent, and not when it is unmapping the first block
in an extent.

Addresses-Debian-Bug: #537510

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
9922c53a4df10e660a1b425629a1f4db2b4fc03f 18-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: fix memory leak in error path in ext2fs_block_iterate2()

Reported-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
25c7e0c3042cb92a71d25cb3c2709a55b9f120a6 12-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix minor gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dir_iterate.c
xt2fs/extent.c
xt2fs/gen_bitmap.c
cf268fd4849693e13b993bab53c85b6422d0aee4 11-Jul-2009 Theodore Ts'o <tytso@mit.edu> Remove tst_csum.c from lib/ext2fs/Makefile.in's SRCS list

The tst_csum test is now part of csum.c, so there isn't a separate
tst_csum.c file that should be listed as one of the source files in
lib/ext2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
0dc29161125fa4650e4b8832fc0f570435ef0fe3 10-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Make ext2fs_extent_set_bmap() more robust against ENOSPC

In the case where we ext2fs_extent_set_bmap() is replacing the block
mapping at the beginning of an already-existing extent, insert a new
extent if necessary before shrinking an existing extent, to avoid data
loss if the disk is full.

This mostly addresses the problem described in Red Hat Bugzilla's
statistics are still wrong, but at least the files on the filesystem
are not corrupted. If there is a failure during the
inode_scan_and_fix pass, the simplest thing to do may be to tell the
user to run e2fsck -fy.

Addresses-Red-Hat-Bug: #510379

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
ef1a526dfbe663bb80ab75c2e7985ae8d9021b76 09-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Add new function ext2fs_test_inode_bitmap_range()

Optimize ext2fs_test_block_bitmap_range() and add a new function,
ext2fs_test_inode_bitmap_range(), which works the same way as
ext2fs_block_bitmap_range() but for inode bitmaps. It's needed for
some code in the development branch, so let's drop it into the maint
branch to make life easier in the future.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
xt2fs/gen_bitmap.c
4bd87f22906188b6dba36d4b9ba5fc7acd337699 07-Jul-2009 Eric Sandeen <sandeen@redhat.com> libext2fs: reset handle after inserting new extent

Commit 53422e moved the new extent insertion in
ext2fs_extent_set_bmap() prior to the modification of the original
extent, but the insert function left the handle pointing to the new
extent. This left us modifying the -new- extent, instead of the
original one, and winding up with a corrupt extent tree something
like:

BLOCKS:
(0-1):588791-588792, (0):588791

We need to move back to the previous extent prior
to modification, if we inserted a new one.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
c13351f6c53f175696044c0203bb3009af606c64 02-Jul-2009 Theodore Ts'o <tytso@mit.edu> Add support for configure --enable-verbose-makecmds

Some people don't want to see the concise "kernel-style" make output.
This configure option allows build engines that want to see the full
set of commands executed by the makefile to get what they want. Most
people will find this more distracting than useful, unless they need
to debug the Makefiles.

(It is not necessary to rerun configure to enable this verbose make
output temprarily; if a developer wants to do a quick debug of a
directory's makefile, he or she can simply edit the definition of the
$(E) and $(Q) variables in the Makefile; instructions can be found in
the MCONFIG file which is included in at the beginning of every
Makefile.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.checker
akefile.darwin-lib
akefile.elf-lib
akefile.library
akefile.profile
akefile.solaris-lib
lkid/Makefile.in
2p/Makefile.in
t/Makefile.in
xt2fs/Makefile.in
s/Makefile.in
uid/Makefile.in
a6a1c0815c045fd12f65546e16d495338097f32a 02-Jul-2009 Theodore Ts'o <tytso@mit.edu> Fix Makefile dependencies for libcom_err

The e2fsprogs makefiles were using the same Makefile variable
LIBCOM_ERR for the link-line arguments as well as the dependencies.
Since LIBCOM_ERR can now include non-file arguments such as
"-lpthread", we need to use a separate DEPLIBCOM_ERR variable that
only has build file dependencies.

Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR.

Addresses-Sourceforge-Patches: #2813809

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
s/Makefile.in
3381a63c54f2221e3742211df39c5e2ee13d16cc 01-Jul-2009 Theodore Ts'o <tytso@mit.edu> libuuid: Don't run uuidd if it would fail due to permission problems

Some distributions don't like installing uuidd setuid or setgid. So
if the setuid or setigid bit is not set with uuidd, and the current
process does not have write access to the UUIDD work directory, don't
try running uuidd, since it won't work properly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
uid/uuidd.h
caa6003b6419d001593478a46fb4cbf8e502e818 30-Jun-2009 Theodore Ts'o <tytso@mit.edu> libuuid, uuidd: Avoid infinite loop while reading from the socket fd

If for some reason the uuidd daemon or the process calling uuidd
exited unexpectely, the read_all() function would end up looping
forever, either in uuidd or in libuuid. Fix this terminating the loop
if no data can be read after five tries to read from the file
descriptor.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
e8b9466fc9d4aec66476f1bc7a48436da02ab557 30-Jun-2009 Theodore Ts'o <tytso@mit.edu> libuuid: Make sure fd's 0, 1, and 2 are valid before exec'ing uuidd

When closing all of the file descriptors before starting uuidd, make
sure file descriptors 0, 1, and 2 are reserved by opening /dev/null.
This prevents strange bugs caused by assumptions regarding file
descriptors <= 2 as being special.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
6a8da46d284721e95f893d4f229a2bec473797e1 29-Jun-2009 Nic Case <number9652@yahoo.com> libext2fs: ensure validate_entry doesn't read beyond blocksize

ext2fs_validate_entry would read beyond the end of the block to get
dirent->rec_len for certain arguments (like if blocksize ==
final_offset). This patch adds a check so that doesn't happen, and
changes the types of the arguments to avoid a compiler warning.

Signed-off-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dir_iterate.c
8a480350952f6f0fdbce54326b6d847e66368897 22-Jun-2009 Theodore Ts'o <tytso@mit.edu> Fix encoding for rec_len in directories for >= 64k blocksize file systems

Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could
occur if the directory block is completely empty in 64k blocksize
filesystems), while the kernel interpreted 65535 to mean 65536. The
kernel will accept both to mean 65536, and encodes 65535 to be 65536.
This commit changes e2fsprogs to match.

We add the encoding agreed upon for 128k and 256k filesystems, but we
don't enable support for these larger block sizes, since they haven't
been fully tested.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/ext2fs.h
xt2fs/link.c
xt2fs/newdir.c
827c1887118eb68a64f8455d0b7cbbbed65e714a 17-Jun-2009 Eric Sandeen <sandeen@redhat.com> libext2fs: initialize large inodes for journal & resize

I noticed that neither the journal nor resize inodes have
i_extra_isize set post-mkfs; while this isn't likely
to be a big problem, I think the below patch tidies
it up.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/mkjournal.c
xt2fs/res_gdt.c
125a36780626cdb0fc4d62fd529486baa8bce54c 18-Jun-2009 Eric Sandeen <sandeen@redhat.com> libext2fs: write only core inode in update_path()

The ext2_extent_handle only has a struct ext2_inode allocated on
it, and the same amount copied into it in that same function,
but in update_path() we're possibly writing out more than that -
for example 256 bytes, from that address. This causes uninitialized
memory to get written to disk, overwriting the parts of the
inode past the osd2 member (the end of the smaller structure).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
7b59b4a8ee4a65ef14eb364cde574d34ec8c014f 15-Jun-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix memory leak in the extents handling function

Each time an extent handle is opened and closed, if the inode has an
extent tree which does not fit in the inode's i_block structure, a
filesystem block buffer was not getting released. Since e2fsck opens
an extent handle for every inode using extents, this can translate to
a very large amount of memory getting lost.

Thanks to Henrik 'Mauritz' Johnson for discovering and pointing out
this leak, which he ran into while running the "rdump" command in
debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
272631e4baa9f3a87813690d2e79161c8dc4b387 01-Jun-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Add ext2fs_block_iterate3()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
xt2fs/ext2fs.h
8717c3a8f31dea3b31ddaeccf74ea3b34ca72c04 01-Jun-2009 Valerie Aurora Henson <vaurora@redhat.com> libext2fs: Add 64-bit bitops

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.c
xt2fs/bitops.h
xt2fs/tst_bitops.c
b4e0163d53613ae47f79c661f7c1e2009a271c79 22-Jul-2009 Valerie Aurora Henson <vaurora@redhat.com> libe2p: Add new function parse_num_blocks2()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/e2p.h
2p/parse_num.c
0180a05e7449ba3ba6b15f7a5c372f712331cb89 01-Jun-2009 Theodore Ts'o <tytso@mit.edu> e2p: Print 64-bit block numbers in the superblock

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
5635e75c918866849746cf50d1a9a301c241fed4 21-Jul-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
6a0ee32dcb0984b50c3afb9234706e69b3e6b9d3 12-Jul-2009 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
73d0c4cce5cc6de9525e8a3c9ee690f066d8c0ba 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add 64-bit mkjournal.c interface

Added 64-bit mkjournal.c interface. Needed to zero inode tables.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/mkjournal.c
743011fbac672c488e54b843bf8a759bef10862e 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add ext2fs_div64_ceil()

Add a new div_cell routine able to handle 64bit values

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
4f8d6ab222beea3557e26aba9eefedb81db956ab 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add 64-bit openfs interface

Add new ext2fs_descriptor_block_loc2() routine that takes blk64_t as
an input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/openfs.c
20f2ccb3262b11d3a7b892cb9a11ea1c8c2ddd3b 12-Jul-2009 Jose R. Santos <jrs@us.ibm.com> Use new ext2fs_super_and_bgd_loc2 call in libext2fs

The new ext2fs_super_and_bgd_loc2() function has some changes aside
from just blk64_t support. Lets make sure that the interfaces are
sane by adding libext2fs support early to get the new API tested here.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/closefs.c
71300f35de9b7fd0ab4252500ec5a4da1d9a1424 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add 64-bit closefs interface

Add new ext2fs_super_and_bgd_loc2() that returns blk64_t pointers.
The function now returns the number of blocks used by super block and
group descriptors since with flex_bg, it can no longer be assumed that
bitmaps and inode tables still resided within the block group.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/ext2fs.h
b91f14b870d5b4a4d71b62d81b078f2eb40878ae 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add 64-bit ext_attr interface

Add ext2fs_read_ext_attr2(), ext2fs_write_ext_attr2() and
ext2fs_adjust_ea_refcount2() that take blk64_t as an input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/ext_attr.c
8a5e1812ae21d3d847a4df1067a105f284eb187c 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add 64-bit alloc interface

Add new ext2fs_new_block2(), ext2fs_get_free_blocks2() and
ext2fs_alloc_block2() that take and return blk64_t.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/ext2fs.h
e8328e31a98a92b39611314612a40b6113921fe2 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add 64-bit alloc_stats interface

Add new ext2fs_block_alloc_stats2() routine that takes blk64_t as an
input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_stats.c
xt2fs/ext2fs.h
57e2467d6211b2ff0dbcc23f705afd3b95fb917f 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add 64-bit dirblock interface

Add new ext2fs_(read|write)_dir_block3() routines that take blk64_t as
an input.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dirblock.c
xt2fs/ext2fs.h
319158f9bd1d49ae0f697cfa9910d67ba5be8627 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Use blk64_t for blocks in struct ext2_file

The ext2_file structure is never exposed through the libext2fs API so
it is safe to use 64-bit blocks for blockno and physclock without
breaking the ABI.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fileio.c
e3854b3b7c7c499a663d752f9196a0d74eb5ec98 06-Jun-2009 Jose R. Santos <jrs@us.ibm.com> Add new blk64_t handling functions

Add new blknum.c file which contains funtions to handle blk64_t and
low/high values in super blocks and inodes.

(Includes fixes from Nick Dokos, and additions from Valerie Aurora Henson)

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/blknum.c
xt2fs/ext2fs.h
f6b4c27562837e5964726c1b6b86497c989dd03d 01-Jun-2009 Jose R. Santos <jrs@us.ibm.com> libext2fs: Add ext2_off64_t type

The ext2_off_t type is u32. Create a new 64-bit ext2_off64_t for
64bit offsets.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
1adc384bc559da2a2fd3d65e563a89bb7d296094 12-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Add 64-bit support to the undo manager

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/undo_io.c
3c4d4d7459f46adbd10b97b37fe0def2313d1d21 06-Jun-2009 Valerie Aurora Henson <vaurora@redhat.com> libext2fs: Define bg_itable_unused_hi in the ext4_group_desc structure

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
337079375e418c48516e75879d4341bead185619 30-May-2009 Theodore Ts'o <tytso@mit.edu> Update lib/xt2fs/Makefile.in using "make depend"
xt2fs/Makefile.in
470e737a872918afd9067de1ce92d571d5671d40 29-May-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Move test code for csum.c inline instead of in a separate file

Move the test code which is used to build the tst_csum progam from
tst_csum into csum.c under an #ifdef DEBUG to simplify things and to
avoid compile problems caused by not having a prototype for
ext2fs_group_desc_csum().

Addresses-Sourceforge-Bug: #2484331

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/csum.c
xt2fs/tst_csum.c
86522281f8be6e5fca0b3ed552786db4979a45a4 29-May-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Add an explicit error code for missing mtab file

To reduce user confusion, if the /etc/mtab file is missing
ext2fs_check_mount_point and ext2fs_check_if_mounted will return a
new, explicit error code to indicate this case.

Addresses-Debian-Bug: #527859

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_err.et.in
xt2fs/ismounted.c
84b239aea4da04c7a569b428d3abf6c720e82645 19-May-2009 number9652 <number9652@yahoo.com> libext2fs: add ext2fs_extent_open2

The patch below adds a function, ext2fs_extent_open2(), that behaves
as ext2fs_extent_open(), but will use the user-supplied inode
structure when opening an extent instead of reading the inode from
disk. It also changes several of the calls to extent_open() to use
this enhancement.

Signed-off-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
xt2fs/bmap.c
xt2fs/ext2fs.h
xt2fs/extent.c
312c2a404c1af85b88b855687b6a30cd24ca9e34 28-May-2009 Eric Sandeen <sandeen@redhat.com> chattr: manpage tidyups

Tidy up the chattr(1) manpage to completely document all
available options, and differentiate those which are read-only
early in the manpage as well.

* Remove "I" from settable attribute list
* add "e" to 2nd list of settable attributes & descriptions
* Note that h/E/I/X/Z are readonly
* Correct "H" to "h" for huge file attribute description
* fix long_name for indexed directory in flags_array

Addresses-Red-Hat-Bugzilla: BZ#502971

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/pf.c
53422e8a5644e22ea3f6e0efba82a765b72e4308 20-May-2009 Eric Sandeen <sandeen@redhat.com> resize2fs: fix ENOSPC corruption case

http://people.redhat.com/esandeen/livecd-creator-imagefile.bz2
contains an image (for now) which, when resized to 578639, corrupts
the filesystem.

This is a bit crazy, I guess, because the fs currently has only
1 free block, but still, we should be graceful about the failure.
Perhaps it would make sense to check the requested valuea against
the minimum value resize2fs would compute for "-P" and fail (at
least without a force).

But in any case, this exposed 2 bugs when moving that one block
required an extent split, which is what hit the ENOSPC.

For starters, ext2fs_extent_set_bmap() in the "(re/un)mapping last
block in extent" case was replacing the old extent before the
new one was created; when the new extent creation failed, it
left us in an inconsistent state. Simply changing the order of
the two should fix this problem.

Next, ext2fs_extent_insert was calling ext2fs_extent_delete()
on *any* error, including one caused by failure to allocate a new
block to split the node to hold that extent ... the handle was left
unchanged, and we deleted the -original- extent.

As a quick fix for this, just don't do the delete if we fail the split,
though this may need to be smarter. I don't think we have terribly
consistent behavior about where a handle is left on various errors.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
5dd3311eeb2c49a2812610603accbfcfee762bb1 18-May-2009 Theodore Ts'o <tytso@mit.edu> blkid: Don't use a hard-coded path for /bin/rm in test_probe.in

Addresses-Sourceforge-Bug: #2780205

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/test_probe.in
5fdb89e30e96db74ab035524dded4a809aef441c 04-May-2009 Theodore Ts'o <tytso@mit.edu> Add missing file: lib/ext2fs/fiemap.h

This file is needed so the updated filefrag program will compile. I
missed a "git add"; oops.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/fiemap.h
46f3eeca59a1fc8233790bbed604e4634e0f3fbe 27-Apr-2009 Karel Zak <kzak@redhat.com> blkid: use /sys/block/dm-<N>/dm/name

The Linux kernel (since 2.6.29, patch 784aae735d9b0bba3f8b9faef4c8b30df3bf0128)
exports the real DM device names in /sys/block/<ptname>/dm/name.

The sysfs based solution is nicer and faster than scan for devno in
/dev/mapper/.

CC: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/devname.c
4271e23942bdc60e1fa6c0b26bc666a94a8b3e1d 27-Apr-2009 Karel Zak <kzak@redhat.com> blkid: use /dev/mapper/<name> rather than /dev/dm-<N>

The libblkid (since v1.41.1) returns private device-mapper names (e.g.
/dev/dm-0). It's because the probe_one() function scans /dev before
/dev/mapper.

brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/dm-0
brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/mapper/TestVolGroup-TestLogVolume

Old version:
# blkid -t LABEL="TEST-LABEL" -o device
/dev/dm-0

Fixed version:
# blkid -t LABEL="TEST-LABEL" -o device
/dev/mapper/TestVolGroup-TestLogVolume

Addresses-Red-Hat-Bug: #497259
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/devname.c
6d67ee305cdfff7131a4105551409d1603dba81d 03-May-2009 Theodore Ts'o <tytso@mit.edu> Avoid unneeded updates of block group descriptors in ext2fs_closefs()

If the superblock is clean, and we only need to update
s_kbytes_written, then we only need to update the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
41aeae11a657eb64c47f733850fc78350cd48cde 24-Apr-2009 Theodore Ts'o <tytso@mit.edu> Update lib/ext2fs/Makefile.in using "make depend"

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
8203fe506a06524587c18940b6cd19a0592a4bd2 23-Apr-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: read the block group descriptors more efficiently

When opening a filesystem, make ext2fs_open2() much more efficient by
reading the normal block group descriptors all at once, instead of one
block at a time.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
4e60e06847c781efffc8c43342b7756bbe5cff45 23-Apr-2009 Eric Sandeen <sandeen@redhat.com> blkid: remove whole-disk entries from cache when partitions are found

We can get into a situation in blkid where whole disks remain
in the cache, even though partitions are found. For labels
such as sun disklabels which may have the first partition
beginning at sector 0, this is even somewhat likely.

1) create a sun disklabel w/partitions
2) mkfs the first partition (at sector 0)
3) remove the partition table
4) run blkid - this finds the fs on the whole disk, places in cache
5) recreate the partition table
6) run blkid - this finds the partition, places in cache

And now we have both /dev/sda and /dev/sda1 in cache.

There are heuristics in probe_all to avoid putting the whole disk
in cache if it has partitions, but there is nothing to remove the
whole-disk entry in the above case. I think the below patch
suffices, although I haven't quite convinced myself that setting
the lens[which]=0; is the right logic for that bit of state...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
f9110f4480eade2d849c4cc08efa49bf0f7f5148 23-Apr-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Skip relative pathnames in /etc/mtab in ismounted.c

The functions which test to see if a device is mounted can get
confused by entries in /etc/mtab for virtual filesystems:

rootfs / rootfs rw 0 0
none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0

If the device name doesn't start with a slash, ignore the /etc/mtab
entry, so that relative pathnames passed into functions such as
ext2fs_check_mount_point() or ext2fs_check_if_mounted() don't return
false positives.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ismounted.c
46d6f84ebe3cfdd703f40a56f9904c04d10cc138 22-Apr-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix format string type warnings in alloc_stats.c

Fix gcc warnings caused by wrong types passed com_err() in
ext2fs_inode_alloc_stats2 and in ext2fs_block_alloc_stats().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_stats.c
935a123f3b9156e18d1397a05e5b5f1a5e021f22 22-Apr-2009 Theodore Ts'o <tytso@mit.edu> libss: Fix warn_unused_result warnings from gcc

Fixed a potential bug where by partial returns from the write system
call could the fallback pager to drop characters.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/pager.c
9ea68828f31d5be1f6622321464533b35dd6d762 22-Apr-2009 Theodore Ts'o <tytso@mit.edu> libss: ss_execute_line: reflect any error codes from system() to the caller

This is primarily to silence a gcc warning, but it's better to reflect
the error from system() up to the caller. In this case we don't
actually use it for anything, but that's OK.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/execute_cmd.c
d3395ae71a38ff562e0af3a174ecbc5b523057d6 22-Apr-2009 Theodore Ts'o <tytso@mit.edu> libcom_err: Declare prototypes for et_list_lock/unlock in com_err.h

Define the prototypes for et_list_lock() and et_list_unlock() in
com_err.h. This promotes better error checking and avoids warnings
when compiling the library and programs that call these functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/com_err.h
022c925c5a2e92269f5795ba85719f75874e8424 22-Apr-2009 Theodore Ts'o <tytso@mit.edu> libe2p: Declare prototypes for the journal feature name functions in e2p.h

Define the prototypes for e2p_jrnl_feature2string() and
e2p_jrnl_string2feature() in e2p.h. This promotes better error
checking and avoids warnings when compiling the library and programs
that call these functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/e2p.h
1207e36d0a8674d6c627bb9b2759faf1e290e13e 15-Apr-2009 Theodore Ts'o <tytso@mit.edu> libuuid: Close all file descriptors before running uuidd

This avoids problems when the calling program has open file
descriptors (especially sockets) open.

Also fix up some warn_unused_result warnings from gcc.

Addresses-Launchpad-bug: #305057

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
341b52dfa8c2afc11d8410de9bd381b03e75c6af 17-Mar-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: external journal devices should not cause ext2fs_open2 to fail

This fixes a regression introduced in commit 79a9ab14 which caused
attempts to open external journals to fail due to overly strict
filesystem consistency checks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
671326f6251d88d27fe7f299f7ede4a452dfca61 23-Feb-2009 Jim Meyering <jim@meyering.net> libss: Avoid leak upon failed realloc in ss_add_request_table()

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
s/request_tbl.c
4e711be8d04cb6da9e3e3628f82ee66bfbda23f2 23-Feb-2009 Jim Meyering <jim@meyering.net> libext2fs: don't leak strdup'd dev name in dosio.c upon error

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/dosio.c
45e338f5332a54295893dba2e32cc093d1316f60 23-Feb-2009 Jim Meyering <jim@meyering.net> remove useless if-before-free tests

In case you're wondering about whether this change is safe from a
portability standpoint, fear not. This has been beaten to death
in other forums. Here are a few threads:

http://thread.gmane.org/gmane.comp.version-control.git/74187
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712
http://thread.gmane.org/gmane.emacs.devel/98144
http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092

There has been debate about whether it's a good idea from a
performance standpoint, too, but imho you'll have a hard time
finding an instance where this sort of change induces a
measurable performance penalty. If you do, please let me know.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/cache.c
lkid/dev.c
lkid/devno.c
lkid/probe.c
lkid/resolve.c
lkid/save.c
lkid/tag.c
xt2fs/dosio.c
xt2fs/extent.c
xt2fs/initialize.c
xt2fs/nt_io.c
s/execute_cmd.c
1361821e7e248166f0740c832b164e6cd6b89de9 08-Mar-2009 Theodore Ts'o <tytso@mit.edu> blkid: Add fallback to ext4 for 2.6.29+ kernels if ext2 is not present

Starting in 2.6.29, ext4 can be used to support filesystems without a
journal. So if ext2 is not present, and the kernel version is greater
than 2.6.29, and ext4 is present, return a filesystme type of ext4.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
a90f5391dda78f7bc4a8196a78355584ace0adf5 25-Feb-2009 Eric Sandeen <sandeen@redhat.com> blkid: recognize ext4(dev) without journal

ext4/ext4dev no longer require a journal.

w/o this blkid doesn't recognize after:

# mkfs.ext4 /dev/blah
# tune2fs -O ^has_journal
# blkid /dev/blah

We still must have one ext3-incompat-feature to flag
as ext4(dev) so we shouldn't ever mis-recognize it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
f2fe5da31deebc689bb64e71c8e873efc925d312 24-Feb-2009 Eric Sandeen <sandeen@redhat.com> e2fsprogs: fix potential null ptr defef in check_for_modules()

The coverity scanner found this one.

If a line in modules.dep has a ":" but no "/" then:

if ((cp = strchr(buf, ':')) != NULL)
*cp = 0;
else
continue;
if ((cp = strrchr(buf, '/')) != NULL)
cp++;
/* XXX else cp is still null */
i = strlen(cp);

... we will deref a null pointer (cp). This can be
demonstrated by putting a line like:

foo.ko:

into modules.dep. The below change just says that if no "/" is
found, treat the whole string as the module name.

Addresses-Red-Hat-Bugzilla: #486997

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
b7c5b4030870b31d73019d9d9ec55d550772590b 06-Mar-2009 Theodore Ts'o <tytso@mit.edu> Add support for a new superblock field: s_kbytes_written

This field tracks the lifetime amount of writes to the filesystem. It
will be updated by the kernel as well as by e2fsprogs programs which
write to the filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
xt2fs/closefs.c
xt2fs/ext2_fs.h
xt2fs/swapfs.c
cf4e06d665e53ec7a5af67c9104e7278777a8488 22-Jan-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Add sanity checks to ext2fs_{block,inode}_alloc_stats

If ext2fs_inode_alloc_stats2() or ext2fs_block_alloc_stats() is passed
an insanely large inode or block number, it's possible for these
functions to overrun an array boundary and cause the calling program
to crash with a memory error.

Detect this case, and since these functions don't return an error
code, print a warning message, much like we do in ext2fs_warn_bitmap2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_stats.c
a93d40696073076b26bc11052f7cc99588d74dae 22-Jan-2009 Theodore Ts'o <tytso@mit.edu> ext2fs_new_inode(): Add sanity check to assure a valid inode number

Add a sanity check to makesure that even if the superblock field
s_first_inode is insane, that we won't return an invalid inode number.
(The function will return the error EXT2_ET_INODE_ALLOC_FAIL in that
case.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
9f7a1fc936497d5ab1ebe88baa704e91880849cc 20-Jan-2009 Theodore Ts'o <tytso@mit.edu> ext2fs_get_device_size: Fix error handling

The previous patch would return EFBIG for any failure called from
ext2fs_get_device_size2(). (I didn't merge this fix with the
preceeding commit to allow merges to happen more easily.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/getsize.c
beab8de477110970785077fb3204f171d3fcc485 20-Aug-2008 Jose R. Santos <jrs@us.ibm.com> Add 64-bit getsize interface.

Added interface capable of opening 64-bit block device.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/getsize.c
5299580c1ced39e7a6d7ac2717a3d6a3cab299b0 20-Jan-2009 Theodore Ts'o <tytso@mit.edu> Use format strings directly to prevent -Werror=format-security failures

Gcc is too stupid to realize that:

const char *usage="String which has no percent signs";

com_err(progname, 0, usage);

is OK. I refuse to bow to stupidity with:

com_err(progname, 0, "%s", usage);

but I will use the string directly for the sake of people who like to
build with -Werror=format-security.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/test_ss.c
31e2a75484816db0e5e68afacb13beef7e751061 20-Jan-2009 Theodore Ts'o <tytso@mit.edu> blkid: Add support for detecting user-level suspend as a swsuspend signature

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
801b0053336cc5fe5b3447ddad58505352a6578e 08-Jan-2009 Eric Sandeen <sandeen@redhat.com> blkid: recognize btrfs

Add btrfs detection to libblkid, now that the disk format should be
recognizable in the future.

# misc/blkid /tmp/fsfile
/tmp/fsfile: LABEL="mylabel" UUID="102b07f0-0e79-4b42-8a4e-1dde418bbe6d" TYPE="btrfs"

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
lkid/probe.h
79a9ab145467b95b96a885e6ac0b2cdd22cde516 20-Jan-2009 Thiemo Nagel <thiemo.nagel@ph.tum.de> ext2fs_open2: Add more checks for filesystem consistency

Add more checks to assure the filesystem is sane to avoid later
division by zero errors.

Patch adds consistency checks on superblock to fix serveral crashes:
* require EXT2_INODES_PER_GROUP != 0
* require EXT2_DESC_PER_BLOCK != 0
* require s_first_data_block < s_blocks_count
* require group_desc_count * EXT2_INODES_PER_GROUP == s_inodes_count

Signed-off-by: Thiemo Nagel <thiemo.nagel@ph.tum.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
a7843581f5c862db79286c7e73f5ca76d59dccea 20-Jan-2009 Theodore Ts'o <tytso@mit.edu> ext2fs_read_inode_full: Add safety check to avoid SEGV's on corrupted fs's

Thanks to Thiemo Nagel for suggesting this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
07f1a070ff45c8381c3ddf8552c726525104e1ee 20-Jan-2009 Theodore Ts'o <tytso@mit.edu> ext2fs_block_iterate2: Preserve the uninit flag in extents

When modifying a block via the block_iterate interface, preserve the
uninit flag in the extent. Resize2fs uses this interface, so we have
to preserve the uninit status when relocating a block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
d3a8fc5ae68477118e32813230518bf4ccc73bf9 19-Jan-2009 Theodore Ts'o <tytso@mit.edu> ext2fs_block_iterate2: Reflect errors from ext2fs_extent_set_bmap to caller

If the callback function tries to change a block, and
ext2fs_extent_set_bmap() fails for some reason (for example, there
isn't enough disk space to split a node and expand the extent tree,
make sure that error is reflected back up to the caller.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
7518c176867099eb529502103106501861a71280 26-Dec-2008 Theodore Ts'o <tytso@mit.edu> e2fsck: Fix an unhandled corruption case in scan_extent_node()

A corrupted interior node in an extent tree would cause e2fsck to
crash with the error message:

Error1: Corrupt extent header on inode 107192
Aborted (core dumped)

Handle this and related failures when scanning an inode's extent tree
more robustly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
03fa6f8ae28a87018325c892f731097cc97d9eac 16-Nov-2008 Theodore Ts'o <tytso@mit.edu> Fix various signed/unsigned gcc warnings

Some of these could affect filesystems between 2^31 and 2^32-1 blocks.

Thanks to Valerie Aurora Henson for pointing out the problems in
lib/ext2fs/alloc_tables.c, which led me to do a "make gcc-wall" scan
over the source tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_tables.c
xt2fs/inode.c
9e7da0bdc1f426f553b72721c769a8ffe3c536da 14-Oct-2008 Eric Sandeen <sandeen@redhat.com> blkid: recognize ext3 with test_fs set as ext3

It seems that if we have the test_filesystem flag set on an ext3
filesystem(!) on a system which provides ext4, blkid gets confused.

According to the current logic:

* It's not an ext4dev filesystem, because the system provides ext4.
* It's not an ext4 filesystem, because it has no ext4 features.
* It's not an ext3 filesystem, because the test flag is set.

In the end, it's nothing.

blkid should return *something* that is mountable... I'm inclined to
think that ext3 should be the right answer, if no ext4-specific features
are set.

This would mean just dropping the EXT2_FLAGS_TEST_FILESYS test in
probe_ext3(), because ext4 & ext4dev probes have come first already.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
fe144e11e961a8fb2c568f486bd5bcd49582e24f 18-Oct-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Refuse to create a device structure for a non-existent device

Fix blkid_get_dev() so it will never return a device structure if the
device file doesn't exist.

Addresses-Debian-Bug: #502541

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
6964a17720ca88acd2075b57dde9c381f093e492 11-Oct-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Fix file descriptor leak when checking for a module

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
7ed7a4b6ed8b2fce891874a0eafdc8f77c3ffc34 11-Oct-2008 Eric Sandeen <sandeen@redhat.com> unix_io: check for read-only devices when opening R/W

When we open a device on linux, test whether it is writable
right away, rather than trying to proceed and clean up when
writes start failing.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/unix_io.c
18f734301012301efbeb87a7c67f6cf82f1721d7 08-Oct-2008 Eric Sandeen <sandeen@redhat.com> e2fsprogs: fix blkid detection of ext4dev as ext4

If only ext4 is available (as a module or in /proc/filesystems)
blkid wasn't properly testing for it, because the time checks
were backwards and always failed. This caused old ext4dev
filesystems to fail to mount as ext4. With this patch it works
fine.

Also, don't try to check for modules on a non-Linux system.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
d58d8320e881a751cc40e3f2ab00c6e16c8447db 02-Oct-2008 Theodore Ts'o <tytso@mit.edu> Update Makefile depend information for crc16.o

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
98e9fb9d539ca645f11345b33854fe204915c080 02-Oct-2008 Theodore Ts'o <tytso@mit.edu> libcom_err: Add missing type declarations to clean up -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/error_message.c
902be4ab7d57242feffc6b631cff1b953a7f95c9 02-Oct-2008 Theodore Ts'o <tytso@mit.edu> libcom_err: Fix file descriptor leak after an exec

Some applications repeatedly re-exec themselves, and if they use the
com_err library, they can leak a file descriptor for each re-exec.
Fix this by setting the close-on-exec flag on the debug file
descriptor. In addition, if the COMERR_DEBUG environment variable
isn't set, don't open the file handle at all.

Addresses-Red-Hat-Bugzilla: #464689

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/error_message.c
d7f45af802330a0e1450afa05185d3722e77a76c 12-Sep-2008 Theodore Ts'o <tytso@mit.edu> libcom_err: Use sem_post/sem_init to prevent race conditions

SuSE has been carrying a patch for a long time to prevent a largely
theoretical race condition if a multi-threaded application adds and
removes error tables in multiple threads. Unfortunately SuSE's
approach breaks compatibility by forcing applications to link and
compile with the -pthread option; using pthread mutexes has
historically been problematic.

This commit fixes things in a more portable way by using
sem_post/sem_wait instead, which is an older interface that doesn't
require the pthreads library. Linux happens to implement
sem_post/sem_init using futexes, and -lrt ends up pulling in
-lpthread, but the advantage of using POSIX semaphores is that
applications don't have to be built using -pthread, unlike the use of
pthread mutexes.

The add_error_table() and remove_error_table() interfaces are the
preferred interfaces and locking protection have been added to only
these interfaces. I have not added locking protection to the
generated initialize_xxx_error_table and initialize_xxx_error_table_r
interfaces, to avoid adding symbol dependencies that would cause a
library to fail to work when linking against older com_err libraries
that do not export et_list_lock() and et_list_unlock(). Threaded
applications shouldn't be using these interfaces in any case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/Makefile.in
t/com_err.pc.in
t/error_message.c
0eeec8ac61bf1eaa31533b2be825cd75580829c9 12-Sep-2008 Theodore Ts'o <tytso@mit.edu> Fix compiling under diet libc

Some recent changes had caused diet libc support to bitrot. Fix up
missing header files and other portability fixups needed for dietlibc.
(Many of these changes also improve general portability.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/crc16.c
xt2fs/crc16.h
xt2fs/csum.c
xt2fs/tst_csum.c
a846a6e0a7d237f206a7e5445ce3a2392d0f434a 07-Sep-2008 Theodore Ts'o <tytso@mit.edu> Install with relative symlinks if $(root_libdir) == $(libdir)

When installing the ELF link library, avoid using absolute pathnames
if $(root_libdir) and $(libdir) are the same.

Addresses-Sourceforge-Bug: #1782913

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.elf-lib
97be89b60bd57272ece637bc2f300a5288b78831 03-Sep-2008 Theodore Ts'o <tytso@mit.edu> Fix pkg-config files: use Requires.private and fix the include directory

Addresses-Sourceforge-Bug: #2089537

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/blkid.pc.in
2p/e2p.pc.in
t/com_err.pc.in
xt2fs/ext2fs.pc.in
s/ss.pc.in
uid/uuid.pc.in
e01f9be336274e527cdb794cca2b0c1501e8b0d7 02-Sep-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Compile ext2fs_swab64() for all platforms

Although nothing uses ext2fs_swab64() yet, debian's dpkg-gensymbols
picked up the fact that ext2fs_swab64() isn't getting defined on
non-x86 platforms. Oops. This patch moves the definition of
ext2fs_swab64() to a place where it will be compiled for all
architectures.

Addresses-Debian-Bug: #497515

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
5c0255e8ad02f4046c77a860506b6907c533ef7b 02-Sep-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Remove unused ext2fs_find_{first,ext}_bit_set()

These functions were commented out for x86, but they were still being
defined for other architectures. We now remove them entirely.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
af773654b2faf1d001fa2fa6b929a67ce7c7ca00 01-Sep-2008 Theodore Ts'o <tytso@mit.edu> Enable test_io debugging by default

Test I/O debugging is incredibly useful for rooting out problems, so
let's enable by default, especially now that its overhead is only
incurred when it is needed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
7fd2651f67a43fad3cc1cc2db7c0e5f9c568023c 01-Sep-2008 Theodore Ts'o <tytso@mit.edu> libe2p: Fix potential core-dumping bug in iterate_on_dir()

iterate_on_dir() can try to copy too much data from the directory
entry, resulting in a crash.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/iod.c
94b993d56a7fbd32626f86d654640f4a80998d34 30-Aug-2008 Theodore Ts'o <tytso@mit.edu> Update makefile dependency for lib/e2p/Makefile.in

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/Makefile.in
b55d73985cc7a33e2b57161e5ea1a5a2ad1bff9c 28-Aug-2008 Theodore Ts'o <tytso@mit.edu> Further optimize journal placement for flex_bg filesystems

If the number of block groups is greater than half the flex_bg size,
the journal we be placed in the flex_bg super-group which is closest
to the mid-point of the filesystem, and in the first free block group
beyond where the metadata for the flex_bg is stored.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkjournal.c
efc6f628e15de95bcd13e4f0ee223cb42115d520 28-Aug-2008 Theodore Ts'o <tytso@mit.edu> Remove trailing whitespace for the entire source tree

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/blkid.h
lkid/cache.c
lkid/dev.c
lkid/devname.c
lkid/devno.c
lkid/getsize.c
lkid/probe.c
lkid/probe.h
lkid/read.c
lkid/resolve.c
lkid/save.c
lkid/tag.c
lkid/tst_types.c
2p/e2p.h
2p/feature.c
2p/fsetflags.c
2p/getflags.c
2p/getversion.c
2p/hashstr.c
2p/iod.c
2p/ls.c
2p/mntopts.c
2p/ostype.c
2p/parse_num.c
2p/percent.c
2p/pf.c
2p/setflags.c
2p/uuid.c
t/com_err.c
t/com_err.h
t/com_right.c
xt2fs/alloc.c
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/badblocks.c
xt2fs/bb_compat.c
xt2fs/bb_inode.c
xt2fs/bitmaps.c
xt2fs/bitops.c
xt2fs/bitops.h
xt2fs/block.c
xt2fs/bmap.c
xt2fs/bmove.c
xt2fs/brel.h
xt2fs/brel_ma.c
xt2fs/check_desc.c
xt2fs/closefs.c
xt2fs/csum.c
xt2fs/dblist.c
xt2fs/dblist_dir.c
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/dirhash.c
xt2fs/dosio.c
xt2fs/dupfs.c
xt2fs/e2image.h
xt2fs/expanddir.c
xt2fs/ext2_fs.h
xt2fs/ext2_io.h
xt2fs/ext2fs.h
xt2fs/ext2fsP.h
xt2fs/ext_attr.c
xt2fs/extent.c
xt2fs/fileio.c
xt2fs/finddev.c
xt2fs/flushb.c
xt2fs/freefs.c
xt2fs/gen_bitmap.c
xt2fs/get_pathname.c
xt2fs/getsectsize.c
xt2fs/getsize.c
xt2fs/imager.c
xt2fs/ind_block.c
xt2fs/initialize.c
xt2fs/inline.c
xt2fs/inode.c
xt2fs/inode_io.c
xt2fs/io_manager.c
xt2fs/irel.h
xt2fs/irel_ma.c
xt2fs/ismounted.c
xt2fs/jfs_dat.h
xt2fs/kernel-jbd.h
xt2fs/kernel-list.h
xt2fs/link.c
xt2fs/llseek.c
xt2fs/lookup.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/namei.c
xt2fs/native.c
xt2fs/newdir.c
xt2fs/openfs.c
xt2fs/read_bb.c
xt2fs/read_bb_file.c
xt2fs/res_gdt.c
xt2fs/rw_bitmaps.c
xt2fs/swapfs.c
xt2fs/tdb.c
xt2fs/tdb.h
xt2fs/tdbtool.c
xt2fs/test_io.c
xt2fs/tst_badblocks.c
xt2fs/tst_bitops.c
xt2fs/tst_byteswap.c
xt2fs/tst_getsectsize.c
xt2fs/tst_getsize.c
xt2fs/tst_iscan.c
xt2fs/tst_super_size.c
xt2fs/tst_types.c
xt2fs/unix_io.c
xt2fs/unlink.c
xt2fs/valid_blk.c
popen.c
s/error.c
s/get_readline.c
s/listen.c
s/pager.c
s/requests.c
s/test_ss.c
uid/clear.c
uid/compare.c
uid/copy.c
uid/gen_uuid.c
uid/isnull.c
uid/pack.c
uid/parse.c
uid/tst_uuid.c
uid/unpack.c
uid/unparse.c
uid/uuid.h
uid/uuidP.h
uid/uuid_time.c
4690e621acd4579dae60b6f55f58284ee805e86d 28-Aug-2008 Theodore Ts'o <tytso@mit.edu> Improve future compatibility for the 64-bit I/O channel functions

Provide a C language wrapper function for io_channel_read_blk64() and
io_channel_write_blk64() instead of using a C preprocessor macro, with
an fallback to the old 32-bit functions if an application-provided I/O
channel manager doesn't supply 64-bit method functions and the block
numbers can fit in 32-bit integer.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_err.et.in
xt2fs/ext2_io.h
xt2fs/io_manager.c
9033faf5257be85aab4baffa53e0bef96ab9c0f5 28-Aug-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix ext2fs_bmap() to work with extents and BMAP_ALLOC

Fix bugs with extents support when allocating blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
xt2fs/extent.c
64987c052c235d60373995d36b5c01291c464b74 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_block_iterate2: Fix memory leak on error paths

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
961306d31ad36a9eef4e515343c9e355afc6e19c 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> If the filesystem supports extents create an extent-based journal inode

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkjournal.c
685d544effc774de1580fec047629cd814bad660 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_block_iterate2: Add BLOCK_FLAG_APPEND support for extent-based files

This is needed so that extent-based inodes (including a journal inode)
can be created via block_iterate.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
1af01e94cc020ab989cc97cec1b755bf2a476508 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> Create the journal in the middle of the filesystem

This speeds up access to the journal by eliminating worst-case seeks
from one end of the disk to another, which can be quite common in very
fsync-intensive workloads if the file is located near the end of the
disk, and the journal is located the beginning of the disk.

In addition, this can help eliminate journal fragmentation when
flex_bg is enabled, since the first block group has a large amount of
metadata.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkjournal.c
674c0cc4cb137c6362cb1ae71b6db5cbccbad83a 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_mkjournal(): Don't allocate an extra block to the journal

Addresses-Sourceforge-Bug: 1483791

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkjournal.c
e6baebd2a9b205c2eaf8de0807e75bfba7061cad 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Give a priority bonus to "leaf" devicemapper devices

Give a boost to dm devices which are not used to build other dm
devices, since "leaf" devices are generally more likely to be
interesting as devices to mount.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
0bb740621f33f54161416684b9003e93f11d2779 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Unexport the private symbol blkid_devdirs

blkid_devdirs was defined in blkidP.h and was never intended to be
used outside of the library. Since it no longer needs to be shared
across object files, rename it and turn it into a static variable.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/blkidP.h
lkid/devno.c
7515a7447836708241b2b30ca7d70d1257265e75 27-Aug-2008 Theodore Ts'o <tytso@mit.edu> Remove use of devmapper library by the blkid library

The devmapper library is no longer needed given commit f4e89bcd.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/Makefile.in
lkid/blkid.pc.in
lkid/devname.c
f4e89bcdf2870820ff262e3aed04cbb5374d7fdd 26-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Optimize devicemapper support

This commit works by removing all calls from libdevmapper altogether,
and using the standard support for "normal" non-dm devices.

It depends on dm devices being placed in /dev/mapper (but the previous
code had this dependency anyway), and /proc/partitions containing dm
devices.

We don't actually rip out the libdevmapper code in this commit, but
just disable it via #undef HAVE_DEVMAPPER, just so it's easier to
review and understand the fundamental code changes. A subsequent
commit will remove the libdevmapper code, as well as unexport
the blkid_devdirs string array.

Thanks to Karel Zak for inspiring me to look at the dm code in blkid,
so I could realize how much it deserved to ripped out by its roots. :-)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/blkidP.h
lkid/devname.c
lkid/devno.c
5dd77dbe5a0ac6d78c1c6441fae4087be56d9088 26-Aug-2008 Theodore Ts'o <tytso@mit.edu> Add support for with empty directory blocks in 64k blocksize filesystems

The rec_len field in the directory entry is 16 bits, so if the
filesystem is completely empty, rec_len of 0 is used to designate
65536, for the case where the directory entry takes the entire 64k
block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dir_iterate.c
xt2fs/dirblock.c
xt2fs/link.c
xt2fs/newdir.c
d56ccbd8f97e90d34a2b18a45fbd6681d3dba726 25-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Fix namespace leakage of unicode_16be_to_utf8

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
e32677cd58456f7581ec5dcc6583f89cb4a1acdd 25-Aug-2008 Theodore Ts'o <tytso@mit.edu> libe2p: Fix namespace leakage of os_tab

Make os_tab static, since there's no reason it should be exposed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ostype.c
c4dcb1c10ae5e3d523823fe0a2c84d0841ca2ea1 25-Aug-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix namespace leakage of crc16 functions

Rename crc16 to ext2fs_crc16, and make crc16_table static, since
there's not reason it should be exposed at all.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/crc16.c
xt2fs/crc16.h
xt2fs/csum.c
xt2fs/tst_csum.c
03efde8abe79c80ff369206d06d4f1e476b08f53 24-Aug-2008 Andreas Dilger <adilger@sun.com> add debugfs command to print known features

Print out the currently supported features of e2fsprogs/libext2fs
via a new "debugfs supported_features" command. This helps scripts
to know whether it is possible to try and enable specific features
in the filesystem.

Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/Makefile.in
2p/e2p.h
2p/feature.c
9f9e5c3aea024c92c50e8bb834a3ea33d9e1f55d 24-Aug-2008 Andreas Dilger <adilger@sun.com> libext2fs: grow dblist more aggressively

Make the dblist grow more quickly when many directory blocks are added,
otherwise the array has to get copied too often, which is slow when it
is large.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/dblist.c
864b8d4eab6a8b38fa9f89ac1475ad364f5a40b8 25-Aug-2008 Andreas Dilger <adilger@sun.com> Fix miscellaneous compile warnings

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/read.c
b41fb002257d4b997560cd77676b78219be03c24 24-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Strengthen the JFS probe routine

Check to make sure a JFS filesystem is really correct by checking the
relationship between the following fields in the JFS superblock:
s_bsize, s_l2bsize, s_pbsize, s_l2pbsize, and s_l2bfactor. Thanks to
Lesh Bogdanow for this suggestion.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
lkid/probe.h
78d89cda680498957e4ad78602751d1f905cee08 24-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Fix false detection of DFSee created filesystems.

OS/2 and DFSee creates a pseudo FAT-12/16 header in the first 512
bytes of a filesystem which looks enough like a FAT-12/16 to fool
blkid. Part of this is because we don't require ms_magic or vs_magic
to be the strings "FAT12 ", "FAT16 ", or "FAT32 ", since some FAT
filesystem formatters don't set ms_magic or vs_magic. To address
this, we explicitly test for "JFS " and "HPFS " in ms_magic,
and if they are found, we assume the filesystem is definitely not
a FAT filesystem.

Addresses-Launchpad-Bug: #255255

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
baf8ab980e73e6600ac1ec45e6058796fc9dc0b0 23-Aug-2008 Manish Katiyar <mkatiyar@gmail.com> libext2fs: Fix memory leak in ext2fs_initialize().

Below patch ensures that cleanup is done properly in ext2fs_initialize
from all return paths in case of errors.

Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
9c460caae3dab7803c0e7d9399b47e790cf90661 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Enhance support for MacOS's hfs, hfsplus, and hfsx filesystems

Add detection for hfsx filesystems. Add label and uuid detetion for
hfs, hfsplus, and hfsx.

Addresses-Sourceforge-Feature-Requests: #2060292

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
lkid/probe.h
5b7adf06904e6577c5d8bee7f0197a1b1032fa68 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Fix potential crash if blkid cache is out of date when probing

Fix bug added in 57926c8c5566f0ef5b77db326d58aa0643cf6270

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
6ec9ef1881e636540cfe28e6f32c93e1781ad173 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> libuuid: Windows portability fixes

Make the uuid library (more) portable for Windows.

Addresses-Sourceforge-Feature-Request: #1937287

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
uid/tst_uuid.c
uid/uuid.h
uid/uuid_time.c
2d40a91e171ec1cfb6bb80a0e788e0740bb1d747 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Replace use of sprintf with strcpy/strcat to help SILO

Some bootloaders, like SILO, don't provide sprintf in their limited
bootloader environment. Since the uses in rw_bitmaps.c is only doing
sprintf("foo %s"), it's easy to replace that usage with strcpy/strcat.

Addresses-Sourceforge-Bug: #2049120

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
xt2fs/rw_bitmaps.c
c71d781370c29f283fdaea01783b5257e508df0f 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Add support for uninit_bg feature to allocation functions

If the allocation functions need to allocate out of a block group
where the inode and/or block bitmaps have not yet been initialized,
initialize them so ext2fs_new_block() and ext2fs_new_inode() work
correctly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
213fe9288bbebe6566f554996660a7c242a910dd 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_block_iterate2(): Support changing interior nodes of an extent tree

Resize2fs needs to be able to relocate the interior nodes of an extent
tree. Add support for this feature via ext2fs_extent_replace().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
da994e9c11749fc9a427e742273b27853b74fe1d 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_set_bmap(): Avoid creating extra extents for resize2fs

When resize2fs moves blocks belonging to an inode, it will call
ext2fs_extent_set_bmap() for logical blocks 0, 1, 2, 3, ...

Optimize for this calling pattern so we don't end up creating a
separate extent for each block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
2047e0a1eec1d128523e116f38b279f9cb8fe06b 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_set_bmap(): fix bug when replacing a single block extent

When replacing a single block extent, make sure we set or clear the
uninitialized extent flag as requested by the caller.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
a9ea7285e6d97fba4fa4af059db73f0413acfcab 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> Fix ext2fs_extent_set_bmap() when setting a block before the first extent

When setting a logical block which is before the first extent in the
extent tree, make sure the new extent goes in front, at the very
beginning of the extent tree. This fixes a bug where previously the
new extent would be inserted out of order in this case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
57fd39e94339f6a60f3c1df0818e5305cdbb7569 21-Aug-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix reading bitmaps from e2image files

Fix a signed vs. unsigned bug that was accidentally introduced in
commit f1f115a7, which was introduced in e2fsprogs 1.41.0

Addresses-Debian-Bug: #495830

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/rw_bitmaps.c
f93d9f653c0a617556727a9cafb60486b58ae6a8 15-Aug-2008 Manish Katiyar <mkatiyar@gmail.com> libext2fs : Fix memory leaks in ext2fs_extent_open()

Memory allocated for the ext2_extent_handle is not getting freed from
all the return paths in case of error. Below patch fixes it.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
f64b36d138813f4128dd7d58d6131a85e5e50c99 06-Aug-2008 Li Zefan <lizf@cn.fujitsu.com> Fix a typo in lib/e2p/Makefile.in

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/Makefile.in
3bcc6276a0c229791ca4a4fee4cf6d8d48ebe824 14-Aug-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Initialize unset inode timestamps when writing a new inode

As Li Zefan <lizf@cn.fujitsu.com> reported, the creation timestamp was
not getting set on the lost+found inode. This patch makes sure all of
the timestamps are appropriately set.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
xt2fs/mkdir.c
dcf051eccc61ed33199c840af8e3f7bd6f8d59b6 31-Jul-2008 Benno Schulenberg <bensberg@justemail.net> libblkid: On the man page, replace empty references with an existing one.

And update the FSF's address.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/libblkid.3.in
57926c8c5566f0ef5b77db326d58aa0643cf6270 10-Aug-2008 Theodore Ts'o <tytso@mit.edu> blkid: Fix probing logic so we find renamed devices

This fixes a bug where if there is an entry in the /etc/blkid.tab file
for a particular device (major, minor) number but the filename does
not exist, blkid wouldn't try to find the correct filename.

Addresses-Debian-Bug: #493216
lkid/devname.c
ac24e62c4e51f63a570a86519e0dcd09d1458ebb 18-Jul-2008 Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> e2fsprogs: Fix tst_extents output on bigendian machine.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
b5264593993145fa17a1758f064443075ebea072 17-Jul-2008 Frederic Bohe <frederic.bohe@bull.net> Fix inode table allocation with flexbg

Disordered inode tables may appear when inode_blocks_per_group is lesser
or equal to the number of groups in a flex group.

This bug can be reproduced with:
mkfs.ext4 -t ext4dev -G512 70G

In that case, you can see with dump2fs that inode tables for groups 510
and 511 are placed just after group 51's inode table instead of being
placed after group 509's inode table.

Signed-off-by: Frederic Bohe <frederic.bohe@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/alloc_tables.c
8eb3b8a0a0d6a4213dc1ad2c7bbae60f076b04d7 15-Jul-2008 Manish Katiyar <mkatiyar@gmail.com> ext2fs_read_inode: Check the validity of the inode number earlier

It looks like the right place to check for ino=0 in
ext2fs_read_inode_full() is before creating the inode cache, otherwise
since we set icache[i].ino = 0 in create_icache(), it will match the
loop below and thus we return a wrong value.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
f56aa6e6ee00fe22a311657494e5e91275a54a7e 14-Jul-2008 Theodore Ts'o <tytso@mit.edu> Don't assume that /bin/true is always in /bin

... because it isn't on MacOS X

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
bb47c2a4aff6ec6b9be7f30cd04cf7c858a84de4 14-Jul-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Make sure we never reference a null dev->bid_type

There were a few places where we don't check to make sure
dev->bid_type is non-NULL before dereferencing the pointer, mostly in
debug code.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/dev.c
lkid/devname.c
lkid/save.c
4729455f0a68f2fa0a83ec8460d1d4bccba9dcfa 14-Jul-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Don't check the group checksum when !GDT_CSUM

ext2fs_group_desc_csum_verify() is always checking the bg_checksum (to
make sure it is zero) even when the GDT_CSUM feature is not present.
This is normally OK, but apparently there are filesystems in the wild
where this field has not be initialized to zero.

Addresses-Debian-Bug: #490637

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
2a7bfe835317bb9f3ebcd20079b2bb800f4b9eaa 13-Jul-2008 Theodore Ts'o <tytso@mit.edu> Flush stdio buffers before calling setbuf()

On Solaris setbuf() will discard any pending output to the stream, so
make we call fflush() before calling setbuf().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/test_ss.c
ebabf2ad6d19af5c674b624bafe619dedbc94403 13-Jul-2008 Theodore Ts'o <tytso@mit.edu> Define _XOPEN_SOURCE to 600 consistently for Solaris C99 support

Solaris's header files are very picky about which C compiler can be
used for SUSv3 conformance. Use of C99 is not compatible with SUSv2
(_XOPEN_SOURCE=500), and C89 is not compatible with SUSv3
(_XOPEN_SOURCE=600). Since we need some SUSv3 functions, consistently
use SUSv3 so that e2fsprogs will build on Solaris using c99.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tdb.c
5a299b56857c20273a43add86ecdaf9a6db0e2b8 13-Jul-2008 Theodore Ts'o <tytso@mit.edu> Remove gcc-specific varargs macro in extent.c

Use "#ifdef DEBUG // printf... // #endif" instead of dbg_printf().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
f926a7006de647132fff634b9fd9c1fa8f41abd4 13-Jul-2008 Theodore Ts'o <tytso@mit.edu> Remove vararg macro which causes portability problems from ext3_extent.h

Also remove other unneeded kernel-only cruft for ext3_extent.h.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext3_extents.h
5c3e1b917caf780943695da3e5d772688ca7ab91 13-Jul-2008 Theodore Ts'o <tytso@mit.edu> Use K&R style comments instead of C99 comments for portability

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext3_extents.h
318824c1bb7b73edfe66ae4976676c37eacd0c58 13-Jul-2008 Theodore Ts'o <tytso@mit.edu> Fix Solaris shell script portability issues

Solaris ships with a pathetically ancient shell in /bin/sh,
so fix various shell scripts to accomodate.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
49b4670e5c794f3c0f6f5df61dfa199d6cc7de65 11-Jul-2008 Manish Katiyar <mkatiyar@gmail.com> libext2fs: Add stricter/earlier tests for blocksize in ext2fs_open()

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
adc4e77d89d9a423c3fbe6457676b020c9ad3a64 11-Jul-2008 Manish Katiyar <mkatiyar@gmail.com> libext2fs: fix potential memory leak in ext2fs_initialize()

If we fail doing ext2fs_allocate_block_bitmap() or
ext2fs_allocate_inode_bitmap() we directly goto cleanup and don't free
the memory allocated to buf.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
3da77aab976ce1b93673be9c5c63b253664d11da 10-Jul-2008 Theodore Ts'o <tytso@mit.edu> Update dependencies in the Makefile for lib/ext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
009c02baf90a55b4b2d9c9e3d0a4cfc3e2531640 10-Jul-2008 Theodore Ts'o <tytso@mit.edu> Make ext2fs_check_desc() more stringent to force use of backup superbocks

E2fsck could to do more damage to a filesystem by trying to relocate
inode tables due to corrupted block group descriptors, and the
relocation could seriously damage the filesystem.

This patch enhances ext2fs_check_desk() so it detects more
self-inconsistent block group descriptors, including the cases where
e2sck might be tempted to relocate the inode table, and reports the
block group descriptors as invalid; this will cause e2fsck to attempt
to use the backup superblocks, which hopefully have not been trashed.

Addresses-Sourceforge-Bug: #1840291

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_sb.c
xt2fs/check_desc.c
2be8fe43976537b75a6ee154ff3ba47e538b55fb 10-Jul-2008 Theodore Ts'o <tytso@mit.edu> mke2fs,tune2fs: Enable huge_file, dir_nlink, and extra_isize features

Also change mke2fs.conf to enable huge_file,dir_nlink,extra_isize, and
uninit_bg by default for ext4 filesystems, and enable extra_isize in
the library as well.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
3fc1db6218f885b5f0a50084f4634f7b793d638f 08-Jul-2008 Andreas Dilger <adilger@sun.com> blkid: Make regression test tolerate older versions of mkswap

The blkid/tests contains new tests for swap, but the type-1 swapfile
test depends on mkswap supporting the "-U" option to specify the UUID.
This is not available even on relatively recent versions of mkswap
(2.13.1 16-Jan-2008) so the test needs to be changed to handle this.
If the "-U" option is not supported, don't verify the UUID in the blkid
output during testing.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/test_probe.in
ba4a021009d84682690f10e452dc81f99fe2ffdd 07-Jul-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix FLEX_BG offset used by ext2fs_allocate_group_table

The offset for both inode bitmaps and inode tables is overshot by one
block causing a hole between the group of bitmaps and inode tables
when initializing a filesystem using mke2fs.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
c03d99242901fccfb597d8bbc674899a8f22075d 04-Jul-2008 Ricardo M. Correia <Ricardo.M.Correia@Sun.COM> Add ZFS test image to blkid test suite

Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/tests/zfs.img.bz2
lkid/tests/zfs.results
79e62409b3a247e258d9e9206484ed8f193a183e 07-Jul-2008 Eric Sandeen <sandeen@redhat.com> Clean up some trivial build warnings

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
xt2fs/tst_csum.c
bf58e3d1c68be63d673d232154bde5854e031afc 29-Jun-2008 Theodore Ts'o <tytso@mit.edu> blkid: Eliminate stale entries that duplicate a verified device

Addresses-Debian-Bug: #487758, #487783

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
b697f9d01c5f07842426f7d8e918bf3110028662 29-Jun-2008 Theodore Ts'o <tytso@mit.edu> blkid: Make sure a device returned by blkid_find_dev_with_tag exists

There could be stale entries in blkid file, so if the device does not
exist, skip it.

Addresses-Debian-Bug: #487758, #487783

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/tag.c
772b89d34212e4b36c2025c80304e166bc25a2f3 21-Jun-2008 Eric Sandeen <sandeen@redhat.com> blkid: use list_for_each_safe in garbage collection

We need to use list_for_each_safe in case a device gets removed from
the list during garbage collection.

Also make the manpage slightly more informative about
what the -g garbage collection option does.

Addresses-Debian-Bug: #487758, #487783

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/cache.c
92e94afe4cc52deeef120941e6ac4d8ca4cda55e 23-Jun-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Don't include ss/ss.h except when debugging

extent.c should only try to include ss/ssh.h when it is compiled with
-DDEBUG. Otherwise it's not necessary and it breaks the Debian MIPS
build (and the Debian MIPS build only) because it tries to build
libext2fs without building libss as part of a MIPS-specific build
rule.

Addresses-Debian-Bug: #487675

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
8d45e2104cdebcd509810786756cfb2e40588620 21-Jun-2008 Theodore Ts'o <tytso@mit.edu> blkid: Fix cc portability problem in probe_lvm2()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
7f6a74b6d6bba48d5c9410dc28f8038ea8cfa979 18-Jun-2008 Eric Sandeen <sandeen@redhat.com> blkid: fix swap tests (again)

Some architectures (ppc ...) need a bigger swapfile than is shipped,
in the test image so the current re-make of swap was failing.

We could either ship a bigger image or just dd a bigger file...

There is one more minor problem with the tests; older mkswap does not
support the -U uuid specification. I'm not sure offhand what to do
about that problem, or if it really needs fixing.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/test_probe.in
71ff129e9f5c942ce4d2eb20e269100d15c1a6ae 18-Jun-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'

Conflicts:

README
resize/online.c
version.h
cc19b958602775ef48f347d16859ce6623a385da 17-Jun-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Fix marginal C code in probe_lvm2()

Modern gcc accepted what was there previously, but it's clearly not
correct C code, and this may have been the explanation for why a user
trying to compile a recent version of e2fsprogs failed to do so on Red
Hat 7.3.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
bc507e31ad8a890232dc2b3aec9ee9d68e95622a 17-Jun-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_zero_blocks: Avoid clearing more blocks than requested

This could cause certain mke2fs feature combinations to result in the
initial blocks of the inode table getting wiped out when the journal
is created.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/mkjournal.c
81f6857b1520553fc6fec8e159e7dc429aeb4c9b 08-Jun-2008 Theodore Ts'o <tytso@mit.edu> Fix LIBSS dependency problem for tests/test_icount and lib/ss/test_ss

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
9d99416ea38f159e61aef10f76a1e417e8cb3090 08-Jun-2008 Theodore Ts'o <tytso@mit.edu> Fix dependency for $(LIBSS) when an explicit dlopen() library is needed

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
5c4f8d674845095050f94ea95f3c73072cbe34b5 07-Jun-2008 Theodore Ts'o <tytso@mit.edu> resize2fs: Add support to use the ext4 online resize ioctl's

First try the ext3 ioctl, but if we get an error, try using the ext4
ioctl.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
dabfa68f81207f3ec5e9cc3215f3eb9e891294e7 07-Jun-2008 Theodore Ts'o <tytso@mit.edu> Update Makefile dependencies for lib/ext2fs
xt2fs/Makefile.in
8895f43a60269464f654e9d87c28768875cd703a 07-Jun-2008 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall warnings in libext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_tables.c
xt2fs/csum.c
xt2fs/extent.c
xt2fs/undo_io.c
96f4bb1fbc763ff1236417a28e0de457ffc95a0c 07-Jun-2008 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall warnings in libuuid

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/tst_uuid.c
dc9345a0bddcbbe2dbdc6df3afdb97a9bb470f55 07-Jun-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'

Conflicts:

configure
488c75a6a62acb07b82bcfab327d30eb5ea54703 07-Jun-2008 Theodore Ts'o <tytso@mit.edu> Fix ext2fs_swap{16,32,64} for external applications on big-endian machines

The public header files depend on the the autoconf defines
WORDS_BIGENDIAN and HAVE_SYS_TYPES_H, so we add them to ext2_types.h
so that external programs which try to use ext2fs_swap*() will work
correctly on big-endian systems. Fortunately, few if any programs
need to use this libext2's byte-swap functions directly.

Addresses-Debian-Bug: #484879

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_types.h.in
185c4aeaf23d48375e3506218305031663203d0f 23-May-2008 Theodore Ts'o <tytso@mit.edu> e2fsck: Add support to check journal checksums

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/jfs_compat.h
xt2fs/kernel-jbd.h
69fbde418b1a197bf793e51b12e23f528b967093 24-May-2008 Theodore Ts'o <tytso@mit.edu> Re-enable byte-swapping functions for use by journal checksums

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
2ea504bd64dc391530c0eb33904afa27f4156c0e 04-Jun-2008 Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> libext2fs: Fix build failure on powerpc in ext2fs_swap_inode_full()

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/swapfs.c
8aa53bfa691c21d8716efae1307bced6b705ce31 03-Jun-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
c9bad3ce1ac50e317adef1400458e6e30d0be20a 30-May-2008 Ricardo M. Correia <Ricardo.M.Correia@Sun.COM> Add ZFS detection to libblkid

This patch adds ZFS filesystem detection to libblkid.

It probes for VDEV_BOOT_MAGIC in the first 2 ZFS labels in big-endian
and little-endian formats.
Unfortunately the probe table doesn't support probing from the end of
the device, otherwise we could also probe in the 3rd and 4th labels (in
case the first 2 labels were accidentally overwritten)..

Eventually we would set the UUID from the ZFS pool GUID and the LABEL tag
from the pool name, but that requires parsing an XDR encoding of the pool
configuration which is not trivial.

Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
f5c562e2324a8950d659ebfc8db4356121d6104e 02-Jun-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Add callback functions for _alloc_block() and _block_alloc_stats()

Add callback functions for ext2fs_alloc_block() and
ext2fs_block_alloc_stats(). This is needed so e2fsck can be informed
when the extent_set_bmap() function needs to allocate or deallocate
blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
xt2fs/alloc_stats.c
xt2fs/ext2fs.h
ec9d6dd3203e8a4d548c0b6c943033ab5518a423 27-May-2008 Theodore Ts'o <tytso@mit.edu> Wire ext2fs_bmap2() to use ext2fs_extent_set_bmap()

This commit enables read/write access via the ext2fs_bmap2() interface
for extent-based inodes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
d7b92206ba7f987a68ba42971c930039729831e1 27-May-2008 Theodore Ts'o <tytso@mit.edu> Wire ext2fs_block_iterate2() to use ext2fs_extent_set_bmap()

This commit enables read/write access via the block iterator for
extent-based inodes.

Also fixed some bugs regarding the handling on non-leaf extent nodes
when iterating over extents in a file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
c802ad9ed6c6756dfb65d31f0f559e90df3825d5 20-May-2008 Eric Sandeen <sandeen@redhat.com> Teach ext2fs_extent_delete() to remove an empty extent node from the tree

ext2fs_extent_delete() will also update the parent node and decrement
the inode block count.

Passing in the EXT2_EXTENT_DELETE_KEEP_EMPTY flag will allow the empty
node to remain.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/extent.c
f4e9963c0966734d8dc16877753698193b83cd65 20-May-2008 Eric Sandeen <sandeen@redhat.com> libext2fs: add new function ext2fs_extent_set_bmap()

Allows unmapping or remapping single mapped logical blocks,
and mapping currently unmapped blocks.

Also implements ext2fs_extent_fix_parents() to fix parent
index logical starts, if the first index of a node changes
its logical start block.

Currently this can result in unnecessary new single-block extents; I
think perhaps ext2fs_extent_insert should grow a flag to request
merging with a nearby extent?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/extent.c
xt2fs/extent_dbg.ct
01229db57ee71518f81d87d6bf900c62fe1de100 20-May-2008 Eric Sandeen <sandeen@redhat.com> Teach ext2fs_extent_insert() to split the current node if necessary

If ext2fs_extent_insert finds that the requested node
for insertion is full, it will currently fail.

With this patch it will split as necessary to make room, unless an
EXT2_EXTENT_INSERT_NOSPLIT flag is passed to it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/extent.c
9fd6a96d9bf089d8d0ece3bba23b0ef19d03c102 20-May-2008 Eric Sandeen <sandeen@redhat.com> libext2fs: Teach extent.c how to split nodes

When called for a given handle, the new function extent_node_split()
will split the current node such that half of the node's entries will
be moved to a new tree block. The parent will then be updated to
point to the (now smaller) original node as well as the new node.

If the root node is requested to be split, it will move all
entries out to a new node, and leave a single entry in the
root pointing to that new node.

If the reqested split node's parent is full it will recursively
split up to the root to make room for the new node's insertion.

If you ask to split a non-root node with only one entry,
it will refuse (we'd have an empty node otherwise).

It also updates the i_blocks count when a new block has
successfully been connected to the tree.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ext2_err.et.in
xt2fs/extent.c
xt2fs/extent_dbg.ct
aa8e2f1c31374bfc6e479aea008896d179b100b4 02-Jun-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_open: If the inode is empty, initialize the extent tree

If the inode's i_block[] array is completely empty, create an empty
extent tree in the in-core inode and set the EXT4_EXTENT_FL inode
flag. This makes it easy to create a new inode using extents.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
05a32de263228ce8f78746143384e5ebe2677d14 02-Jun-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_replace: Support uninit extents and check validity of e_len

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_err.et.in
xt2fs/extent.c
168b6b53be70f77150712d63b183a026d0bf5543 26-May-2008 Theodore Ts'o <tytso@mit.edu> Remove bashism in test script for libblkid

Thanks to Christian Kujau for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/test_probe.in
c7015e491fbd1aefde15faf9b30d086d9fc9d35e 25-May-2008 Theodore Ts'o <tytso@mit.edu> Add 64-bit support to the test_io manager

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/test_io.c
c0af709e52dd4952d78f051ea5c082437ee3412b 21-May-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'

Conflicts:

README
version.h
492ea6556e82caf88d77c78bde2beb8849aa4eaf 20-May-2008 Theodore Ts'o <tytso@mit.edu> blkid: If the device mtime is newer that the cache time, force a revalidation

This fixes problems turned up by a test case written by Erez Zadok's
group which constantly reformats filesystems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
bb767b2fc3b4420f566df6f563574fd8e5c856b1 16-May-2008 Theodore Ts'o <tytso@mit.edu> ext2fs.h: Add l_i_file_acl_high and l_version_hi to on-disk inode structure

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
9817a2ba2d408077dab12090b4b4250d0d9a282a 13-May-2008 Eric Sandeen <sandeen@redhat.com> fix extent_goto for non-0 leaf levels

The logic for stopping at the right level in extent_goto was wrong,
so if you asked it to go to any level other than 0 (the leaf
level) it would fail.

Also add this argument to the tst_extents goto command to test it.

(I thought this was a failure in my split code but it was this
helper that was causing problems...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
22269b8b60da320b3c27ea8d053f9e2b0fbe2ae2 12-May-2008 Eric Sandeen <sandeen@redhat.com> - fix swap sanity tests in blkid, and blkid tests

Swap is actually native-endian on disk, and with the latest
swapspace sanity checks I added we need to have native swapspace
examples in the blkid tests, so re-mkswap them during testing.

One one other required change, though; mkswap requires at least
10 pages of swap, so the image needs to be increased to 10x64k
if mkswap is to succeed...

Maybe it'd be better to just dd it out on the fly?

Addresses-redhat-bugzilla: 445786

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
lkid/test_probe.in
cc435cb11aaa5da9bba5272aeca8eb8d23039dec 06-May-2008 Matthias Koenig <mkoenig@suse.de> libuuid: don't use unitialized variable

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
uid/gen_uuid.c
b93cb0664e1e118e2d5f6788152cb876ad3f13bc 12-May-2008 Theodore Ts'o <tytso@mit.edu> Fix parallel build problem

Problem was introduced by commit a4b69b7f1809898c87bdc11502ca258a8f16a220

Thanks to Eric Sandeen from Red Hat for pointing out this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.library
faa08e4c92eedef72b1e477cea6bda08ecf99311 28-Apr-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'next' into tt/flex-bg
c86085044195c8b721fe9ee327d790316399781e 27-Apr-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_add_journal_inode: Optimize writing the journal data blocks

Add a new function ext2fs_zero_blocks(), and use it so that journal
data blocks is written in larger chunks to speed up the creation of
the journal.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/mkjournal.c
72a168b59cbabdcfb1fe9db30f3d63f6f9731324 13-Aug-2007 Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> libext2fs: Add undo I/O manager

This I/O manager saves the contents of the location being overwritten
to a tdb database. This helps in undoing the changes done to the
file system.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/ext2_io.h
xt2fs/undo_io.c
9ba400027fb00ce43d14673346bbfb6f5719985a 22-Apr-2008 Theodore Ts'o <tytso@mit.edu> mke2fs: New bitmap and inode table allocation for FLEX_BG

Change the way we allocate bitmaps and inode tables if the FLEX_BG
feature is used at mke2fs time. It places calculates a new offset for
bitmaps and inode table base on the number of groups that the user
wishes to pack together using the new "-G" option. Creating a
filesystem with 64 block groups in a flex group can be done by:

mke2fs -j -I 256 -O flex_bg -G 32 /dev/sdX

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/alloc_tables.c
xt2fs/initialize.c
494a1daad37a8098e7db166d558aab3e9e37ac48 22-Apr-2008 Theodore Ts'o <tytso@mit.edu> Basic flexible block group support

Add superblock definition, and dumpe2fs and debugfs support.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2p/ls.c
xt2fs/ext2_fs.h
d11736c6ddcd6e687d857bd902ed772311cd66bc 23-Apr-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_open_inode_scan: Handle an non-zero bg_itable_used in block group 0

Previously, the portion of the inode table for block group 0 was
always completely zero'ed out, so the ext2fs_open_inode_scan() didn't
handle a non-zero bg_itable_used value for the first block group. Fix
this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
0f2794c020b34de391f7a42e3b155ccb0ed2830f 23-Apr-2008 Theodore Ts'o <tytso@mit.edu> mke2fs/libext2fs: Fix lazy inode table initialization

This fixes some bugs which I introduced recently while revamping the
uninit_bg code. Since mke2fs is no longer calling
ext2fs_set_gdt_csum(), it's important that ext2fs_initialize()
correctly initialize bg_itable_unused for all block group descriptors.
In addition, mke2fs needs to zero out the the reserved inodes based on
the values of bg_itable_unused set by ext2fs_initialize().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
4476105bf377eb9bd30d2771b21b2ada06c13e82 22-Apr-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'

Conflicts:

configure
8bcaaabb1a023af4852dbf0dba76249982c62e40 22-Apr-2008 Theodore Ts'o <tytso@mit.edu> blkid: Keep cached filesystem information on EACCES and ENOENT errors

When a nonprivileged user uses the blkid command, we want to keep the
cached filesystem information, and opening a device file could result
in an EACCESS or ENOENT (if an intervening directory is mode 700). We
were previously testing for EPERM, which was really the wrong error
code to be testing against.

Addresses-Launchpad-Bug: #220275

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
5711ed297b1a3d94086256b5b3b891d4f77b21ca 21-Apr-2008 Theodore Ts'o <tytso@mit.edu> Transfer responsibility of setting the *_UNINIT flags to libext2fs

Mke2fs used to have special case, ugly code in
setup_lazy_bg/setup_uninit_bg flag which set the flags based on all
sorts of special cases. Change it so that it is done in libext2fs,
and fix mke2fs to use alloc_stats functions which will take care of
clearing the *_UNINIT flags automatically as needed.

This is preparatory work to make the flex_bg allocation patch much
cleaner.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_sb.c
xt2fs/alloc_stats.c
xt2fs/csum.c
xt2fs/initialize.c
16b851cdae98244e117fe91d93b267fcad1102b3 21-Apr-2008 Theodore Ts'o <tytso@mit.edu> Remove LAZY_BG feature

This simplifies the code, and using the uninit_bg with the inode table
lazily initialized is just as good.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
xt2fs/ext2fs.h
xt2fs/inode.c
xt2fs/rw_bitmaps.c
4a568505ab904d39d9553e9c1d1c565615a5c6ca 21-Apr-2008 Theodore Ts'o <tytso@mit.edu> Add comments documenting ext2fs_[reserve_]super_and_bgd_loc()

Add an explanation of exactly what ext2fs_super_and_bgd_loc() and
ext2fs_reserve_super_and_bgd_loc() do, and more importantly, exactly
what they return. Note that most callers should *not* rely on the
return value since it's rarely useful, especially once the flex_bg
feature is enabled and inode table and allocation bitmap blocks may
not be in the block group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc_sb.c
xt2fs/closefs.c
456e9892707c2f88b951c67113b265e45a1b2556 19-Apr-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_set_gdt_csum: Remove setting of BLOCK_UNINIT

This function tried to set BLOCK_UNINIT based on the return value of
ext2fs_super_and_bgd_loc. That's not something that works once we
start allowing flex_bg since the block group metadata might not be
located in the blockgroup itself.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
3c5556ed4a6da11d65fe7dd4992291a500da819c 19-Apr-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_set_gdt_csum: Remove bogus setting of ITABLE_ZEROED

It used to be the case that ext2fs_set_gdt_csum set the ITABLE_ZEROED
flag if the INODE_UNINIT is not set. This assumed that the only
caller of ext2fs_set_gdt_csum was e2fsck (which was not true), and
that e2fsck would take care of zeroing the inode table (whic was also
not true).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
41a5afa87b0408bc213d72712a0f6fa9177680c4 20-Apr-2008 Theodore Ts'o <tytso@mit.edu> libe2p: Print the s_min_extra_isize and s_wanted_extra_isize fields

Make dumpe2fs and debugfs print out the s_min_extra_isize and
s_wanted_extra_isize fields from the superblock.

Update tests expect files as appropriate.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
00a92841c28123e67e3d10646f9d87d754337f9a 20-Apr-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Initialize s_min_extra_isize and s_wanted_extra_isize

Set the s_min_extra_isize and s_wanted_extra_isize superblock fields
to reasonable defaults in ext2fs_initialize().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
6360d129d003f25942f62fab2cdc5e1d97cc88a6 18-Apr-2008 Eric Sandeen <sandeen@redhat.com> blkid: more sanity checks for swap v1

mkswap followed by pvcreate on a block device
will still turn up as "swap" in blkid, because
pvcreate isn't particularly careful about zeroing
old signatures. (neither is mkswap, for that matter).

Testing for appropriate version and page counts
gives us a bit more confidence that we have a
real swap (v1) partition.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
ba1e1254b0c173d7f2f7978feb883111e4c6b921 18-Apr-2008 Theodore Ts'o <tytso@mit.edu> Change the primary name of the extents feature to be 'extent'

This was the original name used by Lustre's patches; keep the plural
when converting feature names to a feature mask for compatibility's
sake.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
2930dad2b20fe4b04ee3e9f5c7a76d8bf63342b0 18-Apr-2008 Theodore Ts'o <tytso@mit.edu> Rename the feature uninit_groups to uninit_bg

Allow the old name of uninit_groups when converting feature names for
backwards compatibility for scripts running mke2fs and tune2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
c21ed7705be908a5697095e597849804302edd21 08-Apr-2008 Eric Sandeen <sandeen@redhat.com> Make extent_goto() deterministic when logical block not found

Make sure that extent_goto() leaves us at the last extent
prior to the requested logical block, if the logical block
requested lands in a hole.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
5e057d5cad3e0f3bd9faa3c1124a3a592cb32919 08-Apr-2008 Eric Sandeen <sandeen@redhat.com> Fix ext2fs_extent_insert when at last extent in node

ext2fs_extent_insert() only did a memmove if path->left
was > 0, but if we are at the last extent in the node,
path->left == 0, and this node must be moved before the
current extent is replaced with the newly inserted node.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/extent.c
108e62e3162fddd423e877dda8faebe8bd96ead5 08-Apr-2008 Eric Sandeen <sandeen@redhat.com> print a bit more info for the tst_extents info command

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
daf7a6e5d1621d4d84feabedb286e23dc5ad7dbb 17-Apr-2008 Theodore Ts'o <tytso@mit.edu> Fix tst_extents build when building w/o dynamic libraries

$(LIBSS) should automatically include @DLOPEN_LIB@ so the right thing
happens for programs that need to use the ss library.

Reorder the library link order for tst_extents since the blkid library
uses libuuid functions.

Thanks to Eric Sandeen for pointing this problem out!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
1ca1059fd0126fd2c065f272a566c18f14bab16d 09-Apr-2008 Theodore Ts'o <tytso@mit.edu> Add support for the HUGE_FILE feature

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/pf.c
xt2fs/Makefile.in
xt2fs/bb_inode.c
xt2fs/bmap.c
xt2fs/expanddir.c
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
xt2fs/i_block.c
xt2fs/mkdir.c
xt2fs/mkjournal.c
xt2fs/read_bb.c
xt2fs/res_gdt.c
a91b3f36dd48aabfacedb3c092fd88235b030d9c 17-Apr-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'
6a141f218e0c91769958af532ed7fbb239996579 09-Apr-2008 Theodore Ts'o <tytso@mit.edu> Fix non-POSIX ">&" in the Makefile for lib/ss's "make check" rule

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
01c196b4f121cb77f50b9af2c54838aa4c6e06a0 30-Mar-2008 Eric Sandeen <sandeen@redhat.com> Fix a couple of implicit function declarations

Fedora seems to be gearing up to add
-Werror-implicit-function-declaration
to the standard build flags, so I thought I'd get out ahead
of this one...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
ae389208e974c97d69640c5cbb020de0f337e0f7 06-Apr-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
52bb0b050ab7001f92f8110c0167cedec53bdcb5 06-Apr-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix resize inode creation with non-standard s_first_data_block

Thanks to Max Lindner (lokimuh) for pointing this out.

I'm playing around a bit with ext2 and multi-user encryption and I
need space for my key management. So I set s_first_data_block to 4000
or something like that.

This way mke2fs segfaults when executing
ext2fs_create_resize_inode() because

blk_t goal = 3 + sb->s_reserved_gdt_blocks + fs->desc_blocks +
fs->inode_blocks_per_group;

will produce a integer underrun later and segfault then in the
ext2fs_test_bit assembler inline function.

when exchanging 3 with 2 + sb->s_first_data_block, mke2fs does not
segfault.

I'm not 100% sure if thats the correct way dealing with this issue
but I think its a proper solution.

Addresses-Sourceforge-Bug: #1935847

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/res_gdt.c
3541698f038aafe838dcb8154fac62237981052a 01-Apr-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix big-endian bug in tst_csum.c

It's not necessary to byte-swap the checksum.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tst_csum.c
a4b69b7f1809898c87bdc11502ca258a8f16a220 01-Apr-2008 Theodore Ts'o <tytso@mit.edu> Add dependency rule so that static library when necessary for "make check"

Some library makefiles use $(LIB)/$(LIBRARY).a as a dependency for the
static library built by the makefile fragment. Add it as a target
created when building $(LIBRARY).a so that it is rebuilt when necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.library
4b57781f504a2dd3873eafdcd4e4a962825eed6b 01-Apr-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Make all test programs link only against the static library

This is needed so that all of the test programs compile correctly on
big-endian systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
6f19f44a4c180079b402070efa6733da02eaac3e 31-Mar-2008 Andreas Dilger <adilger@dilger.ca> libext2fs: Micro-optimization in inode scan code

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode.c
f628acea2671dda839fc086f1017718e41e34eca 31-Mar-2008 Andreas Dilger <adilger@dilger.ca> ext2fs_set_gdt_csum(): Return an error code on errors instead of void

Change the function signature so that ext2fs_set_gdt_csum() returns an
error code.

If the inode bitmap hasn't been loaded return EXT2_ET_NO_INODE_BITMAP.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
xt2fs/ext2fs.h
d78ea441a2e52f776cc192cc7d1d8b3be2abd971 31-Mar-2008 Andreas Dilger <adilger@dilger.ca> ext2fs_set_gdt_csum(): Force the last block group to have a valid block bitmap

Never set the UNINIT_BLOCKS flag for the last group since the kernel
doesn't handle the case graefully if there is a full set of blocks in
each blockgroup marked UNINIT_BLOCKS. The kernel should be fixed up,
but in the meantime this avoids hitting the problem, and is more
consistent with lazy_bg not marking the last group UNINIT.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
80fc4e698a308de22ace6179f45e0bb67befa74b 31-Mar-2008 Andreas Dilger <adilger@dilger.ca> ext2fs_set_gdt_csum(): Clean up superblock dirty flag handling

Only mark the superblock as dirty if the function actually managed to
change part of the block group descriptor.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/csum.c
02a73f12df0dbc3636e6fe1b952e438737937669 30-Mar-2008 Andreas Dilger <adilger@dilger.ca> Fix the copyright notice in lib/ext2fs/tst_csum.c to be GPLv2 only

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tst_csum.c
d89ad0aefd5a38b401d945998a5b65de75d828f6 25-Mar-2008 Eric Sandeen <sandeen@redhat.com> Fix parallel builds for lib/ext2fs/extent.o

Updated the Makefile dependencies using "make depend".

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
fb6627a3fb4fbcb6904716c7a59e5ef9eb5dfafb 24-Mar-2008 Eric Sandeen <sandeen@redhat.com> libext2fs: Fix byte-swap logic for i_block[] in inodes with extents

ext2fs_swap_inode_full() was incorrectly swapping the i_block array
for extents.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/swapfs.c
85b59c40f4b37e43e58aef188b07a3b6678ce782 19-Mar-2008 Eric Sandeen <sandeen@redhat.com> Fix ext2fs_extent_get for uninit leaf extents

The ext2fs_extent_get() function was not OR-ing together UNINIT
and LEAF flags in the case where an extent was both; so if we
had an extent which was both uniint and leaf, pass1 would bail
out where depth == max_depth but was not marked as leaf, and
e2fsck (from the next branch) would abort with:

e2fsck 1.40.8 (13-Mar-2008)
Pass 1: Checking inodes, blocks, and sizes
Error1: No 'down' extent
Aborted

Also, if the error is encountered again, print the inode number
to aid debugging until it's properly handled, at least.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
3542ba0d37fe58eba91b1b42f20de0fdbfb2ac43 22-Oct-2007 Jose R. Santos <jrs@us.ibm.com> Rename feature name from gdt_checksum to uninit_groups

This name is a more intuitive option when running mke2fs.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/feature.c
d4f34d41be97e23db07d5ed606fcc1a26f5a3c76 22-Oct-2007 Jose R. Santos <jrs@us.ibm.com> Add uninit block group support to various libext2fs functions

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/alloc_stats.c
xt2fs/alloc_tables.c
xt2fs/ext2fs.h
xt2fs/initialize.c
xt2fs/inode.c
xt2fs/openfs.c
xt2fs/rw_bitmaps.c
ca2634a46ab9da85a3a015a7772770d9dbe5848e 22-Oct-2007 Jose R. Santos <jrs@us.ibm.com> Add initial checksum support for the gdt_checksum/uninit_group feature

- Add support for computing CRC-16 value.
- Add call to check/verify/set csum on block_groups.
- Add a test program to verify csum operations.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/crc16.c
xt2fs/crc16.h
xt2fs/csum.c
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
xt2fs/tst_csum.c
2d328bb76d2d63bdfdba923b54c28bd686bd8fec 18-Mar-2008 Theodore Ts'o <tytso@mit.edu> Fix miscellaneous gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
xt2fs/bmap.c
xt2fs/closefs.c
xt2fs/dblist.c
xt2fs/ext2fs.h
xt2fs/extent.c
xt2fs/ind_block.c
xt2fs/openfs.c
a7c9cb7d0dc464eda26958595b728a6c3a4cacbc 02-Feb-2008 Andreas Dilger <adilger@sun.com> Add support for the DIR_NLINK feature.

This patch includes the changes required to e2fsck to understand the
nlink count changes made in the kernel.

In e2fsck pass 4, when we fetch the actual link count, if it is
exceeds 65,000 we set the link count to 1. We silently fix the
situation where the nlink count of the directory is 1, and there are
fewer than 65,000 subdirectories, since since that can happen
naturally.

Patch originally from CFS, significantly rewritten by Theodore Ts'o.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
xt2fs/ext2fs.h
60bbd1af533daf8c726d6e5e4f17b293494bd939 13-Mar-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Make icount use a 32-bit counter

In order to more accurately count the number of directories, which
with the DIR_NLINKS feature can now be greater than 65,000, change
icount to use a 32-bit counter. This doesn't cost us anything extra
when the icount data structures are stored in memory, since due to
padding for alignment reasons.

If the actual count is greater than 65,500, we return 65,500. This is
because e2fsck doesn't actually need to know the exact count; it only
needs to know if the number of subdirectories is greater than 65,000.
In the future if someone really needs to know the exact number, we
could add a 32-bit interface. One isn't needed now, though.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/icount.c
6567e5a684610832962a951a50712574eff59808 15-Mar-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'
a80f3694a7b99756e747683f01ab8a5bca022251 15-Mar-2008 Theodore Ts'o <tytso@mit.edu> ext2_fs.h: Rename EXT4_ORPHAN_FS to be EXT3_ORPHAN_FS

No application will ever use the ORPHAN_FS flag, since it only shows
up in kernel memory, but it's been pointed out it was first used in
ext3, and so it should be renamed for accuracy.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
82e541885ea912bc6764b97e2545f851cf7e3ff3 29-Feb-2008 Eric Sandeen <sandeen@redhat.com> Fix ext2fs_swap_inode_full() for in-inode xattrs on big-endian machines

After the fix for resize2fs's inode mover losing in-inode
extended attributes, the regression test I wrote caught
that the attrs were still getting lost on powerpc.

Looks like the problem is that ext2fs_swap_inode_full()
isn't paying attention to whether or not the EA magic is
in hostorder, so it's not recognized (and not swapped)
on BE machines. Patch below seems to fix it.

Yay for regression tests. ;)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/swapfs.c
252b7363690e71bfd01517d6b348a5996d98ac7f 14-Mar-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix fencepost error in ext2fs_extent_insert()

ext2fs_extent_insert() was copying n-1 of the existing extents when
moving things down to make room for the new extent.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
83d9be1d5daf170066dd0e74afdd8e7063c1855e 14-Mar-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix ext2fs_extent_delete() to always point at a valid entry

When deleting the last entry in a node, back up the current pointer so
it is always pointing at a valid entry.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
51b263e3690ba3136fe63e5c722e0593772620e2 03-Mar-2008 Jose R. Santos <jrs@us.ibm.com> Add {read,write}_blk64 to inode_io.c

Add 64-bit block capable routines to inode IO manager. Since fileio.c
does not yet have 64bit support, these routines will not handle 64bit
block numbers correctly yet.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/inode_io.c
59ecd32dcb1d890bd52444c7cdeaabf8d9b2dbd1 03-Mar-2008 Jose R. Santos <jrs@us.ibm.com> Add {read,write}_blk64 to unix_io.c

Add 64-bit block capable routines to Unix IO manager.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/unix_io.c
3154e1cceb9f49bd3898e9a91723141af55cdd36 03-Mar-2008 Jose R. Santos <jrs@us.ibm.com> Add 64-bit IO manager operations to struct_io_manager.

In order to provide 64-bit block support for IO managers an maintain
ABI compatibility with the old API, some new functions need to be
added to struct_io_manger. Luckily, strcut_io_manager has some
reserved space that we can use to add these new functions.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_io.h
a040a99b6cc4bf9f10d39747ca6947f0462a2eb2 13-Mar-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'

Conflicts:

lib/ext2fs/ext2_err.et.in
52b1dd5e496c199e9cbcc238f26fd2264a07a2cf 13-Mar-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Add ext2fs_dblist_get_last() and ext2fs_dblist_drop_last()

Add two new functions which allows the caller to examine the last
directory block entry added to the list, and to drop if it necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dblist.c
xt2fs/ext2_err.et.in
xt2fs/ext2fs.h
dd232049d19112d46d4b296c1b253ef05e9dc67c 09-Mar-2008 Theodore Ts'o <tytso@mit.edu> blkid: Fix portability problem caused by using uint instead of unsigned int

This is needed to fix compilation with DJGPP; thanks to Cristophe
Grenier for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
a49670e64e28ac3b15e36cb6bd0a8135d3ecdbbb 28-Feb-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'

Conflicts:

lib/blkid/devname.c
lib/blkid/probe.c
misc/mke2fs.c
misc/tune2fs.c
3a538e42441afa5e5b34942062acb976e0d345f6 27-Feb-2008 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall warnings for lib/blkid/probe.c

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
1f1ee1948525632736e8135d797db116d2a34c8d 27-Feb-2008 Theodore Ts'o <tytso@mit.edu> libblkid: Add error checking to devicemapper code to avoid segfaults

If a device mapper volume disappears while libblkid code is running,
it is possible for the devicemapper code to return errors, and since
libblkid wasn't checking for error returns, it would dereference a
null pointer and crash. Add error checking to prevent this.

Addresses-RedHat-Bugzilla: #433857

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
ab52e12a904b4a31fc3416f0ef7d959f0c38e773 27-Feb-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Add EXT2_FLAG_NONFREE_ON_ERROR to ext2fs_open2()

Add a flag which returns the partially completed filesystem object so
e2fsck can print more intelligent error messages.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/openfs.c
7100351d352903aa84cb2978ef9389ee5b0b09ad 26-Feb-2008 Theodore Ts'o <tytso@mit.edu> libe2p: New e2p_edit_feature2 which provides better error handling

This creates a new enhanced edit_feature function for libe2p which
supports a different set of feature flags that are OK to clear as
opposed to set, and which returns more specific information about why
the user provided an invalid edit feature command.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/e2p.h
2p/feature.c
395529bb4676856a026f5f0c92d494491c3ebb75 22-Feb-2008 Theodore Ts'o <tytso@mit.edu> libe2p: Change Raid to RAID in display option

Update m_raid_opt test so that it reflects the code change.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
e6bbc002c5a3d30df156d4f23bc93a7f2dbde3a1 21-Feb-2008 Valerie Clement <valerie.clement@bull.net> Add missing shift for ei_leaf_hi

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
d46d67a84530e203e8bfa659370b720b17e3f30c 21-Feb-2008 Valerie Clement <valerie.clement@bull.net> Add missing free in ext2fs_extent_free()

handle->path should be freed in ext2fs_extent_free()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/extent.c
7a3e1b7bff8c6734921ca80401a6377e070a7cb1 19-Feb-2008 Theodore Ts'o <tytso@mit.edu> Fix memory leak in ext2fs_alloc_block()

If a block buffer was not supplied and ext2fs_alloc_block() returned
with no errors, it would leak a temporary block buffer.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/alloc.c
a451d92f38188f7218a837a395b310354864b5a4 31-Jan-2008 Eric Sandeen <sandeen@redhat.com> blkid: detect LVM2 physical volumes

Bits liberally stolen from lvm2 userspace.

Addresses-Red-Hat-Bugzilla: #409321

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/probe.c
lkid/probe.h
0157e7c635c845c0e636576206718d8abaf70e08 19-Feb-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
6b226c3de2aea0ae3a44a56d0322ba3a7f561886 19-Feb-2008 Theodore Ts'o <tytso@mit.edu> libe2p: Make list_super2() print the RAID stride and stripe-width

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
0c17cb25f24730dca138a976a390f105d2191736 19-Feb-2008 Theodore Ts'o <tytso@mit.edu> Add support for setting RAID stride and strip-width via mke2fs and tune2fs

This is useful for mballoc to align block allocation on the RAID
stripe boundaries.

Signed-off-by: Rupesh Thakare <rupesh@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
fefaef39e046781ddc75d15a8f12369f17dbd17d 02-Feb-2008 Andreas Dilger <adilger@sun.com> Improve support for in-inode EA's

Add vertificaton of the in-inode EA information, and allow in-inode
EA's to have a checksum.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/ext_attr.c
xt2fs/swapfs.c
15d482ba6e46b6979d8d9e9b3b28e0942b626c2e 21-Aug-2007 Theodore Ts'o <tytso@mit.edu> e2fsck: Add support for extents

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
cc9bf5d246fc23267e14cc328728f146aee142e2 18-Feb-2008 Theodore Ts'o <tytso@mit.edu> Add read/only support for extents to ext2fs_bmap()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
xt2fs/ext2fs.h
206fea69f8624843c2ffd32bab171059ec137780 04-Feb-2008 Theodore Ts'o <tytso@mit.edu> Add read-only extents support to ext2fs_block_iterate2()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
xt2fs/ext2_err.et.in
3eb07f649350acfd9e145584d57aac3c1b65d0ba 15-Oct-2007 Theodore Ts'o <tytso@mit.edu> Add support for extents to libext2fs

Initial implemenation of extents support in libext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/ext2_err.et.in
xt2fs/ext2fs.h
xt2fs/ext3_extents.h
xt2fs/extent.c
xt2fs/extent_dbg.ct
4ce3b77480496a20cf380bd18a8ae4a414b7d4a0 01-Sep-2007 Theodore Ts'o <tytso@mit.edu> Don't byte swap extents information in the inode

Responsibility for byte swapping the extents information rests with
the low-level extent code, which translates the on-disk extents
information to the abstract extent format. The on-disk format will
eventually get more complicated, in order to add support for 64-bit
block numbers, bit-compressed extents, etc. So to avoid needing to
expose all of that complexity in swapfs.c, the in-memory contents of
i_blocks will not be byte-swapped and will be identical to the on-disk
format.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/swapfs.c
bbf54adb034dbf589d40c4b28c9bb7fe492b87ed 17-Feb-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
3eed36b25409dea0cc41c001766456026b5504c8 17-Feb-2008 Theodore Ts'o <tytso@mit.edu> Update to latest samba tdb library before LGPLv3 change

The major changes were:

* Fix realloc() leak on failure case from Jim Meyering
* Fixed various problems in transaction lock code
* Made transaction_brlock() static
* Added more fine-grained locking features

Moved from svn revision #22080 to #23590

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/tdb.c
xt2fs/tdb.h
xt2fs/tdb/build-tdb
xt2fs/tdb/patches/copyright
xt2fs/tdb/patches/ext2tdb-rename
xt2fs/tdb/patches/replace-includes
xt2fs/tdb/patches/static-functions
xt2fs/tdb/patches/static-prototypes
xt2fs/tdb/patches/tdbtool-includes
e7cc6f7d0b86d76963058ef099ca553da29d2c3f 16-Feb-2008 Christophe GRENIER <grenier@cgsecurity.org> Add portability checks to support DJGPP

DJGPP lacks sys/select.h and sys/un.h; add header checks to be more
portable.

Signed-off-by: Christophe Grenier <grenier@cgsecurity.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/tdb.c
uid/gen_uuid.c
e70f32b79d29e287f8347c5d41c6716f094cc654 15-Feb-2008 Theodore Ts'o <tytso@mit.edu> libuuid: use fcntl locking instead of lockf

Cygwin doesn't support lockf(), so move to fcntl() locking as more
portable. Also fix a bug which could cause get_lock() to loop forever
if the attempt to lock the file fails for some reason.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
357d1863d64ce807c2904e101fc87d3f6be2f3ca 03-Feb-2008 Theodore Ts'o <tytso@mit.edu> libext2: Add BLOCK_FLAG_READ_ONLY flag to ext2fs_block_iterate2()

This flag allows the caller to promise that it will not try to modify
the block numbers returned by the iterator.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/block.c
xt2fs/dir_iterate.c
xt2fs/ext2_err.et.in
xt2fs/ext2fs.h
xt2fs/read_bb.c
ef80fdc8ad014c55e601018f4f6ec22065c37030 10-Feb-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
47526e3568f93a13caa347408496f1f1d48af74c 10-Feb-2008 Theodore Ts'o <tytso@mit.edu> libcom_err: Use thread local storage to fix reentrancy problems

Address the theoretical problem of two threads trying to format a
different unknown error code by using TLS.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/error_message.c
5010f295cac73e19497bd834a27755fc80a2e4f2 10-Feb-2008 Theodore Ts'o <tytso@mit.edu> Document the BLKID_FILE environment variable in the libblkid man page

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/libblkid.3.in
a4045c21a30ddf36528b0b1fc0cc6e4fffb33ce6 10-Feb-2008 Theodore Ts'o <tytso@mit.edu> blkid: Add support for returning labels for UDF filesystems

Addresses-Sourceforge-Bug: #1886394

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
lkid/tests/udf.img.bz2
lkid/tests/udf.results
838f133c72a583eae67414368e46ee0303e0a51f 10-Feb-2008 Theodore Ts'o <tytso@mit.edu> blkid: Flush cached filesystem information on any error other than EPERM

USB devices can return ENOMEDIUM, and when the filesystem cached
information wasn't flushed, it resulted in the wrong location of a
filesystem to be returned to the caller. The only justification for
using cached information when the open fails is in the case of a
permission denied error.

Addresses-Debian-Bug: #463787
lkid/probe.c
cfc19311947dc4bd1731f641a8c52135a02e5559 08-Feb-2008 Theodore Ts'o <tytso@mit.edu> blkid: Automatically chose between ext4 and ext4dev as appropriate

Add logic that on Linux systems will check for the presence of the
ext4dev filesystem; if it isn't present, fall back to ext4 for
filesystems that are marked as being "OK for use on test filesystem
code". If they are OK for use for in-development filesystem code, it
should also be fine to use stable filesystem code if there is no test
filesystem code (ext4dev) available.

The reverse is not true, of course. We don't ever want to mount a
production filesystem using test filesystem code unless the user gives
us explicit permission via "tune2fs -E test_fs".

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
428f6b32a9029e1f0bc2559233954955a6aae64c 28-Jan-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:

configure
lib/ext2fs/ext2_fs.h
misc/e2image.c
c2dbc18a9425815b6e93eb8b95d05a1168fb6e23 27-Jan-2008 Theodore Ts'o <tytso@mit.edu> Use lseek() instead of llseek() of sizeof(long) == sizeof(long long)

Previously we used a hard-coded test where for the Alpha and the IA64,
we used lseek instead of llseek(). Generalize this to whenver
sizeof(long) is the same as sizeof(long long).

It turns out this fixes a FTBFS problem on the x86_64 for Debian,
since dietlibc doesn't provide llseek() on that architecture.

Addresses-Debian-Bug: #459614

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/llseek.c
xt2fs/llseek.c
edeee8f36f25b8d4bd6a9f6694f00a4060dd03f3 27-Jan-2008 Theodore Ts'o <tytso@mit.edu> libuuid: Make sure execl() variadic function is properly terminated

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
69d742284d083c8f6ce7d9240019e21f2fbd9ed5 27-Jan-2008 Theodore Ts'o <tytso@mit.edu> blkid: Add support for HFS+ detection

From SLES 10 patch: e2fsprogs-blkid_probe_hfsplus.patch

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
lkid/probe.h
4dc30dac2c2732e25765984263a3ecafd8c66932 27-Jan-2008 Theodore Ts'o <tytso@mit.edu> blkid: Make sure the blocksize in reiserfs is sane

This avoids a floating point exception for corrupt reiserfs images

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
2921332fd88b843ffb828d9c18f05bfd171ace76 27-Jan-2008 Theodore Ts'o <tytso@mit.edu> Teach the blkid library about ext4/ext4dev

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
lkid/probe.h
6cb27404f51f97e2665fa0e0c4c0f7bc47e698ec 27-Jan-2008 Theodore Ts'o <tytso@mit.edu> Add support for the test_fs flag

The test_fs flag is an "ok to be used with test kernel code" flag. It
makes it easier for us to determine whether a filesystem should be
mounted using ext4 or not.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ls.c
xt2fs/ext2_fs.h
xt2fs/initialize.c
153439222e6a16e40be324408d8d19361bc1e65e 21-Jan-2008 Theodore Ts'o <tytso@mit.edu> Define helper functions ext2fs_set_i_{u,g}id_high() for MacOS compatibility

This is needed for all non-Linux/Hurd/Masix systems...

Addresses-Sourceforge-Bug: #1863819

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
c40ad3674c9d2f0709cbe8f2f607633f25c4bb4b 11-Jan-2008 Pixel <pixel@mandriva.com> blkid: have ntfs's UUID compatible with vol_id

Ensure the length of the UUID is always the same

without the patch:

% blkid /tmp/a /tmp/b
/tmp/a: UUID="7130E4771519577F" TYPE="ntfs"
/tmp/b: UUID="7E9B4A7CCE99CA" TYPE="ntfs"

with the patch:

% blkid /tmp/a /tmp/b
/tmp/a: UUID="7130E4771519577F" TYPE="ntfs"
/tmp/b: UUID="007E9B4A7CCE99CA" TYPE="ntfs"

ie same as:

% vol_id --uuid /tmp/a ; vol_id --uuid /tmp/b
7130E4771519577F
007E9B4A7CCE99CA

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
42c0b61ca58ddc64ede08c0c02ebe3f9eb5b9570 01-Jan-2008 Theodore Ts'o <tytso@mit.edu> Fix profile, checker, and shared-library building on non-Linux platforms

Approximately two years ago a revamp of the e2fsprogs build
infrastructure broke the Makefile fragments for building BSD, Solaris,
and Darwin shared libraries, as well as profiling and checker
libraries. Apparently no one had noticed except for
pierre42@users.sourceforge.net.

Addresses-Sourceforge-Bug: #1819034

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
akefile.bsd-lib
akefile.checker
akefile.darwin-lib
akefile.profile
akefile.solaris-lib
fef2b38d8e5b475655771f8208265a8fa9246601 01-Jan-2008 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:

configure
debian/rules
e2fsck/swapfs.c
lib/ext2fs/ext2_fs.h
7132d48d83f79992773b6d9f1cace8d96366f08b 01-Jan-2008 Theodore Ts'o <tytso@mit.edu> Fix build failure on non-Linux/non-Hurd/non-Masix systems

The previous fix didn't quite work, but this one should!

Addresses-Sourceforge-Bug: #1861633

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
0cfde3d15a88d088d49e80e18797cc7929603534 01-Jan-2008 Theodore Ts'o <tytso@mit.edu> libss: Remove unnecessary Makefile dependency for test_ss

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
904dad55e6111a1312be5725f95ca28de58a775c 01-Jan-2008 Theodore Ts'o <tytso@mit.edu> Update dependencies in lib/uuid/Makefile.in

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/Makefile.in
9320c6ffcdaa1ce236a462468fd7fa16bfca798e 31-Dec-2007 Theodore Ts'o <tytso@mit.edu> Fix build error in blkid/tst_types.c when using diet libc

When compiling with diet libc, <sys/types.h> must be included in order
to define the types used in asm/types.h. Strange choice, but
workable. This doesn't cause much problems for e2fsprogs except
blkid/tst_types.h, which needed a #include of <sys/types.h>.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/tst_types.c
29dd9d1e90c8ccefa2f8bdc6463694edc3a909d7 31-Dec-2007 Theodore Ts'o <tytso@mit.edu> Test for sys/syscall.h in configure to fix dietlibc build problem

When compiling with dietlibc, sys/syscall.h isn't supported; as of
dietlibc 0.30, it exists but it references a non-existent asm/unistd.h
header file. So we have to test for its existence and avoid using it
in lib/uuid/gen_uuid.c if it is not supported.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
5610f9924bfe506852701f1f11f6ca9f421e8a57 31-Dec-2007 Theodore Ts'o <tytso@mit.edu> Add --disable-uuidd configure option

Add a configure option which causes the uuidd helper daemon not to be
built or used by the uuid library.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
3306861158a1ca27b7ec83bb33fb8fbbf043d24c 30-Dec-2007 Theodore Ts'o <tytso@mit.edu> Fix build failure on non-Linux/non-Hurd/non-Masix systems

inode_uid() and inode_gid() weren't getting defined on systems that
were not Linux, Hurd, or Masix.

Addresses-Sourceforge-Bug: #1859778

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
e5aace908e9d1161a594944d9360f9f0cdd18099 27-Dec-2007 Theodore Ts'o <tytso@mit.edu> Convert use of ext2fs_get_mem to ext2fs_get_array for overflow detection

Add some additional checks, primarily in resize2fs and in the rarely
used (and soon to-be-deprecated) e2fsck byte-swap filesystem function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
f79fb4976cd1e4775a4959be3ddda557204939e0 21-Dec-2007 Theodore Ts'o <tytso@mit.edu> libuuid: Fix bug which caused uuidd to fail if sizeof(int) != sizeof(int *)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
3166c58dc0e2be55c9414e019607902c85485e83 18-Dec-2007 Theodore Ts'o <tytso@mit.edu> Add #define needed for Hurd ioctl definitions

Addresses-Debian-Bug: #437720

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_fs.h
d37a4fa78806d9dd02586ef6696332ba944ae906 17-Dec-2007 Theodore Ts'o <tytso@mit.edu> libuuid: Only try to start the uuidd daemon a limited number of times

If we fail to create the uuidd daemon after 5 or 6 tries, another
10,000 tries probably won't be successful.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
9d8c203a462ee18c1fd09a68cfe0e2ec7d8288da 17-Dec-2007 Theodore Ts'o <tytso@mit.edu> libuuid: When starting uuidd, use waitpid() to reap the zombie process

The uuidd process will fork and let the parent process exit to create
the daemon. So use waitpid to reap the zombie, as well as using it to
time when it is safe to try to connect to the daemon.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
2165003bd5d3dc25a623417add49f2c38360d2b7 17-Dec-2007 Theodore Ts'o <tytso@mit.edu> uuidd: Use /var/lib/libuuid instead of /var/run/uuidd

/var/run can get completely removed at reboot, and uuidd doesn't have
permissions to recreate /var/run/uuidd. So instead use
/var/lib/libuuidd for the unix domain socket and pid files.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/uuidd.h
b689b8dd14e69c652d2c8211bdef3effe81cfd65 17-Dec-2007 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:

lib/ext2fs/closefs.c
740837def7fc55ba6b0368f46a4b4abcaba0becd 16-Dec-2007 Theodore Ts'o <tytso@mit.edu> Add uuidd daemon to prevent duplicate time-based UUID's

Also store the clock sequence information in a state file in
/var/lib/misc/uuid-clock so that if the time goes backwards the clock
sequence counter can get bumped. This allows us to completely
correctly generate time-based (version 1) UUID's according to the
algorithm specified RFC 4122.

Addresses-Sourceforge-Bug: #1529672
Addresses-Red-Hat-Bugzilla: #233471

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/gen_uuid.c
uid/uuidd.h
6b6c27fb8a45f264194d8dd637643d8b4898271a 16-Dec-2007 Theodore Ts'o <tytso@mit.edu> libcom_err: Fix sign-extension problem on 64-bit systems in error_message()

On 64-bit systems (or anything with sizeof(long) > sizeof(int)), we
sometimes get error codes passed to error_message which have been cast
from an (int) to an (unsigned int). This almost always happens if
you're using libgssapi_krb5, which returns an error code which is less
than 0 but is returned in an (unsigned int).

For example, -1765328377L gets cast to 2529638919, which is
0x96c73a07, not 0xffffffff96c73a07, so error_message() fails to find a
matching error table.

When error_message() then calls the error_table_name() function to get a
name to use in the "unknown code" message, it gets a correct value back.

This happens because error_table_name() drops most of the higher bits of
the parameter it's passed before doing anything else with it (& 077777777f,
or & 0xffffff). If we did the same thing in error_message(), we wouldn't
have a problem there, either.

Problem reported and fixed by: Nalin Dahyabhai

Addresses-Sourceforge-Bug: #1809658

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/error_message.c
20c10a766788d9271e36f3ba3b0682a3027cb272 16-Dec-2007 Theodore Ts'o <tytso@mit.edu> blkid: Avoid division by zero error when probing an invalid FAT filesystem

Addresses-Sourceforge-Bug: #1831627

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
bef406047dcd20ff6910714fea986ca29efccb73 16-Dec-2007 Theodore Ts'o <tytso@mit.edu> libss: Fix "make check" test case to work portably

The "make check" test in lib/ss would fail if '.' is not in the user's
PATH, and if the libss shared library had not yet been installed yet.

Addresses-Sourceforge-Bug: #1848974

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
daecda1cad1205d6697086e8a190d35eb3f6950f 16-Dec-2007 Theodore Ts'o <tytso@mit.edu> Fix uuid_unparse man page to give a correct example UUID output string

Addresses-Debian-Bug: #444883

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/uuid_unparse.3.in
9a083af71a2388ae47252f8af2b796f9055f4af7 16-Dec-2007 Theodore Ts'o <tytso@mit.edu> ext2fs_flushfs: Remove the NEEDS_RECOVERY from the backup superblocks

Now that e2fsck tries to backup the primary superblock to the backups
when the feature sets ar different, it's important when tune2fs writes
out a changed superblock, that we filter out the
EXT3_FEATURE_INCOMPAT_RECOVER feature to the backup superblocks, since
it will be removed from the primary superblock either when the
filesystem is mounted uncleanly or when journal is replayed.

Addresses-Debian-Bug: #454926

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
e6a4571eec5ce0e75fb8a5a41c30bf0e68d90efe 09-Dec-2007 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:

lib/ext2fs/closefs.c
ee01079a17bfecd17292ccd60058056fb3a8ba6c 10-Nov-2007 Theodore Ts'o <tytso@mit.edu> libext2fs: Add checks to prevent integer overflows passed to malloc()

This addresses a potential security vulnerability where an untrusted
filesystem can be corrupted in such a way that a program using
libext2fs will allocate a buffer which is far too small. This can
lead to either a crash or potentially a heap-based buffer overflow
crash. No known exploits exist, but main concern is where an
untrusted user who possesses privileged access in a guest Xen
environment could corrupt a filesystem which is then accessed by the
pygrub program, running as root in the dom0 host environment, thus
allowing the untrusted user to gain privileged access in the host OS.

Thanks to the McAfee AVERT Research group for reporting this issue.

Addresses CVE-2007-5497.

Signed-off-by: Rafal Wojtczuk <rafal_wojtczuk@mcafee.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/badblocks.c
xt2fs/bb_inode.c
xt2fs/block.c
xt2fs/bmap.c
xt2fs/bmove.c
xt2fs/brel_ma.c
xt2fs/closefs.c
xt2fs/dblist.c
xt2fs/dupfs.c
xt2fs/ext2fs.h
xt2fs/fileio.c
xt2fs/icount.c
xt2fs/initialize.c
xt2fs/inode.c
xt2fs/irel_ma.c
xt2fs/openfs.c
xt2fs/res_gdt.c
1113bf706fb9671187ae1afa3bb8b877731203a0 02-Dec-2007 Theodore Ts'o <tytso@mit.edu> libss: Fix parallel build failure

A missing dependency on ss_err.h meant that std_rqs.o could fail when
e2fsprogs was being built using make -j.

Thanks to Robert Kerr for reporting this bug.

Addresses-Sourceforge-Bug: #1842331

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
38361bbbb55735cf0f4ed6d56079c70fb3328036 29-Nov-2007 Eric Sandeen <sandeen@sandeen.net> e2fsprogs: fix blkid whole-disk scanning heuristics

The heuristics in blkid/devname.c probe_all() for scanning whole disks
with no partitions assume that a device name with no digit on the end
will always be present as a delineator, i.e.:

sda
sda1
sdb
sdc

In this case, when sdc is seen, it's the clue to go back and scan sdb.
However, for something like:

sda
sda1
sdb
loop0

this falls down, and sdb is never scanned.
(thanks to Karel Zak for pointing this out).

Addresses-Red-Hat-Bugzilla: #400321

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
7e5a86a66044c4bf4021d1e2900a8748011f17b5 01-Dec-2007 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix a corner case bug in ext2fs_unlink

We cannot merge a removed directory entry to just arbitrary previous
directory entry. The previous entry must be in the same block. So
really bad things can happen when are deleting the first directory
entry in a block where the last directory entry in the previous
directory block is not in use. We fix this bug by checking to see if
the current entry is not the first one in the block before trying to
merge it to the previous entry.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/unlink.c
8cdd6a6f34a66806fb200f2a55c8fa4142d79511 09-Nov-2007 Andreas Dilger <adilger@sun.com> fix check_mntent_file() to pass mode for open(O_CREAT)

On my FC8 install, ismounted.c fails to build because open(O_CREAT) is
used without passing a mode. The following trivial patch fixes it.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ismounted.c
33b92836cd20510974ba5839177887bbb0b1e3d4 26-Nov-2007 Theodore Ts'o <tytso@mit.edu> Fix errors in test_ss.c so it can be an example application and test case

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/Makefile.in
s/test_cmd.ct
s/test_script
s/test_script_expected
s/test_ss.c
5ea565fd37821b2708c2b7f1e49fe6fc94587794 04-Nov-2007 Theodore Ts'o <tytso@mit.edu> Merge basic FLEX_BG support

Merge commit 'c2d4300b8a4a13d8a78b86c386f76259f23feec2' into next
c2d4300b8a4a13d8a78b86c386f76259f23feec2 14-Aug-2007 Jose R. Santos <jrs@us.ibm.com> Enable FLEX_BG feature support

Add FLEX_BG as a supported feature bit.

Add support to mke2fs to create filesystems with FLEX_BG.

Add support to tune2fs to add (and remove, if it won't break
filesystem consistency) the FLEX_BG feature.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
--

lib/e2p/feature.c | 2 ++
lib/ext2fs/ext2fs.h | 6 ++++--
misc/mke2fs.c | 7 ++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
2p/feature.c
xt2fs/ext2fs.h
88b34b1f87c2d7c3dfc9be7ff6e5d916f06d960a 14-Aug-2007 Jose R. Santos <jrs@us.ibm.com> Relax group descriptor checking for FLEX_BG

The FLEX_BG feature allows the inode table, block bitmap, and inode
bitmaps to be located anywhere in the filesystem. Update e2fsck and
libext2fs's checking code to recognize this.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
--

e2fsck/super.c | 14 ++++++++++++--
lib/ext2fs/check_desc.c | 15 +++++++++++++--
2 files changed, 25 insertions(+), 4 deletions(-)
xt2fs/check_desc.c
4d5cb2ac91a79e491c1b01ea58d1a5bf1ad98f22 22-Oct-2007 Jose R. Santos <jrs@us.ibm.com> lib/ext2fs/Makefile.in: Reorder some of the $(SRCS) in alphabetical order.

All files under $(OBJS) and $(SRCS) should be in alphabetical order
but this is not always the case. Let fix some some of these before
applying new files to the list of $(SRCS).

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
--

lib/ext2fs/Makefile.in | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
xt2fs/Makefile.in
cf0eeec0159b1af67fad9bccce220402cf08dff0 14-Aug-2007 Jose R. Santos <jrs@us.ibm.com> Reserve the INCOMPAT feature number for FLEX_BG.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
--

lib/ext2fs/ext2_fs.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
xt2fs/ext2_fs.h
d9099eec8e8f801932f01b707513b330908080d7 01-Nov-2007 Theodore Ts'o <tytso@mit.edu> Merge branch 'cl/remove-masix' into next
c9548bc37e5d0f55308ebbb74b1e19ce7f88ada1 23-Aug-2007 Coly Li <coyli@suse.de> libext2fs: remove masix support

This patch remove masix support from lib/ext2fs.

Signed-off-by: Coly Li <coyli@suse.de>
xt2fs/ext2_fs.h
xt2fs/swapfs.c
7b7370bd2e3dbda76b12e69c6396fc2e6d39e08c 20-Oct-2007 Dmitry V. Levin <ldv@altlinux.org> blkid.pc, ss.pc: Move private libs from "Libs:" to "Libs.private:"

According to pkg-config(1) manual page, private libraries should be
defined by "Libs.private:" line. Private libraries are libraries which
are not exposed through our library, but are needed in the case of
static linking.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/blkid.pc.in
s/ss.pc.in
710bac86a5777591acd8ef0662c008327f274f33 20-Oct-2007 Dmitry V. Levin <ldv@altlinux.org> texinfo: Fix directory entries

According to texinfo documentation, @dircategory and
@direntry...@end direntry commands are more appropriate.

For details see
http://www.gnu.org/software/texinfo/manual/texinfo/html_node/Installing-Dir-Entries.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
t/com_err.texinfo
3b06802bbbfe4e3dc8dc3d46be1f2c43284ca4f2 20-Oct-2007 Dmitry V. Levin <ldv@altlinux.org> blkid/test_probe.in: Fix temporary files handling

Avoid placing files with predictable names in /tmp.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lkid/test_probe.in
d9039ae0ff3f7929ede576058b3ad3e9c62a47c4 20-Oct-2007 Dmitry V. Levin <ldv@altlinux.org> Check fgets(3) return value

When fgets() function fails, contents of the buffer is undefined. That
is, fgets() return value needs to be checked, to avoid undefined behavior.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
xt2fs/ismounted.c
14bd240b4607971151611626ec83dc821f92be5f 22-Oct-2007 Theodore Ts'o <tytso@mit.edu> libe2p: Change iterate_on_dir so that it counts non-zero returns

To allow error messages to be reflected up, if the callback function
returns a non-zero value, bump a counter and return the number of
times the callback function signals an error by returning a non-zero
status code.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/iod.c
1a4ce9df5884405a7152855b868c3a7bfbeec385 22-Oct-2007 Theodore Ts'o <tytso@mit.edu> libe2p: Use lstat() instead of stat() in fsetflags() and fgetflags()

We can't set the flags on symbolic links, so check for them using
lstat().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/fgetflags.c
2p/fsetflags.c
042a27f8230804062016194ce151baa6cfff034e 15-Oct-2007 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
f493d4e0ac93a5c500a2e9360a2398a8637895b6 15-Oct-2007 Eric Sandeen <sandeen@redhat.com> libblkid: recognize squashfs filesystems on BE systems.

squashfs has no uuid or labels, so all we need is the magic
(for big-endian too!)

Addresses-Red-Hat-Bugzilla: #305151

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
lkid/probe.c
f2de1d38d0819b17895977fabc52d81d0ea6ec00 30-Aug-2007 Valerie Clement <valerie.clement@bull.net> libext2fs: Add EXT2_DESC_SIZE and EXT2_DESC_PER_BLOCK macros

Add macros to support variable-length group descriptors for ext4.

Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/ext2_fs.h
xt2fs/initialize.c
xt2fs/openfs.c
5d38ef1d049bf56d1c1e88b8b4d287c0f9470e61 30-Aug-2007 Valerie Clement <valerie.clement@bull.net> libext2fs: cleanup usage of unsigned int or __u32 and replace it with blk_t

Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/ext2fs.h
3bfca9a499af9f72a2b22ff0d92bcc8686904e8e 30-Aug-2007 Valerie Clement <valerie.clement@bull.net> libext2fs: use ext2fs_group_first_block() instead of open-coded equivalent

Use ext2fs_group_first_block() instead of the open-coded equivalent in
ext2fs_super_and_bgd_loc() and ext2fs_descriptor_block_loc().

Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/closefs.c
xt2fs/openfs.c
eac91b35372c9affff6953165f34fe246272bef9 14-Oct-2007 Theodore Ts'o <tytso@mit.edu> Add blk64_t type definition

This will be used for all new functions so we can gradually move
e2fsprogs to support 64 bit blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
5845efd1238081e48b0fc37e8bb55c87a0a537bf 25-Sep-2007 Eric Sandeen <sandeen@redhat.com> libblkid: detect squashfs

libblkid: recognize squashfs filesystems

squashfs has no uuid or labels, so all we need is the magic.

Addresses-Red-Hat-Bugzilla: #305151

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
lkid/probe.c
2628a1d3e1e581512d136486768685542d2649b1 06-Oct-2007 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint'
f6341e9c70eb4e0ded51ca96aeaa79a72222c069 23-Sep-2007 Theodore Ts'o <tytso@mit.edu> ext2fs_dblist_dir_iterate: Fix ABORT propagation logic

ext2fs_dblist_dir_iterate() calls ext2fs_dblist_iterate(), which calls
ext2fs_process_dir_block(), which in turn calls the helper function
db_dir_proc() which calls callback function passed into
ext2fs_dblist_dir_iterate(). At each stage the conventions for
signalling requests to abort the iteration or to signal errors
changes, db_dir_proc() was not properly mapping the abort request back
to ext2fs_dblist_iterate().

Currently db_dir_proc() is ignoring errors (i/o errors or directory
block corrupt errors) from ext2fs_process_dir_block(), since the main
user of ext2fs_dblist_dir_iterate() is e2fsck, for which this is the
correct behavior. In the future ext2fs_dblist_dir_iterate() could
take a flag which would cause it to abort if
ext2fs_process_dir_block() returns an error; however, it's not clear
how useful this would be since we don't have a way of signalling the
exact nature of which block had the error, and the caller wouldn't
have a good way of knowing what percentage of the directory block list
had been processed. Ultimately this may not be the best interface for
applications that need that level of error reporting.

Thanks to Vladimir V. Saveliev <vs@clusterfs.com> for pointing out
this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/dblist_dir.c
846be6db813895c354cc54beaa8fa6aba8d98085 23-Sep-2007 Theodore Ts'o <tytso@mit.edu> libblkid: Add more magic numbers that might mean there is a FAT filesystem

The FAT filesystem doesn't have its superblock with a set of magic
strings in a fixed location. Therefore, we must also check for the
FAT filesystem if it looks like we have an MBR at the beginning of the
partition. We previously checked if the first byte was a jump
instruction but that missed some USB disks with only one bootable
partition. Now we check for the MBR signature (0x55AA at offset 510)
as well as any partition where byte 0 is \351 or \353.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
ba9d929d914654f8dba36c634bb537ecf0f0bb04 07-Sep-2007 Theodore Ts'o <tytso@mit.edu> Don't crash if s_inode_size is zero

Any attempt to open a filesystem with s_inode_size set to zero causes
a floating point exception. This is true for e2fsck, dumpe2fs,
e2image, etc. Fix ext2fs_open2() so that it returns the error code
EXT2_ET_CORRUPT_SUPERBLOCK instead of crashing.

Thanks to Dean Bender for reporting this bug.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/openfs.c
a5dda0542283d0674f42a0d1b04d33888f512eab 11-Aug-2007 Theodore Ts'o <tytso@mit.edu> Remove configure --enable-swapfs and associated support #defines

This removes the last vestiges of support for the legacy PowerPC
big-endian filesystem format.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/bitops.h
xt2fs/ext2fs.h
xt2fs/swapfs.c
126a291c768b523bc228b276d3bea82675a86d09 11-Aug-2007 Theodore Ts'o <tytso@mit.edu> Clean up libext2fs by byte swapping iff WORDS_BIGENDIAN

We don't need byte swapping to be a run-time option; it can just be a
compile-time option instead.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bmap.c
xt2fs/closefs.c
xt2fs/dirblock.c
xt2fs/ext_attr.c
xt2fs/ind_block.c
xt2fs/inode.c
xt2fs/openfs.c
ccbcc40e3b90ea142766d1fec75a68c47228c087 11-Aug-2007 Theodore Ts'o <tytso@mit.edu> Remove PowerPC bitmap hackery since it's not been needed since Linux 2.1

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/rw_bitmaps.c
a98b51e9dd0384d37a4721d52f5f36a15c2ac94a 04-Aug-2007 Theodore Ts'o <tytso@mit.edu> Miscellaneous Cleanups

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/getsize.c
6d96b00d57d236e2746f8245df6c8ea64abc64c1 04-Aug-2007 Theodore Ts'o <tytso@mit.edu> Add I/O statistics to e2fsck

This patch instruments the libext2fs unix I/O manager and adds bytes
read/written and data rate to e2fsck -tt pass/overall timing output.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2_io.h
xt2fs/test_io.c
xt2fs/unix_io.c
d4e0b1c6f5aa8c6a248d9149ed5634a310952411 04-Aug-2007 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/devname.c
lkid/probe.c
f1f115a78f5ea599fc5f8815a741d43fedd5840d 23-Jul-2007 Theodore Ts'o <tytso@mit.edu> libext2fs: 32-bit bitmap refactorization, part 3

Create new functions ext2fs_{set,get}_{inode,block}_bitmap_range()
which allow programs like e2fsck, dumpe2fs, etc. to get and set chunks
of the bitmap at a time.

Move the representation details of the 32-bit old-style bitmaps into
gen_bitmap.c.

Change calls in dumpe2fs, mke2s, et. al to use the new abstractions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitmaps.c
xt2fs/ext2fs.h
xt2fs/gen_bitmap.c
xt2fs/imager.c
xt2fs/rw_bitmaps.c
50448d3dffc66f86592ee0d4b16e4bbe9d08449e 23-Jul-2007 Theodore Ts'o <tytso@mit.edu> libext2fs: 32-bit bitmap refactorization, part 2

Move the contents of rs_bitmap.c and cmp_bitmaps.c into gen_bitmap.c
and bitmaps.c.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/bitmaps.c
xt2fs/cmp_bitmaps.c
xt2fs/ext2fs.h
xt2fs/gen_bitmap.c
xt2fs/rs_bitmap.c
a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6 23-Jul-2007 Theodore Ts'o <tytso@mit.edu> libext2fs: 32-bit bitmap refactorization, part 1

Move the 32-bit specific bitmap code into gen_bitmap.c, and the
high-level interfaces into bitmaps.c. Eventually we'll move the
new-style bitmap code into gen_bitmap64.c, but first we need to
isolate the code with knowledge of the bitmap internals in one place
first.

In this patch we move allocation, free, copy, clear, set_padding, and
fudge_end function into gen_bitmap.c, and make sure that the bitmaps.c
and bitops.c no longer have any knowledge of the bitmap internals.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/Makefile.in
xt2fs/bitmaps.c
xt2fs/bitops.c
xt2fs/ext2fs.h
xt2fs/freefs.c
xt2fs/gen_bitmap.c
271a375b596240866b4a2967e3b6f38ff7cecdf8 23-Jul-2007 Theodore Ts'o <tytso@mit.edu> Move ext2fs_get_{block,inode}_bitmap_{start,end}() to generic functions

Create ext2fs_get_generic_bitmap_{start,end}() and use them for inline
functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
xt2fs/gen_bitmap.c
8df1827b55f11321bfe508c89b94591bdb97c3a6 23-Jul-2007 Theodore Ts'o <tytso@mit.edu> Uninline ext2fs_{mark,unmark,test}_block_bitmap_range() to gen_bitmap.c

Also uninline ext2fs_fast_{mark,unmark,test}_block_bitmap_range() and
use the generic routines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
xt2fs/gen_bitmap.c
7bf257a9a07d6067fba43ba05f25b3de0436d59c 22-Jul-2007 Theodore Ts'o <tytso@mit.edu> Change fast ext2fs bitmap functions to use the generic bitmap functions

This changes ext2fs_fast_{mark,unmark,test}_{inode,block}_bitmap() to
be inline functions which calls ext2fs_{mark,unmark,test}_generic_bitmap().

This is part of the preparation to support the new-style bitmaps.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
b15beaaf386a13d9fbaf716aac2df44748261af1 22-Jul-2007 Theodore Ts'o <tytso@mit.edu> Move ext2fs_test_generic_bitmap() to gen_bitmap.c

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/bitops.h
xt2fs/gen_bitmap.c
bd828a27e2cfec9f14837d9a693e2a414f44bf91 20-Jul-2007 Eric Sandeen <sandeen@redhat.com> Fix test in ext2fs_check_desc() for inode table within block group

The test in ext2fs_check_desc() is off by one; if the inode table
goes all the way to the last block of the block group, it will
falsely assert that it has extended past it. The last block
of a range is start + len -1, not start + len.

You can create (valid) filesystems that will cause e2fsck to complain
via one of the following mkfs commands:

mkfs.ext3 -F -b 1024 /dev/sdb1 2046000000
mke2fs -j -F -b 4096 -m 0 -N 5217280 /mnt/test/fsfile2 327680
mkfs.ext2 -F -b 1024 -m 0 -g 256 -N 3744 fsfile 1024

Addresses-Red-Hat-Bugzilla: #214765

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/check_desc.c
5a92a627f1e067ecfaa2478cfafeca2817cdc69f 22-Jul-2007 Theodore Ts'o <tytso@mit.edu> Properly calculate overhead in ext2fs_initialize()

For some odd geometries*, mkfs will try to allocate inode tables off
the end of the block group and fail, rather than warning that too
many inodes have been requested.

This is because when ext2fs_initialize calculates metadata overhead,
it is only adding in group descriptor blocks and the superblock
if the *last* bg contains them - but the first bg also has all of
the various metadata bits taking up space.

We need to calculate the overhead both for the first block group and
the last block groups separately, since the two different tests need
to know what the overheads are for those two cases, which may be
different.

*for example "mke2fs -b 1024 -m 0 -g 256 -N 3745 fsfile 1024"

(Note, the test here is a little funky; the expected output is
actually a mkfs failure - but a proper failure instead of the
allocator catching the problem at the last minute)

Addresses-Red-Hat-Bugzilla: #241767

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/initialize.c
db9097caca17401313c0dc840b4ae683e5b5c1df 18-Jul-2007 Eric Sandeen <sandeen@redhat.com> Fix big-endian byte-swapping bug in ext2fs_swap_inode_full()

We need to set t->i_file_acl before we test it in
ext2fs_inode_data_blocks()

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/swapfs.c
0225face1bd0dddaf19ee8089dc28980a0395633 09-Jul-2007 Theodore Ts'o <tytso@mit.edu> Add debugging printf to blkid's probe routine when original fs type failed

This particular bit of code has caused problems before, so make it
easier to debug problems caused by the probe verification looping
forever here.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
a2df22f1e938bbce844b75801106806b56c778b5 08-Jul-2007 Theodore Ts'o <tytso@mit.edu> Stop after the second '.' when parsing version numbers

Now that we are moving to x.y.z version number scheme for maintenance
releases, we ned to change ext2fs_parse_version_string and
blkid_parse_version_string to ignore the second period so we don't
have maintenance releases with a substantially bigger verison number
than the initial x.y release.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/version.c
424a3e4a2367f582edeb062ab12f3f95fdf9e31b 08-Jul-2007 Theodore Ts'o <tytso@mit.edu> Remove Changelog files since they're not used after the git migration

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
hangeLog
lkid/ChangeLog
2p/ChangeLog
t/ChangeLog
xt2fs/ChangeLog
s/ChangeLog
uid/ChangeLog
ac7dd696d60a2cb6d27c2c4855fefc7b26a26d72 08-Jul-2007 Theodore Ts'o <tytso@mit.edu> Fix bug which could cause libblkid to loop forever

When revalidating a partition where there is obsolete information in
/etc/blkid.tab, we end up freeing a the type tag without clearing
dev->bid_type, causing blkid_verify() to loop forever.

Addresses-Debian-Bug: #432052

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/tag.c
4b4df799f1099d50018bd5725b22062456080c05 01-Jul-2007 Theodore Ts'o <tytso@mit.edu> Make it clear in an error message that it is mk_cmds that is complaining

Obviates gentoo patch: e2fsprogs-1.32-mk_cmds-cosmetic.patch

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/mk_cmds.sh.in
becc39103749f73876108d3e1025f2354a22b613 30-Jun-2007 Theodore Ts'o <tytso@mit.edu> Release of e2fsprogs version 1.40

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
1ed49d2c2ab7fdb02158d5feeb86288ece7eb17c 30-Jun-2007 Kalpak Shah <kalpak@clusterfs.com> Fix byte swapping bug in get_next_inode_full()

On big-endian systems, while swapping, ext2fs_swap_inode_full() swaps
only 128+extra_isize bytes and the EAs if they are present. Now if inode
N has EAs, (and this is the inode in the "scratch inode") then inode N+1
also carries seems to have them since the "scratch inode" was never
zeroed.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/inode.c
d7b64725eecb06b2bbc5e90dc338d8d08152a932 24-Jun-2007 Theodore Ts'o <tytso@mit.edu> Update Release Notes, Changelogs, version.h, etc. for 1.40 release

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
hangeLog
lkid/ChangeLog
2p/ChangeLog
t/ChangeLog
xt2fs/ChangeLog
s/ChangeLog
uid/ChangeLog
30dd2622353b9fde462c9112fb0c863620a3bf91 24-Jun-2007 Theodore Ts'o <tytso@mit.edu> Fix divide by zero error in blkid's NTFS probing logic

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/probe.c
0d8b6733c73e871eb2a32ae0f64687c5dec84525 24-Jun-2007 Theodore Ts'o <tytso@mit.edu> Fix the info-dir line for the com_err.texinfo file

Fix the info-dir line so that the menu name does not contain a .info
prefix. First of all, it's ugly, secondly, it causes the install-info
command to fail to remove the com_err info file from the
/usr/share/info/dir file when the comerr-dev package is removed and
purged.

Addresses Debian Bug: #401711

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/ChangeLog
t/com_err.texinfo
915a2669ef3b886bfe848108d237fef6f9fbe1bf 23-Jun-2007 Kalpak Shah <kalpak@clusterfs.com> Fix ext2fs_read_inode_full() so that the whole inode is byte-swapped

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/inode.c
c844010cc41e4c293b652d252145df12448e22c6 23-Jun-2007 Theodore Ts'o <tytso@mit.edu> Fix byte-swapping issues for the i_extra_size field

Thanks to Andreas Dilger and Kalpak Shah for spotting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/swapfs.c
e382a7eaded3ec6b38114988ae9b0723bb48002a 21-Jun-2007 Karsten Hopp <karsten@redhat.com> Add support for LUKS encrypted partitions

This patch adds support for cryptsetup-luks (http://luks.endorphin.org)
UUIDs to libblkid. This is required p.e. to avoid hardcoding device
names for encrypted partitions. Could you please take a look at it and
consider inclusion in the next e2fsprogs release ?

Signed-off-by: Karsten Hopp <karsten@redhat.com>
lkid/ChangeLog
lkid/probe.c
56d1236726d8e4624d2f3a2f4713864c1e66bb40 21-Jun-2007 Theodore Ts'o <tytso@mit.edu> Add default journal size function

Factor out the code which sets the default journal size and move it
into libext2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ext2fs.h
xt2fs/mkjournal.c
cb0c5d701a8852f72fe75c9bd223643fb5222399 19-Jun-2007 Theodore Ts'o <tytso@mit.edu> Add more paranoid NTFS probing and fetch UUID and LABEL information

Hopefully this addresses false positives by the blkid library when
detecting NTFS partitions.

Addresses Launchpad Bug: #110138

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/probe.c
lkid/probe.h
058ad1c70c9a097d282270c6f76d3c3493e15fe2 19-Jun-2007 Theodore Ts'o <tytso@mit.edu> Don't write changes to the backup superblocks by default

This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default. This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups. In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched. So let's change the defaults to avoid
potential problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/openfs.c
a2b2ff61c88ac7583f288a1723d8195a0b7f2f83 31-May-2007 Theodore Ts'o <tytso@mit.edu> Add test to make sure the ext2 superblock structure is 1024 bytes

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/Makefile.in
xt2fs/tst_super_size.c
decb2a5b3a1e346ddb725a3ba01b759d8c9ee4e6 31-May-2007 Theodore Ts'o <tytso@mit.edu> Reserve superblock field for the raid stripe width.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
b62e88af6a1be97b224a3e5c1fea43fa173567ea 31-May-2007 Andreas Dilger <adilger@clusterfs.com> Reserve superblock fields for multiple mount protection feature

There have been reported instances of a filesystem having been mounted
at 2 places at the same time causing a lot of damage to the
filesystem. This patch reserves superblock fields and an INCOMPAT flag
for adding multiple mount protection(MMP) support within the ext4
filesystem itself. The superblock will have a block number
(s_mmp_block) which will hold a MMP structure which has a sequence
number which will be periodically updated every 5 seconds by a mounted
filesystem. Whenever a filesystem will be mounted it will wait for
s_mmp_interval seconds to make sure that the MMP sequence does not
change. To further make sure, we write a random sequence number into
the MMP block and wait for another s_mmp_interval secs. If the
sequence no. doesn't change then the mount will succeed. In case of
failure, the nodename, bdevname and the time at which the MMP block
was last updated will be displayed. tune2fs can be used to set
s_mmp_interval as desired.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
de8f3a76218255e443ba57dec5d74850180fa75d 25-May-2007 Andreas Dilger <adilger@clusterfs.com> Fix gcc -Wall warnings, especially on 64-bit systems

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/getsize.c
lkid/read.c
lkid/tst_types.c
t/ChangeLog
t/error_message.c
xt2fs/ChangeLog
xt2fs/icount.c
xt2fs/tst_bitops.c
xt2fs/tst_types.c
96c6a3acd377698cb99ffd9925bec9b20ca4f6f9 19-May-2007 Theodore Ts'o <tytso@mit.edu> Store the RAID stride value in the superblock and take advantage of it

Store the RAID stride value when a filesystem is created with a requested
RAID stride, and then use it automatically in resize2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
xt2fs/openfs.c
6fb57a92d19696c123d02d89cfa1f1e6703dfc32 19-May-2007 Theodore Ts'o <tytso@mit.edu> libblkid: Fix bug which could cuase bid_type to be corrupted

Fortunately bid_type isn't used much, and bid_label and bid_uuid is
only used by debugging code, so the impact of this bug was very
minor.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/tag.c
7292355283b90f1da3a86713b9f85074da22bb84 18-May-2007 Theodore Ts'o <tytso@mit.edu> Add new function blkid_gc_cache()

New function which performs a garbage collection pass on the
/etc/blkid.tab file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/blkid.h
lkid/cache.c
5113a6e32b298671c86ae7da097bcd24540cebc9 08-May-2007 Eric Sandeen <sandeen@redhat.com> Fix mke2fs and debugfs to support large (> 16 bit) uid's and gid's

Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem. This wasn't working correctly
if the uid/gid was > 16 bits. In additional, debugfs wasn't displaying
large uid/gid's correctly. This patch fixes these two programs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
d362a3fb7ec1a2b46601f55f4dbae83563c27717 19-Apr-2007 Theodore Ts'o <tytso@mit.edu> Define the l_i_iversion field in ext2_inode

The l_i_version field is now defined from the old l_i_reserved1 field in
the ext2 inode. This field will be used to store high 32 bits of the
64-bit inode version number.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
xt2fs/swapfs.c
d22c15a43efa348170c8425c5f6490686c6e9e43 19-Apr-2007 Theodore Ts'o <tytso@mit.edu> ext2fs_get_device_size(): Fix potential fd descriptor leak in an error case

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/getsize.c
3f4c46e3f9871011a3d4dffbf7a0beb35bd27d08 14-Apr-2007 Bryn M. Reeves <breeves@redhat.com> Correct byteswapping for fast symlinks with xattrs

Fix a problem byte-swapping fast symlinks inodes that contain extended
attributes.

Addresses Red Hat Bugzilla: #232663
Addresses LTC Bugzilla: #27634

Signed-off-by: "Bryn M. Reeves" <breeves@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/swapfs.c
c9105ffbe55d2a25dea9fab0595baace3a59bd51 10-Apr-2007 Sergey Vlasov <vsu@altlinux.ru> blkid: Report correct UUID from MD superblocks

The second part of UUID was copied to a wrong place in the buffer.
Now the UUID shown by blkid is the same as shown by /lib/udev/vol_id
(at least with udev-108), but is not in the same form as used by mdadm
(which prints UUID as 4 32-bit words and uses different endiannes).

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
lkid/probe.c
6b8be16e3ac9c5fc350ea25d864df7bb6e2f6f4c 10-Apr-2007 Sergey Vlasov <vsu@altlinux.ru> blkid: Fix MD 0.90 superblock detection on little endian systems

MD 0.90 superblock format is host endian - need to check for bith big
endian and little endian magic. Without this change MD components
created on little endian systems were not detected as such, which
could then lead to false positives when detecting filesystems.

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
lkid/probe.c
a1f642728fe6fd2c361343fec349808ea8a524f4 07-Apr-2007 Theodore Ts'o <tytso@mit.edu> Fix memory leaks from using the tdb library

We weren't freeing allocated memory from calls to tdb_fetch, tdb_firstkey,
and tdb_nextkey. Oops.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/icount.c
1b9d8cb7057387afae106ffa662613205f07e131 06-Apr-2007 Theodore Ts'o <tytso@mit.edu> Add support for using TDB to libext2fs's icount abstraction

Add support for using TDB to store the icount data, so we don't run out
of memory when checking really large filesystems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2fs.h
xt2fs/icount.c
47e90ebd348661ff0d3970ce0d57e6822e403f9f 06-Apr-2007 Theodore Ts'o <tytso@mit.edu> Add new TDB error codes

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_err.et.in
1cb78d8433af774864c9d62a246e5edbc612b123 06-Apr-2007 Theodore Ts'o <tytso@mit.edu> Add a regression test suite for libext2fs's icount abstraction

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/Makefile.in
xt2fs/icount.c
cc37e0d3ae12f47e77da25dea4d6a9439f489f67 06-Apr-2007 Jim Garlick <garlick@llnl.gov> Fix memory leak in ext2fs_write_new_inode()

The following patch addresses a memory leak in libext2fs
that occurs when using ext2fs_write_new_inode() on a file system
configured with large inodes.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/inode.c
106ad96daee151064aa44a857f82ba10c8258b40 05-Apr-2007 Theodore Ts'o <tytso@mit.edu> Add tdb from Samba into libext2fs library.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/Makefile.in
xt2fs/tdb.c
xt2fs/tdb.h
xt2fs/tdb/build-tdb
xt2fs/tdb/patches/copyright
xt2fs/tdb/patches/ext2tdb-rename
xt2fs/tdb/patches/replace-includes
xt2fs/tdb/patches/series
xt2fs/tdb/patches/static-functions
xt2fs/tdb/patches/static-prototypes
xt2fs/tdb/patches/tdbtool-includes
xt2fs/tdbtool.c
4aec958561923bcfd138534d6ff64273b7427a9c 05-Apr-2007 Theodore Ts'o <tytso@mit.edu> Add #include's to avoid compiler warnings in lib/ext2fs/tst_types

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/tst_types.c
641b66bc7ee0a880b0eb0125dff5f8ed8dd5a160 03-Apr-2007 Theodore Ts'o <tytso@mit.edu> Fix potential infinite loop in e2fsck on really big filesystems

Prevent floating point precision errors on really big filesystems from
causing the search interpolation algorithm in the icount abstraction
from looping forever.

Addresses Debian Bug: #411838

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/icount.c
51764fb1040ab671beb0336cb7b9909830947552 03-Apr-2007 Theodore Ts'o <tytso@mit.edu> resize2fs (libe2p): Fix resize2fs parsing of size parameter (in sector units)

This was actually a bug in libe2p's parse_num_blocks() function. When
handling the 's' suffix, it was ignoring the blocksize information
passed in from the caller and always interpreting the number in terms of
a 1k blocksize.

Addresses Debian Bug: #408298

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ChangeLog
2p/parse_num.c
e0a700d45d4d5f85ddedc2344f336e9bb73a8b29 24-Mar-2007 Brian Behlendorf <behlendorf1@llnl.gov> [COVERITY] Fix (error case) memory leak in blkid library (parse_dev)

Coverity ID: 29: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/read.c
f93625b292e69e03755fd63cf3fa6f2cce14a344 21-Mar-2007 Brian Behlendorf <behlendorf1@llnl.gov> [COVERITY] Fix (error case) memory leak in libext2fs (ext2fs_image_inode_write)

Use pre-existing early exit label in function to handle proper
error code return and local memory allocation cleanup.

Coverity ID: 23: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
xt2fs/ChangeLog
xt2fs/imager.c
e649be9daaa1190258c7d5f6521f7be19b0bed28 21-Mar-2007 Brian Behlendorf <behlendorf1@llnl.gov> [COVERITY] Fix (error case) memory leak in libext2fs (ext2fs_write_inode_full)

Need to free w_inode on early exit if w_inode != &temp_inode.

Coverity ID: 22: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
xt2fs/ChangeLog
xt2fs/inode.c
f19c46dfbcffd6d494a6df057bc602515a39246e 21-Mar-2007 Brian Behlendorf <behlendorf1@llnl.gov> [COVERITY] Fix memory leak in libss (ss_execute_line)

Fix a memory leak by freeing the argv[] array if ss_parse_line returns 0
for argc 0 (which will happen if the user his return and sends an empty
line to the application).

Potentially need to free argv before early return since it was allocated
memory. Need to be careful since it may be possible for ss_parse() to have
freed the memory allocated to it if it detects an unbalanced set of quotes
passed to it.

Coverity ID: 21: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
s/ChangeLog
s/execute_cmd.c
5f7fe7fe0e96965b9cb4f6d1e2fa08acc175d7be 21-Mar-2007 Theodore Ts'o <tytso@mit.edu> [VALGRIND] Fix memory leak in libblkid (blkid_get_devname)

Nyah, nyah, Coverity didn't find this one. :-)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/resolve.c
61bf36ef2d322ccdc231557a6ee45c7569a507c5 21-Mar-2007 Brian Behlendorf <behlendorf1@llnl.gov> [COVERITY] Fix memory leak in libe2p (e2p_edit_mntopts)

Need to free memory allocated to buf.

Coverity ID: 17: Resource Leak
Coverity ID: 18: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ChangeLog
2p/mntopts.c
2711ca1c2344b7a8d38e36508f3daae261da7a02 21-Mar-2007 Brian Behlendorf <behlendorf1@llnl.gov> [COVERITY] Fix memory leak in libe2p (e2p_edit_feature)

Coverity ID: 15: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ChangeLog
2p/feature.c
d2021de5cf94d7a55181004beee296b310901718 19-Mar-2007 Brian Behlendorf <behlendorf1@llnl.gov> [COVERITY] Fix bad error checking for NULL parameter in ss library

Looks like flawed reasoning. Here if info_dir is NULL then you are
guaranteed to blow up since you will dereference it. It seems like the
correct thing to do here (what the code author meant to do) was to set
*code_ptr = SS_ET_NO_INFO_DIR if info_dir was NULL or if *info_dir was
an empty string (aka *info_dir == '\0').

Coverity ID: 8: Forward Null

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
s/ChangeLog
s/help.c
d90be5b1437b839e5f1afcee7073798d833e4534 18-Mar-2007 Theodore Ts'o <tytso@mit.edu> [COVERITY] Allow blkid_dev_has_tag to check if a tag exists when value==NULL

blkid_dev_has_tag() will immediately return -1 (an error if value is
NULL. Thus at the test later on value cannot be NULL. There are two
possible ways to go about fixing this. The first would be to remove the
first NULL check for value. The second one would be to remove the
second check (and the deadcode).

I chose the second path because the functionality added is something
which a programmer could reasonably expect given the function name, and
it is highly unlikely any existing code is depending on the fact that
blkid_dev_has_tag() will return an error if value is NULL.

Coverity ID: 3: Deadcode

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/tag.c
257ace82b77a281da6d0491294eda6f0b27ef424 07-Mar-2007 Theodore Ts'o <tytso@mit.edu> Fix memory leak in blkid library

Addresses Debian Bug: #413661

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/devname.c
lkid/probe.c
ec84b746f553f150935f82dd8d487517fcad745b 22-Dec-2006 Theodore Ts'o <tytso@mit.edu> Add debugging code to the com_err library

If the environment variable COMERR_DEBUG is set to 1, print out debugging
messages as error tables are added and removed from the com_err library.
If the COMERR_DEBUG_FILE environment variable is set (and the process is
not setuid) the debugging messages may be redirected to a file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/ChangeLog
t/error_message.c
d2a3bf2ccc2df5167289e9fc084fec3cea78c950 30-Nov-2006 Theodore Ts'o <tytso@mit.edu> Fix (as yet unused) struct ext4_group_desc to add a missing bg_pad field

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
83732f11d641763ed7beeacbc413a103bd130f8f 18-Nov-2006 Theodore Ts'o <tytso@mit.edu> Add libreadline.so.5 to the list of readline libraries used by libss

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
s/ChangeLog
s/get_readline.c
dec5cd13fff821d1d3f6a922fbd986b3a86abb77 15-Nov-2006 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall complaints in libext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/bitops.h
xt2fs/ext2_ext_attr.h
xt2fs/kernel-jbd.h
xt2fs/namei.c
2694f31946f0c168cc8d098f3970f0ae08d94e7b 14-Nov-2006 Theodore Ts'o <tytso@mit.edu> Fix type punning bugs in ext2fs_get_mem() and ext2fs_free_mem()

This was causing dumpe2fs to crash on the ARM platform when examining
the badblocks list.

Also reverts an incorrect fix made by changeset 38078f692c20

Addresses Debian Bug: #397044
xt2fs/ChangeLog
xt2fs/badblocks.c
xt2fs/ext2fs.h
cf8272e1081f69d898d5182ed516e28807135dea 13-Nov-2006 Theodore Ts'o <tytso@mit.edu> Allow debugfs and dumpe2fs to support fs features under development

Add support for the new flag EXT2_FLAG_SOFTSUPP_FEATURES flag to
ext2fs_open() , which allows application to open filesystes with features
which are currently only partially supported by e2fsprogs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2fs.h
xt2fs/openfs.c
89dd65704f4397c49d40ae8c171928831e6a74bf 13-Nov-2006 Theodore Ts'o <tytso@mit.edu> Check in ext4 extent headers into the source tree

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/Makefile.in
xt2fs/ext2fs.h
xt2fs/ext3_extents.h
477007e1b1f8880f8974729167fcfca8076dbd6c 13-Nov-2006 Theodore Ts'o <tytso@mit.edu> Add support for printing new filesystem features

Add support for printing the huge_file, gdt_checksum, dir_nlink,
extra_isize, extent, and 64bit features.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ChangeLog
2p/feature.c
413a78f657d0f095037ea60eb0236a28da1f7e7f 13-Nov-2006 Theodore Ts'o <tytso@mit.edu> Work around GCC bug on the Arm platform

Addresses Debian Bug: #397044

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/badblocks.c
05155f9bff3935bd45a506a0fe0a277070d23094 12-Nov-2006 Theodore Ts'o <tytso@mit.edu> Set local environment variables to C so mk_cmds and compile_et always work

Addresses SourceForge Bug: #1532177

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/ChangeLog
t/compile_et.sh.in
s/ChangeLog
s/mk_cmds.sh.in
2aee23f325037fce1db32d556e6cf9adaa97ce04 12-Nov-2006 Theodore Ts'o <tytso@mit.edu> Allow unix_io offsets greater than 2G

Addresses SourceForge Bug: #1547922

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/unix_io.c
f77704e416fca7dbe4cc91abba674d2ae3c14f6f 12-Nov-2006 Theodore Ts'o <tytso@mit.edu> Add directory hashed signed/unsigned hint to superblock

The e2fsprogs and kernel implementation of directory hash tree has a
bug which causes the implementation to be dependent on whether
characters are signed or unsigned. Platforms such as the PowerPC,
Arm, and S/390 have signed characters by default, which means that
hash directories on those systems are incompatible with hash
directories on other systems, such as the x86.

To fix this we add a new flags field to the superblock, and define two
new bits in that field to indicate whether or not the directory should
be signed or unsigned. If the bits are not set, e2fsck and fixed
kernels will set them to the signed/unsigned value of the currently
running platform, and then respect those bits when calculating the
directory hash. This allows compatibility with current filesystems,
as well as allowing cross-architectural compatibility.

Addresses Debian Bug: #389772

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ChangeLog
2p/ls.c
xt2fs/ChangeLog
xt2fs/dirhash.c
xt2fs/ext2_fs.h
xt2fs/initialize.c
xt2fs/swapfs.c
6b3ce9871c3424d0b41e0c7227ddc116d2e0de1a 11-Nov-2006 Theodore Ts'o <tytso@mit.edu> On-disk format for controlling the inode size

- EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE (0x0040?) - add s_min_extra_isize and
s_want_extra_isize fields to superblock, which allow specifying
the minimum and desired i_extra_isize fields in large inodes
(for nsec+epoch timestamps, potential other uses). Needs RO_COMPAT
flag handling, needs e2fsck support, patch complete, little testing.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
xt2fs/swapfs.c
8061d2c144bf22ce3e170e40a194932da4baf8fb 11-Nov-2006 Theodore Ts'o <tytso@mit.edu> On-disk format definition for 64-bit support

- EXT4_FEATURE_INCOMPAT_64BIT (0x0080) - support for 64-bit block count
fields in the superblock (s_blocks_count_hi, s_free_blocks_count_hi),
large group descriptors (s_desc_size), extents with high 16 bits
(ee_start_hi, ei_leaf_hi), inode ACL (i_file_acl_hi). May also grow
to encompass the previously proposed BIG_BG.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
xt2fs/swapfs.c
bec6f49a46ec78a4c5928a22214848a7ea654704 11-Nov-2006 Theodore Ts'o <tytso@mit.edu> On-disk format for large number of subdirectories

- EXT4_FEATURE_RO_COMPAT_DIR_NLINK (0x0020?) - allow directories to have
> 65000 subdirectories (i_nlinks) by setting i_nlinks = 1 for such
directories. RO_COMPAT protects old filesystems from unlinking such
directories incorrectly and losing all files therein.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
8815fb8a00f5a441eb62f035353db9e0cca90b38 11-Nov-2006 Theodore Ts'o <tytso@mit.edu> On-disk format definition for group descriptor checksums

- EXT4_FEATURE_RO_COMPAT_GDT_CSUM (0x0010?) - store a crc16 checksum in
the group descriptor (s_uuid[16] | __u32 group | ext3_group_desc
(excluding gd_checksum itself)). This allows the kernel to more safely
manage UNINIT groups.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
xt2fs/swapfs.c
5d17119d14fe1276936c85d7986695a4543b1aa1 11-Nov-2006 Theodore Ts'o <tytso@mit.edu> On-disk format definition for huge files

- EXT4_FEATURE_RO_COMPAT_HUGE_FILE (0x0008) - change i_blocks to be
in units of s_blocksize units instead of 512-byte sectors, use
l_i_frag and l_i_fsize as i_blocks_hi (could also be part of 64BIT).

E2fsck and debugfs changed to support i_blocks_hi instead of l_i_frag and
l_i_fsize.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2_fs.h
xt2fs/swapfs.c
ae2868acf0acb6dd5e4426e6c109c02cd16dfec0 22-Oct-2006 Theodore Ts'o <tytso@mit.edu> Add failsafe against duplicate UUID's generated by threaded programs

Add in randomness based on Linux's thread id (gettid) to avoid race
conditions when two threads try to generate uuid's at the same time.
This shouldn't be an issue if /dev/urandom has proper locking and is
present, so this is just a failsafe.

Addresses SourceForge Bug: #1529672

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
uid/ChangeLog
uid/gen_uuid.c
b6b65c3de480c8e17c2bf9ab12196c7dde325380 22-Oct-2006 Theodore Ts'o <tytso@mit.edu> Add datarootdir definition for compatibility with autoconf 2.60

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/ChangeLog
t/compile_et.sh.in
s/ChangeLog
s/mk_cmds.sh.in
3efc3a04fc77bf53d5d1ad433144b82b441e0806 02-Oct-2006 Eric Sandeen <esandeen@sandeen.net> Check for potential 64-bit overflow in ext2fs_get_device_size()

Check for potential overflow for filesystems contained in regular files
where the filesystem image size is returned by stat64().

Signed-off-by: Eric Sandeen <esandeen@sandeen.net>
xt2fs/ChangeLog
xt2fs/getsize.c
fa2d516fb353d3dba3a6b0dad309d8ea76a2e15c 02-Oct-2006 Theodore Ts'o <tytso@mit.edu> Fix build problem if byte swapping has been disabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/bitops.h
23bb9b106adcf32c41e1700d0eb17939e55cd6bb 29-Sep-2006 Theodore Ts'o <tytso@mit.edu> Fix e2p_percent() crash if percentage was zero.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ChangeLog
2p/percent.c
5b984ab51f774b16ce8f11e46388fba4ac631755 25-Sep-2006 Theodore Ts'o <tytso@mit.edu> blkid_devno_to_devname(): Avoid recursive loops due to symlinks in /dev

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/devno.c
633f453db14b0fb91294887a9629f5cc2f95407f 18-Sep-2006 Karel Zak <kzak@redhat.com> Fix blkid bug with correctly reporting FAT filesystem labels that are empty

Signed-off-by: Karel Zak <kzak@redhat.com>
lkid/ChangeLog
lkid/probe.c
b5517ca6678d590b52f38ad701fbaf6c9716b73d 18-Sep-2006 Karel Zak <kzak@redhat.com> Add GFS/GFS2 support to the blkid library.

Signed-off-by: Karel Zak <kzak@redhat.com>
lkid/ChangeLog
lkid/probe.c
lkid/probe.h
f335864338a6fbce8134a445ffdd0cdeb3f3f1bc 12-Sep-2006 Eric Sandeen <esandeen@redhat.com> Add checks to make sure inode counts don't overflow a 32-bit value

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
xt2fs/ChangeLog
xt2fs/initialize.c
abf23439d51a3ddbca475b931abebd381ff7ceea 12-Sep-2006 Eric Sandeen <esandeen@redhat.com> Create new ext2fs library inlines: ext2fs_group_{first,last}_block()

Create new ext2fs library inline functions in order to calculate
the starting and ending blocks in a block group.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
xt2fs/ChangeLog
xt2fs/alloc_tables.c
xt2fs/check_desc.c
xt2fs/ext2fs.h
d0ff90d5202428583c78a60c3042e7b60d88bc45 12-Sep-2006 Eric Sandeen <esandeen@redhat.com> Fix signed vs unsigned printf format strings for block and inode numbers

There were still some %d's lurking when we print blocks & inodes; also
many of the counters in the e2fsck_struct were signed, and probably
need to be unsigned to avoid overflows.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
xt2fs/ChangeLog
xt2fs/bmove.c
xt2fs/getsize.c
xt2fs/icount.c
xt2fs/tst_badblocks.c
xt2fs/tst_getsize.c
xt2fs/tst_iscan.c
xt2fs/unix_io.c
xt2fs/write_bb_file.c
62c6d1403ea00dd72890862c761a41baa10a7ad4 12-Sep-2006 Eric Sandeen <esandeen@redhat.com> Remove unused variables

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
xt2fs/ChangeLog
xt2fs/closefs.c
xt2fs/initialize.c
bb1a46a430a99f73ddaf7cf74e380dd5cf36382f 12-Sep-2006 Eric Sandeen <esandeen@redhat.com> Fix loops over group descriptors to prevent 2**32-1 block number overflows

For loops iterating over all group descriptors, consistently define
first_block and last_block in a way that they are inclusive of the
range, and do not overflow.

Previously on the last block group we did a test of <= first +
dec_blocks; this would actually wrap back to 0 for a total block count
of 2^32-1

Also add handling of last block group which may be smaller.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
xt2fs/ChangeLog
xt2fs/check_desc.c
a02fa9beb8ea198766a81c0bf01aa04dc8787237 12-Sep-2006 Theodore Ts'o <tytso@mit.edu> Fix bug in device mapper scanning; probe_one() doesn't want a leading /dev

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lkid/ChangeLog
lkid/devname.c
a8862d9e90d0d94761ba28dbbf9674308fd7d7c0 30-Aug-2006 Theodore Ts'o <tytso@mit.edu> Fix potential 2**32-1 overflow by using e2p_percent()

Add a new functiom, e2p_percent(), which correct calculates the percentage
of a number based on a given percentage, without worrying about overflow
issues. This is used where we calculate the number of reserved blocks using
a percentage of the total number of blocks in a filesystem.

Based on patches from Eric Sandeen, but generalized to use this new function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2p/ChangeLog
2p/Makefile.in
2p/e2p.h
2p/percent.c
5830d6be9c33e23bb20c339036083e6e4fa6795e 30-Aug-2006 Eric Sandeen <esandeen@redhat.com> Detect overflows in loop counters

For loops such as:

for (i=1; i <= fs->super->s_blocks_count; i++) {
<do_stuff>
}

if i is an int and s_blocks_count is (2^32-1), the condition is never false.
Change these loops to:

for (i=1; i <= fs->super->s_blocks_count && i > 0; i++) {
<do_stuff>
}

to stop the loop when we overflow i

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/bitmaps.c
69022e029f3273b3b860bf701219cd3fe615f76b 30-Aug-2006 Theodore Ts'o <tytso@mit.edu> Fix potential 2**32-1 overflow problems by ext2fs_div_ceil()

Add a new function, ext2fs_div_ceil(), which correctly calculates a division
of two unsigned integer where the result is always rounded up the next
largest integer. This is used everywhere where we might have
previously caused an overflow when the number of blocks
or inodes is too close to 2**32-1.

Based on patches from Eric Sandeen, but generalized to use this new function

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
xt2fs/ChangeLog
xt2fs/ext2fs.h
xt2fs/initialize.c
xt2fs/openfs.c
f776a2354d94b3936173a028cc6ee1973e561fec 20-Aug-2006 Andreas Dilger <adilger@clusterfs.com> blkid.8.in: Fix description of the -l option to be more accurate

This patch fixes the blkid.8.in description of the "-l" option. The man
page gives the impression that the first match is the one that is returned.
However, the blkid_find_dev_with_tag() function returns the device with
the highest priority (which is good, because that is what people really want).

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
lkid/ChangeLog
cc6d1a9ef73a1165aa541da0ab856617f7f02fb0 20-Aug-2006 Andreas Dilger <adilger@clusterfs.com> This patch fixes up an error in the lib/blkid/Makefile.in which was causing
all lib/blkid/tst* files to be removed with "make clean", in particular
tst_types.c. That was causing a failure of "make check" in an RPM source
tree. Fix is to explicitly list the test binaries, as lib/ext2fs/Makefile.in
does.

As "make check" was only calling test_probe and tst_types (and none
of the other tst_* tests) it was not clear what was going on, and an
"hg update" would always return the old tst_types.c file back so the
problem was only being seen intermittently... It isn't clear whether
you want the other tst_* programs to be run as part of "make check".

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
lkid/ChangeLog
lkid/Makefile.in
a62e3f0378d2a9b861fc4809a810980c1c3bde35 06-Aug-2006 Andreas Dilger <adilger@clusterfs.com> Add 64-bit byte swapping functions

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
xt2fs/ChangeLog
xt2fs/bitops.h
8fe81a3d53fbaa1670ece5fb7fd11dd5ae45b8da 06-Aug-2006 Andreas Dilger <adilger@clusterfs.com> Rename EXT3_EXTENTS_FL to EXT4_EXTENTS_FL and make it visible to the user

lsattr will display the EXT4_EXTENTS_FL flag

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2p/ChangeLog
2p/pf.c
xt2fs/ChangeLog
xt2fs/ext2_fs.h
3f5ef9642bc08bf2a9088a0ec58ec9b0abadf0a6 05-Aug-2006 Andreas Dilger <adilger@clusterfs.com> Create the generated files read-only to remind developers not to edit them.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
t/ChangeLog
t/compile_et.sh.in
s/ChangeLog
s/mk_cmds.sh.in
067911ae734bb5fef7c5780a639533847b5b578c 16-Jul-2006 Andreas Dilger <adilger@clusterfs.com> Allow default inode_size to be specified in mke2fs.conf and document mke2fs -I

This patch allows "inode_size" to be specified in the mke2fs.conf file,
and always compiles in the "-I" option. In addition, it disallows
specifying the inode size on rev 0 filesystems, though I don't think
this was much of a danger anyways.

Clean up dead lines in ext2fs.h.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
xt2fs/ChangeLog
xt2fs/ext2fs.h
347e52de90c736e113fc4e4aff5190e10d327606 28-Jun-2006 Andreas Dilger <adilger@clusterfs.com> Protect ext2_ext_attr.h from multiple inclusion

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
hangeLog
xt2fs/ext2_ext_attr.h
9a519c0284de70baadfe39e773c369c378aae6a6 21-Jun-2006 Andreas Dilger <adilger@clusterfs.com> fix comment for blkid_get_dev_size()

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
lkid/getsize.c
aadac9b7bbe7d1f4f0db02f3d7dbd70a856f9153 30-May-2006 Matthias Andree <matthias.andree@gmx.de> Add parentheses and casts to make GCC happy.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
lkid/probe.c
df3e159870beae4b02f1f59bf2a28e3e0fdd6519 30-May-2006 Matthias Andree <matthias.andree@gmx.de> Add missing #include <ctype.h>.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
xt2fs/getsize.c
406ba674fe33469c600a4dd7ed5853cac34ca4e7 30-May-2006 Matthias Andree <matthias.andree@gmx.de> Fix non-Linux compiler warning (missing return statement).

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
xt2fs/ismounted.c
94fa1108eecb92bc595ae6f4927d2aeaea4049e8 30-May-2006 Matthias Andree <matthias.andree@gmx.de> Fix SIGBUS through unaligned access to FAT superblocks.

SPARCs do not like unaligned halfword access and throw SIGBUS.
Read data "manually" instead.

Tested on Solaris 8/SPARC with gcc 2.95.3.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
lkid/probe.c
0ac93a00c98af2f44e5d291788c7ccaa3ed239d3 30-May-2006 Matthias Andree <matthias.andree@gmx.de> Change more "echo -n" to "printf" to avoid screen clutter.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
lkid/test_probe.in
bdc3514af41b5fbfea16c5192d5aade1da641cf4 30-May-2006 Matthias Andree <matthias.andree@gmx.de> Swi