Commit Graph

35 Commits (205593f65b2f78c2cc8116a7827c241ebc8387fc)

Author SHA1 Message Date
Darrick J. Wong dc248a10ca libext2fs: support atexit cleanups
Use the atexit() function to provide a means for the library to clean
itself up on program exit.  This will be used by the undo IO manager
to flush the undo file state to disk if the program should terminate
without closing the io channel, since most e2fsprogs clients will
simply exit() when they hit errors.

This won't help for signal termination; client programs must set
up signal handlers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-05 10:40:34 -04:00
Darrick J. Wong 24997f1cd2 misc: cppcheck cleanups
Fix a number of things that cppcheck complains about.  Most of these
are minor resource leaks and forgotten declarations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14 09:34:11 -04:00
Zheng Liu be31a8de5a libext2fs: export inode cache creation function
Currently we have already exported inode cache flush and free functions
for users.  This commit exports inode cache creation function.  Later
we will use this function to initialize inode cache and do some unit
tests for inline data.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:15 -05:00
Zheng Liu 54e880b870 libext2fs: handle inline data in read/write function
Currently ext2fs_file_read/write are used to copy data from/to a file.
But they manipulate data by blocksize.  For supporting inline data, we
handle it in two new fucntions called ext2fs_file_read/write_inline_data.

In read path the implementation is straightforward.  But in write path
things get more complicated because if the size of data is greater than
the maximum size of inline data we will expand this file.  So now we
will check this in ext2fs_inline_data_set.  If this inode doesn't have
enough space, it will return EXT2_ET_INLINE_DATA_NO_SPACE error.  Then
the caller will check this error and tries to expand the file.

The following commands in debugfs can handle inline_data feature after
applying this patch:
	- dump
	- cat
	- rdump
	- write

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-04 08:46:14 -05:00
Zheng Liu 97581d4481 debugfs: handle inline data feature in punch command
Now punch command only can remove all inline data because now
punch command is based on block unit and the size of inline data is
never beyond a block size.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:14 -05:00
Zheng Liu 82e77d07ee debugfs: make mkdir command support inline data
This commit tries to make mkdir command in debugfs support inline data.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:14 -05:00
Zheng Liu 46bd6bdfc8 debugfs: make expand command support inline data
This commit defines a ext2fs_inline_data_expand() to expand an inode with
inline data.  In this commit this function only can expand a directory.
But later it will expand a file.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:14 -05:00
Zheng Liu 133e94627b debugfs: make stat command support inline data
If there is an inode with inline data, we just print the size of inline
data in stat command.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:13 -05:00
Zheng Liu 416c1de94d libext2fs: handle inline data in dir iterator function
Inline_data is handled in dir iterator because a lot of commands use
this function to traverse directory entries in debugfs.  We need to
handle inline_data individually because inline_data is saved in two
places.  One is in i_block, and another is in ibody extended attribute.

After applied this commit, the following commands in debugfs can
support the inline_data feature:
	- cd
	- chroot
	- link*
	- ls
	- ncheck
	- pwd
	- unlink

* TODO: Inline_data doesn't expand to ibody extended attribute because
  link command doesn't handle DIR_NO_SPACE error until now.  But if we
  have already expanded inline data to ibody ea area, link command can
  occupy this space.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:08 -05:00
Theodore Ts'o e4681bca17 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.8.in
2013-12-16 01:35:56 -05:00
Andreas Dilger 269da3b806 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>
2013-12-15 23:26:31 -05:00
Theodore Ts'o 2d3df8dc7f Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/newdir.c
2013-12-12 15:39:14 -05:00
Darrick J. Wong 1e7451493e 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>
2013-12-12 12:40:58 -05:00
Theodore Ts'o e337e7fad8 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/rehash.c
	e2fsck/super.c
2013-10-12 22:26:28 -04:00
Darrick J. Wong 4dbfd79d14 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>
2013-10-07 09:51:48 -04:00
Darrick J. Wong 91db7e206d libext2fs: read and write full size inodes
Change libext2fs to read and write full-size inodes in preparation for
the metadata checksumming patchset, which will require this.  Due to
ABI compatibility requirements, this change must be hidden from client
programs.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-07-30 17:42:15 -04:00
Theodore Ts'o dfe74c5c67 libext2fs: call numeric_progress functions through a operations struct
Instead of calling ext2fs_numeric_progress_*() directly from closefs.c
and alloc_tables.c, call it via a operations structure which is only
initialized by the one program (mke2fs) which needs it.

This reduces the number of C library symbols needed by boot loader
systems such as yaboot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-07-30 17:19:19 -04:00
Theodore Ts'o 67861e5bf3 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>
2011-12-18 00:28:43 -05:00
Niu Yawei 08ae93a2ed 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>
2011-11-19 23:11:20 -05:00
Andreas Dilger 65d05cec3d 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>
2011-06-11 11:33:02 -04:00
Theodore Ts'o ab13b5a979 libext2fs: Create 64-bit dblist functions
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 10:00:00 -04:00
Theodore Ts'o 97d26ce9e3 Merge branch 'maint' into next
Conflicts:
	e2fsck/journal.c
	e2fsck/pass1.c
	e2fsck/pass2.c
	misc/mke2fs.c
2010-06-07 12:42:40 -04:00
Theodore Ts'o 543547a52a 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>
2010-05-17 23:04:39 -04:00
Theodore Ts'o c21cde9986 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>
2010-01-30 20:20:21 -05:00
Valerie Aurora Henson 95fd65bb7f 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>
2009-08-23 19:20:03 -04:00
Theodore Ts'o 69365c689b 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>
2009-08-22 13:27:40 -04:00
Theodore Ts'o efc6f628e1 Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 23:07:54 -04:00
Theodore Ts'o b7a00563b2 Add support to e2fsck to reindex directories to use hash trees. 2002-07-20 00:28:07 -04:00
Theodore Ts'o 8bd0c95908 dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):
Add support for a new flag, DIRENT_FLAG_INCLUDE_REMOVED,
	which will return deleted directory entries.
	ext2fs_dir_iterate2 takes a new callback function which
	is identical with the one used by
	ext2fs_dblist_dir_iterate().  If the directory entry is
	deleted, the callback function will be called with the
	entry paraemter set to DIRENT_DELETED_FILE.

Makefile.in, alloc_stats.c (ext2fs_inode_alloc_stats,
	ext2fs_block_alloc_stats): New functions which update
	block/inode allocation statistics in the bitmaps, block
	group descriptors, and superblock.

mkjournal.c (mkjournal_proc), mkdir.c (ext2fs_mkdir),
expanddir.c (expand_dir_proc), bb_inode.c
	(clear_bad_block_proc, set_bad_block_proc,
	ext2fs_update_bb_inode), alloc.c (ext2fs_alloc_block):
	Update to use new block/inode allocation statistics.
2002-01-03 03:29:19 -05:00
Theodore Ts'o 31dbecd482 Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
  	brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
  	expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
  	icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
  	mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
  	tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
  	to protect applications that attempt to compile
  	-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?).  So
  	we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 04:54:39 +00:00
Theodore Ts'o 03673dbb04 Many files:
alloc_tables.c (ext2fs_allocate_group_table): Fix bug so that if the
  	stride length hits a bad value, we retry the block allocation starting
  	at the beginning of the block group.
  ext2fs.h, bb_inode.c, block.c, bmove.c, dir_iterate.c, expanddir.c,
  	ext2fsP.h, read_bb.c: Change blkcnt_t to be e2_blkcnt_t to avoid
  	collision with LFS API.
1998-06-10 20:39:43 +00:00
Theodore Ts'o 36a43d675e Many files:
block.c (ext2fs_block_iterate3): Make the ref_offset field contain the
  	offset into the inode.i_blocks array when ref_block is zero.  Since we
  	haven't done a formal release of e2fsprogs since block_iterate2 was
  	first introduced, I removed block_iterate2, and renamed block_iterate3
  	to be block_iterate2.
  bb_inode.c, bmove.c, dblist_dir.c, dir_iterate.c, expanddir.c,
  	ext2fs.h, ext2fsP.h, read_bb.c: Change use of block_iterate and
  	block_iterate2 to block_iterate2 with the new prototype for the
  	interator function.  (using blkcnt_t forr blockcount)
ChangeLog, debugfs.c, ls.c, lsdel.c:
  debugfs.c, ls.c, lsdel.c: Add support for large files.  (The high 32
  	bits share space with the i_dir_acl field.)
1998-03-24 16:17:51 +00:00
Theodore Ts'o b5abe6fac9 Many files:
inode.c (ext2fs_open_inode_scan): Initialize the group variables
  	so that we don't need to call get_next_blockgroup() the first
  	time around.  Saves a bit of time, and prevents us from
  	needing to assign -1 to current_group (which is an unsigned
  	value).
  icount.c (insert_icount_el): Cast the estimated number of inodes
  	from a float to an ino_t.
  alloc.c, alloc_tables.c, badlbocks.c, bb_compat.c, bb_inode.c,
  	bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c,
  	check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c,
  	dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c,
  	ext2fs.h, fileio.c, freefs.c, get_pathname.c, getsize.c,
  	icount.c, initialize.c, inline.c, inode.c, irel_ma.c,
  	ismounted.c, link.c, lookup.c, mkdir.c, namei.c, native.c,
  	newdir.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c,
  	rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c,
  	tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c,
  	version.c: If EXT2_FLAT_INCLUDES is defined, then assume all
  	of the ext2-specific header files are in a flat directory.
  block.c, bmove.c, dirblock.c, fileio.c: Explicitly cast
  	all assignments from void * to be compatible with C++.
  closefs.c (ext2fs_flush): Add a call to io_channel_flush() to
  	make sure the contents of the disk are flushed to disk.
  dblist.c (ext2fs_add_dir_block): Change new to be new_entry to
  	avoid C++ namespace clash.
  bitmaps.c (ext2fs_copy_bitmap): Change new to be new_map to
  	avoid C++ namespace clash.
  ext2fs.h, bb_inode.c, block.c, bmove.c, brel.h, brel_ma.c,
  	irel.h, irel_ma.c, dblist.c, dblist_dir.c, dir_iterate.c,
  	ext2fsP.h, expanddir.c, get_pathname.c, inode.c, link.c,
  	unlink.c: Change private to be priv_data (to avoid C++
  	namespace clash)
1998-01-19 14:47:53 +00:00
Theodore Ts'o a29f4d30f2 Many files:
Checkin of e2fsprogs 1.10
1997-04-29 21:26:48 +00:00
Theodore Ts'o 19c78dc07f Many files:
Checked in e2fsprogs-1.07
1997-04-29 16:17:09 +00:00