mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-11-27 12:04:43 +08:00
debugfs: fix mknod command on some 32-bit platforms due to LFS
On some platforms the layout of struct stat changes if _FILE_OFFSET_BITS is set to 64 (which force the use of 64-bit types and 64-bit variants for system calls such as stat, lseek, etc.) This is not true (mercifully) on i386, but it is true for the 32-bit mips platform on Linux. This caused debugfs's mknod command to fail, since it used struct stat to pass the desired st_mode and st_rdev fields for the to-be-created device file or FIFO, and this would be different for create_inode.c and debugfs.c. Linking together different object files together compiled with different values of _FILE_OFFSET_BITS is perilous, but for now, let's fix the specific problem by passing the two fields in the stat structure that we really care about. This fixes two regression tests on the 32-bit MIPS platform: d_special_files and r_move_itable. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
ae3a1d571b
commit
47e6105264
@ -1767,7 +1767,8 @@ void do_mknod(int argc, char *argv[])
|
||||
goto usage;
|
||||
|
||||
st.st_rdev = makedev(major, minor);
|
||||
retval = do_mknod_internal(current_fs, cwd, argv[1], &st);
|
||||
retval = do_mknod_internal(current_fs, cwd, argv[1],
|
||||
st.st_mode, st.st_rdev);
|
||||
if (retval)
|
||||
com_err(argv[0], retval, 0);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ static errcode_t set_inode_xattr(ext2_filsys fs EXT2FS_ATTR((unused)),
|
||||
#ifndef _WIN32
|
||||
/* Make a special files (block and character devices), fifo's, and sockets */
|
||||
errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd, const char *name,
|
||||
struct stat *st)
|
||||
unsigned int st_mode, unsigned int st_rdev)
|
||||
{
|
||||
ext2_ino_t ino;
|
||||
errcode_t retval;
|
||||
@ -243,7 +243,7 @@ errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd, const char *name,
|
||||
unsigned long devmajor, devminor, mode;
|
||||
int filetype;
|
||||
|
||||
switch(st->st_mode & S_IFMT) {
|
||||
switch(st_mode & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
mode = LINUX_S_IFCHR;
|
||||
filetype = EXT2_FT_CHRDEV;
|
||||
@ -299,8 +299,8 @@ errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd, const char *name,
|
||||
fs->now ? fs->now : time(0);
|
||||
|
||||
if (filetype != S_IFIFO) {
|
||||
devmajor = major(st->st_rdev);
|
||||
devminor = minor(st->st_rdev);
|
||||
devmajor = major(st_rdev);
|
||||
devminor = minor(st_rdev);
|
||||
|
||||
if ((devmajor < 256) && (devminor < 256)) {
|
||||
inode.i_block[0] = devmajor * 256 + devminor;
|
||||
@ -798,7 +798,8 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
|
||||
case S_IFIFO:
|
||||
#ifndef _WIN32
|
||||
case S_IFSOCK:
|
||||
retval = do_mknod_internal(fs, parent_ino, name, &st);
|
||||
retval = do_mknod_internal(fs, parent_ino, name,
|
||||
st.st_mode, st.st_rdev);
|
||||
if (retval) {
|
||||
com_err(__func__, retval,
|
||||
_("while creating special file "
|
||||
|
@ -40,7 +40,8 @@ extern errcode_t populate_fs2(ext2_filsys fs, ext2_ino_t parent_ino,
|
||||
const char *source_dir, ext2_ino_t root,
|
||||
struct fs_ops_callbacks *fs_callbacks);
|
||||
extern errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd,
|
||||
const char *name, struct stat *st);
|
||||
const char *name, unsigned int st_mode,
|
||||
unsigned int st_rdev);
|
||||
extern errcode_t do_symlink_internal(ext2_filsys fs, ext2_ino_t cwd,
|
||||
const char *name, char *target,
|
||||
ext2_ino_t root);
|
||||
|
Loading…
Reference in New Issue
Block a user