/*
* linux/fs/ufs/super.c
*
* Copyright (C) 1998
* Daniel Pirkl <daniel.pirkl@email.cz>
* Charles University, Faculty of Mathematics and Physics
*/
/* Derived from
*
* linux/fs/ext2/super.c
*
* Copyright (C) 1992, 1993, 1994, 1995
* Remy Card (card@masi.ibp.fr)
* Laboratoire MASI - Institut Blaise Pascal
* Universite Pierre et Marie Curie (Paris VI)
*
* from
*
* linux/fs/minix/inode.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* Big-endian to little-endian byte-swapping/bitmaps by
* David S. Miller (davem@caip.rutgers.edu), 1995
*/
/*
* Inspired by
*
* linux/fs/ufs/super.c
*
* Copyright (C) 1996
* Adrian Rodriguez (adrian@franklins-tower.rutgers.edu)
* Laboratory for Computer Science Research Computing Facility
* Rutgers, The State University of New Jersey
*
* Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
*
* Kernel module support added on 96/04/26 by
* Stefan Reinauer <stepan@home.culture.mipt.ru>
*
* Module usage counts added on 96/04/29 by
* Gertjan van Wingerde <gwingerde@gmail.com>
*
* Clean swab support on 19970406 by
* Francois-Rene Rideau <fare@tunes.org>
*
* 4.4BSD (FreeBSD) support added on February 1st 1998 by
* Niels Kristian Bech Jensen <nkbj@image.dk> partially based
* on code by Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>.
*
* NeXTstep support added on February 5th 1998 by
* Niels Kristian Bech Jensen <nkbj@image.dk>.
*
* write support Daniel Pirkl <daniel.pirkl@email.cz> 1998
*
* HP/UX hfs filesystem support added by
* Martin K. Petersen <mkp@mkp.net>, August 1999
*
* UFS2 (of FreeBSD 5.x) support added by
* Niraj Kumar <niraj17@iitbombay.org>, Jan 2004
*
* UFS2 write support added by
* Evgeniy Dushistov <dushistov@mail.ru>, 2007
*/
#include <linux/module.h>
#include <linux/bitops.h>
#include <stdarg.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/quotaops.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/parser.h>
#include <linux/smp_lock.h>
#include <linux/buffer_head.h>
#include <linux/vfs.h>
#include <linux/log2.h>
#include <linux/mount.h>
#include <linux/seq_file.h>
#include "ufs_fs.h"
#include "ufs.h"
#include "swab.h"
#include "util.h"
#ifdef CONFIG_UFS_DEBUG
/*
* Print contents of ufs_super_block, useful for debugging
*/
static void ufs_print_super_stuff(struct super_block *sb,
struct ufs_super_block_first *usb1,
struct ufs_super_block_second *usb2,
struct ufs_super_block_third *usb3)
{
u32 magic = fs32_to_cpu(sb, usb3->fs_magic);
printk("ufs_print_super_stuff\n");
printk(" magic: 0x%x\n", magic);
if (fs32_to_cpu(sb, usb3->fs_magic) == UFS2_MAGIC) {
printk(" fs_size: %llu\n", (unsigned long long)
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size));
printk(" fs_dsize: %llu\n", (unsigned long long)
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize));
printk(" bsize: %u\n",
fs32_to_cpu(sb, usb1->fs_bsize));
printk(" fsize: %u\n",
fs32_to_cpu(sb, usb1->fs_fsize));
printk(" fs_volname: %s\n", usb2->fs_un.fs_u2.fs_volname);
printk(" fs_sblockloc: %llu\n", (unsigned long long)
fs64_to_cpu(sb, usb2->fs_un.fs_u2.fs_sblockloc));
printk(" cs_ndir(No of dirs): %llu\n", (unsigned long long)
fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir));
printk(" cs_nbfree(No of free blocks): %llu\n",
(unsigned long long)
fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree));
printk(KERN_INFO" cs_nifree(Num of free inodes): %llu\n",
(unsigned long long)
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree));
printk(KERN_INFO" cs_nffree(Num of free frags): %llu\n",
(unsigned long long)
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree));
printk(KERN_INFO" fs_maxsymlinklen: %u\n",
fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen));
} else {
printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno));
printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno));
printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno));
printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno));
printk(" cgoffset: %u\n",
fs32_to_cpu(sb, usb1->fs_cgoffset));
printk(" ~cgmask: 0x%x\n",
~fs32_to_cpu(sb, usb1->fs_cgmask));
printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size));
printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize));
printk(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg));
printk(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize));
printk(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize));
printk(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag));
printk(" fragshift: %u\n",
fs32_to_cpu(sb, usb1->fs_fragshift));
printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask));
printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift));
printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize));
printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc));
printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg));
printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg));
printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg));
printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr));
printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize));
printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize));
printk(" fstodb: %u\n",
fs32_to_cpu(sb, usb1->fs_fsbtodb));
printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos));
printk(" ndir %u\n",
fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir));
printk(" nifree %u\n",
fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree));
printk(" nbfree %u\n",
fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree));
printk(" nffree %u\n",
fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree));
}
printk("\n");
}
/*
* Print contents of ufs_cylinder_group, useful for debugging
*/
static void ufs_print_cylinder_stuff(struct super_block *sb,
struct ufs_cylinder_group *cg)
{
printk("\nufs_print_cylinder_stuff\n");
printk("size of ucg: %zu\n", sizeof(struct ufs_cylinder_group));
printk(" magic: %x\n", fs32_to_cpu(sb, cg->cg_magic));
printk(" time: %u\n", fs32_to_cpu(sb, cg->cg_time));
printk(" cgx: %u\n", fs32_to_cpu(sb, cg->cg_cgx));
printk(" ncyl: %u\n", fs16_to_cpu(sb, cg->cg_ncyl));
printk(" niblk: %u\n", fs16_to_cpu(sb, cg->cg_niblk));
printk(" ndblk: %u\n", fs32_to_cpu(sb, cg->cg_ndblk));
printk(" cs_ndir: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_ndir));
printk(" cs_nbfree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nbfree));
printk(" cs_nifree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nifree));
printk(" cs_nffree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nffree));
printk(" rotor: %u\n", fs32_to_cpu(sb, cg->cg_rotor));
printk(" frotor: %u\n", fs32_to_cpu(sb, cg->cg_frotor));
printk(" irotor: %u\n", fs32_to_cpu(sb, cg->cg_irotor));
print
|