Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/ufs/super.c |
| 3 | * |
| 4 | * Copyright (C) 1998 |
| 5 | * Daniel Pirkl <daniel.pirkl@email.cz> |
| 6 | * Charles University, Faculty of Mathematics and Physics |
| 7 | */ |
| 8 | |
| 9 | /* Derived from |
| 10 | * |
| 11 | * linux/fs/ext2/super.c |
| 12 | * |
| 13 | * Copyright (C) 1992, 1993, 1994, 1995 |
| 14 | * Remy Card (card@masi.ibp.fr) |
| 15 | * Laboratoire MASI - Institut Blaise Pascal |
| 16 | * Universite Pierre et Marie Curie (Paris VI) |
| 17 | * |
| 18 | * from |
| 19 | * |
| 20 | * linux/fs/minix/inode.c |
| 21 | * |
| 22 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 23 | * |
| 24 | * Big-endian to little-endian byte-swapping/bitmaps by |
| 25 | * David S. Miller (davem@caip.rutgers.edu), 1995 |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * Inspired by |
| 30 | * |
| 31 | * linux/fs/ufs/super.c |
| 32 | * |
| 33 | * Copyright (C) 1996 |
| 34 | * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu) |
| 35 | * Laboratory for Computer Science Research Computing Facility |
| 36 | * Rutgers, The State University of New Jersey |
| 37 | * |
| 38 | * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be) |
| 39 | * |
| 40 | * Kernel module support added on 96/04/26 by |
| 41 | * Stefan Reinauer <stepan@home.culture.mipt.ru> |
| 42 | * |
| 43 | * Module usage counts added on 96/04/29 by |
Gertjan van Wingerde | f762dd6 | 2009-03-21 23:18:57 +0100 | [diff] [blame] | 44 | * Gertjan van Wingerde <gwingerde@gmail.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | * |
| 46 | * Clean swab support on 19970406 by |
| 47 | * Francois-Rene Rideau <fare@tunes.org> |
| 48 | * |
| 49 | * 4.4BSD (FreeBSD) support added on February 1st 1998 by |
| 50 | * Niels Kristian Bech Jensen <nkbj@image.dk> partially based |
| 51 | * on code by Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>. |
| 52 | * |
| 53 | * NeXTstep support added on February 5th 1998 by |
| 54 | * Niels Kristian Bech Jensen <nkbj@image.dk>. |
| 55 | * |
| 56 | * write support Daniel Pirkl <daniel.pirkl@email.cz> 1998 |
| 57 | * |
| 58 | * HP/UX hfs filesystem support added by |
| 59 | * Martin K. Petersen <mkp@mkp.net>, August 1999 |
| 60 | * |
| 61 | * UFS2 (of FreeBSD 5.x) support added by |
| 62 | * Niraj Kumar <niraj17@iitbombay.org>, Jan 2004 |
| 63 | * |
Evgeniy Dushistov | cbcae39 | 2007-02-12 00:54:30 -0800 | [diff] [blame] | 64 | * UFS2 write support added by |
| 65 | * Evgeniy Dushistov <dushistov@mail.ru>, 2007 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | */ |
| 67 | |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #include <linux/module.h> |
| 70 | #include <linux/bitops.h> |
| 71 | |
| 72 | #include <stdarg.h> |
| 73 | |
| 74 | #include <asm/uaccess.h> |
| 75 | #include <asm/system.h> |
| 76 | |
| 77 | #include <linux/errno.h> |
| 78 | #include <linux/fs.h> |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 79 | #include <linux/quotaops.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #include <linux/slab.h> |
| 81 | #include <linux/time.h> |
| 82 | #include <linux/stat.h> |
| 83 | #include <linux/string.h> |
| 84 | #include <linux/blkdev.h> |
| 85 | #include <linux/init.h> |
| 86 | #include <linux/parser.h> |
| 87 | #include <linux/smp_lock.h> |
| 88 | #include <linux/buffer_head.h> |
| 89 | #include <linux/vfs.h> |
vignesh babu | 9e8c427 | 2007-07-15 23:41:36 -0700 | [diff] [blame] | 90 | #include <linux/log2.h> |
Evgeniy Dushistov | 2a9807c | 2007-10-16 23:26:32 -0700 | [diff] [blame] | 91 | #include <linux/mount.h> |
| 92 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Mike Frysinger | e542059 | 2008-02-08 04:21:31 -0800 | [diff] [blame] | 94 | #include "ufs_fs.h" |
Christoph Hellwig | bcd6d4e | 2007-10-16 23:26:51 -0700 | [diff] [blame] | 95 | #include "ufs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | #include "swab.h" |
| 97 | #include "util.h" |
| 98 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 99 | #ifdef CONFIG_UFS_DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | /* |
| 101 | * Print contents of ufs_super_block, useful for debugging |
| 102 | */ |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 103 | static void ufs_print_super_stuff(struct super_block *sb, |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 104 | struct ufs_super_block_first *usb1, |
| 105 | struct ufs_super_block_second *usb2, |
| 106 | struct ufs_super_block_third *usb3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 108 | u32 magic = fs32_to_cpu(sb, usb3->fs_magic); |
| 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | printk("ufs_print_super_stuff\n"); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 111 | printk(" magic: 0x%x\n", magic); |
| 112 | if (fs32_to_cpu(sb, usb3->fs_magic) == UFS2_MAGIC) { |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 113 | printk(" fs_size: %llu\n", (unsigned long long) |
| 114 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size)); |
| 115 | printk(" fs_dsize: %llu\n", (unsigned long long) |
| 116 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize)); |
| 117 | printk(" bsize: %u\n", |
| 118 | fs32_to_cpu(sb, usb1->fs_bsize)); |
| 119 | printk(" fsize: %u\n", |
| 120 | fs32_to_cpu(sb, usb1->fs_fsize)); |
| 121 | printk(" fs_volname: %s\n", usb2->fs_un.fs_u2.fs_volname); |
| 122 | printk(" fs_sblockloc: %llu\n", (unsigned long long) |
| 123 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.fs_sblockloc)); |
| 124 | printk(" cs_ndir(No of dirs): %llu\n", (unsigned long long) |
| 125 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir)); |
| 126 | printk(" cs_nbfree(No of free blocks): %llu\n", |
| 127 | (unsigned long long) |
| 128 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree)); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 129 | printk(KERN_INFO" cs_nifree(Num of free inodes): %llu\n", |
| 130 | (unsigned long long) |
| 131 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree)); |
| 132 | printk(KERN_INFO" cs_nffree(Num of free frags): %llu\n", |
| 133 | (unsigned long long) |
| 134 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree)); |
Evgeniy Dushistov | 90b315a | 2008-02-08 04:20:16 -0800 | [diff] [blame] | 135 | printk(KERN_INFO" fs_maxsymlinklen: %u\n", |
| 136 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen)); |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 137 | } else { |
| 138 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); |
| 139 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); |
| 140 | printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); |
| 141 | printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); |
| 142 | printk(" cgoffset: %u\n", |
| 143 | fs32_to_cpu(sb, usb1->fs_cgoffset)); |
| 144 | printk(" ~cgmask: 0x%x\n", |
| 145 | ~fs32_to_cpu(sb, usb1->fs_cgmask)); |
| 146 | printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); |
| 147 | printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); |
| 148 | printk(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg)); |
| 149 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize)); |
| 150 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize)); |
| 151 | printk(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag)); |
| 152 | printk(" fragshift: %u\n", |
| 153 | fs32_to_cpu(sb, usb1->fs_fragshift)); |
| 154 | printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); |
| 155 | printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); |
| 156 | printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); |
| 157 | printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); |
| 158 | printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); |
| 159 | printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); |
| 160 | printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); |
| 161 | printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); |
| 162 | printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); |
| 163 | printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); |
| 164 | printk(" fstodb: %u\n", |
| 165 | fs32_to_cpu(sb, usb1->fs_fsbtodb)); |
| 166 | printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); |
| 167 | printk(" ndir %u\n", |
| 168 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir)); |
| 169 | printk(" nifree %u\n", |
| 170 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree)); |
| 171 | printk(" nbfree %u\n", |
| 172 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)); |
| 173 | printk(" nffree %u\n", |
| 174 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree)); |
| 175 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | printk("\n"); |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | * Print contents of ufs_cylinder_group, useful for debugging |
| 181 | */ |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 182 | static void ufs_print_cylinder_stuff(struct super_block *sb, |
| 183 | struct ufs_cylinder_group *cg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
| 185 | printk("\nufs_print_cylinder_stuff\n"); |
Andrew Morton | 96710b2 | 2006-06-25 05:47:28 -0700 | [diff] [blame] | 186 | printk("size of ucg: %zu\n", sizeof(struct ufs_cylinder_group)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | printk(" magic: %x\n", fs32_to_cpu(sb, cg->cg_magic)); |
| 188 | printk(" time: %u\n", fs32_to_cpu(sb, cg->cg_time)); |
| 189 | printk(" cgx: %u\n", fs32_to_cpu(sb, cg->cg_cgx)); |
| 190 | printk(" ncyl: %u\n", fs16_to_cpu(sb, cg->cg_ncyl)); |
| 191 | printk(" niblk: %u\n", fs16_to_cpu(sb, cg->cg_niblk)); |
| 192 | printk(" ndblk: %u\n", fs32_to_cpu(sb, cg->cg_ndblk)); |
| 193 | printk(" cs_ndir: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_ndir)); |
| 194 | printk(" cs_nbfree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nbfree)); |
| 195 | printk(" cs_nifree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nifree)); |
| 196 | printk(" cs_nffree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nffree)); |
| 197 | printk(" rotor: %u\n", fs32_to_cpu(sb, cg->cg_rotor)); |
| 198 | printk(" frotor: %u\n", fs32_to_cpu(sb, cg->cg_frotor)); |
| 199 | printk(" irotor: %u\n", fs32_to_cpu(sb, cg->cg_irotor)); |
| 200 | printk(" frsum: %u, %u, %u, %u, %u, %u, %u, %u\n", |
| 201 | fs32_to_cpu(sb, cg->cg_frsum[0]), fs32_to_cpu(sb, cg->cg_frsum[1]), |
| 202 | fs32_to_cpu(sb, cg->cg_frsum[2]), fs32_to_cpu(sb, cg->cg_frsum[3]), |
| 203 | fs32_to_cpu(sb, cg->cg_frsum[4]), fs32_to_cpu(sb, cg->cg_frsum[5]), |
| 204 | fs32_to_cpu(sb, cg->cg_frsum[6]), fs32_to_cpu(sb, cg->cg_frsum[7])); |
| 205 | printk(" btotoff: %u\n", fs32_to_cpu(sb, cg->cg_btotoff)); |
| 206 | printk(" boff: %u\n", fs32_to_cpu(sb, cg->cg_boff)); |
| 207 | printk(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); |
| 208 | printk(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); |
| 209 | printk(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 210 | printk(" clustersumoff %u\n", |
| 211 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clustersumoff)); |
| 212 | printk(" clusteroff %u\n", |
| 213 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clusteroff)); |
| 214 | printk(" nclusterblks %u\n", |
| 215 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_nclusterblks)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | printk("\n"); |
| 217 | } |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 218 | #else |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 219 | # define ufs_print_super_stuff(sb, usb1, usb2, usb3) /**/ |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 220 | # define ufs_print_cylinder_stuff(sb, cg) /**/ |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 221 | #endif /* CONFIG_UFS_DEBUG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | |
Josef 'Jeff' Sipek | ee9b6d6 | 2007-02-12 00:55:41 -0800 | [diff] [blame] | 223 | static const struct super_operations ufs_super_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
| 225 | static char error_buf[1024]; |
| 226 | |
| 227 | void ufs_error (struct super_block * sb, const char * function, |
| 228 | const char * fmt, ...) |
| 229 | { |
| 230 | struct ufs_sb_private_info * uspi; |
| 231 | struct ufs_super_block_first * usb1; |
| 232 | va_list args; |
| 233 | |
| 234 | uspi = UFS_SB(sb)->s_uspi; |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 235 | usb1 = ubh_get_usb_first(uspi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
| 237 | if (!(sb->s_flags & MS_RDONLY)) { |
| 238 | usb1->fs_clean = UFS_FSBAD; |
Evgeniy Dushistov | 9695ef1 | 2006-06-25 05:47:22 -0700 | [diff] [blame] | 239 | ubh_mark_buffer_dirty(USPI_UBH(uspi)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | sb->s_dirt = 1; |
| 241 | sb->s_flags |= MS_RDONLY; |
| 242 | } |
| 243 | va_start (args, fmt); |
Alexey Dobriyan | 4a6e617 | 2006-12-06 20:37:04 -0800 | [diff] [blame] | 244 | vsnprintf (error_buf, sizeof(error_buf), fmt, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | va_end (args); |
| 246 | switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) { |
| 247 | case UFS_MOUNT_ONERROR_PANIC: |
| 248 | panic ("UFS-fs panic (device %s): %s: %s\n", |
| 249 | sb->s_id, function, error_buf); |
| 250 | |
| 251 | case UFS_MOUNT_ONERROR_LOCK: |
| 252 | case UFS_MOUNT_ONERROR_UMOUNT: |
| 253 | case UFS_MOUNT_ONERROR_REPAIR: |
| 254 | printk (KERN_CRIT "UFS-fs error (device %s): %s: %s\n", |
| 255 | sb->s_id, function, error_buf); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | void ufs_panic (struct super_block * sb, const char * function, |
| 260 | const char * fmt, ...) |
| 261 | { |
| 262 | struct ufs_sb_private_info * uspi; |
| 263 | struct ufs_super_block_first * usb1; |
| 264 | va_list args; |
| 265 | |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 266 | lock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | uspi = UFS_SB(sb)->s_uspi; |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 268 | usb1 = ubh_get_usb_first(uspi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
| 270 | if (!(sb->s_flags & MS_RDONLY)) { |
| 271 | usb1->fs_clean = UFS_FSBAD; |
Evgeniy Dushistov | 9695ef1 | 2006-06-25 05:47:22 -0700 | [diff] [blame] | 272 | ubh_mark_buffer_dirty(USPI_UBH(uspi)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | sb->s_dirt = 1; |
| 274 | } |
| 275 | va_start (args, fmt); |
Alexey Dobriyan | 4a6e617 | 2006-12-06 20:37:04 -0800 | [diff] [blame] | 276 | vsnprintf (error_buf, sizeof(error_buf), fmt, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | va_end (args); |
| 278 | sb->s_flags |= MS_RDONLY; |
| 279 | printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n", |
| 280 | sb->s_id, function, error_buf); |
| 281 | } |
| 282 | |
| 283 | void ufs_warning (struct super_block * sb, const char * function, |
| 284 | const char * fmt, ...) |
| 285 | { |
| 286 | va_list args; |
| 287 | |
| 288 | va_start (args, fmt); |
Alexey Dobriyan | 4a6e617 | 2006-12-06 20:37:04 -0800 | [diff] [blame] | 289 | vsnprintf (error_buf, sizeof(error_buf), fmt, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | va_end (args); |
| 291 | printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n", |
| 292 | sb->s_id, function, error_buf); |
| 293 | } |
| 294 | |
| 295 | enum { |
Evgeniy Dushistov | 2a9807c | 2007-10-16 23:26:32 -0700 | [diff] [blame] | 296 | Opt_type_old = UFS_MOUNT_UFSTYPE_OLD, |
| 297 | Opt_type_sunx86 = UFS_MOUNT_UFSTYPE_SUNx86, |
| 298 | Opt_type_sun = UFS_MOUNT_UFSTYPE_SUN, |
| 299 | Opt_type_sunos = UFS_MOUNT_UFSTYPE_SUNOS, |
| 300 | Opt_type_44bsd = UFS_MOUNT_UFSTYPE_44BSD, |
| 301 | Opt_type_ufs2 = UFS_MOUNT_UFSTYPE_UFS2, |
| 302 | Opt_type_hp = UFS_MOUNT_UFSTYPE_HP, |
| 303 | Opt_type_nextstepcd = UFS_MOUNT_UFSTYPE_NEXTSTEP_CD, |
| 304 | Opt_type_nextstep = UFS_MOUNT_UFSTYPE_NEXTSTEP, |
| 305 | Opt_type_openstep = UFS_MOUNT_UFSTYPE_OPENSTEP, |
| 306 | Opt_onerror_panic = UFS_MOUNT_ONERROR_PANIC, |
| 307 | Opt_onerror_lock = UFS_MOUNT_ONERROR_LOCK, |
| 308 | Opt_onerror_umount = UFS_MOUNT_ONERROR_UMOUNT, |
| 309 | Opt_onerror_repair = UFS_MOUNT_ONERROR_REPAIR, |
| 310 | Opt_err |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | }; |
| 312 | |
Steven Whitehouse | a447c09 | 2008-10-13 10:46:57 +0100 | [diff] [blame] | 313 | static const match_table_t tokens = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | {Opt_type_old, "ufstype=old"}, |
| 315 | {Opt_type_sunx86, "ufstype=sunx86"}, |
| 316 | {Opt_type_sun, "ufstype=sun"}, |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 317 | {Opt_type_sunos, "ufstype=sunos"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | {Opt_type_44bsd, "ufstype=44bsd"}, |
| 319 | {Opt_type_ufs2, "ufstype=ufs2"}, |
| 320 | {Opt_type_ufs2, "ufstype=5xbsd"}, |
| 321 | {Opt_type_hp, "ufstype=hp"}, |
| 322 | {Opt_type_nextstepcd, "ufstype=nextstep-cd"}, |
| 323 | {Opt_type_nextstep, "ufstype=nextstep"}, |
| 324 | {Opt_type_openstep, "ufstype=openstep"}, |
Evgeniy Dushistov | 2a9807c | 2007-10-16 23:26:32 -0700 | [diff] [blame] | 325 | /*end of possible ufs types */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | {Opt_onerror_panic, "onerror=panic"}, |
| 327 | {Opt_onerror_lock, "onerror=lock"}, |
| 328 | {Opt_onerror_umount, "onerror=umount"}, |
| 329 | {Opt_onerror_repair, "onerror=repair"}, |
| 330 | {Opt_err, NULL} |
| 331 | }; |
| 332 | |
| 333 | static int ufs_parse_options (char * options, unsigned * mount_options) |
| 334 | { |
| 335 | char * p; |
| 336 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 337 | UFSD("ENTER\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
| 339 | if (!options) |
| 340 | return 1; |
| 341 | |
| 342 | while ((p = strsep(&options, ",")) != NULL) { |
| 343 | substring_t args[MAX_OPT_ARGS]; |
| 344 | int token; |
| 345 | if (!*p) |
| 346 | continue; |
| 347 | |
| 348 | token = match_token(p, tokens, args); |
| 349 | switch (token) { |
| 350 | case Opt_type_old: |
| 351 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 352 | ufs_set_opt (*mount_options, UFSTYPE_OLD); |
| 353 | break; |
| 354 | case Opt_type_sunx86: |
| 355 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 356 | ufs_set_opt (*mount_options, UFSTYPE_SUNx86); |
| 357 | break; |
| 358 | case Opt_type_sun: |
| 359 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 360 | ufs_set_opt (*mount_options, UFSTYPE_SUN); |
| 361 | break; |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 362 | case Opt_type_sunos: |
| 363 | ufs_clear_opt(*mount_options, UFSTYPE); |
| 364 | ufs_set_opt(*mount_options, UFSTYPE_SUNOS); |
| 365 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | case Opt_type_44bsd: |
| 367 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 368 | ufs_set_opt (*mount_options, UFSTYPE_44BSD); |
| 369 | break; |
| 370 | case Opt_type_ufs2: |
| 371 | ufs_clear_opt(*mount_options, UFSTYPE); |
| 372 | ufs_set_opt(*mount_options, UFSTYPE_UFS2); |
| 373 | break; |
| 374 | case Opt_type_hp: |
| 375 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 376 | ufs_set_opt (*mount_options, UFSTYPE_HP); |
| 377 | break; |
| 378 | case Opt_type_nextstepcd: |
| 379 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 380 | ufs_set_opt (*mount_options, UFSTYPE_NEXTSTEP_CD); |
| 381 | break; |
| 382 | case Opt_type_nextstep: |
| 383 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 384 | ufs_set_opt (*mount_options, UFSTYPE_NEXTSTEP); |
| 385 | break; |
| 386 | case Opt_type_openstep: |
| 387 | ufs_clear_opt (*mount_options, UFSTYPE); |
| 388 | ufs_set_opt (*mount_options, UFSTYPE_OPENSTEP); |
| 389 | break; |
| 390 | case Opt_onerror_panic: |
| 391 | ufs_clear_opt (*mount_options, ONERROR); |
| 392 | ufs_set_opt (*mount_options, ONERROR_PANIC); |
| 393 | break; |
| 394 | case Opt_onerror_lock: |
| 395 | ufs_clear_opt (*mount_options, ONERROR); |
| 396 | ufs_set_opt (*mount_options, ONERROR_LOCK); |
| 397 | break; |
| 398 | case Opt_onerror_umount: |
| 399 | ufs_clear_opt (*mount_options, ONERROR); |
| 400 | ufs_set_opt (*mount_options, ONERROR_UMOUNT); |
| 401 | break; |
| 402 | case Opt_onerror_repair: |
| 403 | printk("UFS-fs: Unable to do repair on error, " |
| 404 | "will lock lock instead\n"); |
| 405 | ufs_clear_opt (*mount_options, ONERROR); |
| 406 | ufs_set_opt (*mount_options, ONERROR_REPAIR); |
| 407 | break; |
| 408 | default: |
| 409 | printk("UFS-fs: Invalid option: \"%s\" " |
| 410 | "or missing value\n", p); |
| 411 | return 0; |
| 412 | } |
| 413 | } |
| 414 | return 1; |
| 415 | } |
| 416 | |
| 417 | /* |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 418 | * Diffrent types of UFS hold fs_cstotal in different |
| 419 | * places, and use diffrent data structure for it. |
| 420 | * To make things simplier we just copy fs_cstotal to ufs_sb_private_info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | */ |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 422 | static void ufs_setup_cstotal(struct super_block *sb) |
Evgeniy Dushistov | e295cfc | 2006-02-03 03:04:04 -0800 | [diff] [blame] | 423 | { |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 424 | struct ufs_sb_info *sbi = UFS_SB(sb); |
| 425 | struct ufs_sb_private_info *uspi = sbi->s_uspi; |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 426 | struct ufs_super_block_first *usb1; |
| 427 | struct ufs_super_block_second *usb2; |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 428 | struct ufs_super_block_third *usb3; |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 429 | unsigned mtype = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE; |
| 430 | |
| 431 | UFSD("ENTER, mtype=%u\n", mtype); |
| 432 | usb1 = ubh_get_usb_first(uspi); |
| 433 | usb2 = ubh_get_usb_second(uspi); |
| 434 | usb3 = ubh_get_usb_third(uspi); |
| 435 | |
| 436 | if ((mtype == UFS_MOUNT_UFSTYPE_44BSD && |
| 437 | (usb1->fs_flags & UFS_FLAGS_UPDATED)) || |
| 438 | mtype == UFS_MOUNT_UFSTYPE_UFS2) { |
| 439 | /*we have statistic in different place, then usual*/ |
| 440 | uspi->cs_total.cs_ndir = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir); |
| 441 | uspi->cs_total.cs_nbfree = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree); |
| 442 | uspi->cs_total.cs_nifree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree); |
| 443 | uspi->cs_total.cs_nffree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree); |
| 444 | } else { |
| 445 | uspi->cs_total.cs_ndir = fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir); |
| 446 | uspi->cs_total.cs_nbfree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree); |
| 447 | uspi->cs_total.cs_nifree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree); |
| 448 | uspi->cs_total.cs_nffree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree); |
| 449 | } |
| 450 | UFSD("EXIT\n"); |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * Read on-disk structures associated with cylinder groups |
| 455 | */ |
| 456 | static int ufs_read_cylinder_structures(struct super_block *sb) |
| 457 | { |
| 458 | struct ufs_sb_info *sbi = UFS_SB(sb); |
| 459 | struct ufs_sb_private_info *uspi = sbi->s_uspi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | struct ufs_buffer_head * ubh; |
| 461 | unsigned char * base, * space; |
| 462 | unsigned size, blks, i; |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 463 | struct ufs_super_block_third *usb3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 465 | UFSD("ENTER\n"); |
| 466 | |
| 467 | usb3 = ubh_get_usb_third(uspi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | /* |
| 469 | * Read cs structures from (usually) first data block |
| 470 | * on the device. |
| 471 | */ |
| 472 | size = uspi->s_cssize; |
| 473 | blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; |
| 474 | base = space = kmalloc(size, GFP_KERNEL); |
| 475 | if (!base) |
| 476 | goto failed; |
Evgeniy Dushistov | e295cfc | 2006-02-03 03:04:04 -0800 | [diff] [blame] | 477 | sbi->s_csp = (struct ufs_csum *)space; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | for (i = 0; i < blks; i += uspi->s_fpb) { |
| 479 | size = uspi->s_bsize; |
| 480 | if (i + uspi->s_fpb > blks) |
| 481 | size = (blks - i) * uspi->s_fsize; |
| 482 | |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 483 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 484 | |
| 485 | if (!ubh) |
| 486 | goto failed; |
| 487 | |
| 488 | ubh_ubhcpymem (space, ubh, size); |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 489 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | space += size; |
| 491 | ubh_brelse (ubh); |
| 492 | ubh = NULL; |
| 493 | } |
| 494 | |
| 495 | /* |
| 496 | * Read cylinder group (we read only first fragment from block |
| 497 | * at this time) and prepare internal data structures for cg caching. |
| 498 | */ |
| 499 | if (!(sbi->s_ucg = kmalloc (sizeof(struct buffer_head *) * uspi->s_ncg, GFP_KERNEL))) |
| 500 | goto failed; |
| 501 | for (i = 0; i < uspi->s_ncg; i++) |
| 502 | sbi->s_ucg[i] = NULL; |
| 503 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { |
| 504 | sbi->s_ucpi[i] = NULL; |
| 505 | sbi->s_cgno[i] = UFS_CGNO_EMPTY; |
| 506 | } |
| 507 | for (i = 0; i < uspi->s_ncg; i++) { |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 508 | UFSD("read cg %u\n", i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | if (!(sbi->s_ucg[i] = sb_bread(sb, ufs_cgcmin(i)))) |
| 510 | goto failed; |
| 511 | if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) |
| 512 | goto failed; |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 513 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | } |
| 516 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { |
| 517 | if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) |
| 518 | goto failed; |
| 519 | sbi->s_cgno[i] = UFS_CGNO_EMPTY; |
| 520 | } |
| 521 | sbi->s_cg_loaded = 0; |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 522 | UFSD("EXIT\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | return 1; |
| 524 | |
| 525 | failed: |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 526 | kfree (base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | if (sbi->s_ucg) { |
| 528 | for (i = 0; i < uspi->s_ncg; i++) |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 529 | if (sbi->s_ucg[i]) |
| 530 | brelse (sbi->s_ucg[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | kfree (sbi->s_ucg); |
| 532 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 533 | kfree (sbi->s_ucpi[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | } |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 535 | UFSD("EXIT (FAILED)\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | return 0; |
| 537 | } |
| 538 | |
| 539 | /* |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 540 | * Sync our internal copy of fs_cstotal with disk |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | */ |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 542 | static void ufs_put_cstotal(struct super_block *sb) |
Evgeniy Dushistov | e295cfc | 2006-02-03 03:04:04 -0800 | [diff] [blame] | 543 | { |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 544 | unsigned mtype = UFS_SB(sb)->s_mount_opt & UFS_MOUNT_UFSTYPE; |
| 545 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
| 546 | struct ufs_super_block_first *usb1; |
| 547 | struct ufs_super_block_second *usb2; |
| 548 | struct ufs_super_block_third *usb3; |
| 549 | |
| 550 | UFSD("ENTER\n"); |
| 551 | usb1 = ubh_get_usb_first(uspi); |
| 552 | usb2 = ubh_get_usb_second(uspi); |
| 553 | usb3 = ubh_get_usb_third(uspi); |
| 554 | |
| 555 | if ((mtype == UFS_MOUNT_UFSTYPE_44BSD && |
| 556 | (usb1->fs_flags & UFS_FLAGS_UPDATED)) || |
| 557 | mtype == UFS_MOUNT_UFSTYPE_UFS2) { |
| 558 | /*we have statistic in different place, then usual*/ |
| 559 | usb2->fs_un.fs_u2.cs_ndir = |
| 560 | cpu_to_fs64(sb, uspi->cs_total.cs_ndir); |
| 561 | usb2->fs_un.fs_u2.cs_nbfree = |
| 562 | cpu_to_fs64(sb, uspi->cs_total.cs_nbfree); |
| 563 | usb3->fs_un1.fs_u2.cs_nifree = |
| 564 | cpu_to_fs64(sb, uspi->cs_total.cs_nifree); |
| 565 | usb3->fs_un1.fs_u2.cs_nffree = |
| 566 | cpu_to_fs64(sb, uspi->cs_total.cs_nffree); |
| 567 | } else { |
| 568 | usb1->fs_cstotal.cs_ndir = |
| 569 | cpu_to_fs32(sb, uspi->cs_total.cs_ndir); |
| 570 | usb1->fs_cstotal.cs_nbfree = |
| 571 | cpu_to_fs32(sb, uspi->cs_total.cs_nbfree); |
| 572 | usb1->fs_cstotal.cs_nifree = |
| 573 | cpu_to_fs32(sb, uspi->cs_total.cs_nifree); |
| 574 | usb1->fs_cstotal.cs_nffree = |
| 575 | cpu_to_fs32(sb, uspi->cs_total.cs_nffree); |
| 576 | } |
| 577 | ubh_mark_buffer_dirty(USPI_UBH(uspi)); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 578 | ufs_print_super_stuff(sb, usb1, usb2, usb3); |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 579 | UFSD("EXIT\n"); |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * ufs_put_super_internal() - put on-disk intrenal structures |
| 584 | * @sb: pointer to super_block structure |
| 585 | * Put on-disk structures associated with cylinder groups |
| 586 | * and write them back to disk, also update cs_total on disk |
| 587 | */ |
| 588 | static void ufs_put_super_internal(struct super_block *sb) |
| 589 | { |
| 590 | struct ufs_sb_info *sbi = UFS_SB(sb); |
| 591 | struct ufs_sb_private_info *uspi = sbi->s_uspi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | struct ufs_buffer_head * ubh; |
| 593 | unsigned char * base, * space; |
| 594 | unsigned blks, size, i; |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 595 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 597 | UFSD("ENTER\n"); |
Christoph Hellwig | 6cfd014 | 2009-05-05 15:40:36 +0200 | [diff] [blame] | 598 | |
| 599 | lock_kernel(); |
| 600 | |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 601 | ufs_put_cstotal(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | size = uspi->s_cssize; |
| 603 | blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; |
Evgeniy Dushistov | e295cfc | 2006-02-03 03:04:04 -0800 | [diff] [blame] | 604 | base = space = (char*) sbi->s_csp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | for (i = 0; i < blks; i += uspi->s_fpb) { |
| 606 | size = uspi->s_bsize; |
| 607 | if (i + uspi->s_fpb > blks) |
| 608 | size = (blks - i) * uspi->s_fsize; |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 609 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 611 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | ubh_memcpyubh (ubh, space, size); |
| 613 | space += size; |
| 614 | ubh_mark_buffer_uptodate (ubh, 1); |
| 615 | ubh_mark_buffer_dirty (ubh); |
| 616 | ubh_brelse (ubh); |
| 617 | } |
| 618 | for (i = 0; i < sbi->s_cg_loaded; i++) { |
| 619 | ufs_put_cylinder (sb, i); |
| 620 | kfree (sbi->s_ucpi[i]); |
| 621 | } |
| 622 | for (; i < UFS_MAX_GROUP_LOADED; i++) |
| 623 | kfree (sbi->s_ucpi[i]); |
| 624 | for (i = 0; i < uspi->s_ncg; i++) |
| 625 | brelse (sbi->s_ucg[i]); |
| 626 | kfree (sbi->s_ucg); |
| 627 | kfree (base); |
Christoph Hellwig | 6cfd014 | 2009-05-05 15:40:36 +0200 | [diff] [blame] | 628 | |
| 629 | unlock_kernel(); |
| 630 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 631 | UFSD("EXIT\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | static int ufs_fill_super(struct super_block *sb, void *data, int silent) |
| 635 | { |
| 636 | struct ufs_sb_info * sbi; |
| 637 | struct ufs_sb_private_info * uspi; |
| 638 | struct ufs_super_block_first * usb1; |
| 639 | struct ufs_super_block_second * usb2; |
| 640 | struct ufs_super_block_third * usb3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | struct ufs_buffer_head * ubh; |
| 642 | struct inode *inode; |
| 643 | unsigned block_size, super_block_size; |
| 644 | unsigned flags; |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 645 | unsigned super_block_offset; |
Duane Griffin | 9e6766c | 2009-01-08 22:43:48 +0000 | [diff] [blame] | 646 | unsigned maxsymlen; |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 647 | int ret = -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | |
| 649 | uspi = NULL; |
| 650 | ubh = NULL; |
| 651 | flags = 0; |
| 652 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 653 | UFSD("ENTER\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
Panagiotis Issaris | f8314dc | 2006-09-27 01:49:37 -0700 | [diff] [blame] | 655 | sbi = kzalloc(sizeof(struct ufs_sb_info), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | if (!sbi) |
| 657 | goto failed_nomem; |
| 658 | sb->s_fs_info = sbi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 660 | UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | |
| 662 | #ifndef CONFIG_UFS_FS_WRITE |
| 663 | if (!(sb->s_flags & MS_RDONLY)) { |
| 664 | printk("ufs was compiled with read-only support, " |
| 665 | "can't be mounted as read-write\n"); |
| 666 | goto failed; |
| 667 | } |
| 668 | #endif |
| 669 | /* |
| 670 | * Set default mount options |
| 671 | * Parse mount options |
| 672 | */ |
| 673 | sbi->s_mount_opt = 0; |
| 674 | ufs_set_opt (sbi->s_mount_opt, ONERROR_LOCK); |
| 675 | if (!ufs_parse_options ((char *) data, &sbi->s_mount_opt)) { |
| 676 | printk("wrong mount options\n"); |
| 677 | goto failed; |
| 678 | } |
| 679 | if (!(sbi->s_mount_opt & UFS_MOUNT_UFSTYPE)) { |
| 680 | if (!silent) |
| 681 | printk("You didn't specify the type of your ufs filesystem\n\n" |
| 682 | "mount -t ufs -o ufstype=" |
Michael Owen | c690a72 | 2006-03-24 18:21:44 +0100 | [diff] [blame] | 683 | "sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...\n\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | ">>>WARNING<<< Wrong ufstype may corrupt your filesystem, " |
| 685 | "default is ufstype=old\n"); |
| 686 | ufs_set_opt (sbi->s_mount_opt, UFSTYPE_OLD); |
| 687 | } |
| 688 | |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 689 | uspi = kzalloc(sizeof(struct ufs_sb_private_info), GFP_KERNEL); |
| 690 | sbi->s_uspi = uspi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | if (!uspi) |
| 692 | goto failed; |
Evgeniy Dushistov | f336953 | 2007-02-08 14:20:25 -0800 | [diff] [blame] | 693 | uspi->s_dirblksize = UFS_SECTOR_SIZE; |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 694 | super_block_offset=UFS_SBLOCK; |
| 695 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | /* Keep 2Gig file limit. Some UFS variants need to override |
| 697 | this but as I don't know which I'll let those in the know loosen |
| 698 | the rules */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { |
| 700 | case UFS_MOUNT_UFSTYPE_44BSD: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 701 | UFSD("ufstype=44bsd\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | uspi->s_fsize = block_size = 512; |
| 703 | uspi->s_fmask = ~(512 - 1); |
| 704 | uspi->s_fshift = 9; |
| 705 | uspi->s_sbsize = super_block_size = 1536; |
| 706 | uspi->s_sbbase = 0; |
| 707 | flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; |
| 708 | break; |
| 709 | case UFS_MOUNT_UFSTYPE_UFS2: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 710 | UFSD("ufstype=ufs2\n"); |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 711 | super_block_offset=SBLOCK_UFS2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | uspi->s_fsize = block_size = 512; |
| 713 | uspi->s_fmask = ~(512 - 1); |
| 714 | uspi->s_fshift = 9; |
| 715 | uspi->s_sbsize = super_block_size = 1536; |
| 716 | uspi->s_sbbase = 0; |
| 717 | flags |= UFS_TYPE_UFS2 | UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | break; |
| 719 | |
| 720 | case UFS_MOUNT_UFSTYPE_SUN: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 721 | UFSD("ufstype=sun\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | uspi->s_fsize = block_size = 1024; |
| 723 | uspi->s_fmask = ~(1024 - 1); |
| 724 | uspi->s_fshift = 10; |
| 725 | uspi->s_sbsize = super_block_size = 2048; |
| 726 | uspi->s_sbbase = 0; |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 727 | uspi->s_maxsymlinklen = 0; /* Not supported on disk */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | flags |= UFS_DE_OLD | UFS_UID_EFT | UFS_ST_SUN | UFS_CG_SUN; |
| 729 | break; |
| 730 | |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 731 | case UFS_MOUNT_UFSTYPE_SUNOS: |
| 732 | UFSD(("ufstype=sunos\n")) |
| 733 | uspi->s_fsize = block_size = 1024; |
| 734 | uspi->s_fmask = ~(1024 - 1); |
| 735 | uspi->s_fshift = 10; |
| 736 | uspi->s_sbsize = 2048; |
| 737 | super_block_size = 2048; |
| 738 | uspi->s_sbbase = 0; |
| 739 | uspi->s_maxsymlinklen = 0; /* Not supported on disk */ |
| 740 | flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_SUNOS | UFS_CG_SUN; |
| 741 | break; |
| 742 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | case UFS_MOUNT_UFSTYPE_SUNx86: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 744 | UFSD("ufstype=sunx86\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | uspi->s_fsize = block_size = 1024; |
| 746 | uspi->s_fmask = ~(1024 - 1); |
| 747 | uspi->s_fshift = 10; |
| 748 | uspi->s_sbsize = super_block_size = 2048; |
| 749 | uspi->s_sbbase = 0; |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 750 | uspi->s_maxsymlinklen = 0; /* Not supported on disk */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | flags |= UFS_DE_OLD | UFS_UID_EFT | UFS_ST_SUNx86 | UFS_CG_SUN; |
| 752 | break; |
| 753 | |
| 754 | case UFS_MOUNT_UFSTYPE_OLD: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 755 | UFSD("ufstype=old\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | uspi->s_fsize = block_size = 1024; |
| 757 | uspi->s_fmask = ~(1024 - 1); |
| 758 | uspi->s_fshift = 10; |
| 759 | uspi->s_sbsize = super_block_size = 2048; |
| 760 | uspi->s_sbbase = 0; |
| 761 | flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD; |
| 762 | if (!(sb->s_flags & MS_RDONLY)) { |
| 763 | if (!silent) |
| 764 | printk(KERN_INFO "ufstype=old is supported read-only\n"); |
| 765 | sb->s_flags |= MS_RDONLY; |
| 766 | } |
| 767 | break; |
| 768 | |
| 769 | case UFS_MOUNT_UFSTYPE_NEXTSTEP: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 770 | UFSD("ufstype=nextstep\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | uspi->s_fsize = block_size = 1024; |
| 772 | uspi->s_fmask = ~(1024 - 1); |
| 773 | uspi->s_fshift = 10; |
| 774 | uspi->s_sbsize = super_block_size = 2048; |
| 775 | uspi->s_sbbase = 0; |
Evgeniy Dushistov | 0c664f9 | 2007-12-04 23:45:06 -0800 | [diff] [blame] | 776 | uspi->s_dirblksize = 1024; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD; |
| 778 | if (!(sb->s_flags & MS_RDONLY)) { |
| 779 | if (!silent) |
| 780 | printk(KERN_INFO "ufstype=nextstep is supported read-only\n"); |
| 781 | sb->s_flags |= MS_RDONLY; |
| 782 | } |
| 783 | break; |
| 784 | |
| 785 | case UFS_MOUNT_UFSTYPE_NEXTSTEP_CD: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 786 | UFSD("ufstype=nextstep-cd\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | uspi->s_fsize = block_size = 2048; |
| 788 | uspi->s_fmask = ~(2048 - 1); |
| 789 | uspi->s_fshift = 11; |
| 790 | uspi->s_sbsize = super_block_size = 2048; |
| 791 | uspi->s_sbbase = 0; |
Evgeniy Dushistov | 0c664f9 | 2007-12-04 23:45:06 -0800 | [diff] [blame] | 792 | uspi->s_dirblksize = 1024; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD; |
| 794 | if (!(sb->s_flags & MS_RDONLY)) { |
| 795 | if (!silent) |
| 796 | printk(KERN_INFO "ufstype=nextstep-cd is supported read-only\n"); |
| 797 | sb->s_flags |= MS_RDONLY; |
| 798 | } |
| 799 | break; |
| 800 | |
| 801 | case UFS_MOUNT_UFSTYPE_OPENSTEP: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 802 | UFSD("ufstype=openstep\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | uspi->s_fsize = block_size = 1024; |
| 804 | uspi->s_fmask = ~(1024 - 1); |
| 805 | uspi->s_fshift = 10; |
| 806 | uspi->s_sbsize = super_block_size = 2048; |
| 807 | uspi->s_sbbase = 0; |
Evgeniy Dushistov | f336953 | 2007-02-08 14:20:25 -0800 | [diff] [blame] | 808 | uspi->s_dirblksize = 1024; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; |
| 810 | if (!(sb->s_flags & MS_RDONLY)) { |
| 811 | if (!silent) |
| 812 | printk(KERN_INFO "ufstype=openstep is supported read-only\n"); |
| 813 | sb->s_flags |= MS_RDONLY; |
| 814 | } |
| 815 | break; |
| 816 | |
| 817 | case UFS_MOUNT_UFSTYPE_HP: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 818 | UFSD("ufstype=hp\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | uspi->s_fsize = block_size = 1024; |
| 820 | uspi->s_fmask = ~(1024 - 1); |
| 821 | uspi->s_fshift = 10; |
| 822 | uspi->s_sbsize = super_block_size = 2048; |
| 823 | uspi->s_sbbase = 0; |
| 824 | flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD; |
| 825 | if (!(sb->s_flags & MS_RDONLY)) { |
| 826 | if (!silent) |
| 827 | printk(KERN_INFO "ufstype=hp is supported read-only\n"); |
| 828 | sb->s_flags |= MS_RDONLY; |
| 829 | } |
| 830 | break; |
| 831 | default: |
| 832 | if (!silent) |
| 833 | printk("unknown ufstype\n"); |
| 834 | goto failed; |
| 835 | } |
| 836 | |
| 837 | again: |
| 838 | if (!sb_set_blocksize(sb, block_size)) { |
| 839 | printk(KERN_ERR "UFS: failed to set blocksize\n"); |
| 840 | goto failed; |
| 841 | } |
| 842 | |
| 843 | /* |
| 844 | * read ufs super block from device |
| 845 | */ |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 846 | |
| 847 | ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + super_block_offset/block_size, super_block_size); |
| 848 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | if (!ubh) |
| 850 | goto failed; |
| 851 | |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 852 | usb1 = ubh_get_usb_first(uspi); |
| 853 | usb2 = ubh_get_usb_second(uspi); |
| 854 | usb3 = ubh_get_usb_third(uspi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 856 | /* Sort out mod used on SunOS 4.1.3 for fs_state */ |
| 857 | uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); |
| 858 | if (((flags & UFS_ST_MASK) == UFS_ST_SUNOS) && |
| 859 | (uspi->s_postblformat != UFS_42POSTBLFMT)) { |
| 860 | flags &= ~UFS_ST_MASK; |
| 861 | flags |= UFS_ST_SUN; |
| 862 | } |
| 863 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | /* |
| 865 | * Check ufs magic number |
| 866 | */ |
| 867 | sbi->s_bytesex = BYTESEX_LE; |
| 868 | switch ((uspi->fs_magic = fs32_to_cpu(sb, usb3->fs_magic))) { |
| 869 | case UFS_MAGIC: |
| 870 | case UFS2_MAGIC: |
| 871 | case UFS_MAGIC_LFN: |
| 872 | case UFS_MAGIC_FEA: |
| 873 | case UFS_MAGIC_4GB: |
| 874 | goto magic_found; |
| 875 | } |
| 876 | sbi->s_bytesex = BYTESEX_BE; |
| 877 | switch ((uspi->fs_magic = fs32_to_cpu(sb, usb3->fs_magic))) { |
| 878 | case UFS_MAGIC: |
| 879 | case UFS2_MAGIC: |
| 880 | case UFS_MAGIC_LFN: |
| 881 | case UFS_MAGIC_FEA: |
| 882 | case UFS_MAGIC_4GB: |
| 883 | goto magic_found; |
| 884 | } |
| 885 | |
| 886 | if ((((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_NEXTSTEP) |
| 887 | || ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_NEXTSTEP_CD) |
| 888 | || ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_OPENSTEP)) |
| 889 | && uspi->s_sbbase < 256) { |
| 890 | ubh_brelse_uspi(uspi); |
| 891 | ubh = NULL; |
| 892 | uspi->s_sbbase += 8; |
| 893 | goto again; |
| 894 | } |
| 895 | if (!silent) |
| 896 | printk("ufs_read_super: bad magic number\n"); |
| 897 | goto failed; |
| 898 | |
| 899 | magic_found: |
| 900 | /* |
| 901 | * Check block and fragment sizes |
| 902 | */ |
| 903 | uspi->s_bsize = fs32_to_cpu(sb, usb1->fs_bsize); |
| 904 | uspi->s_fsize = fs32_to_cpu(sb, usb1->fs_fsize); |
| 905 | uspi->s_sbsize = fs32_to_cpu(sb, usb1->fs_sbsize); |
| 906 | uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask); |
| 907 | uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift); |
| 908 | |
vignesh babu | 9e8c427 | 2007-07-15 23:41:36 -0700 | [diff] [blame] | 909 | if (!is_power_of_2(uspi->s_fsize)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | printk(KERN_ERR "ufs_read_super: fragment size %u is not a power of 2\n", |
| 911 | uspi->s_fsize); |
| 912 | goto failed; |
| 913 | } |
| 914 | if (uspi->s_fsize < 512) { |
| 915 | printk(KERN_ERR "ufs_read_super: fragment size %u is too small\n", |
| 916 | uspi->s_fsize); |
| 917 | goto failed; |
| 918 | } |
| 919 | if (uspi->s_fsize > 4096) { |
| 920 | printk(KERN_ERR "ufs_read_super: fragment size %u is too large\n", |
| 921 | uspi->s_fsize); |
| 922 | goto failed; |
| 923 | } |
vignesh babu | 9e8c427 | 2007-07-15 23:41:36 -0700 | [diff] [blame] | 924 | if (!is_power_of_2(uspi->s_bsize)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | printk(KERN_ERR "ufs_read_super: block size %u is not a power of 2\n", |
| 926 | uspi->s_bsize); |
| 927 | goto failed; |
| 928 | } |
| 929 | if (uspi->s_bsize < 4096) { |
| 930 | printk(KERN_ERR "ufs_read_super: block size %u is too small\n", |
| 931 | uspi->s_bsize); |
| 932 | goto failed; |
| 933 | } |
| 934 | if (uspi->s_bsize / uspi->s_fsize > 8) { |
| 935 | printk(KERN_ERR "ufs_read_super: too many fragments per block (%u)\n", |
| 936 | uspi->s_bsize / uspi->s_fsize); |
| 937 | goto failed; |
| 938 | } |
| 939 | if (uspi->s_fsize != block_size || uspi->s_sbsize != super_block_size) { |
| 940 | ubh_brelse_uspi(uspi); |
| 941 | ubh = NULL; |
| 942 | block_size = uspi->s_fsize; |
| 943 | super_block_size = uspi->s_sbsize; |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 944 | UFSD("another value of block_size or super_block_size %u, %u\n", block_size, super_block_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | goto again; |
| 946 | } |
| 947 | |
Andrew Morton | f664f1f | 2007-10-29 14:37:21 -0700 | [diff] [blame] | 948 | sbi->s_flags = flags;/*after that line some functions use s_flags*/ |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 949 | ufs_print_super_stuff(sb, usb1, usb2, usb3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | |
| 951 | /* |
| 952 | * Check, if file system was correctly unmounted. |
| 953 | * If not, make it read only. |
| 954 | */ |
Andrew Morton | f664f1f | 2007-10-29 14:37:21 -0700 | [diff] [blame] | 955 | if (((flags & UFS_ST_MASK) == UFS_ST_44BSD) || |
| 956 | ((flags & UFS_ST_MASK) == UFS_ST_OLD) || |
| 957 | (((flags & UFS_ST_MASK) == UFS_ST_SUN || |
| 958 | (flags & UFS_ST_MASK) == UFS_ST_SUNOS || |
| 959 | (flags & UFS_ST_MASK) == UFS_ST_SUNx86) && |
| 960 | (ufs_get_fs_state(sb, usb1, usb3) == (UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time))))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | switch(usb1->fs_clean) { |
| 962 | case UFS_FSCLEAN: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 963 | UFSD("fs is clean\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | break; |
| 965 | case UFS_FSSTABLE: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 966 | UFSD("fs is stable\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | break; |
| 968 | case UFS_FSOSF1: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 969 | UFSD("fs is DEC OSF/1\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | break; |
| 971 | case UFS_FSACTIVE: |
| 972 | printk("ufs_read_super: fs is active\n"); |
| 973 | sb->s_flags |= MS_RDONLY; |
| 974 | break; |
| 975 | case UFS_FSBAD: |
| 976 | printk("ufs_read_super: fs is bad\n"); |
| 977 | sb->s_flags |= MS_RDONLY; |
| 978 | break; |
| 979 | default: |
| 980 | printk("ufs_read_super: can't grok fs_clean 0x%x\n", usb1->fs_clean); |
| 981 | sb->s_flags |= MS_RDONLY; |
| 982 | break; |
| 983 | } |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 984 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | printk("ufs_read_super: fs needs fsck\n"); |
| 986 | sb->s_flags |= MS_RDONLY; |
| 987 | } |
| 988 | |
| 989 | /* |
| 990 | * Read ufs_super_block into internal data structures |
| 991 | */ |
| 992 | sb->s_op = &ufs_super_ops; |
| 993 | sb->dq_op = NULL; /***/ |
| 994 | sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); |
| 995 | |
| 996 | uspi->s_sblkno = fs32_to_cpu(sb, usb1->fs_sblkno); |
| 997 | uspi->s_cblkno = fs32_to_cpu(sb, usb1->fs_cblkno); |
| 998 | uspi->s_iblkno = fs32_to_cpu(sb, usb1->fs_iblkno); |
| 999 | uspi->s_dblkno = fs32_to_cpu(sb, usb1->fs_dblkno); |
| 1000 | uspi->s_cgoffset = fs32_to_cpu(sb, usb1->fs_cgoffset); |
| 1001 | uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); |
| 1002 | |
| 1003 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1004 | uspi->s_u2_size = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size); |
| 1005 | uspi->s_u2_dsize = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
| 1006 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); |
| 1008 | uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); |
| 1009 | } |
| 1010 | |
| 1011 | uspi->s_ncg = fs32_to_cpu(sb, usb1->fs_ncg); |
| 1012 | /* s_bsize already set */ |
| 1013 | /* s_fsize already set */ |
| 1014 | uspi->s_fpb = fs32_to_cpu(sb, usb1->fs_frag); |
| 1015 | uspi->s_minfree = fs32_to_cpu(sb, usb1->fs_minfree); |
| 1016 | uspi->s_bmask = fs32_to_cpu(sb, usb1->fs_bmask); |
| 1017 | uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask); |
| 1018 | uspi->s_bshift = fs32_to_cpu(sb, usb1->fs_bshift); |
| 1019 | uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift); |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1020 | UFSD("uspi->s_bshift = %d,uspi->s_fshift = %d", uspi->s_bshift, |
| 1021 | uspi->s_fshift); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | uspi->s_fpbshift = fs32_to_cpu(sb, usb1->fs_fragshift); |
| 1023 | uspi->s_fsbtodb = fs32_to_cpu(sb, usb1->fs_fsbtodb); |
| 1024 | /* s_sbsize already set */ |
| 1025 | uspi->s_csmask = fs32_to_cpu(sb, usb1->fs_csmask); |
| 1026 | uspi->s_csshift = fs32_to_cpu(sb, usb1->fs_csshift); |
| 1027 | uspi->s_nindir = fs32_to_cpu(sb, usb1->fs_nindir); |
| 1028 | uspi->s_inopb = fs32_to_cpu(sb, usb1->fs_inopb); |
| 1029 | uspi->s_nspf = fs32_to_cpu(sb, usb1->fs_nspf); |
| 1030 | uspi->s_npsect = ufs_get_fs_npsect(sb, usb1, usb3); |
| 1031 | uspi->s_interleave = fs32_to_cpu(sb, usb1->fs_interleave); |
| 1032 | uspi->s_trackskew = fs32_to_cpu(sb, usb1->fs_trackskew); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 1033 | |
| 1034 | if (uspi->fs_magic == UFS2_MAGIC) |
| 1035 | uspi->s_csaddr = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_csaddr); |
| 1036 | else |
| 1037 | uspi->s_csaddr = fs32_to_cpu(sb, usb1->fs_csaddr); |
| 1038 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | uspi->s_cssize = fs32_to_cpu(sb, usb1->fs_cssize); |
| 1040 | uspi->s_cgsize = fs32_to_cpu(sb, usb1->fs_cgsize); |
| 1041 | uspi->s_ntrak = fs32_to_cpu(sb, usb1->fs_ntrak); |
| 1042 | uspi->s_nsect = fs32_to_cpu(sb, usb1->fs_nsect); |
| 1043 | uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); |
| 1044 | uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); |
| 1045 | uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1046 | uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_un.fs_u1.fs_cpc); |
| 1047 | uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_contigsumsize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); |
| 1049 | uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | uspi->s_nrpos = fs32_to_cpu(sb, usb3->fs_nrpos); |
| 1051 | uspi->s_postbloff = fs32_to_cpu(sb, usb3->fs_postbloff); |
| 1052 | uspi->s_rotbloff = fs32_to_cpu(sb, usb3->fs_rotbloff); |
| 1053 | |
| 1054 | /* |
| 1055 | * Compute another frequently used values |
| 1056 | */ |
| 1057 | uspi->s_fpbmask = uspi->s_fpb - 1; |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1058 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | uspi->s_apbshift = uspi->s_bshift - 3; |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1060 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | uspi->s_apbshift = uspi->s_bshift - 2; |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1062 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | uspi->s_2apbshift = uspi->s_apbshift * 2; |
| 1064 | uspi->s_3apbshift = uspi->s_apbshift * 3; |
| 1065 | uspi->s_apb = 1 << uspi->s_apbshift; |
| 1066 | uspi->s_2apb = 1 << uspi->s_2apbshift; |
| 1067 | uspi->s_3apb = 1 << uspi->s_3apbshift; |
| 1068 | uspi->s_apbmask = uspi->s_apb - 1; |
| 1069 | uspi->s_nspfshift = uspi->s_fshift - UFS_SECTOR_BITS; |
| 1070 | uspi->s_nspb = uspi->s_nspf << uspi->s_fpbshift; |
| 1071 | uspi->s_inopf = uspi->s_inopb >> uspi->s_fpbshift; |
| 1072 | uspi->s_bpf = uspi->s_fsize << 3; |
| 1073 | uspi->s_bpfshift = uspi->s_fshift + 3; |
| 1074 | uspi->s_bpfmask = uspi->s_bpf - 1; |
Evgeniy Dushistov | 90b315a | 2008-02-08 04:20:16 -0800 | [diff] [blame] | 1075 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_44BSD || |
| 1076 | (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_UFS2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | uspi->s_maxsymlinklen = |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1078 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | |
Duane Griffin | 9e6766c | 2009-01-08 22:43:48 +0000 | [diff] [blame] | 1080 | if (uspi->fs_magic == UFS2_MAGIC) |
| 1081 | maxsymlen = 2 * 4 * (UFS_NDADDR + UFS_NINDIR); |
| 1082 | else |
| 1083 | maxsymlen = 4 * (UFS_NDADDR + UFS_NINDIR); |
| 1084 | if (uspi->s_maxsymlinklen > maxsymlen) { |
| 1085 | ufs_warning(sb, __func__, "ufs_read_super: excessive maximum " |
| 1086 | "fast symlink size (%u)\n", uspi->s_maxsymlinklen); |
| 1087 | uspi->s_maxsymlinklen = maxsymlen; |
| 1088 | } |
| 1089 | |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 1090 | inode = ufs_iget(sb, UFS_ROOTINO); |
| 1091 | if (IS_ERR(inode)) { |
| 1092 | ret = PTR_ERR(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | goto failed; |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 1094 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | sb->s_root = d_alloc_root(inode); |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 1096 | if (!sb->s_root) { |
| 1097 | ret = -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1098 | goto dalloc_failed; |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 1099 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 1101 | ufs_setup_cstotal(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | /* |
| 1103 | * Read cylinder group structures |
| 1104 | */ |
| 1105 | if (!(sb->s_flags & MS_RDONLY)) |
| 1106 | if (!ufs_read_cylinder_structures(sb)) |
| 1107 | goto failed; |
| 1108 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1109 | UFSD("EXIT\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | return 0; |
| 1111 | |
| 1112 | dalloc_failed: |
| 1113 | iput(inode); |
| 1114 | failed: |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 1115 | if (ubh) |
| 1116 | ubh_brelse_uspi (uspi); |
| 1117 | kfree (uspi); |
| 1118 | kfree(sbi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | sb->s_fs_info = NULL; |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1120 | UFSD("EXIT (FAILED)\n"); |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 1121 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | |
| 1123 | failed_nomem: |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1124 | UFSD("EXIT (NOMEM)\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | return -ENOMEM; |
| 1126 | } |
| 1127 | |
Christoph Hellwig | 8c80065 | 2009-06-08 10:08:05 +0200 | [diff] [blame] | 1128 | static int ufs_sync_fs(struct super_block *sb, int wait) |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1129 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | struct ufs_sb_private_info * uspi; |
| 1131 | struct ufs_super_block_first * usb1; |
| 1132 | struct ufs_super_block_third * usb3; |
| 1133 | unsigned flags; |
| 1134 | |
Christoph Hellwig | ebc1ac1 | 2009-05-11 23:35:03 +0200 | [diff] [blame] | 1135 | lock_super(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | lock_kernel(); |
Christoph Hellwig | 8c80065 | 2009-06-08 10:08:05 +0200 | [diff] [blame] | 1137 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1138 | UFSD("ENTER\n"); |
Christoph Hellwig | 8c80065 | 2009-06-08 10:08:05 +0200 | [diff] [blame] | 1139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | flags = UFS_SB(sb)->s_flags; |
| 1141 | uspi = UFS_SB(sb)->s_uspi; |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 1142 | usb1 = ubh_get_usb_first(uspi); |
| 1143 | usb3 = ubh_get_usb_third(uspi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | |
Christoph Hellwig | 8c80065 | 2009-06-08 10:08:05 +0200 | [diff] [blame] | 1145 | usb1->fs_time = cpu_to_fs32(sb, get_seconds()); |
| 1146 | if ((flags & UFS_ST_MASK) == UFS_ST_SUN || |
| 1147 | (flags & UFS_ST_MASK) == UFS_ST_SUNOS || |
| 1148 | (flags & UFS_ST_MASK) == UFS_ST_SUNx86) |
| 1149 | ufs_set_fs_state(sb, usb1, usb3, |
| 1150 | UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); |
| 1151 | ufs_put_cstotal(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | sb->s_dirt = 0; |
Christoph Hellwig | 8c80065 | 2009-06-08 10:08:05 +0200 | [diff] [blame] | 1153 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1154 | UFSD("EXIT\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | unlock_kernel(); |
Christoph Hellwig | ebc1ac1 | 2009-05-11 23:35:03 +0200 | [diff] [blame] | 1156 | unlock_super(sb); |
Christoph Hellwig | 8c80065 | 2009-06-08 10:08:05 +0200 | [diff] [blame] | 1157 | |
| 1158 | return 0; |
| 1159 | } |
| 1160 | |
| 1161 | static void ufs_write_super(struct super_block *sb) |
| 1162 | { |
| 1163 | if (!(sb->s_flags & MS_RDONLY)) |
| 1164 | ufs_sync_fs(sb, 1); |
| 1165 | else |
| 1166 | sb->s_dirt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | } |
| 1168 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1169 | static void ufs_put_super(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | { |
| 1171 | struct ufs_sb_info * sbi = UFS_SB(sb); |
| 1172 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 1173 | UFSD("ENTER\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | |
Christoph Hellwig | 8c85e12 | 2009-04-28 18:00:26 +0200 | [diff] [blame] | 1175 | if (sb->s_dirt) |
| 1176 | ufs_write_super(sb); |
| 1177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | if (!(sb->s_flags & MS_RDONLY)) |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 1179 | ufs_put_super_internal(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | |
| 1181 | ubh_brelse_uspi (sbi->s_uspi); |
| 1182 | kfree (sbi->s_uspi); |
| 1183 | kfree (sbi); |
| 1184 | sb->s_fs_info = NULL; |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1185 | UFSD("EXIT\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | return; |
| 1187 | } |
| 1188 | |
| 1189 | |
| 1190 | static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) |
| 1191 | { |
| 1192 | struct ufs_sb_private_info * uspi; |
| 1193 | struct ufs_super_block_first * usb1; |
| 1194 | struct ufs_super_block_third * usb3; |
| 1195 | unsigned new_mount_opt, ufstype; |
| 1196 | unsigned flags; |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1197 | |
| 1198 | lock_kernel(); |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1199 | lock_super(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | uspi = UFS_SB(sb)->s_uspi; |
| 1201 | flags = UFS_SB(sb)->s_flags; |
Evgeniy | 7b4ee73 | 2006-01-14 11:42:06 +0300 | [diff] [blame] | 1202 | usb1 = ubh_get_usb_first(uspi); |
| 1203 | usb3 = ubh_get_usb_third(uspi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | |
| 1205 | /* |
| 1206 | * Allow the "check" option to be passed as a remount option. |
| 1207 | * It is not possible to change ufstype option during remount |
| 1208 | */ |
| 1209 | ufstype = UFS_SB(sb)->s_mount_opt & UFS_MOUNT_UFSTYPE; |
| 1210 | new_mount_opt = 0; |
| 1211 | ufs_set_opt (new_mount_opt, ONERROR_LOCK); |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1212 | if (!ufs_parse_options (data, &new_mount_opt)) { |
| 1213 | unlock_super(sb); |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1214 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | return -EINVAL; |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1216 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | if (!(new_mount_opt & UFS_MOUNT_UFSTYPE)) { |
| 1218 | new_mount_opt |= ufstype; |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 1219 | } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | printk("ufstype can't be changed during remount\n"); |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1221 | unlock_super(sb); |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1222 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | return -EINVAL; |
| 1224 | } |
| 1225 | |
| 1226 | if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { |
| 1227 | UFS_SB(sb)->s_mount_opt = new_mount_opt; |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1228 | unlock_super(sb); |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1229 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1230 | return 0; |
| 1231 | } |
| 1232 | |
| 1233 | /* |
| 1234 | * fs was mouted as rw, remounting ro |
| 1235 | */ |
| 1236 | if (*mount_flags & MS_RDONLY) { |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 1237 | ufs_put_super_internal(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | usb1->fs_time = cpu_to_fs32(sb, get_seconds()); |
| 1239 | if ((flags & UFS_ST_MASK) == UFS_ST_SUN |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 1240 | || (flags & UFS_ST_MASK) == UFS_ST_SUNOS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1241 | || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) |
| 1242 | ufs_set_fs_state(sb, usb1, usb3, |
| 1243 | UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); |
Evgeniy Dushistov | 9695ef1 | 2006-06-25 05:47:22 -0700 | [diff] [blame] | 1244 | ubh_mark_buffer_dirty (USPI_UBH(uspi)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | sb->s_dirt = 0; |
| 1246 | sb->s_flags |= MS_RDONLY; |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 1247 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | /* |
| 1249 | * fs was mounted as ro, remounting rw |
| 1250 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | #ifndef CONFIG_UFS_FS_WRITE |
| 1252 | printk("ufs was compiled with read-only support, " |
| 1253 | "can't be mounted as read-write\n"); |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1254 | unlock_super(sb); |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1255 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | return -EINVAL; |
| 1257 | #else |
| 1258 | if (ufstype != UFS_MOUNT_UFSTYPE_SUN && |
Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 1259 | ufstype != UFS_MOUNT_UFSTYPE_SUNOS && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | ufstype != UFS_MOUNT_UFSTYPE_44BSD && |
Evgeniy Dushistov | cbcae39 | 2007-02-12 00:54:30 -0800 | [diff] [blame] | 1261 | ufstype != UFS_MOUNT_UFSTYPE_SUNx86 && |
| 1262 | ufstype != UFS_MOUNT_UFSTYPE_UFS2) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | printk("this ufstype is read-only supported\n"); |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1264 | unlock_super(sb); |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1265 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | return -EINVAL; |
| 1267 | } |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 1268 | if (!ufs_read_cylinder_structures(sb)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | printk("failed during remounting\n"); |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1270 | unlock_super(sb); |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1271 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | return -EPERM; |
| 1273 | } |
| 1274 | sb->s_flags &= ~MS_RDONLY; |
| 1275 | #endif |
| 1276 | } |
| 1277 | UFS_SB(sb)->s_mount_opt = new_mount_opt; |
Al Viro | bbd6851 | 2009-05-06 10:43:07 -0400 | [diff] [blame] | 1278 | unlock_super(sb); |
Alessio Igor Bogani | 337eb00 | 2009-05-12 15:10:54 +0200 | [diff] [blame] | 1279 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | return 0; |
| 1281 | } |
| 1282 | |
Evgeniy Dushistov | 2a9807c | 2007-10-16 23:26:32 -0700 | [diff] [blame] | 1283 | static int ufs_show_options(struct seq_file *seq, struct vfsmount *vfs) |
| 1284 | { |
| 1285 | struct ufs_sb_info *sbi = UFS_SB(vfs->mnt_sb); |
| 1286 | unsigned mval = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE; |
Steven Whitehouse | a447c09 | 2008-10-13 10:46:57 +0100 | [diff] [blame] | 1287 | const struct match_token *tp = tokens; |
Evgeniy Dushistov | 2a9807c | 2007-10-16 23:26:32 -0700 | [diff] [blame] | 1288 | |
| 1289 | while (tp->token != Opt_onerror_panic && tp->token != mval) |
| 1290 | ++tp; |
| 1291 | BUG_ON(tp->token == Opt_onerror_panic); |
| 1292 | seq_printf(seq, ",%s", tp->pattern); |
| 1293 | |
| 1294 | mval = sbi->s_mount_opt & UFS_MOUNT_ONERROR; |
| 1295 | while (tp->token != Opt_err && tp->token != mval) |
| 1296 | ++tp; |
| 1297 | BUG_ON(tp->token == Opt_err); |
| 1298 | seq_printf(seq, ",%s", tp->pattern); |
| 1299 | |
| 1300 | return 0; |
| 1301 | } |
| 1302 | |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1303 | static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1304 | { |
David Howells | 726c334 | 2006-06-23 02:02:58 -0700 | [diff] [blame] | 1305 | struct super_block *sb = dentry->d_sb; |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1306 | struct ufs_sb_private_info *uspi= UFS_SB(sb)->s_uspi; |
| 1307 | unsigned flags = UFS_SB(sb)->s_flags; |
| 1308 | struct ufs_super_block_first *usb1; |
| 1309 | struct ufs_super_block_second *usb2; |
| 1310 | struct ufs_super_block_third *usb3; |
Coly Li | 41d577a | 2009-04-02 16:59:44 -0700 | [diff] [blame] | 1311 | u64 id = huge_encode_dev(sb->s_bdev->bd_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | |
| 1313 | lock_kernel(); |
| 1314 | |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1315 | usb1 = ubh_get_usb_first(uspi); |
| 1316 | usb2 = ubh_get_usb_second(uspi); |
| 1317 | usb3 = ubh_get_usb_third(uspi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
| 1320 | buf->f_type = UFS2_MAGIC; |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1321 | buf->f_blocks = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 1322 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1323 | buf->f_type = UFS_MAGIC; |
| 1324 | buf->f_blocks = uspi->s_dsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | } |
Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 1326 | buf->f_bfree = ufs_blkstofrags(uspi->cs_total.cs_nbfree) + |
| 1327 | uspi->cs_total.cs_nffree; |
| 1328 | buf->f_ffree = uspi->cs_total.cs_nifree; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | buf->f_bsize = sb->s_blocksize; |
| 1330 | buf->f_bavail = (buf->f_bfree > (((long)buf->f_blocks / 100) * uspi->s_minfree)) |
| 1331 | ? (buf->f_bfree - (((long)buf->f_blocks / 100) * uspi->s_minfree)) : 0; |
| 1332 | buf->f_files = uspi->s_ncg * uspi->s_ipg; |
| 1333 | buf->f_namelen = UFS_MAXNAMLEN; |
Coly Li | 41d577a | 2009-04-02 16:59:44 -0700 | [diff] [blame] | 1334 | buf->f_fsid.val[0] = (u32)id; |
| 1335 | buf->f_fsid.val[1] = (u32)(id >> 32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | |
| 1337 | unlock_kernel(); |
| 1338 | |
| 1339 | return 0; |
| 1340 | } |
| 1341 | |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 1342 | static struct kmem_cache * ufs_inode_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | |
| 1344 | static struct inode *ufs_alloc_inode(struct super_block *sb) |
| 1345 | { |
| 1346 | struct ufs_inode_info *ei; |
Christoph Lameter | e94b176 | 2006-12-06 20:33:17 -0800 | [diff] [blame] | 1347 | ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | if (!ei) |
| 1349 | return NULL; |
| 1350 | ei->vfs_inode.i_version = 1; |
| 1351 | return &ei->vfs_inode; |
| 1352 | } |
| 1353 | |
| 1354 | static void ufs_destroy_inode(struct inode *inode) |
| 1355 | { |
| 1356 | kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); |
| 1357 | } |
| 1358 | |
Alexey Dobriyan | 51cc506 | 2008-07-25 19:45:34 -0700 | [diff] [blame] | 1359 | static void init_once(void *foo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | { |
| 1361 | struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; |
| 1362 | |
Christoph Lameter | a35afb8 | 2007-05-16 22:10:57 -0700 | [diff] [blame] | 1363 | inode_init_once(&ei->vfs_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | } |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 1365 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | static int init_inodecache(void) |
| 1367 | { |
| 1368 | ufs_inode_cachep = kmem_cache_create("ufs_inode_cache", |
| 1369 | sizeof(struct ufs_inode_info), |
Paul Jackson | fffb60f | 2006-03-24 03:16:06 -0800 | [diff] [blame] | 1370 | 0, (SLAB_RECLAIM_ACCOUNT| |
| 1371 | SLAB_MEM_SPREAD), |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 1372 | init_once); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | if (ufs_inode_cachep == NULL) |
| 1374 | return -ENOMEM; |
| 1375 | return 0; |
| 1376 | } |
| 1377 | |
| 1378 | static void destroy_inodecache(void) |
| 1379 | { |
Alexey Dobriyan | 1a1d92c | 2006-09-27 01:49:40 -0700 | [diff] [blame] | 1380 | kmem_cache_destroy(ufs_inode_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | #ifdef CONFIG_QUOTA |
| 1384 | static ssize_t ufs_quota_read(struct super_block *, int, char *,size_t, loff_t); |
| 1385 | static ssize_t ufs_quota_write(struct super_block *, int, const char *, size_t, loff_t); |
| 1386 | #endif |
| 1387 | |
Josef 'Jeff' Sipek | ee9b6d6 | 2007-02-12 00:55:41 -0800 | [diff] [blame] | 1388 | static const struct super_operations ufs_super_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | .alloc_inode = ufs_alloc_inode, |
| 1390 | .destroy_inode = ufs_destroy_inode, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | .write_inode = ufs_write_inode, |
| 1392 | .delete_inode = ufs_delete_inode, |
| 1393 | .put_super = ufs_put_super, |
| 1394 | .write_super = ufs_write_super, |
Christoph Hellwig | 8c80065 | 2009-06-08 10:08:05 +0200 | [diff] [blame] | 1395 | .sync_fs = ufs_sync_fs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | .statfs = ufs_statfs, |
| 1397 | .remount_fs = ufs_remount, |
Evgeniy Dushistov | 2a9807c | 2007-10-16 23:26:32 -0700 | [diff] [blame] | 1398 | .show_options = ufs_show_options, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | #ifdef CONFIG_QUOTA |
| 1400 | .quota_read = ufs_quota_read, |
| 1401 | .quota_write = ufs_quota_write, |
| 1402 | #endif |
| 1403 | }; |
| 1404 | |
| 1405 | #ifdef CONFIG_QUOTA |
| 1406 | |
| 1407 | /* Read data from quotafile - avoid pagecache and such because we cannot afford |
| 1408 | * acquiring the locks... As quota files are never truncated and quota code |
| 1409 | * itself serializes the operations (and noone else should touch the files) |
| 1410 | * we don't have to be afraid of races */ |
| 1411 | static ssize_t ufs_quota_read(struct super_block *sb, int type, char *data, |
| 1412 | size_t len, loff_t off) |
| 1413 | { |
| 1414 | struct inode *inode = sb_dqopt(sb)->files[type]; |
| 1415 | sector_t blk = off >> sb->s_blocksize_bits; |
| 1416 | int err = 0; |
| 1417 | int offset = off & (sb->s_blocksize - 1); |
| 1418 | int tocopy; |
| 1419 | size_t toread; |
| 1420 | struct buffer_head *bh; |
| 1421 | loff_t i_size = i_size_read(inode); |
| 1422 | |
| 1423 | if (off > i_size) |
| 1424 | return 0; |
| 1425 | if (off+len > i_size) |
| 1426 | len = i_size-off; |
| 1427 | toread = len; |
| 1428 | while (toread > 0) { |
| 1429 | tocopy = sb->s_blocksize - offset < toread ? |
| 1430 | sb->s_blocksize - offset : toread; |
| 1431 | |
| 1432 | bh = ufs_bread(inode, blk, 0, &err); |
| 1433 | if (err) |
| 1434 | return err; |
| 1435 | if (!bh) /* A hole? */ |
| 1436 | memset(data, 0, tocopy); |
| 1437 | else { |
| 1438 | memcpy(data, bh->b_data+offset, tocopy); |
| 1439 | brelse(bh); |
| 1440 | } |
| 1441 | offset = 0; |
| 1442 | toread -= tocopy; |
| 1443 | data += tocopy; |
| 1444 | blk++; |
| 1445 | } |
| 1446 | return len; |
| 1447 | } |
| 1448 | |
| 1449 | /* Write to quotafile */ |
| 1450 | static ssize_t ufs_quota_write(struct super_block *sb, int type, |
| 1451 | const char *data, size_t len, loff_t off) |
| 1452 | { |
| 1453 | struct inode *inode = sb_dqopt(sb)->files[type]; |
| 1454 | sector_t blk = off >> sb->s_blocksize_bits; |
| 1455 | int err = 0; |
| 1456 | int offset = off & (sb->s_blocksize - 1); |
| 1457 | int tocopy; |
| 1458 | size_t towrite = len; |
| 1459 | struct buffer_head *bh; |
| 1460 | |
Arjan van de Ven | 5c81a41 | 2006-07-03 00:25:20 -0700 | [diff] [blame] | 1461 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | while (towrite > 0) { |
| 1463 | tocopy = sb->s_blocksize - offset < towrite ? |
| 1464 | sb->s_blocksize - offset : towrite; |
| 1465 | |
| 1466 | bh = ufs_bread(inode, blk, 1, &err); |
| 1467 | if (!bh) |
| 1468 | goto out; |
| 1469 | lock_buffer(bh); |
| 1470 | memcpy(bh->b_data+offset, data, tocopy); |
| 1471 | flush_dcache_page(bh->b_page); |
| 1472 | set_buffer_uptodate(bh); |
| 1473 | mark_buffer_dirty(bh); |
| 1474 | unlock_buffer(bh); |
| 1475 | brelse(bh); |
| 1476 | offset = 0; |
| 1477 | towrite -= tocopy; |
| 1478 | data += tocopy; |
| 1479 | blk++; |
| 1480 | } |
| 1481 | out: |
Evgeniy Polyakov | 15b2fe3 | 2006-01-08 01:04:51 -0800 | [diff] [blame] | 1482 | if (len == towrite) { |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 1483 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | return err; |
Evgeniy Polyakov | 15b2fe3 | 2006-01-08 01:04:51 -0800 | [diff] [blame] | 1485 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | if (inode->i_size < off+len-towrite) |
| 1487 | i_size_write(inode, off+len-towrite); |
| 1488 | inode->i_version++; |
| 1489 | inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; |
| 1490 | mark_inode_dirty(inode); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 1491 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | return len - towrite; |
| 1493 | } |
| 1494 | |
| 1495 | #endif |
| 1496 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1497 | static int ufs_get_sb(struct file_system_type *fs_type, |
| 1498 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | { |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1500 | return get_sb_bdev(fs_type, flags, dev_name, data, ufs_fill_super, mnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | } |
| 1502 | |
| 1503 | static struct file_system_type ufs_fs_type = { |
| 1504 | .owner = THIS_MODULE, |
| 1505 | .name = "ufs", |
| 1506 | .get_sb = ufs_get_sb, |
| 1507 | .kill_sb = kill_block_super, |
| 1508 | .fs_flags = FS_REQUIRES_DEV, |
| 1509 | }; |
| 1510 | |
| 1511 | static int __init init_ufs_fs(void) |
| 1512 | { |
| 1513 | int err = init_inodecache(); |
| 1514 | if (err) |
| 1515 | goto out1; |
| 1516 | err = register_filesystem(&ufs_fs_type); |
| 1517 | if (err) |
| 1518 | goto out; |
| 1519 | return 0; |
| 1520 | out: |
| 1521 | destroy_inodecache(); |
| 1522 | out1: |
| 1523 | return err; |
| 1524 | } |
| 1525 | |
| 1526 | static void __exit exit_ufs_fs(void) |
| 1527 | { |
| 1528 | unregister_filesystem(&ufs_fs_type); |
| 1529 | destroy_inodecache(); |
| 1530 | } |
| 1531 | |
| 1532 | module_init(init_ufs_fs) |
| 1533 | module_exit(exit_ufs_fs) |
| 1534 | MODULE_LICENSE("GPL"); |