* [PATCH 1/6] blkid: fix ZFS device detection @ 2016-03-06 0:38 Andreas Dilger 2016-03-06 0:38 ` [PATCH 2/6] debugfs: improve dump_mmp handling Andreas Dilger ` (5 more replies) 0 siblings, 6 replies; 12+ messages in thread From: Andreas Dilger @ 2016-03-06 0:38 UTC (permalink / raw) To: tytso; +Cc: linux-ext4, Andreas Dilger From: Andreas Dilger <andreas.dilger@intel.com> While the main blkid functionality is in util-linux, there is still use for blkid on non-Linux platforms. Fix the ZFS device detection by looking at multiple uberblocks to see if any are present, rather than looking for the ZFS boot block which is not always present. There are slots for up to 128 uberblocks, but the first 4 are not written to disk on a newly-formatted filesystem, so check several of them at different offsets within the uberblock array. Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> --- lib/blkid/probe.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 4b797ab..161f4f1 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -1440,10 +1440,19 @@ static struct blkid_magic type_array[] = { { "iso9660", 32, 1, 5, "CD001", probe_iso9660 }, { "iso9660", 32, 9, 5, "CDROM", probe_iso9660 }, { "jfs", 32, 0, 4, "JFS1", probe_jfs }, - { "zfs", 8, 0, 8, "\0\0\x02\xf5\xb0\x07\xb1\x0c", probe_zfs }, - { "zfs", 8, 0, 8, "\x0c\xb1\x07\xb0\xf5\x02\0\0", probe_zfs }, - { "zfs", 264, 0, 8, "\0\0\x02\xf5\xb0\x07\xb1\x0c", probe_zfs }, - { "zfs", 264, 0, 8, "\x0c\xb1\x07\xb0\xf5\x02\0\0", probe_zfs }, + /* ZFS has 128 root blocks (#4 is the first used), check only 6 of them */ + { "zfs", 128, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 128, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 132, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 132, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 136, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 136, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 384, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 384, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 388, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 388, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 392, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 392, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, { "hfsplus", 1, 0, 2, "BD", probe_hfsplus }, { "hfsplus", 1, 0, 2, "H+", probe_hfsplus }, { "hfsplus", 1, 0, 2, "HX", probe_hfsplus }, -- 1.8.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] debugfs: improve dump_mmp handling 2016-03-06 0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger @ 2016-03-06 0:38 ` Andreas Dilger 2016-03-06 23:11 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 3/6] misc: add missing declarations on maint Andreas Dilger ` (4 subsequent siblings) 5 siblings, 1 reply; 12+ messages in thread From: Andreas Dilger @ 2016-03-06 0:38 UTC (permalink / raw) To: tytso; +Cc: linux-ext4, Andreas Dilger If MMP is not enabled on a filesystem (s_mmp_block == 0), print this clearly rather than "MMP: block number beyond filesystem range". Add an option to "debugfs dump_mmp" to specify the MMP block number instead of getting it from the superblock s_mmp_block field. Signed-off-by: Andreas Dilger <adilger@dilger.ca> --- debugfs/debugfs.8.in | 9 +++++++-- debugfs/debugfs.c | 25 ++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in index bae14db..4928791 100644 --- a/debugfs/debugfs.8.in +++ b/debugfs/debugfs.8.in @@ -221,8 +221,13 @@ option is given set the owner, group and permissions information on to match .IR filespec . .TP -.B dump_mmp -Display the multiple-mount protection (mmp) field values. +.BI dump_mmp " [mmp_block]" +Display the multiple-mount protection (mmp) field values. If +.I mmp_block +is specified then verify and dump the MMP values from the given block +number, otherwise use the +.B s_mmp_block +field in the superblock to locate and use the existing MMP block. .TP .BI dx_hash " [-h hash_alg] [-s hash_seed] filename" Calculate the directory hash of diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 5423634..260698c 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -2351,12 +2351,31 @@ try_again: void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[]) { struct mmp_struct *mmp_s; + unsigned long long mmp_block; time_t t; errcode_t retval = 0; if (check_fs_open(argv[0])) return; + if (argc > 1) { + char *end = NULL; + mmp_block = strtoull(argv[1], &end, 0); + if (end == argv[0] || mmp_block == 0) { + fprintf(stderr, "%s: invalid MMP block '%s' given\n", + argv[0], argv[1]); + return; + } + } else { + mmp_block = current_fs->super->s_mmp_block; + } + + if (mmp_block == 0) { + fprintf(stderr, "%s: MMP: not active on this filesystem.\n", + argv[0]); + return; + } + if (current_fs->mmp_buf == NULL) { retval = ext2fs_get_mem(current_fs->blocksize, ¤t_fs->mmp_buf); @@ -2368,10 +2387,10 @@ void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[]) mmp_s = current_fs->mmp_buf; - retval = ext2fs_mmp_read(current_fs, current_fs->super->s_mmp_block, - current_fs->mmp_buf); + retval = ext2fs_mmp_read(current_fs, mmp_block, current_fs->mmp_buf); if (retval) { - com_err(argv[0], retval, "reading MMP block.\n"); + com_err(argv[0], retval, "reading MMP block %llu.\n", + mmp_block); return; } -- 1.8.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/6] debugfs: improve dump_mmp handling 2016-03-06 0:38 ` [PATCH 2/6] debugfs: improve dump_mmp handling Andreas Dilger @ 2016-03-06 23:11 ` Theodore Ts'o 0 siblings, 0 replies; 12+ messages in thread From: Theodore Ts'o @ 2016-03-06 23:11 UTC (permalink / raw) To: Andreas Dilger; +Cc: linux-ext4 On Sat, Mar 05, 2016 at 05:38:32PM -0700, Andreas Dilger wrote: > If MMP is not enabled on a filesystem (s_mmp_block == 0), print this > clearly rather than "MMP: block number beyond filesystem range". > > Add an option to "debugfs dump_mmp" to specify the MMP block number > instead of getting it from the superblock s_mmp_block field. > > Signed-off-by: Andreas Dilger <adilger@dilger.ca> Thanks, applied. - Ted ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/6] misc: add missing declarations on maint 2016-03-06 0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger 2016-03-06 0:38 ` [PATCH 2/6] debugfs: improve dump_mmp handling Andreas Dilger @ 2016-03-06 0:38 ` Andreas Dilger 2016-03-06 23:12 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 4/6] lsattr: treat inode generation as an unsigned int Andreas Dilger ` (3 subsequent siblings) 5 siblings, 1 reply; 12+ messages in thread From: Andreas Dilger @ 2016-03-06 0:38 UTC (permalink / raw) To: tytso; +Cc: linux-ext4, Andreas Dilger Fix compile warnings for missing declarations on the maint branch. Signed-off-by: Andreas Dilger <adilger@dilger.ca> --- misc/util.c | 3 +++ util/subst.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/misc/util.c b/misc/util.c index 2898830..5a24e7e 100644 --- a/misc/util.c +++ b/misc/util.c @@ -21,6 +21,9 @@ #ifdef HAVE_ERRNO_H #include <errno.h> #endif +#if HAVE_UNISTD_H +#include <unistd.h> +#endif #ifdef HAVE_LINUX_MAJOR_H #include <linux/major.h> #endif diff --git a/util/subst.c b/util/subst.c index 91f6d44..db72923 100644 --- a/util/subst.c +++ b/util/subst.c @@ -19,8 +19,12 @@ #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H #include <sys/stat.h> +#endif #include <fcntl.h> #include <time.h> #include <utime.h> -- 1.8.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/6] misc: add missing declarations on maint 2016-03-06 0:38 ` [PATCH 3/6] misc: add missing declarations on maint Andreas Dilger @ 2016-03-06 23:12 ` Theodore Ts'o 0 siblings, 0 replies; 12+ messages in thread From: Theodore Ts'o @ 2016-03-06 23:12 UTC (permalink / raw) To: Andreas Dilger; +Cc: linux-ext4 On Sat, Mar 05, 2016 at 05:38:33PM -0700, Andreas Dilger wrote: > Fix compile warnings for missing declarations on the maint branch. > > Signed-off-by: Andreas Dilger <adilger@dilger.ca> Thanks, applied. - Ted ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 4/6] lsattr: treat inode generation as an unsigned int 2016-03-06 0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger 2016-03-06 0:38 ` [PATCH 2/6] debugfs: improve dump_mmp handling Andreas Dilger 2016-03-06 0:38 ` [PATCH 3/6] misc: add missing declarations on maint Andreas Dilger @ 2016-03-06 0:38 ` Andreas Dilger 2016-03-06 23:13 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 5/6] findsuper: improve output if s_mkfs_time unset Andreas Dilger ` (2 subsequent siblings) 5 siblings, 1 reply; 12+ messages in thread From: Andreas Dilger @ 2016-03-06 0:38 UTC (permalink / raw) To: tytso; +Cc: linux-ext4, Andreas Dilger The EXT2_GETVERSION ioctl is defined to take a "long" parameter, but fgetversion() calls ioctl() with an "int" parameter instead. This is handled in the kernel correctly, but the generation is sign-extended in fgetversion() before return on 64-bit systems and lsattr prints it as a huge positive number for inode generation above 0x80000000: 1635574212 -------------e-- /mnt/ost0/O/0/d0/12928 18446744073045131735 -------------e-- /mnt/ost0/O/0/d0/166240 782808861 -------------e-- /mnt/ost0/O/0/d0/31744 18446744072181134840 -------------e-- /mnt/ost0/O/0/d0/135008 Correctly assign the returned generation number as an unsigned value, and print it with a 10-character field width. The version is printed left-aligned for consistency with the old code and to ensure it is always printed in the first column for use with tools like "cut": 1635574212 -------------e-- /mnt/ost0/O/0/d0/12928 3630547415 -------------e-- /mnt/ost0/O/0/d0/166240 782808861 -------------e-- /mnt/ost0/O/0/d0/31744 2766550520 -------------e-- /mnt/ost0/O/0/d0/135008 Do not return a random value from the stack as the version on error. Clean up some style issues and consolidate some duplicate code. Signed-off-by: Andreas Dilger <adilger@dilger.ca> --- lib/e2p/fgetversion.c | 36 +++++++++++++++++++----------------- misc/lsattr.c | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/e2p/fgetversion.c b/lib/e2p/fgetversion.c index e6cee8b..2ad813b 100644 --- a/lib/e2p/fgetversion.c +++ b/lib/e2p/fgetversion.c @@ -37,32 +37,34 @@ #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK) #endif -int fgetversion (const char * name, unsigned long * version) +int fgetversion(const char *name, unsigned long *version) { + unsigned int ver = -1; + int rc = -1; #if HAVE_EXT2_IOCTLS -#if !APPLE_DARWIN - int fd, r, ver, save_errno = 0; +# if !APPLE_DARWIN + int fd, save_errno = 0; - fd = open (name, OPEN_FLAGS); + fd = open(name, OPEN_FLAGS); if (fd == -1) return -1; - r = ioctl (fd, EXT2_IOC_GETVERSION, &ver); - if (r == -1) + + rc = ioctl(fd, EXT2_IOC_GETVERSION, &ver); + if (rc == -1) save_errno = errno; - *version = ver; - close (fd); - if (save_errno) + close(fd); + if (rc == -1) errno = save_errno; - return r; -#else - int ver=-1, err; - err = syscall(SYS_fsctl, name, EXT2_IOC_GETVERSION, &ver, 0); - *version = ver; - return(err); -#endif +# else /* APPLE_DARWIN */ + rc = syscall(SYS_fsctl, name, EXT2_IOC_GETVERSION, &ver, 0); +# endif /* !APPLE_DARWIN */ #else /* ! HAVE_EXT2_IOCTLS */ extern int errno; + errno = EOPNOTSUPP; - return -1; #endif /* ! HAVE_EXT2_IOCTLS */ + if (rc == 0) + *version = ver; + + return rc; } diff --git a/misc/lsattr.c b/misc/lsattr.c index e5e5969..4c34e2f 100644 --- a/misc/lsattr.c +++ b/misc/lsattr.c @@ -92,7 +92,7 @@ static int list_attributes (const char * name) name); return -1; } - printf ("%5lu ", generation); + printf ("%-10lu ", generation); } if (pf_options & PFOPT_LONG) { printf("%-28s ", name); -- 1.8.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] lsattr: treat inode generation as an unsigned int 2016-03-06 0:38 ` [PATCH 4/6] lsattr: treat inode generation as an unsigned int Andreas Dilger @ 2016-03-06 23:13 ` Theodore Ts'o 0 siblings, 0 replies; 12+ messages in thread From: Theodore Ts'o @ 2016-03-06 23:13 UTC (permalink / raw) To: Andreas Dilger; +Cc: linux-ext4 On Sat, Mar 05, 2016 at 05:38:34PM -0700, Andreas Dilger wrote: > The EXT2_GETVERSION ioctl is defined to take a "long" parameter, but > fgetversion() calls ioctl() with an "int" parameter instead. This is > handled in the kernel correctly, but the generation is sign-extended > in fgetversion() before return on 64-bit systems and lsattr prints > it as a huge positive number for inode generation above 0x80000000: > > 1635574212 -------------e-- /mnt/ost0/O/0/d0/12928 > 18446744073045131735 -------------e-- /mnt/ost0/O/0/d0/166240 > 782808861 -------------e-- /mnt/ost0/O/0/d0/31744 > 18446744072181134840 -------------e-- /mnt/ost0/O/0/d0/135008 > > Correctly assign the returned generation number as an unsigned value, > and print it with a 10-character field width. The version is printed > left-aligned for consistency with the old code and to ensure it is > always printed in the first column for use with tools like "cut": > > 1635574212 -------------e-- /mnt/ost0/O/0/d0/12928 > 3630547415 -------------e-- /mnt/ost0/O/0/d0/166240 > 782808861 -------------e-- /mnt/ost0/O/0/d0/31744 > 2766550520 -------------e-- /mnt/ost0/O/0/d0/135008 > > Do not return a random value from the stack as the version on error. > Clean up some style issues and consolidate some duplicate code. > > Signed-off-by: Andreas Dilger <adilger@dilger.ca> Thanks, applied. - Ted ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 5/6] findsuper: improve output if s_mkfs_time unset 2016-03-06 0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger ` (2 preceding siblings ...) 2016-03-06 0:38 ` [PATCH 4/6] lsattr: treat inode generation as an unsigned int Andreas Dilger @ 2016-03-06 0:38 ` Andreas Dilger 2016-03-06 23:16 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 6/6] debugfs: update to handle newer inode fields Andreas Dilger 2016-03-06 23:10 ` [PATCH 1/6] blkid: fix ZFS device detection Theodore Ts'o 5 siblings, 1 reply; 12+ messages in thread From: Andreas Dilger @ 2016-03-06 0:38 UTC (permalink / raw) To: tytso; +Cc: linux-ext4, Andreas Dilger If s_mkfs_time is not set in the superblock, print the s_mtime field instead to identify the different superblocks. This can happen if the superblock is corrupted, since s_mkfs_time is not reset by e2fsck. Signed-off-by: Andreas Dilger <adilger@dilger.ca> --- misc/findsuper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/misc/findsuper.c b/misc/findsuper.c index eb9130b..b3b76cd 100644 --- a/misc/findsuper.c +++ b/misc/findsuper.c @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) if (print_jnl_copies) printf(_("[*] probably superblock written in the ext3 " "journal superblock,\n\tso start/end/grp wrong\n")); - printf(_("byte_offset byte_start byte_end fs_blocks blksz grp last_mount_time sb_uuid label\n")); + printf(_("byte_offset byte_start byte_end fs_blocks blksz grp mkfs/mount_time sb_uuid label\n")); for (; lseek64(fd, sk, SEEK_SET) != -1 && read(fd, &ext2, 512) == 512; sk += skiprate) { static unsigned char last_uuid[16] = "blah"; @@ -230,7 +230,10 @@ int main(int argc, char *argv[]) WHY("free_inodes_count > inodes_count (%u > %u)\n", ext2.s_free_inodes_count, ext2.s_inodes_count); - tm = ext2.s_mtime; + if (ext2.s_mkfs_time != 0) + tm = ext2.s_mkfs_time; + else + tm = ext2.s_mtime; s = ctime(&tm); s[24] = 0; bsize = 1 << (ext2.s_log_block_size + 10); -- 1.8.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] findsuper: improve output if s_mkfs_time unset 2016-03-06 0:38 ` [PATCH 5/6] findsuper: improve output if s_mkfs_time unset Andreas Dilger @ 2016-03-06 23:16 ` Theodore Ts'o 0 siblings, 0 replies; 12+ messages in thread From: Theodore Ts'o @ 2016-03-06 23:16 UTC (permalink / raw) To: Andreas Dilger; +Cc: linux-ext4 On Sat, Mar 05, 2016 at 05:38:35PM -0700, Andreas Dilger wrote: > If s_mkfs_time is not set in the superblock, print the s_mtime field > instead to identify the different superblocks. This can happen if the > superblock is corrupted, since s_mkfs_time is not reset by e2fsck. > > Signed-off-by: Andreas Dilger <adilger@dilger.ca> Thanks, applied. - Ted ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 6/6] debugfs: update to handle newer inode fields 2016-03-06 0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger ` (3 preceding siblings ...) 2016-03-06 0:38 ` [PATCH 5/6] findsuper: improve output if s_mkfs_time unset Andreas Dilger @ 2016-03-06 0:38 ` Andreas Dilger 2016-03-07 0:54 ` Theodore Ts'o 2016-03-06 23:10 ` [PATCH 1/6] blkid: fix ZFS device detection Theodore Ts'o 5 siblings, 1 reply; 12+ messages in thread From: Andreas Dilger @ 2016-03-06 0:38 UTC (permalink / raw) To: tytso; +Cc: linux-ext4, Andreas Dilger Remove the printing of fragment fields that are HURD only, and instead print the i_checksum_lo and i_checksum_hi fields. Allow setting newer fields in extra inode space with modify_inode. Add inode_includes() macro to simplify checking for fields in the large inode, rather than hard-coding field offsets in the code. Fix corresponding tests for newly added Checksum field. Signed-off-by: Andreas Dilger <adilger@dilger.ca> --- debugfs/debugfs.c | 197 +++++++++++++++++++++++++++---------------- lib/ext2fs/ext2_fs.h | 22 ++--- tests/d_special_files/expect | 10 +-- tests/f_badcluster/expect | 14 +-- 4 files changed, 140 insertions(+), 103 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 260698c..332fd5a 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -527,6 +527,10 @@ static void dump_xattr_string(FILE *out, const char *str, int len) fprintf(out, "%02x ", (unsigned char)str[i]); } +#define inode_includes(size, field) \ + (size >= (sizeof(((struct ext2_inode_large *)0)->field) + \ + offsetof(struct ext2_inode_large, field))) + static void internal_dump_inode_extra(FILE *out, const char *prefix EXT2FS_ATTR((unused)), ext2_ino_t inode_num EXT2FS_ATTR((unused)), @@ -725,15 +729,12 @@ void internal_dump_inode(FILE *out, const char *prefix, int do_dump_blocks) { const char *i_type; - char frag, fsize; int os = current_fs->super->s_creator_os; - struct ext2_inode_large *large_inode; - int is_large_inode = 0; + struct ext2_inode_large *large_inode = (struct ext2_inode_large *)inode; + unsigned inode_size = EXT2_GOOD_OLD_INODE_SIZE; if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE) - is_large_inode = 1; - large_inode = (struct ext2_inode_large *) inode; - + inode_size += large_inode->i_extra_isize; if (LINUX_S_ISDIR(inode->i_mode)) i_type = "directory"; else if (LINUX_S_ISREG(inode->i_mode)) i_type = "regular"; else if (LINUX_S_ISLNK(inode->i_mode)) i_type = "symlink"; @@ -745,14 +746,14 @@ void internal_dump_inode(FILE *out, const char *prefix, fprintf(out, "%sInode: %u Type: %s ", prefix, inode_num, i_type); fprintf(out, "%sMode: %04o Flags: 0x%x\n", prefix, inode->i_mode & 0777, inode->i_flags); - if (is_large_inode && large_inode->i_extra_isize >= 24) { + + if (inode_includes(inode_size, i_version_hi)) fprintf(out, "%sGeneration: %u Version: 0x%08x:%08x\n", prefix, inode->i_generation, large_inode->i_version_hi, inode->osd1.linux1.l_i_version); - } else { + else fprintf(out, "%sGeneration: %u Version: 0x%08x\n", prefix, inode->i_generation, inode->osd1.linux1.l_i_version); - } fprintf(out, "%sUser: %5d Group: %5d Size: ", prefix, inode_uid(*inode), inode_gid(*inode)); if (LINUX_S_ISREG(inode->i_mode)) @@ -763,7 +764,8 @@ void internal_dump_inode(FILE *out, const char *prefix, fprintf(out, "%sFile ACL: %d Directory ACL: %d Translator: %d\n", prefix, - inode->i_file_acl, LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0, + inode->i_file_acl, LINUX_S_ISDIR(inode->i_mode) ? + inode->i_dir_acl : 0, inode->osd1.hurd1.h_i_translator); else fprintf(out, "%sFile ACL: %llu Directory ACL: %d\n", @@ -780,46 +782,53 @@ void internal_dump_inode(FILE *out, const char *prefix, else fprintf(out, "%sLinks: %d Blockcount: %u\n", prefix, inode->i_links_count, inode->i_blocks); - switch (os) { - case EXT2_OS_HURD: - frag = inode->osd2.hurd2.h_i_frag; - fsize = inode->osd2.hurd2.h_i_fsize; - break; - default: - frag = fsize = 0; - } - fprintf(out, "%sFragment: Address: %d Number: %d Size: %d\n", - prefix, inode->i_faddr, frag, fsize); - if (is_large_inode && large_inode->i_extra_isize >= 24) { - fprintf(out, "%s ctime: 0x%08x:%08x -- %s", prefix, + if (os == EXT2_OS_HURD) + fprintf(out, + "%sFragment: Address: %d Number: %d Size: %d\n", + prefix, inode->i_faddr, inode->osd2.hurd2.h_i_frag, + inode->osd2.hurd2.h_i_fsize); + else + fprintf(out, + "%sFragment Address: %d Checksum: 0x%04x%04x\n", + prefix, inode->i_faddr, + inode_includes(inode_size, i_checksum_hi) ? + large_inode->i_checksum_hi : 0, + inode->osd2.linux2.l_i_checksum_lo); + if (inode_includes(inode_size, i_ctime_extra)) + fprintf(out, "%sctime: 0x%08x:%08x -- %s", prefix, inode->i_ctime, large_inode->i_ctime_extra, time_to_string(inode->i_ctime)); - fprintf(out, "%s atime: 0x%08x:%08x -- %s", prefix, + else + fprintf(out, "%sctime: 0x%08x -- %s", prefix, inode->i_ctime, + time_to_string(inode->i_ctime)); + if (inode_includes(inode_size, i_atime_extra)) + fprintf(out, "%satime: 0x%08x:%08x -- %s", prefix, inode->i_atime, large_inode->i_atime_extra, time_to_string(inode->i_atime)); - fprintf(out, "%s mtime: 0x%08x:%08x -- %s", prefix, + else + fprintf(out, "%satime: 0x%08x -- %s", prefix, inode->i_atime, + time_to_string(inode->i_atime)); + if (inode_includes(inode_size, i_mtime_extra)) + fprintf(out, "%smtime: 0x%08x:%08x -- %s", prefix, inode->i_mtime, large_inode->i_mtime_extra, time_to_string(inode->i_mtime)); + else + fprintf(out, "%smtime: 0x%08x -- %s", prefix, inode->i_mtime, + time_to_string(inode->i_mtime)); + if (inode_includes(inode_size, i_crtime_extra)) fprintf(out, "%scrtime: 0x%08x:%08x -- %s", prefix, large_inode->i_crtime, large_inode->i_crtime_extra, time_to_string(large_inode->i_crtime)); - } else { - fprintf(out, "%sctime: 0x%08x -- %s", prefix, inode->i_ctime, - time_to_string(inode->i_ctime)); - fprintf(out, "%satime: 0x%08x -- %s", prefix, inode->i_atime, - time_to_string(inode->i_atime)); - fprintf(out, "%smtime: 0x%08x -- %s", prefix, inode->i_mtime, - time_to_string(inode->i_mtime)); - } if (inode->i_dtime) - fprintf(out, "%sdtime: 0x%08x -- %s", prefix, inode->i_dtime, - time_to_string(inode->i_dtime)); - if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE) + fprintf(out, "%sdtime: 0x%08x -- %s", prefix, inode->i_dtime, + time_to_string(inode->i_dtime)); + if (inode_size > EXT2_GOOD_OLD_INODE_SIZE) internal_dump_inode_extra(out, prefix, inode_num, - (struct ext2_inode_large *) inode); - if (LINUX_S_ISLNK(inode->i_mode) && ext2fs_inode_data_blocks(current_fs,inode) == 0) + (struct ext2_inode_large *)inode); + if (LINUX_S_ISLNK(inode->i_mode) && + ext2fs_inode_data_blocks(current_fs, inode) == 0) fprintf(out, "%sFast_link_dest: %.*s\n", prefix, - (int) inode->i_size, (char *)inode->i_block); + (int)inode->i_size, (char *)inode->i_block); else if (LINUX_S_ISBLK(inode->i_mode) || LINUX_S_ISCHR(inode->i_mode)) { int major, minor; const char *devnote; @@ -1202,15 +1211,15 @@ static void modify_u32(char *com, const char *prompt, *val = v; } - void do_modify_inode(int argc, char *argv[]) { - struct ext2_inode inode; + struct ext2_inode_large inode; + struct ext2_inode *inodep; ext2_ino_t inode_num; - int i; - unsigned char *frag, *fsize; + int i; + int inode_size; char buf[80]; - int os; + int os; const char *hex_format = "0x%x"; const char *octal_format = "0%o"; const char *decimal_format = "%d"; @@ -1220,53 +1229,61 @@ void do_modify_inode(int argc, char *argv[]) return; os = current_fs->super->s_creator_os; + inode_size = EXT2_INODE_SIZE(current_fs->super); - if (debugfs_read_inode(inode_num, &inode, argv[1])) + inodep = (struct ext2_inode *)&inode; + if (debugfs_read_inode_full(inode_num, inodep, argv[1], inode_size)) return; modify_u16(argv[0], "Mode", octal_format, &inode.i_mode); modify_u16(argv[0], "User ID", decimal_format, &inode.i_uid); modify_u16(argv[0], "Group ID", decimal_format, &inode.i_gid); modify_u32(argv[0], "Size", unsignedlong_format, &inode.i_size); - modify_u32(argv[0], "Creation time", decimal_format, &inode.i_ctime); - modify_u32(argv[0], "Modification time", decimal_format, &inode.i_mtime); + modify_u32(argv[0], "High 32bits of size", decimal_format, + &inode.i_size_high); + modify_u32(argv[0], "Change time", decimal_format, &inode.i_ctime); + modify_u32(argv[0], "Modification time",decimal_format, &inode.i_mtime); modify_u32(argv[0], "Access time", decimal_format, &inode.i_atime); modify_u32(argv[0], "Deletion time", decimal_format, &inode.i_dtime); modify_u16(argv[0], "Link count", decimal_format, &inode.i_links_count); + modify_u32(argv[0], "Block count",unsignedlong_format, &inode.i_blocks); if (os == EXT2_OS_LINUX) - modify_u16(argv[0], "Block count high", unsignedlong_format, + modify_u16(argv[0], "High 16bits of lock count", + unsignedlong_format, &inode.osd2.linux2.l_i_blocks_hi); - modify_u32(argv[0], "Block count", unsignedlong_format, &inode.i_blocks); modify_u32(argv[0], "File flags", hex_format, &inode.i_flags); modify_u32(argv[0], "Generation", hex_format, &inode.i_generation); -#if 0 - modify_u32(argv[0], "Reserved1", decimal_format, &inode.i_reserved1); -#endif - modify_u32(argv[0], "File acl", decimal_format, &inode.i_file_acl); - if (LINUX_S_ISDIR(inode.i_mode)) - modify_u32(argv[0], "Directory acl", decimal_format, &inode.i_dir_acl); - else - modify_u32(argv[0], "High 32bits of size", decimal_format, &inode.i_size_high); + modify_u32(argv[0], "File ACL", decimal_format, &inode.i_file_acl); - if (os == EXT2_OS_HURD) + if (os == EXT2_OS_HURD) { modify_u32(argv[0], "Translator Block", decimal_format, &inode.osd1.hurd1.h_i_translator); - - modify_u32(argv[0], "Fragment address", decimal_format, &inode.i_faddr); - switch (os) { - case EXT2_OS_HURD: - frag = &inode.osd2.hurd2.h_i_frag; - fsize = &inode.osd2.hurd2.h_i_fsize; - break; - default: - frag = fsize = 0; - } - if (frag) - modify_u8(argv[0], "Fragment number", decimal_format, frag); - if (fsize) - modify_u8(argv[0], "Fragment size", decimal_format, fsize); - - for (i=0; i < EXT2_NDIR_BLOCKS; i++) { + modify_u32(argv[0], "Fragment address", decimal_format, + &inode.i_faddr); + modify_u8(argv[0], "Fragment number", decimal_format, + &inode.osd2.hurd2.h_i_frag); + modify_u8(argv[0], "Fragment size", decimal_format, + &inode.osd2.hurd2.h_i_fsize); + } else { + modify_u32(argv[0], "Fragment address", decimal_format, + &inode.i_faddr); + modify_u32(argv[0], "Change Version", decimal_format, + &inode.osd1.linux1.l_i_version); + modify_u16(argv[0], "High 16bits of file ACL", + unsignedlong_format, + &inode.osd2.linux2.l_i_file_acl_high); + modify_u16(argv[0], "High 16bits of user ID", + unsignedlong_format, + &inode.osd2.linux2.l_i_uid_high); + modify_u16(argv[0], "High 16bits of group ID", + unsignedlong_format, + &inode.osd2.linux2.l_i_gid_high); + modify_u16(argv[0], "Low 16bits of checksum", + unsignedlong_format, + &inode.osd2.linux2.l_i_checksum_lo); + } + + for (i = 0; i < EXT2_NDIR_BLOCKS; i++) { sprintf(buf, "Direct Block #%d", i); modify_u32(argv[0], buf, decimal_format, &inode.i_block[i]); } @@ -1276,7 +1293,39 @@ void do_modify_inode(int argc, char *argv[]) &inode.i_block[EXT2_DIND_BLOCK]); modify_u32(argv[0], "Triple Indirect Block", decimal_format, &inode.i_block[EXT2_TIND_BLOCK]); - if (debugfs_write_inode(inode_num, &inode, argv[1])) + + if (inode_includes(inode_size, i_extra_isize)) { + modify_u16(argv[0], "Extra inode size", decimal_format, + &inode.i_extra_isize); + i = inode.i_extra_isize; + } else { + i = 0; + } + + if (inode_includes(inode_size, i_checksum_hi)) + modify_u16(argv[0], "High 16bits of checksum", decimal_format, + &inode.i_checksum_hi); + if (inode_includes(inode_size, i_ctime_extra)) + modify_u32(argv[0], "Extra change time", + decimal_format, &inode.i_ctime_extra); + if (inode_includes(inode_size, i_mtime_extra)) + modify_u32(argv[0], "Extra modification time", + decimal_format, &inode.i_mtime_extra); + if (inode_includes(inode_size, i_atime_extra)) + modify_u32(argv[0], "Extra access time", + decimal_format, &inode.i_atime_extra); + if (inode_includes(inode_size, i_crtime)) + modify_u32(argv[0], "Creation time", + decimal_format, &inode.i_crtime); + if (inode_includes(inode_size, i_crtime_extra)) + modify_u32(argv[0], "Extra creation time", + decimal_format, &inode.i_crtime_extra); + if (inode_includes(inode_size, i_version_hi)) + modify_u32(argv[0], "High 32bits change version", + decimal_format, &inode.i_version_hi); + + if (debugfs_write_inode_full(inode_num, inodep, argv[1], + EXT2_INODE_SIZE(current_fs->super))) return; } #endif /* READ_ONLY */ diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 6c3620c..42024fa 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -461,26 +461,14 @@ struct ext2_inode_large { #define i_dir_acl i_size_high -#if defined(__KERNEL__) || defined(__linux__) -#define i_reserved1 osd1.linux1.l_i_reserved1 -#define i_frag osd2.linux2.l_i_frag -#define i_fsize osd2.linux2.l_i_fsize -#define i_uid_low i_uid -#define i_gid_low i_gid -#define i_uid_high osd2.linux2.l_i_uid_high -#define i_gid_high osd2.linux2.l_i_gid_high -#else #if defined(__GNU__) - -#define i_translator osd1.hurd1.h_i_translator -#define i_frag osd2.hurd2.h_i_frag; -#define i_fsize osd2.hurd2.h_i_fsize; #define i_uid_high osd2.hurd2.h_i_uid_high #define i_gid_high osd2.hurd2.h_i_gid_high -#define i_author osd2.hurd2.h_i_author - -#endif /* __GNU__ */ -#endif /* defined(__KERNEL__) || defined(__linux__) */ +#else +#define i_uid_high osd2.linux2.l_i_uid_high +#define i_gid_high osd2.linux2.l_i_gid_high +#define i_checksum_lo osd2.linux2.l_i_checksum_lo +#endif /* __GNU__ */ #define inode_uid(inode) ((inode).i_uid | (inode).osd2.linux2.l_i_uid_high << 16) #define inode_gid(inode) ((inode).i_gid | (inode).osd2.linux2.l_i_gid_high << 16) diff --git a/tests/d_special_files/expect b/tests/d_special_files/expect index 2b2dbfa..cfdc505 100644 --- a/tests/d_special_files/expect +++ b/tests/d_special_files/expect @@ -7,7 +7,7 @@ Generation: 0 Version: 0x00000000 User: 0 Group: 0 Size: 3 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 0 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 atime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 mtime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 @@ -19,7 +19,7 @@ Generation: 0 Version: 0x00000000 User: 0 Group: 0 Size: 80 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 2 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 atime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 mtime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 @@ -44,7 +44,7 @@ Generation: 0 Version: 0x00000000 User: 0 Group: 0 Size: 0 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 0 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 atime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 mtime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 @@ -57,7 +57,7 @@ Generation: 0 Version: 0x00000000 User: 0 Group: 0 Size: 0 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 0 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 atime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 mtime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 @@ -69,7 +69,7 @@ Generation: 0 Version: 0x00000000 User: 0 Group: 0 Size: 0 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 0 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 atime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 mtime: 0x50f560e0 -- Tue Jan 15 14:00:00 2013 diff --git a/tests/f_badcluster/expect b/tests/f_badcluster/expect index 6cfffb7..c10a0c7 100644 --- a/tests/f_badcluster/expect +++ b/tests/f_badcluster/expect @@ -115,7 +115,7 @@ Generation: 1117152157 Version: 0x00000001 User: 0 Group: 0 Size: 3072 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 32 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 atime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 mtime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 @@ -127,7 +127,7 @@ Generation: 1117152158 Version: 0x00000001 User: 0 Group: 0 Size: 3072 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 32 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 atime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 mtime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 @@ -139,7 +139,7 @@ Generation: 1117152159 Version: 0x00000001 User: 0 Group: 0 Size: 3072 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 32 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 atime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 mtime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 @@ -151,7 +151,7 @@ Generation: 1117152160 Version: 0x00000001 User: 0 Group: 0 Size: 3072 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 32 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 atime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 mtime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 @@ -165,7 +165,7 @@ Generation: 1117152161 Version: 0x00000001 User: 0 Group: 0 Size: 6144 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 32 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 atime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 mtime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 @@ -177,7 +177,7 @@ Generation: 1117152162 Version: 0x00000001 User: 0 Group: 0 Size: 3072 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 32 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 atime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 mtime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 @@ -189,7 +189,7 @@ Generation: 1117152163 Version: 0x00000001 User: 0 Group: 0 Size: 3072 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 32 -Fragment: Address: 0 Number: 0 Size: 0 +Fragment Address: 0 Checksum: 0x00000000 ctime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 atime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 mtime: 0x539ff5b2 -- Tue Jun 17 08:00:50 2014 -- 1.8.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 6/6] debugfs: update to handle newer inode fields 2016-03-06 0:38 ` [PATCH 6/6] debugfs: update to handle newer inode fields Andreas Dilger @ 2016-03-07 0:54 ` Theodore Ts'o 0 siblings, 0 replies; 12+ messages in thread From: Theodore Ts'o @ 2016-03-07 0:54 UTC (permalink / raw) To: Andreas Dilger; +Cc: linux-ext4 On Sat, Mar 05, 2016 at 05:38:36PM -0700, Andreas Dilger wrote: > Remove the printing of fragment fields that are HURD only, and > instead print the i_checksum_lo and i_checksum_hi fields. > > Allow setting newer fields in extra inode space with modify_inode. > > Add inode_includes() macro to simplify checking for fields in the > large inode, rather than hard-coding field offsets in the code. > > Fix corresponding tests for newly added Checksum field. > > Signed-off-by: Andreas Dilger <adilger@dilger.ca> This patch changes way too much at one time, and won't apply given other changes that have been made by Li Xi and myself. I wouldn't bother adding stuff to modify_inode; that's an old interface that is extremely awkward to use, and is there because there might be a few people who might like it. These days, set_inode_field is the new interface that is much more flexible and easier to use. Li Xi has added inode_includes into lib/ext2fs/ext2_fs.h. I will probably rename it to ext2fs_inode_includes() just to avoid namespace collision problems. Cheers, - Ted ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] blkid: fix ZFS device detection 2016-03-06 0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger ` (4 preceding siblings ...) 2016-03-06 0:38 ` [PATCH 6/6] debugfs: update to handle newer inode fields Andreas Dilger @ 2016-03-06 23:10 ` Theodore Ts'o 5 siblings, 0 replies; 12+ messages in thread From: Theodore Ts'o @ 2016-03-06 23:10 UTC (permalink / raw) To: Andreas Dilger; +Cc: linux-ext4, Andreas Dilger On Sat, Mar 05, 2016 at 05:38:31PM -0700, Andreas Dilger wrote: > From: Andreas Dilger <andreas.dilger@intel.com> > > While the main blkid functionality is in util-linux, there is still > use for blkid on non-Linux platforms. > > Fix the ZFS device detection by looking at multiple uberblocks to > see if any are present, rather than looking for the ZFS boot block > which is not always present. > > There are slots for up to 128 uberblocks, but the first 4 are not > written to disk on a newly-formatted filesystem, so check several > of them at different offsets within the uberblock array. > > Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Thanks, applied. - Ted ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-03-07 0:54 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-06 0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger 2016-03-06 0:38 ` [PATCH 2/6] debugfs: improve dump_mmp handling Andreas Dilger 2016-03-06 23:11 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 3/6] misc: add missing declarations on maint Andreas Dilger 2016-03-06 23:12 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 4/6] lsattr: treat inode generation as an unsigned int Andreas Dilger 2016-03-06 23:13 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 5/6] findsuper: improve output if s_mkfs_time unset Andreas Dilger 2016-03-06 23:16 ` Theodore Ts'o 2016-03-06 0:38 ` [PATCH 6/6] debugfs: update to handle newer inode fields Andreas Dilger 2016-03-07 0:54 ` Theodore Ts'o 2016-03-06 23:10 ` [PATCH 1/6] blkid: fix ZFS device detection Theodore Ts'o
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).