summaryrefslogtreecommitdiff
path: root/lib/ext2fs
AgeCommit message (Collapse)AuthorFilesLines
2011-06-04libext2fs: change EXT2_MAX_BLOCKS_PER_GROUP() to be cluster size awareTheodore Ts'o1-1/+5
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>
2011-06-04libext2fs: require cluster size == block_size when opening a !bigalloc fsTheodore Ts'o1-0/+6
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>
2011-05-18e2image: Add support for qcow2 formatLukas Czerner5-14/+377
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>
2011-05-18e2fsprogs: Add memory allocation and zero-out helpersLukas Czerner1-1/+27
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>
2011-05-14mke2fs: make s_inodes_per_group >= 8 in ext2fs_initializeTao Ma1-0/+2
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>
2011-05-08e2fsprogs: fix memory leak in ext2fs_free_generic_bmap()Lukas Czerner1-0/+1
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>
2011-05-08e2fsprogs: fix freeing bitmap in allocation error pathLukas Czerner1-1/+1
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>
2011-03-18Merge branch 'maint' into nextTheodore Ts'o2-2/+4
Conflicts: lib/e2p/ls.c
2011-03-18add new superblock field: s_overhead_blocksTheodore Ts'o2-2/+4
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>
2011-02-27mke2fs: If the device supports discard, don't print an error messageTheodore Ts'o1-0/+3
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>
2011-02-27Merge branch 'maint' into nextTheodore Ts'o6-31/+32
Conflicts: lib/ext2fs/initialize.c
2011-02-25Add basic BIGALLOC support for cluster-based allocationTheodore Ts'o6-28/+22
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>
2011-02-25e2fsprogs: reserving code points for new ext4 quota featureAditya Kali3-3/+10
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>
2011-02-20Merge branch 'maint' into nextTheodore Ts'o1-15/+3
Conflicts: misc/mke2fs.conf.5.in
2011-02-20e2fsprogs: enable user namespace xattrs by defaultEric Sandeen1-0/+1
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>
2011-02-20e2fsprogs: turn off enforced fsck intervals by defaultEric Sandeen1-15/+2
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>
2010-12-22Merge branch 'maint' into nextTheodore Ts'o1-1/+3
Conflicts: resize/resize2fs.c
2010-12-22libext2fs: Don't use the extended rec_len encoding for standard file systemsTheodore Ts'o1-1/+3
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>
2010-12-22libext2fs: fix possible memory leak in write_journal_inode()Namhyung Kim1-0/+1
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>
2010-12-21ext2fs: fix memory leak in an error case in inode_open()Theodore Ts'o1-2/+3
Reported-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-20libext2fs: fix potential free() of garbage in ext2fs_update_bb_inode()Theodore Ts'o1-2/+1
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>
2010-12-20libext2fs: fix dubious code in ext2fs_unmark_generic_bitmap()Namhyung Kim1-1/+1
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>
2010-12-20libext2fs: remove unnecessary casts to ext2fs_generic_bitmapNamhyung Kim1-49/+30
Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20libext2fs: fix dubious code in ext2fs_numeric_progress_init()Namhyung Kim1-1/+1
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>
2010-12-20libext2fs: fix potential build failure with OMIT_COM_ERRNamhyung Kim1-6/+6
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>
2010-12-20Merge branch 'maint' into nextTheodore Ts'o3-6/+10
Conflicts: lib/ext2fs/block.c lib/ext2fs/csum.c resize/main.c
2010-12-16libext2fs: Fix compile bug on big-endian architecturesTheodore Ts'o1-1/+1
Addresses-Sourceforge-Bug: #3138115 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-16libext2fs: fix ref_offset callback with sparse files in ext2fs_block_iterate2()Theodore Ts'o1-1/+2
Addresses-Sourceforge-Bug: 3081087 Reported-by: vmo@users.sourceforge.net Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-16e2fsprogs: fix type-punning warningsEric Sandeen2-5/+8
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>
2010-11-22e2fsck: Discard free data and inode blocks.Lukas Czerner1-1/+2
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>
2010-11-22e2fsprogs: Add CHANNEL_FLAGS_DISCARD_ZEROES flag for io_managerLukas Czerner2-1/+16
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>
2010-11-22e2fsprogs: Add discard function into struct_io_managerLukas Czerner4-1/+66
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>
2010-11-22Fix EXT4_FEATURE_RO_COMPAT_HUGE_FILE checkJustin Maggard1-2/+2
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>
2010-09-24Merge branch 'maint' into nextTheodore Ts'o9-94/+186
Conflicts: configure configure.in lib/ext2fs/ext2fs.h misc/mke2fs.c
2010-09-24libext2fs: Change EXT2_FLAG_DIRECT_IO to avoid conflict with devel branchTheodore Ts'o1-1/+1
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>
2010-09-24ext2fs: Optimize for Direct I/OTheodore Ts'o3-8/+14
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>
2010-09-24ext2fs: Add Direct I/O support to the ext2fs libraryTheodore Ts'o5-83/+144
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>
2010-09-23libext2fs: Fix memory leak in the Unix I/O layer when changing block sizeTheodore Ts'o1-0/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-23ext2fs: add ext2fs_get_memalign() functionTheodore Ts'o1-1/+18
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-18tune2fs, debugfs, libext2fs: Add support for ext4 default mount optionsTheodore Ts'o2-2/+8
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>
2010-07-30libext2fs: fix obvious big-endian bugs introduced by 64-bit changesTheodore Ts'o2-5/+8
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>
2010-07-30libext2fs: Add ext2fs_file_size_size2() and truncate the file if necessaryTheodore Ts'o2-8/+23
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 Davoli2-0/+11
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-07-22libext2fs: Add new function ext2fs_punch()Theodore Ts'o3-6/+356
This function deallocates a range of blocks from a passed-in file. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-22libext2fs: Don't make a copy of the inode in ext2fs_extent_open2()Theodore Ts'o1-9/+4
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>
2010-07-21libext2fs: Fix ext2fs_iblk_{add,sub}_blocks() when the i_blocks_hi is non-zeroTheodore Ts'o1-8/+9
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-20tst_extents: Fix 64-bit bugs in do_goto_block()Theodore Ts'o1-6/+8
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-19Merge branch 'maint' into nextTheodore Ts'o4-5/+149
Conflicts: resize/extent.c
2010-07-05Enhance tst_super_size so that it checks the superblock fields as wellTheodore Ts'o1-3/+116
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>
2010-07-05Add superblock fields which track first and most recent fs errorsTheodore Ts'o1-1/+22
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>