From 252e211e90ce56bf005cb533ad5a297c18c19407 Mon Sep 17 00:00:00 2001 From: Mark Fortescue Date: Tue, 16 Oct 2007 23:26:31 -0700 Subject: Add in SunOS 4.1.x compatible mode for UFS Add in support for SunOS 4.1.x flavor of BSD 4.2 UFS filing system Macros have been put in to alow suport for the old static table Cylinder Groups but this implementation does not use them yet. This also fixes Solaris UFS filing system access by disabling fast symbolic links as Sun's version of UFS does not support on-disk fast symbolic links. Tested by: Ppartitioning a new disk using SunOS 4.1.1, creating a UFS filing system on one of the partitions and writing some files to the filing system. Using Linux-2.6.22 (patched) to read the files and then write a shed load of files to the UFS partition. Using SunOS 4.1.1 to verify the filing system is OK and to check the files. The test host is a sun4c SS1 Clone. [akpm@linux-foundation.org: coding style fixes] [adobriyan@gmail.com: fix oops] Signed-off-by: Mark Fortescue Cc: Evgeniy Dushistov Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/ufs_fs.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h index daeba22b7656..52730d2c9ad9 100644 --- a/include/linux/ufs_fs.h +++ b/include/linux/ufs_fs.h @@ -170,8 +170,9 @@ typedef __u16 __bitwise __fs16; #define UFS_ST_MASK 0x00000700 /* mask for the following */ #define UFS_ST_OLD 0x00000000 #define UFS_ST_44BSD 0x00000100 -#define UFS_ST_SUN 0x00000200 -#define UFS_ST_SUNx86 0x00000400 +#define UFS_ST_SUN 0x00000200 /* Solaris */ +#define UFS_ST_SUNOS 0x00000300 +#define UFS_ST_SUNx86 0x00000400 /* Solaris x86 */ /*cylinder group encoding */ #define UFS_CG_MASK 0x00003000 /* mask for the following */ #define UFS_CG_OLD 0x00000000 @@ -204,6 +205,7 @@ typedef __u16 __bitwise __fs16; #define UFS_MOUNT_UFSTYPE_SUNx86 0x00000400 #define UFS_MOUNT_UFSTYPE_HP 0x00000800 #define UFS_MOUNT_UFSTYPE_UFS2 0x00001000 +#define UFS_MOUNT_UFSTYPE_SUNOS 0x00002000 #define ufs_clear_opt(o,opt) o &= ~UFS_MOUNT_##opt #define ufs_set_opt(o,opt) o |= UFS_MOUNT_##opt @@ -374,7 +376,14 @@ struct ufs_csum_core { * struct ufs_super_block_(first,second,third) instead. */ struct ufs_super_block { - __fs32 fs_link; /* UNUSED */ + union { + struct { + __fs32 fs_link; /* UNUSED */ + } fs_42; + struct { + __fs32 fs_state; /* file system state flag */ + } fs_sun; + } fs_u0; __fs32 fs_rlink; /* UNUSED */ __fs32 fs_sblkno; /* addr of super-block in filesys */ __fs32 fs_cblkno; /* offset of cyl-block in filesys */ @@ -545,6 +554,15 @@ struct ufs_super_block { #define CG_MAGIC 0x090255 #define ufs_cg_chkmagic(sb, ucg) \ (fs32_to_cpu((sb), (ucg)->cg_magic) == CG_MAGIC) +/* + * Macros for access to old cylinder group array structures + */ +#define ufs_ocg_blktot(sb, ucg) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_btot) +#define ufs_ocg_blks(sb, ucg, cylno) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_b[cylno]) +#define ufs_ocg_inosused(sb, ucg) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_iused) +#define ufs_ocg_blksfree(sb, ucg) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_free) +#define ufs_ocg_chkmagic(sb, ucg) \ + (fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_magic) == CG_MAGIC) /* * size of this structure is 172 B @@ -590,6 +608,28 @@ struct ufs_cylinder_group { /* actually longer */ }; +/* Historic Cylinder group info */ +struct ufs_old_cylinder_group { + __fs32 cg_link; /* linked list of cyl groups */ + __fs32 cg_rlink; /* for incore cyl groups */ + __fs32 cg_time; /* time last written */ + __fs32 cg_cgx; /* we are the cgx'th cylinder group */ + __fs16 cg_ncyl; /* number of cyl's this cg */ + __fs16 cg_niblk; /* number of inode blocks this cg */ + __fs32 cg_ndblk; /* number of data blocks this cg */ + struct ufs_csum cg_cs; /* cylinder summary information */ + __fs32 cg_rotor; /* position of last used block */ + __fs32 cg_frotor; /* position of last used frag */ + __fs32 cg_irotor; /* position of last used inode */ + __fs32 cg_frsum[8]; /* counts of available frags */ + __fs32 cg_btot[32]; /* block totals per cylinder */ + __fs16 cg_b[32][8]; /* positions of free blocks */ + __u8 cg_iused[256]; /* used inode map */ + __fs32 cg_magic; /* magic number */ + __u8 cg_free[1]; /* free block map */ +/* actually longer */ +}; + /* * structure of an on-disk inode */ @@ -796,7 +836,14 @@ struct ufs_sb_private_info { * ufs_super_block_third 356 */ struct ufs_super_block_first { - __fs32 fs_link; + union { + struct { + __fs32 fs_link; /* UNUSED */ + } fs_42; + struct { + __fs32 fs_state; /* file system state flag */ + } fs_sun; + } fs_u0; __fs32 fs_rlink; __fs32 fs_sblkno; __fs32 fs_cblkno; -- cgit v1.2.2