diff options
-rw-r--r-- | fs/ufs/super.c | 217 | ||||
-rw-r--r-- | fs/ufs/util.h | 52 | ||||
-rw-r--r-- | include/linux/ufs_fs.h | 61 |
3 files changed, 173 insertions, 157 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index c8339e56638..3aadbd3167a 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -94,82 +94,77 @@ | |||
94 | /* | 94 | /* |
95 | * Print contents of ufs_super_block, useful for debugging | 95 | * Print contents of ufs_super_block, useful for debugging |
96 | */ | 96 | */ |
97 | void ufs_print_super_stuff(struct super_block *sb, | 97 | static void ufs_print_super_stuff(struct super_block *sb, unsigned flags, |
98 | struct ufs_super_block_first * usb1, | 98 | struct ufs_super_block_first *usb1, |
99 | struct ufs_super_block_second * usb2, | 99 | struct ufs_super_block_second *usb2, |
100 | struct ufs_super_block_third * usb3) | 100 | struct ufs_super_block_third *usb3) |
101 | { | 101 | { |
102 | printk("ufs_print_super_stuff\n"); | 102 | printk("ufs_print_super_stuff\n"); |
103 | printk("size of usb: %zu\n", sizeof(struct ufs_super_block)); | 103 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb3->fs_magic)); |
104 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb3->fs_magic)); | 104 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
105 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); | 105 | printk(" fs_size: %llu\n", (unsigned long long) |
106 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); | 106 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size)); |
107 | printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); | 107 | printk(" fs_dsize: %llu\n", (unsigned long long) |
108 | printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); | 108 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize)); |
109 | printk(" cgoffset: %u\n", fs32_to_cpu(sb, usb1->fs_cgoffset)); | 109 | printk(" bsize: %u\n", |
110 | printk(" ~cgmask: 0x%x\n", ~fs32_to_cpu(sb, usb1->fs_cgmask)); | 110 | fs32_to_cpu(sb, usb1->fs_bsize)); |
111 | printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); | 111 | printk(" fsize: %u\n", |
112 | printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); | 112 | fs32_to_cpu(sb, usb1->fs_fsize)); |
113 | printk(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg)); | 113 | printk(" fs_volname: %s\n", usb2->fs_un.fs_u2.fs_volname); |
114 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize)); | 114 | printk(" fs_sblockloc: %llu\n", (unsigned long long) |
115 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize)); | 115 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.fs_sblockloc)); |
116 | printk(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag)); | 116 | printk(" cs_ndir(No of dirs): %llu\n", (unsigned long long) |
117 | printk(" fragshift: %u\n", fs32_to_cpu(sb, usb1->fs_fragshift)); | 117 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir)); |
118 | printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); | 118 | printk(" cs_nbfree(No of free blocks): %llu\n", |
119 | printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); | 119 | (unsigned long long) |
120 | printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); | 120 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree)); |
121 | printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); | 121 | } else { |
122 | printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); | 122 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); |
123 | printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); | 123 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); |
124 | printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); | 124 | printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); |
125 | printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); | 125 | printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); |
126 | printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); | 126 | printk(" cgoffset: %u\n", |
127 | printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); | 127 | fs32_to_cpu(sb, usb1->fs_cgoffset)); |
128 | printk(" fstodb: %u\n", fs32_to_cpu(sb, usb1->fs_fsbtodb)); | 128 | printk(" ~cgmask: 0x%x\n", |
129 | printk(" contigsumsize: %d\n", fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_contigsumsize)); | 129 | ~fs32_to_cpu(sb, usb1->fs_cgmask)); |
130 | printk(" postblformat: %u\n", fs32_to_cpu(sb, usb3->fs_postblformat)); | 130 | printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); |
131 | printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); | 131 | printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); |
132 | printk(" ndir %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir)); | 132 | printk(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg)); |
133 | printk(" nifree %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree)); | 133 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize)); |
134 | printk(" nbfree %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)); | 134 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize)); |
135 | printk(" nffree %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree)); | 135 | printk(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag)); |
136 | printk("\n"); | 136 | printk(" fragshift: %u\n", |
137 | } | 137 | fs32_to_cpu(sb, usb1->fs_fragshift)); |
138 | 138 | printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); | |
139 | /* | 139 | printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); |
140 | * Print contents of ufs2 ufs_super_block, useful for debugging | 140 | printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); |
141 | */ | 141 | printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); |
142 | void ufs2_print_super_stuff( | 142 | printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); |
143 | struct super_block *sb, | 143 | printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); |
144 | struct ufs_super_block *usb) | 144 | printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); |
145 | { | 145 | printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); |
146 | printk("ufs_print_super_stuff\n"); | 146 | printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); |
147 | printk("size of usb: %zu\n", sizeof(struct ufs_super_block)); | 147 | printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); |
148 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb->fs_magic)); | 148 | printk(" fstodb: %u\n", |
149 | printk(" fs_size: %llu\n", | 149 | fs32_to_cpu(sb, usb1->fs_fsbtodb)); |
150 | (unsigned long long)fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_size)); | 150 | printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); |
151 | printk(" fs_dsize: %llu\n", | 151 | printk(" ndir %u\n", |
152 | (unsigned long long)fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize)); | 152 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir)); |
153 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb->fs_bsize)); | 153 | printk(" nifree %u\n", |
154 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb->fs_fsize)); | 154 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree)); |
155 | printk(" fs_volname: %s\n", usb->fs_u11.fs_u2.fs_volname); | 155 | printk(" nbfree %u\n", |
156 | printk(" fs_fsmnt: %s\n", usb->fs_u11.fs_u2.fs_fsmnt); | 156 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)); |
157 | printk(" fs_sblockloc: %llu\n", | 157 | printk(" nffree %u\n", |
158 | (unsigned long long)fs64_to_cpu(sb, | 158 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree)); |
159 | usb->fs_u11.fs_u2.fs_sblockloc)); | 159 | } |
160 | printk(" cs_ndir(No of dirs): %llu\n", | ||
161 | (unsigned long long)fs64_to_cpu(sb, | ||
162 | usb->fs_u11.fs_u2.fs_cstotal.cs_ndir)); | ||
163 | printk(" cs_nbfree(No of free blocks): %llu\n", | ||
164 | (unsigned long long)fs64_to_cpu(sb, | ||
165 | usb->fs_u11.fs_u2.fs_cstotal.cs_nbfree)); | ||
166 | printk("\n"); | 160 | printk("\n"); |
167 | } | 161 | } |
168 | 162 | ||
169 | /* | 163 | /* |
170 | * Print contents of ufs_cylinder_group, useful for debugging | 164 | * Print contents of ufs_cylinder_group, useful for debugging |
171 | */ | 165 | */ |
172 | void ufs_print_cylinder_stuff(struct super_block *sb, struct ufs_cylinder_group *cg) | 166 | static void ufs_print_cylinder_stuff(struct super_block *sb, |
167 | struct ufs_cylinder_group *cg) | ||
173 | { | 168 | { |
174 | printk("\nufs_print_cylinder_stuff\n"); | 169 | printk("\nufs_print_cylinder_stuff\n"); |
175 | printk("size of ucg: %zu\n", sizeof(struct ufs_cylinder_group)); | 170 | printk("size of ucg: %zu\n", sizeof(struct ufs_cylinder_group)); |
@@ -196,11 +191,17 @@ void ufs_print_cylinder_stuff(struct super_block *sb, struct ufs_cylinder_group | |||
196 | printk(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); | 191 | printk(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); |
197 | printk(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); | 192 | printk(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); |
198 | printk(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); | 193 | printk(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); |
199 | printk(" clustersumoff %u\n", fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clustersumoff)); | 194 | printk(" clustersumoff %u\n", |
200 | printk(" clusteroff %u\n", fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clusteroff)); | 195 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clustersumoff)); |
201 | printk(" nclusterblks %u\n", fs32_to_cpu(sb, cg->cg_u.cg_44.cg_nclusterblks)); | 196 | printk(" clusteroff %u\n", |
197 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clusteroff)); | ||
198 | printk(" nclusterblks %u\n", | ||
199 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_nclusterblks)); | ||
202 | printk("\n"); | 200 | printk("\n"); |
203 | } | 201 | } |
202 | #else | ||
203 | # define ufs_print_super_stuff(sb, flags, usb1, usb2, usb3) /**/ | ||
204 | # define ufs_print_cylinder_stuff(sb, cg) /**/ | ||
204 | #endif /* CONFIG_UFS_DEBUG */ | 205 | #endif /* CONFIG_UFS_DEBUG */ |
205 | 206 | ||
206 | static struct super_operations ufs_super_ops; | 207 | static struct super_operations ufs_super_ops; |
@@ -384,9 +385,9 @@ static int ufs_parse_options (char * options, unsigned * mount_options) | |||
384 | */ | 385 | */ |
385 | static int ufs_read_cylinder_structures (struct super_block *sb) | 386 | static int ufs_read_cylinder_structures (struct super_block *sb) |
386 | { | 387 | { |
387 | struct ufs_sb_info * sbi = UFS_SB(sb); | 388 | struct ufs_sb_info *sbi = UFS_SB(sb); |
388 | struct ufs_sb_private_info * uspi; | 389 | struct ufs_sb_private_info *uspi = sbi->s_uspi; |
389 | struct ufs_super_block *usb; | 390 | struct ufs_super_block_third *usb3; |
390 | struct ufs_buffer_head * ubh; | 391 | struct ufs_buffer_head * ubh; |
391 | unsigned char * base, * space; | 392 | unsigned char * base, * space; |
392 | unsigned size, blks, i; | 393 | unsigned size, blks, i; |
@@ -394,10 +395,7 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
394 | 395 | ||
395 | UFSD("ENTER\n"); | 396 | UFSD("ENTER\n"); |
396 | 397 | ||
397 | uspi = sbi->s_uspi; | 398 | usb3 = ubh_get_usb_third(uspi); |
398 | |||
399 | usb = (struct ufs_super_block *) | ||
400 | ((struct ufs_buffer_head *)uspi)->bh[0]->b_data; | ||
401 | 399 | ||
402 | flags = UFS_SB(sb)->s_flags; | 400 | flags = UFS_SB(sb)->s_flags; |
403 | 401 | ||
@@ -418,7 +416,7 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
418 | 416 | ||
419 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) | 417 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) |
420 | ubh = ubh_bread(sb, | 418 | ubh = ubh_bread(sb, |
421 | fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size); | 419 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_csaddr) + i, size); |
422 | else | 420 | else |
423 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); | 421 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); |
424 | 422 | ||
@@ -450,9 +448,8 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
450 | goto failed; | 448 | goto failed; |
451 | if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) | 449 | if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) |
452 | goto failed; | 450 | goto failed; |
453 | #ifdef CONFIG_UFS_DEBUG | 451 | |
454 | ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); | 452 | ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); |
455 | #endif | ||
456 | } | 453 | } |
457 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { | 454 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { |
458 | if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) | 455 | if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) |
@@ -818,12 +815,8 @@ magic_found: | |||
818 | goto again; | 815 | goto again; |
819 | } | 816 | } |
820 | 817 | ||
821 | #ifdef CONFIG_UFS_DEBUG | 818 | |
822 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) | 819 | ufs_print_super_stuff(sb, flags, usb1, usb2, usb3); |
823 | ufs2_print_super_stuff(sb,usb); | ||
824 | else | ||
825 | ufs_print_super_stuff(sb, usb1, usb2, usb3); | ||
826 | #endif | ||
827 | 820 | ||
828 | /* | 821 | /* |
829 | * Check, if file system was correctly unmounted. | 822 | * Check, if file system was correctly unmounted. |
@@ -878,10 +871,9 @@ magic_found: | |||
878 | uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); | 871 | uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); |
879 | 872 | ||
880 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { | 873 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
881 | uspi->s_u2_size = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_size); | 874 | uspi->s_u2_size = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size); |
882 | uspi->s_u2_dsize = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize); | 875 | uspi->s_u2_dsize = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
883 | } | 876 | } else { |
884 | else { | ||
885 | uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); | 877 | uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); |
886 | uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); | 878 | uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); |
887 | } | 879 | } |
@@ -916,8 +908,8 @@ magic_found: | |||
916 | uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); | 908 | uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); |
917 | uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); | 909 | uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); |
918 | uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); | 910 | uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); |
919 | uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_cpc); | 911 | uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_un.fs_u1.fs_cpc); |
920 | uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_contigsumsize); | 912 | uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_contigsumsize); |
921 | uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); | 913 | uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); |
922 | uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); | 914 | uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); |
923 | uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); | 915 | uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); |
@@ -949,7 +941,7 @@ magic_found: | |||
949 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == | 941 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == |
950 | UFS_MOUNT_UFSTYPE_44BSD) | 942 | UFS_MOUNT_UFSTYPE_44BSD) |
951 | uspi->s_maxsymlinklen = | 943 | uspi->s_maxsymlinklen = |
952 | fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_maxsymlinklen); | 944 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); |
953 | 945 | ||
954 | sbi->s_flags = flags; | 946 | sbi->s_flags = flags; |
955 | 947 | ||
@@ -987,7 +979,8 @@ failed_nomem: | |||
987 | return -ENOMEM; | 979 | return -ENOMEM; |
988 | } | 980 | } |
989 | 981 | ||
990 | static void ufs_write_super (struct super_block *sb) { | 982 | static void ufs_write_super(struct super_block *sb) |
983 | { | ||
991 | struct ufs_sb_private_info * uspi; | 984 | struct ufs_sb_private_info * uspi; |
992 | struct ufs_super_block_first * usb1; | 985 | struct ufs_super_block_first * usb1; |
993 | struct ufs_super_block_third * usb3; | 986 | struct ufs_super_block_third * usb3; |
@@ -1027,7 +1020,7 @@ static void ufs_put_super(struct super_block *sb) | |||
1027 | kfree (sbi->s_uspi); | 1020 | kfree (sbi->s_uspi); |
1028 | kfree (sbi); | 1021 | kfree (sbi); |
1029 | sb->s_fs_info = NULL; | 1022 | sb->s_fs_info = NULL; |
1030 | UFSD("EXIT\n"); | 1023 | UFSD("EXIT\n"); |
1031 | return; | 1024 | return; |
1032 | } | 1025 | } |
1033 | 1026 | ||
@@ -1107,31 +1100,29 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1107 | return 0; | 1100 | return 0; |
1108 | } | 1101 | } |
1109 | 1102 | ||
1110 | static int ufs_statfs (struct dentry *dentry, struct kstatfs *buf) | 1103 | static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf) |
1111 | { | 1104 | { |
1112 | struct super_block *sb = dentry->d_sb; | 1105 | struct super_block *sb = dentry->d_sb; |
1113 | struct ufs_sb_private_info * uspi; | 1106 | struct ufs_sb_private_info *uspi= UFS_SB(sb)->s_uspi; |
1114 | struct ufs_super_block_first * usb1; | 1107 | unsigned flags = UFS_SB(sb)->s_flags; |
1115 | struct ufs_super_block * usb; | 1108 | struct ufs_super_block_first *usb1; |
1116 | unsigned flags = 0; | 1109 | struct ufs_super_block_second *usb2; |
1110 | struct ufs_super_block_third *usb3; | ||
1117 | 1111 | ||
1118 | lock_kernel(); | 1112 | lock_kernel(); |
1119 | 1113 | ||
1120 | uspi = UFS_SB(sb)->s_uspi; | 1114 | usb1 = ubh_get_usb_first(uspi); |
1121 | usb1 = ubh_get_usb_first (uspi); | 1115 | usb2 = ubh_get_usb_second(uspi); |
1122 | usb = (struct ufs_super_block *) | 1116 | usb3 = ubh_get_usb_third(uspi); |
1123 | ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; | ||
1124 | 1117 | ||
1125 | flags = UFS_SB(sb)->s_flags; | ||
1126 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { | 1118 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
1127 | buf->f_type = UFS2_MAGIC; | 1119 | buf->f_type = UFS2_MAGIC; |
1128 | buf->f_blocks = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize); | 1120 | buf->f_blocks = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
1129 | buf->f_bfree = ufs_blkstofrags(fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_cstotal.cs_nbfree)) + | 1121 | buf->f_bfree = ufs_blkstofrags( |
1130 | fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_cstotal.cs_nffree); | 1122 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree)) + |
1131 | buf->f_ffree = fs64_to_cpu(sb, | 1123 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree); |
1132 | usb->fs_u11.fs_u2.fs_cstotal.cs_nifree); | 1124 | buf->f_ffree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree); |
1133 | } | 1125 | } else { |
1134 | else { | ||
1135 | buf->f_type = UFS_MAGIC; | 1126 | buf->f_type = UFS_MAGIC; |
1136 | buf->f_blocks = uspi->s_dsize; | 1127 | buf->f_blocks = uspi->s_dsize; |
1137 | buf->f_bfree = ufs_blkstofrags(fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)) + | 1128 | buf->f_bfree = ufs_blkstofrags(fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)) + |
diff --git a/fs/ufs/util.h b/fs/ufs/util.h index e95d1c46461..eacd5e37b8e 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h | |||
@@ -39,12 +39,12 @@ ufs_get_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
39 | { | 39 | { |
40 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 40 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
41 | case UFS_ST_SUN: | 41 | case UFS_ST_SUN: |
42 | return fs32_to_cpu(sb, usb3->fs_u2.fs_sun.fs_state); | 42 | return fs32_to_cpu(sb, usb3->fs_un2.fs_sun.fs_state); |
43 | case UFS_ST_SUNx86: | 43 | case UFS_ST_SUNx86: |
44 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state); | 44 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state); |
45 | case UFS_ST_44BSD: | 45 | case UFS_ST_44BSD: |
46 | default: | 46 | default: |
47 | return fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_state); | 47 | return fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_state); |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
@@ -54,13 +54,13 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
54 | { | 54 | { |
55 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 55 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
56 | case UFS_ST_SUN: | 56 | case UFS_ST_SUN: |
57 | usb3->fs_u2.fs_sun.fs_state = cpu_to_fs32(sb, value); | 57 | usb3->fs_un2.fs_sun.fs_state = cpu_to_fs32(sb, value); |
58 | break; | 58 | break; |
59 | case UFS_ST_SUNx86: | 59 | case UFS_ST_SUNx86: |
60 | usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value); | 60 | usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value); |
61 | break; | 61 | break; |
62 | case UFS_ST_44BSD: | 62 | case UFS_ST_44BSD: |
63 | usb3->fs_u2.fs_44.fs_state = cpu_to_fs32(sb, value); | 63 | usb3->fs_un2.fs_44.fs_state = cpu_to_fs32(sb, value); |
64 | break; | 64 | break; |
65 | } | 65 | } |
66 | } | 66 | } |
@@ -70,7 +70,7 @@ ufs_get_fs_npsect(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
70 | struct ufs_super_block_third *usb3) | 70 | struct ufs_super_block_third *usb3) |
71 | { | 71 | { |
72 | if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86) | 72 | if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86) |
73 | return fs32_to_cpu(sb, usb3->fs_u2.fs_sunx86.fs_npsect); | 73 | return fs32_to_cpu(sb, usb3->fs_un2.fs_sunx86.fs_npsect); |
74 | else | 74 | else |
75 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect); | 75 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect); |
76 | } | 76 | } |
@@ -82,16 +82,16 @@ ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3) | |||
82 | 82 | ||
83 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 83 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
84 | case UFS_ST_SUN: | 84 | case UFS_ST_SUN: |
85 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qbmask[0]; | 85 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qbmask[0]; |
86 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qbmask[1]; | 86 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qbmask[1]; |
87 | break; | 87 | break; |
88 | case UFS_ST_SUNx86: | 88 | case UFS_ST_SUNx86: |
89 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qbmask[0]; | 89 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qbmask[0]; |
90 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qbmask[1]; | 90 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qbmask[1]; |
91 | break; | 91 | break; |
92 | case UFS_ST_44BSD: | 92 | case UFS_ST_44BSD: |
93 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qbmask[0]; | 93 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qbmask[0]; |
94 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qbmask[1]; | 94 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qbmask[1]; |
95 | break; | 95 | break; |
96 | } | 96 | } |
97 | 97 | ||
@@ -105,16 +105,16 @@ ufs_get_fs_qfmask(struct super_block *sb, struct ufs_super_block_third *usb3) | |||
105 | 105 | ||
106 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 106 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
107 | case UFS_ST_SUN: | 107 | case UFS_ST_SUN: |
108 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qfmask[0]; | 108 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qfmask[0]; |
109 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qfmask[1]; | 109 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qfmask[1]; |
110 | break; | 110 | break; |
111 | case UFS_ST_SUNx86: | 111 | case UFS_ST_SUNx86: |
112 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qfmask[0]; | 112 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qfmask[0]; |
113 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qfmask[1]; | 113 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qfmask[1]; |
114 | break; | 114 | break; |
115 | case UFS_ST_44BSD: | 115 | case UFS_ST_44BSD: |
116 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qfmask[0]; | 116 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qfmask[0]; |
117 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qfmask[1]; | 117 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qfmask[1]; |
118 | break; | 118 | break; |
119 | } | 119 | } |
120 | 120 | ||
@@ -302,24 +302,6 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi, | |||
302 | #define ubh_blkmap(ubh,begin,bit) \ | 302 | #define ubh_blkmap(ubh,begin,bit) \ |
303 | ((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb))) | 303 | ((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb))) |
304 | 304 | ||
305 | |||
306 | /* | ||
307 | * Macros for access to superblock array structures | ||
308 | */ | ||
309 | #define ubh_postbl(ubh,cylno,i) \ | ||
310 | ((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \ | ||
311 | ? (*(__s16*)(ubh_get_addr(ubh, \ | ||
312 | (unsigned)(&((struct ufs_super_block *)0)->fs_opostbl) \ | ||
313 | + (((cylno) * 16 + (i)) << 1) ) )) \ | ||
314 | : (*(__s16*)(ubh_get_addr(ubh, \ | ||
315 | uspi->s_postbloff + (((cylno) * uspi->s_nrpos + (i)) << 1) )))) | ||
316 | |||
317 | #define ubh_rotbl(ubh,i) \ | ||
318 | ((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \ | ||
319 | ? (*(__u8*)(ubh_get_addr(ubh, \ | ||
320 | (unsigned)(&((struct ufs_super_block *)0)->fs_space) + (i)))) \ | ||
321 | : (*(__u8*)(ubh_get_addr(ubh, uspi->s_rotbloff + (i))))) | ||
322 | |||
323 | /* | 305 | /* |
324 | * Determine the number of available frags given a | 306 | * Determine the number of available frags given a |
325 | * percentage to hold in reserve. | 307 | * percentage to hold in reserve. |
diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h index 28b31591f68..87b0a658bec 100644 --- a/include/linux/ufs_fs.h +++ b/include/linux/ufs_fs.h | |||
@@ -351,8 +351,12 @@ struct ufs2_csum_total { | |||
351 | __fs64 cs_spare[3]; /* future expansion */ | 351 | __fs64 cs_spare[3]; /* future expansion */ |
352 | }; | 352 | }; |
353 | 353 | ||
354 | #if 0 | ||
354 | /* | 355 | /* |
355 | * This is the actual superblock, as it is laid out on the disk. | 356 | * This is the actual superblock, as it is laid out on the disk. |
357 | * Do NOT use this structure, because of sizeof(ufs_super_block) > 512 and | ||
358 | * it may occupy several blocks, use | ||
359 | * struct ufs_super_block_(first,second,third) instead. | ||
356 | */ | 360 | */ |
357 | struct ufs_super_block { | 361 | struct ufs_super_block { |
358 | __fs32 fs_link; /* UNUSED */ | 362 | __fs32 fs_link; /* UNUSED */ |
@@ -498,6 +502,7 @@ struct ufs_super_block { | |||
498 | __fs32 fs_magic; /* magic number */ | 502 | __fs32 fs_magic; /* magic number */ |
499 | __u8 fs_space[1]; /* list of blocks for each rotation */ | 503 | __u8 fs_space[1]; /* list of blocks for each rotation */ |
500 | }; | 504 | }; |
505 | #endif/*struct ufs_super_block*/ | ||
501 | 506 | ||
502 | /* | 507 | /* |
503 | * Preference for optimization. | 508 | * Preference for optimization. |
@@ -837,16 +842,54 @@ struct ufs_super_block_first { | |||
837 | }; | 842 | }; |
838 | 843 | ||
839 | struct ufs_super_block_second { | 844 | struct ufs_super_block_second { |
840 | __s8 fs_fsmnt[212]; | 845 | union { |
841 | __fs32 fs_cgrotor; | 846 | struct { |
842 | __fs32 fs_csp[UFS_MAXCSBUFS]; | 847 | __s8 fs_fsmnt[212]; |
843 | __fs32 fs_maxcluster; | 848 | __fs32 fs_cgrotor; |
844 | __fs32 fs_cpc; | 849 | __fs32 fs_csp[UFS_MAXCSBUFS]; |
845 | __fs16 fs_opostbl[82]; | 850 | __fs32 fs_maxcluster; |
846 | }; | 851 | __fs32 fs_cpc; |
852 | __fs16 fs_opostbl[82]; | ||
853 | } fs_u1; | ||
854 | struct { | ||
855 | __s8 fs_fsmnt[UFS2_MAXMNTLEN - UFS_MAXMNTLEN + 212]; | ||
856 | __u8 fs_volname[UFS2_MAXVOLLEN]; | ||
857 | __fs64 fs_swuid; | ||
858 | __fs32 fs_pad; | ||
859 | __fs32 fs_cgrotor; | ||
860 | __fs32 fs_ocsp[UFS2_NOCSPTRS]; | ||
861 | __fs32 fs_contigdirs; | ||
862 | __fs32 fs_csp; | ||
863 | __fs32 fs_maxcluster; | ||
864 | __fs32 fs_active; | ||
865 | __fs32 fs_old_cpc; | ||
866 | __fs32 fs_maxbsize; | ||
867 | __fs64 fs_sparecon64[17]; | ||
868 | __fs64 fs_sblockloc; | ||
869 | __fs64 cs_ndir; | ||
870 | __fs64 cs_nbfree; | ||
871 | } fs_u2; | ||
872 | } fs_un; | ||
873 | }; | ||
847 | 874 | ||
848 | struct ufs_super_block_third { | 875 | struct ufs_super_block_third { |
849 | __fs16 fs_opostbl[46]; | 876 | union { |
877 | struct { | ||
878 | __fs16 fs_opostbl[46]; | ||
879 | } fs_u1; | ||
880 | struct { | ||
881 | __fs64 cs_nifree; /* number of free inodes */ | ||
882 | __fs64 cs_nffree; /* number of free frags */ | ||
883 | __fs64 cs_numclusters; /* number of free clusters */ | ||
884 | __fs64 cs_spare[3]; /* future expansion */ | ||
885 | struct ufs_timeval fs_time; /* last time written */ | ||
886 | __fs64 fs_size; /* number of blocks in fs */ | ||
887 | __fs64 fs_dsize; /* number of data blocks in fs */ | ||
888 | __fs64 fs_csaddr; /* blk addr of cyl grp summary area */ | ||
889 | __fs64 fs_pendingblocks;/* blocks in process of being freed */ | ||
890 | __fs32 fs_pendinginodes;/*inodes in process of being freed */ | ||
891 | } fs_u2; | ||
892 | } fs_un1; | ||
850 | union { | 893 | union { |
851 | struct { | 894 | struct { |
852 | __fs32 fs_sparecon[53];/* reserved for future constants */ | 895 | __fs32 fs_sparecon[53];/* reserved for future constants */ |
@@ -874,7 +917,7 @@ struct ufs_super_block_third { | |||
874 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ | 917 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ |
875 | __fs32 fs_state; /* file system state time stamp */ | 918 | __fs32 fs_state; /* file system state time stamp */ |
876 | } fs_44; | 919 | } fs_44; |
877 | } fs_u2; | 920 | } fs_un2; |
878 | __fs32 fs_postblformat; | 921 | __fs32 fs_postblformat; |
879 | __fs32 fs_nrpos; | 922 | __fs32 fs_nrpos; |
880 | __fs32 fs_postbloff; | 923 | __fs32 fs_postbloff; |