summaryrefslogtreecommitdiff
path: root/lib/ext2fs/alloc.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-07libext2fs: don't hang in ext2fs_new_block2() on a full bigalloc file systemTheodore Ts'o1-0/+2
Prevent ext2fs_new_block2() from looping forever when a bigalloc file system is full. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-15misc: quiet "unused variable" compiler warningsAndreas Dilger1-1/+1
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>
2011-06-15libext2fs: fix regression in ext2fs_new_block2() for uninit_bg file systemsTheodore Ts'o1-0/+2
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>
2011-06-10libext2fs: teach block allocation functions about bigalloc/clustersTheodore Ts'o1-5/+12
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>
2010-06-07Merge branch 'maint' into nextTheodore Ts'o1-3/+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-3/+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-10-25Convert to use block group accessor functionsValerie Aurora Henson1-4/+4
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>
2009-10-25libext2fs: Convert ext2fs_bg_flag_test() to ext2fs_bg_flags_test()Theodore Ts'o1-2/+2
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>
2009-10-25libext2fs: clean up ext2fs_bg_flags_ interfacesEric Sandeen1-2/+2
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>
2009-09-07Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()Valerie Aurora Henson1-3/+3
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>
2009-09-07Use accessor functions fields for bg_flags in the block group descriptorsTheodore Ts'o1-4/+4
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>
2009-08-05Convert libext2fs to 64-bit bitmap interfaceValerie Aurora Henson1-12/+8
(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>
2009-07-11Use new ext2fs_super_and_bgd_loc2 call in libext2fsJose R. Santos1-3/+3
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>
2009-06-01Add 64-bit alloc interfaceJose R. Santos1-18/+52
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>
2009-01-22ext2fs_new_inode(): Add sanity check to assure a valid inode numberTheodore Ts'o1-0/+2
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>
2008-11-16Fix various signed/unsigned gcc warningsTheodore Ts'o1-5/+4
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>
2008-08-27Remove trailing whitespace for the entire source treeTheodore Ts'o1-8/+8
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-22libext2fs: Add support for uninit_bg feature to allocation functionsTheodore Ts'o1-0/+81
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>
2008-06-02libext2fs: Add callback functions for _alloc_block() and _block_alloc_stats()Theodore Ts'o1-6/+31
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>
2008-02-19Fix memory leak in ext2fs_alloc_block()Theodore Ts'o1-1/+0
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>
2003-12-07Fix gcc -Wall nitpicksTheodore Ts'o1-1/+2
2003-08-01ext2fs_getmem(), ext2fs_free_mem(), and ext2fs_resize_mem() Theodore Ts'o1-2/+2
all now take a 'void *' instead of a 'void **' in order to avoid pointer aliasing problems with GCC 3.x.
2002-01-03dir_iterate.c (ext2fs_dir_iterate2, ext2fs_process_dir_block):Theodore Ts'o1-7/+1
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.
2001-08-05Performance enhancements to speed up creating a journal and Theodore Ts'o1-2/+2
block and inode allocation in general.
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-01-11Many files:Theodore Ts'o1-5/+5
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.
1998-01-19Many files:Theodore Ts'o1-0/+4
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-10-31Many files:Theodore Ts'o1-3/+3
Rename new error codes to have _ET_ in them for consistency.
1997-10-26Many files:Theodore Ts'o1-4/+4
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-11/+35
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.
1997-10-25Many files:Theodore Ts'o1-6/+29
alloc.c (ext2fs_alloc_block): New function which allocates a block and updates the filesystem accounting records appropriately. ext2_err.et.in: Added new error codes: EXT2_NO_MEMORY, EXT2_INVALID_ARGUMENT, EXT2_BLOCK_ALLOC_FAIL, EXT2_INODE_ALLOC_FAIL, EXT2_NOT_DIRECTORY Change various library files to use these functions instead of EINVAL, ENOENT, etc. ChangeLog, pass1.c, pass3.c: pass3.c (get_lost_and_found): Check error return of EXT2_FILE_NOT_FOUND instead of ENOTDIR pass1.c (pass1_check_directory): Return EXT2_NO_DIRECTORY instead of ENOTDIR expect.icount: Change expected error string to be "Invalid argument passed to ext2 library" instead of just "Invalid argument"
1997-10-19Many files:Theodore Ts'o1-0/+4
Add #ifdef's for HAVE_SYS_STAT_H and HAVE_SYS_TYPES_H
1997-08-10Many files:Theodore Ts'o1-1/+3
block.c (ext2fs_block_iterate2): Use retval which is a errcode_t type. bitmaps.c (make_bitmap): Use size_t instead of int where appropriate. bb_inode.c (set_bad_block_proc): Add #pragma argsused for Turbo C. alloc.c (ext2fs_new_inode): Use ino_t instead of int for the group number. get_pathname.c: Use ino_t instead of int where appropriate. ext2fs.h: Make the magic structure element be errcode_t instead of int. alloc.c alloc_tables.c badblocks.c bb_compat.c bb_inode.c bitmaps.c block.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 freefs.c get_pathname.c icount.c initialize.c inline.c inode.c irel_ma.c link.c llseek.c lookup.c mkdir.c namei.c newdir.c read_bb.c read_bb_file.c rs_bitmap.c rw_bitmaps.c swapfs.c test_io.c tst_badblocks.c tst_iscan.c unix_io.c unlink.c valid_blk.c version.c: Add an #ifdef for HAVE_UNISTD_H
1997-04-29Many files:Theodore Ts'o1-3/+4
Checkin of e2fsprogs 1.10
1997-04-29Many files:Theodore Ts'o1-20/+11
Checked in e2fsprogs-1.07
1997-04-26Many files:Theodore Ts'o1-3/+3
Checkin of e2fsprogs 1.03.
1997-04-26Many files:Theodore Ts'o1-2/+5
Checked in e2fsprogs 0.5c
1997-04-26Many files:Theodore Ts'o1-10/+17
Checkin of e2fsprogs 0.5b
1997-04-26Many files:Theodore Ts'o1-0/+125
Checkin of e2fsprogs 0.5b