summaryrefslogtreecommitdiff
path: root/lib/ext2fs/fileio.c
AgeCommit message (Collapse)AuthorFilesLines
2011-09-18Shorten compile commands run by the build systemTheodore Ts'o1-0/+1
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>
2011-07-08misc: use EXT2_I_SIZE() consistently to get sizeAndreas Dilger1-2/+1
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>
2011-06-11misc: clean up compiler warningsAndreas Dilger1-1/+1
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>
2010-07-30libext2fs: Add ext2fs_file_size_size2() and truncate the file if necessaryTheodore Ts'o1-8/+22
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>
2010-07-22libext2fs: Add new function ext2fs_file_get_inode()Renzo Davoli1-0/+10
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>
2010-06-07Merge branch 'maint' into nextTheodore Ts'o1-2/+2
Conflicts: e2fsck/journal.c e2fsck/pass1.c e2fsck/pass2.c misc/mke2fs.c
2010-05-17libe2p, libext2fs: Update file copyright permission states to match COPYINGTheodore Ts'o1-2/+2
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>
2009-06-01Use blk64_t for blocks in struct ext2_fileJose R. Santos1-6/+6
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>
2008-08-27Remove trailing whitespace for the entire source treeTheodore Ts'o1-17/+17
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-12-05libext2fs: Add checks to prevent integer overflows passed to malloc()Theodore Ts'o1-1/+1
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>
2003-08-21Add support for backing up the journal inode location in the Theodore Ts'o1-9/+22
superblock. E2fsck will automatically save the journal information in the superblock if it is not there already, and will use it if the journal inode appears to be corrupted. ext2fs_add_journal_inode() will also save the backup information, so that new filesystems created by mke2fs and filesystems that have journals added via tune2fs will also have journal location written to the superblock as well. Debugfs's logdump command has been enhanced so that it can use the journal information in the superblock. The debugfs man page has been improved to more fully describe the logdump command. Added two new functions, ext2fs_file_open2() and ext2fs_inode_io_intern2() which take a pointer to an inode structure; this is needed so that e2fsck and debugfs can synthesize a fake journal inode and use it to access the journal.
2003-08-01ext2fs_getmem(), ext2fs_free_mem(), and ext2fs_resize_mem() Theodore Ts'o1-6/+6
all now take a 'void *' instead of a 'void **' in order to avoid pointer aliasing problems with GCC 3.x.
2003-03-10fileio.c (ext2fs_file_lseek): Fix bug added when adding 64-bitTheodore Ts'o1-1/+2
support; avoid null dereference when ret_pos is NULL.
2003-01-22Remove 32-bit limitations for debugfs's dump command and to the Theodore Ts'o1-9/+39
ext2fs library's ext2fs_file_read.
2002-03-07Fix various gcc -Wall complaints.Theodore Ts'o1-1/+1
2002-02-20Add new inode I/O abstraction interface which exports an inode asTheodore Ts'o1-2/+2
an I/O object. Export ext2_file_flush as a public interface. Also minor cleanups to tighten code in other I/O abstractions, and to mark a void * pointer as const in the ext2_file_write interface.
2001-12-16Fix various gcc -Wall nits. Fixed a bug in mke2fs where a bogusTheodore Ts'o1-2/+0
error message could be printed on an malloc() failure, and e2image was optimized to avoid needless system calls by using the stashed inode functions.
2001-05-14Many files:Theodore Ts'o1-5/+0
alloc.c, alloc_tables.c, badblocks.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, ext2_fs.h, fileio.c, finddev.c, flushb.c, freefs.c, get_pathname.c, getsize.c, icount.c, imager.c, initialize.c, inline.c, inode.c, irel_ma.c, ismounted.c, link.c, lookup.c, mkdir.c, mkjournal.c, namei.c, native.c, newdir.c, nt_io.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_byteswap.c, tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c, version.c, write_bb_file.c, ext2_fs.h: Moved file from include/linux. Adjust all files in this directroy to include this file.
2001-05-05ChangeLog, fileio.c:Theodore Ts'o1-91/+107
fileio.c (ext2fs_file_read): Factored out common code and cleaned up function. Fixed a bug where if there was an error reading from the disk, the number of bytes read wasn't reliably set. (Fixes Debian bug #79163) (ext2fs_file_write): Factored out common code and made function more efficient; if writing a full block, don't bother to do a read-modify-write cycle.
2001-01-11Many files:Theodore Ts'o1-2/+2
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.
1999-05-29ChangeLog, fileio.c:Theodore Ts'o1-4/+1
fileio.c (ext2fs_file_open): Remove obsolete comment stating that we don't handle writing yet (we do). Fixed bug where we weren't allocating a big enough buffer for ext2_bmap. ChangeLog, ext2fs.h: ext2fs.h: Add feature definition for AFS IMAGIC inodes. ChangeLog, MCONFIG.in, config.sub: MCONFIG.in: Define man1dir, man3dir, and man8dir in terms of mandir. config.sub: Update config.sub from autoconf 2.13 so that it will recognize new machine types from the Alpha. configure: Update to match latest changes to configure.in
1998-09-03Many files:Theodore Ts'o1-1/+1
rw_bitmaps.c: Fixed signed/unsigned warnings. fileio.c (ext2fs_file_set_size): Remove unneeded extern from the function declaration. dblist.c (make_dblist): Add safety check in case the dblist pointer passed in is null (in which case, assign it to fs->dblist). Fixed some signed/unsigned warnings. bmap.c: Make addr_per_block be of type blk_t to avoid signed/unsigned warnings. namei.c (ext2fs_follow_link): Remove uneeded extern from the function declaration. get_pathname.c (get_pathname_proc): Use return value from ext2fs_get_mem, instead of checking if &gp->name is NULL. dir_iterate.c (ext2fs_process_dir_block): dblist_dir.c (ext2fs_dblist_dir_iterate): Remove uneeded extern from the function declaration. block.c (ext2fs_block_iterate2): If the read_inode call fails, return the error directly instead of jumping to the cleanup routine, since we don't need to do any cleanup. alloc_table.c (ext2fs_allocate_group_table): Make this function take a dgrp_t for its group argument. ext2fs.h: Make dgrp_t an __u32 type, and make fs->desc_group_count be of type dgrp_t.
1998-03-23Many files:Theodore Ts'o1-2/+2
ext2fs.h: Add new superblock fields (s_algorithm_usage_bitmap, s_prealloc_blocks, s_prealloc_dir_blocks). Added conditional defines of new features COMPAT_DIR_PREALLOC, RO_COMPAT_LARGE_FILE RO_COMPAT_BTREE_DIR, INCOMPAT_COMPRESSION, INCOMPAT_DIRNAME_SIZE. Changed the library to declare that we support COMPAT_DIR_PREALLOC, INCOMPAT_DIRNAME_SIZE, RO_COMPAT_LARGE_FILE. fileio.c: Rename function ext2fs_file_llseek to be ext2fs_file_lseek, which is more accurate. block.c: Add new function ext2fs_block_iterate3 which calls the iterator function with the blockcount argument of type blkcnt_t. This version of the function is allowed to handle large files; the other fucntions are not. ext2fs.h: Add new type blkcnt_t ext2_err.et.in: Add error code EXT2_ET_FILE_TOO_BIG block.c (ext2fs_block_iterate2): Fix bug where the block count field wasn't getting correctly incremented for sparse files when the indirect or doubly-indirect block specified in the inode was zero. unlink.c (unlink_proc): lookup.c (lookup_proc): link.c (link_proc): get_pathname.c (get_pathname_proc): dir_iterate.c (ext2fs_process_dir_block): Mask off high 8 bits from dirent->name_len, so it can be used for other purposes. ext2fs.h: Add definition of EXT2_FEATURE_INCOMPAT_DIRNAME_SIZE, and indicate that we have support for this incompatible option.
1998-01-19Many files:Theodore Ts'o1-2/+6
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)
1997-12-01Many files:Theodore Ts'o1-1/+0
dblist.c (ext2fs_get_num_dirs): Make ext2fs_get_num_dirs more paranoid about validating the directory counts from the block group information. all files: Don't include stdlib.h anymore; include it in ext2_fs.h, since that file requires stdlib.h ChangeLog, Makefile.in, dirinfo.c: dirinfo.c (e2fsck_add_dir_info): Use ext2fs_get_num_dirs instead of e2fsck_get_num_dirs, which has been removed. Makefile.in (PROGS): Remove @EXTRA_PROGS@, since we don't want to compile and install flushb. ChangeLog, configure.in: Remove @EXTRA_PROGS@, since we aren't using it in 2fsck/Makefile.in anymore ChangeLog, Makefile.in: Install debugfs in /sbin, instead of /usr/sbin. libext2fs.texinfo: Update version string to be 1.12 Makefile.in: Fix bug in find script which made the exclusion list, where a '-' was missing from an -name option.
1997-11-03ChangeLog, bitops.c, ext2fs.h, fileio.c:Theodore Ts'o1-4/+44
ext2fs.h: Make ext2fs_get_mem take an unsigned argument. fileio.c (ext2fs_file_get_size, ext2fs_file_set_size, ext2fs_file_get_fs): New functions added. bitops.c (ext2fs_warn_bitmap, ext2fs_warn_bitmap2): Don't call com_err if OMIT_COM_ERR is defined.
1997-10-31Many files:Theodore Ts'o1-2/+2
Rename new error codes to have _ET_ in them for consistency.
1997-10-26Many files:Theodore Ts'o1-11/+9
Added definition of ext2fs_get_mem, ext2fs_free_mem, and ext2fs_resize_mem in ext2fs.h, and changed all library routines to use these wrapper functions.
1997-10-25Many files:Theodore Ts'o1-0/+287
ext2fs.h: Added function declarations and constants for bmap.c and fileio.c. ext2_err.et.in: Added new error messages EXT2_FILE_RO and EXT2_ET_MAGIC_EXT2_FILE Makefile.in: Added files bmap.c and fileio.c, and temporarily commented out brel_ma.c and irel_ma.c bmap.c: New file which maps a file's logical block number to its physical block number. fileio.c: New file which implements simple file reading and writing primitives. alloc.c (ext2fs_alloc_block): New function which allocates a block, zeros it, and updates the filesystem accounting records appropriately.