~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/ufs/super.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp