When a nonprivileged user uses the blkid command, we want to keep the
cached filesystem information, and opening a device file could result
in an EACCESS or ENOENT (if an intervening directory is mode 700). We
were previously testing for EPERM, which was really the wrong error
code to be testing against.
Addresses-Launchpad-Bug: #220275
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Thanks to Max Lindner (lokimuh) for pointing this out.
I'm playing around a bit with ext2 and multi-user encryption and I
need space for my key management. So I set s_first_data_block to 4000
or something like that.
This way mke2fs segfaults when executing
ext2fs_create_resize_inode() because
blk_t goal = 3 + sb->s_reserved_gdt_blocks + fs->desc_blocks +
fs->inode_blocks_per_group;
will produce a integer underrun later and segfault then in the
ext2fs_test_bit assembler inline function.
when exchanging 3 with 2 + sb->s_first_data_block, mke2fs does not
segfault.
I'm not 100% sure if thats the correct way dealing with this issue
but I think its a proper solution.
Addresses-Sourceforge-Bug: #1935847
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
No application will ever use the ORPHAN_FS flag, since it only shows
up in kernel memory, but it's been pointed out it was first used in
ext3, and so it should be renamed for accuracy.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
After the fix for resize2fs's inode mover losing in-inode
extended attributes, the regression test I wrote caught
that the attrs were still getting lost on powerpc.
Looks like the problem is that ext2fs_swap_inode_full()
isn't paying attention to whether or not the EA magic is
in hostorder, so it's not recognized (and not swapped)
on BE machines. Patch below seems to fix it.
Yay for regression tests. ;)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add two new functions which allows the caller to examine the last
directory block entry added to the list, and to drop if it necessary.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If a device mapper volume disappears while libblkid code is running,
it is possible for the devicemapper code to return errors, and since
libblkid wasn't checking for error returns, it would dereference a
null pointer and crash. Add error checking to prevent this.
Addresses-RedHat-Bugzilla: #433857
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add a flag which returns the partially completed filesystem object so
e2fsck can print more intelligent error messages.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This creates a new enhanced edit_feature function for libe2p which
supports a different set of feature flags that are OK to clear as
opposed to set, and which returns more specific information about why
the user provided an invalid edit feature command.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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>
This is useful for mballoc to align block allocation on the RAID
stripe boundaries.
Signed-off-by: Rupesh Thakare <rupesh@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The major changes were:
* Fix realloc() leak on failure case from Jim Meyering
* Fixed various problems in transaction lock code
* Made transaction_brlock() static
* Added more fine-grained locking features
Moved from svn revision #22080 to #23590
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
DJGPP lacks sys/select.h and sys/un.h; add header checks to be more
portable.
Signed-off-by: Christophe Grenier <grenier@cgsecurity.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cygwin doesn't support lockf(), so move to fcntl() locking as more
portable. Also fix a bug which could cause get_lock() to loop forever
if the attempt to lock the file fails for some reason.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Address the theoretical problem of two threads trying to format a
different unknown error code by using TLS.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
USB devices can return ENOMEDIUM, and when the filesystem cached
information wasn't flushed, it resulted in the wrong location of a
filesystem to be returned to the caller. The only justification for
using cached information when the open fails is in the case of a
permission denied error.
Addresses-Debian-Bug: #463787
Add logic that on Linux systems will check for the presence of the
ext4dev filesystem; if it isn't present, fall back to ext4 for
filesystems that are marked as being "OK for use on test filesystem
code". If they are OK for use for in-development filesystem code, it
should also be fine to use stable filesystem code if there is no test
filesystem code (ext4dev) available.
The reverse is not true, of course. We don't ever want to mount a
production filesystem using test filesystem code unless the user gives
us explicit permission via "tune2fs -E test_fs".
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Previously we used a hard-coded test where for the Alpha and the IA64,
we used lseek instead of llseek(). Generalize this to whenver
sizeof(long) is the same as sizeof(long long).
It turns out this fixes a FTBFS problem on the x86_64 for Debian,
since dietlibc doesn't provide llseek() on that architecture.
Addresses-Debian-Bug: #459614
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The test_fs flag is an "ok to be used with test kernel code" flag. It
makes it easier for us to determine whether a filesystem should be
mounted using ext4 or not.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Ensure the length of the UUID is always the same
without the patch:
% blkid /tmp/a /tmp/b
/tmp/a: UUID="7130E4771519577F" TYPE="ntfs"
/tmp/b: UUID="7E9B4A7CCE99CA" TYPE="ntfs"
with the patch:
% blkid /tmp/a /tmp/b
/tmp/a: UUID="7130E4771519577F" TYPE="ntfs"
/tmp/b: UUID="007E9B4A7CCE99CA" TYPE="ntfs"
ie same as:
% vol_id --uuid /tmp/a ; vol_id --uuid /tmp/b
7130E4771519577F
007E9B4A7CCE99CA
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Approximately two years ago a revamp of the e2fsprogs build
infrastructure broke the Makefile fragments for building BSD, Solaris,
and Darwin shared libraries, as well as profiling and checker
libraries. Apparently no one had noticed except for
pierre42@users.sourceforge.net.
Addresses-Sourceforge-Bug: #1819034
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When compiling with diet libc, <sys/types.h> must be included in order
to define the types used in asm/types.h. Strange choice, but
workable. This doesn't cause much problems for e2fsprogs except
blkid/tst_types.h, which needed a #include of <sys/types.h>.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When compiling with dietlibc, sys/syscall.h isn't supported; as of
dietlibc 0.30, it exists but it references a non-existent asm/unistd.h
header file. So we have to test for its existence and avoid using it
in lib/uuid/gen_uuid.c if it is not supported.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add a configure option which causes the uuidd helper daemon not to be
built or used by the uuid library.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
inode_uid() and inode_gid() weren't getting defined on systems that
were not Linux, Hurd, or Masix.
Addresses-Sourceforge-Bug: #1859778
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add some additional checks, primarily in resize2fs and in the rarely
used (and soon to-be-deprecated) e2fsck byte-swap filesystem function.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If we fail to create the uuidd daemon after 5 or 6 tries, another
10,000 tries probably won't be successful.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The uuidd process will fork and let the parent process exit to create
the daemon. So use waitpid to reap the zombie, as well as using it to
time when it is safe to try to connect to the daemon.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/var/run can get completely removed at reboot, and uuidd doesn't have
permissions to recreate /var/run/uuidd. So instead use
/var/lib/libuuidd for the unix domain socket and pid files.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Also store the clock sequence information in a state file in
/var/lib/misc/uuid-clock so that if the time goes backwards the clock
sequence counter can get bumped. This allows us to completely
correctly generate time-based (version 1) UUID's according to the
algorithm specified RFC 4122.
Addresses-Sourceforge-Bug: #1529672
Addresses-Red-Hat-Bugzilla: #233471
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
On 64-bit systems (or anything with sizeof(long) > sizeof(int)), we
sometimes get error codes passed to error_message which have been cast
from an (int) to an (unsigned int). This almost always happens if
you're using libgssapi_krb5, which returns an error code which is less
than 0 but is returned in an (unsigned int).
For example, -1765328377L gets cast to 2529638919, which is
0x96c73a07, not 0xffffffff96c73a07, so error_message() fails to find a
matching error table.
When error_message() then calls the error_table_name() function to get a
name to use in the "unknown code" message, it gets a correct value back.
This happens because error_table_name() drops most of the higher bits of
the parameter it's passed before doing anything else with it (& 077777777f,
or & 0xffffff). If we did the same thing in error_message(), we wouldn't
have a problem there, either.
Problem reported and fixed by: Nalin Dahyabhai
Addresses-Sourceforge-Bug: #1809658
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The "make check" test in lib/ss would fail if '.' is not in the user's
PATH, and if the libss shared library had not yet been installed yet.
Addresses-Sourceforge-Bug: #1848974
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>