summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2012-01-17libext2fs: display partial path if fs corrupted in ext2fs_get_pathname()Theodore Ts'o1-5/+16
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>
2012-01-09libext2fs: change getpagesize to sysconfMike Frysinger1-5/+1
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>
2011-12-18libext2fs: add bitmap statisticsLukas Czerner6-8/+265
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>
2011-12-18libext2fs: adjust the description when copying a bitmapTheodore Ts'o1-2/+2
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>
2011-12-18e2fsck: use different bitmap types as appropriateTheodore Ts'o1-1/+0
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>
2011-12-18libext2fs: use the rbtree bitmap by default when initializing a file systemTheodore Ts'o1-0/+1
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>
2011-12-18libext2fs: add pseudo bitmap backend type EXT2FS_BMAP64_AUTODIRTheodore Ts'o3-0/+12
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>
2011-12-18libext2fs: add a bitmap implementation using rbtree'sLukas Czerner5-5/+760
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>
2011-12-18libext2fs: add rbtree libraryLukas Czerner3-2/+640
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>
2011-12-18libext2fs: add tests for the bitmap functionsTheodore Ts'o5-1/+770
These tests allow us to be sure that the new bitmap backends are correctly implemented. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18libext2fs: add default_bitmap_type to the ext2_filsys structureTheodore Ts'o4-10/+19
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-05libext2fs: don't break when ext2fs_clear_generic_bmap() for 32-bit bitmapsTheodore Ts'o1-2/+2
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>
2011-11-29Update Release Notes, Changelogs, version.h, etc. for 1.42 releaseTheodore Ts'o3-24/+47
Also fixed depfix.sed Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-29e2fsck: speed up runs when using tdb for large atypical filesystemsTheodore Ts'o2-5/+16
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>
2011-11-28configure: check for msync() for portability reasonsTheodore Ts'o1-1/+1
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>
2011-11-27libquota: remove use of PATH_MAX and replace it with QUOTA_NAME_LENTheodore Ts'o3-7/+10
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>
2011-11-25libext2fs: move mmp fields to preserve structure layout of ext2_filsysTheodore Ts'o1-7/+7
This helps provide better ABI compatibility for e2fsprogs 1.42. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-25tst_fs_struct: add program to help check ABI compatibility of ext2fs_filsysTheodore Ts'o2-0/+87
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-19libext2fs: enforce a max nested link count in ext2fs_find_block_device()Niu Yawei3-2/+10
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-18debugfs: add filefrag commandTheodore Ts'o1-1/+5
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>
2011-11-18debugfs: add the freefrag commandTheodore Ts'o1-1/+6
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>
2011-11-14libquota: log an error message if ext2fs_file_open() failsTheodore Ts'o1-1/+1
This also fixes a format string type compiler warning. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-14libquota: fix get_dq()Niu Yawei1-0/+1
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>
2011-11-14libquota: fix quota usage computeNiu1-2/+1
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>
2011-11-14libquota: quota file read supportNiu7-18/+179
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>
2011-11-14libquota: cleanup libquota codeAditya Kali9-209/+236
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>
2011-11-14Make quota support disabled by supportTheodore Ts'o2-0/+13
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>
2011-11-11libext2fs: fix write size in ext2fs_mmp_writeEric Sandeen1-1/+1
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>
2011-11-10libext2fs: use HAVE_FSTAT64 instead of HAVE_STAT64 for ext2fs_stat()Theodore Ts'o1-3/+3
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>
2011-11-10libext2: advance group in ext2fs_open2 during swappingEric Sandeen1-2/+2
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>
2011-11-05libext2fs: don't leak tdb_null out of the shared library namespaceTheodore Ts'o2-4/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-16libext2fs: allow ext2fs_get_memalign() to compile w/o posix_memalign()Theodore Ts'o2-16/+35
Addresses-Sourceforge-Bug: #3219173 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-16libext2fs: ext2fs_[set_]file_acl_block needs to check for 64-bit feature flagTheodore Ts'o5-15/+25
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>
2011-10-09Fix more spelling errors found by translators and add pluralizationTheodore Ts'o1-2/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-06libext2fs: make ext2fs_open_file() always use 3 arguments instead of varargsTheodore Ts'o4-11/+6
Some architectures have narrow mode_t's which can cause some portability warnings with varargs. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-05libquota: remove flag argument to commit_dquot()Theodore Ts'o3-11/+4
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>
2011-10-05libcom_err: declare com_err_gettext to be staticTheodore Ts'o1-1/+1
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-05Update for e2fsprogs 1.42-WIP-1005 releaseTheodore Ts'o1-5/+1
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-05libcom_err: add set_com_err_gettext()Theodore Ts'o2-2/+25
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>
2011-10-05compile_et: generate *_err.c files that have strings marked for xgettextTheodore Ts'o7-209/+223
This allows error code strings to be internationalized. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-04libquota: remove NLS supportTheodore Ts'o1-26/+4
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>
2011-10-04libquota: use ext2_loff_t instead of loff_tTheodore Ts'o3-12/+16
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>
2011-10-04libquota: remove get_qf_name()Theodore Ts'o3-19/+4
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>
2011-10-04libquota: clean up some gcc -Wall warningsTheodore Ts'o7-61/+25
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>
2011-10-04libquota: remove get_qf_path()Theodore Ts'o2-20/+0
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>
2011-10-03libext2fs: fix bad cast which causes problems for file systems > 512EBTheodore Ts'o1-1/+1
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>
2011-10-03e2fsprogs: Fix thinko in ext2fs_initialize bigalloc caseEric Sandeen1-1/+1
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>
2011-10-03libext2fs: move #include "ext2fs.h" from crc32c_defs.h to crc32c.cTheodore Ts'o2-17/+17
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>
2011-10-03libext2fs, libquota: fix some makefile dependency issuesTheodore Ts'o2-9/+18
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-03e2fsprogs: include headers for open() in ext2fs.hEric Sandeen1-0/+3
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>