diff -Naur fstyp-0.1/src/linux_fs.h fstyp/src/linux_fs.h --- fstyp-0.1/src/linux_fs.h 2001-11-19 11:18:12.000000000 +0530 +++ fstyp/src/linux_fs.h 2008-11-07 20:20:51.000000000 +0530 @@ -98,8 +98,12 @@ (((uint) s.s_magic[2]) << 16) + \ (((uint) s.s_magic[3]) << 24)) +#define UFS_DISK_OFFSET_IN_BYTES (8 * 1024) +#define UFS2_DISK_OFFSET_IN_BYTES (64 * 1024) +#define UFS2_PIGGY_OFFSET_IN_BYTES (256 * 1024) /* From jj@sunsite.ms.mff.cuni.cz Mon Mar 23 15:19:05 1998 */ #define UFS_SUPER_MAGIC 0x00011954 +#define FS_UFS2_MAGIC 0x19540119 struct ufs_super_block { u_char s_dummy[0x55c]; u_char s_magic[4]; diff -Naur fstyp-0.1/src/mount_guess_fstype.c fstyp/src/mount_guess_fstype.c --- fstyp-0.1/src/mount_guess_fstype.c 2001-11-19 11:23:45.000000000 +0530 +++ fstyp/src/mount_guess_fstype.c 2008-11-07 20:25:02.000000000 +0530 @@ -88,7 +88,7 @@ *magic_known[] = { "adfs", "bfs", "cramfs", "ext", "ext2", "ext3", "hfs", "hpfs", "iso9660", "jfs", "minix", "ntfs", - "qnx4", "reiserfs", "romfs", "swap", "sysv", "udf", "ufs", + "qnx4", "reiserfs", "romfs", "swap", "sysv", "udf", "ufs", "ufs2" "vxfs", "xfs", "xiafs" }; @@ -287,14 +287,35 @@ type = "jfs"; } + /* UFS2 */ if (!type) { - if (lseek(fd, 8192, SEEK_SET) != 8192 + if (lseek(fd, UFS2_DISK_OFFSET_IN_BYTES, SEEK_SET) != UFS2_DISK_OFFSET_IN_BYTES + || read(fd, (char *) &ufssb, sizeof(ufssb)) != sizeof(ufssb)) + goto io_error; + + if (ufsmagic(ufssb) == FS_UFS2_MAGIC) + type = "ufs2"; + } + + if (!type) { + if (lseek(fd, UFS_DISK_OFFSET_IN_BYTES, SEEK_SET) != UFS_DISK_OFFSET_IN_BYTES || read(fd, (char *) &ufssb, sizeof(ufssb)) != sizeof(ufssb)) goto io_error; if (ufsmagic(ufssb) == UFS_SUPER_MAGIC) /* also test swapped version? */ type = "ufs"; } + /* UFS2: On some really piggy systems we check at 256K from the front if + * the above test fails. + */ + if (!type) { + if (lseek(fd, UFS2_PIGGY_OFFSET_IN_BYTES, SEEK_SET) != UFS2_PIGGY_OFFSET_IN_BYTES + || read(fd, (char *) &ufssb, sizeof(ufssb)) != sizeof(ufssb)) + goto io_error; + + if (ufsmagic(ufssb) == FS_UFS2_MAGIC) + type = "ufs2"; + } if (!type) { if (lseek(fd, 0x8000, SEEK_SET) != 0x8000