Release 4.11 fs/efs/super.c
/*
* super.c
*
* Copyright (c) 1999 Al Smith
*
* Portions derived from work (c) 1995,1996 Christian Vogelgsang.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/exportfs.h>
#include <linux/slab.h>
#include <linux/buffer_head.h>
#include <linux/vfs.h>
#include "efs.h"
#include <linux/efs_vh.h>
#include <linux/efs_fs_sb.h>
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf);
static int efs_fill_super(struct super_block *s, void *d, int silent);
static struct dentry *efs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
return mount_bdev(fs_type, flags, dev_name, data, efs_fill_super);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Al Viro | 33 | 84.62% | 2 | 40.00% |
Linus Torvalds (pre-git) | 5 | 12.82% | 2 | 40.00% |
Andries E. Brouwer | 1 | 2.56% | 1 | 20.00% |
Total | 39 | 100.00% | 5 | 100.00% |
static void efs_kill_sb(struct super_block *s)
{
struct efs_sb_info *sbi = SUPER_INFO(s);
kill_block_super(s);
kfree(sbi);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Al Viro | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
static struct file_system_type efs_fs_type = {
.owner = THIS_MODULE,
.name = "efs",
.mount = efs_mount,
.kill_sb = efs_kill_sb,
.fs_flags = FS_REQUIRES_DEV,
};
MODULE_ALIAS_FS("efs");
static struct pt_types sgi_pt_types[] = {
{0x00, "SGI vh"},
{0x01, "SGI trkrepl"},
{0x02, "SGI secrepl"},
{0x03, "SGI raw"},
{0x04, "SGI bsd"},
{SGI_SYSV, "SGI sysv"},
{0x06, "SGI vol"},
{SGI_EFS, "SGI efs"},
{0x08, "SGI lv"},
{0x09, "SGI rlv"},
{0x0A, "SGI xfs"},
{0x0B, "SGI xfslog"},
{0x0C, "SGI xlv"},
{0x82, "Linux swap"},
{0x83, "Linux native"},
{0, NULL}
};
static struct kmem_cache * efs_inode_cachep;
static struct inode *efs_alloc_inode(struct super_block *sb)
{
struct efs_inode_info *ei;
ei = kmem_cache_alloc(efs_inode_cachep, GFP_KERNEL);
if (!ei)
return NULL;
return &ei->vfs_inode;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 40 | 97.56% | 1 | 50.00% |
Christoph Lameter | 1 | 2.44% | 1 | 50.00% |
Total | 41 | 100.00% | 2 | 100.00% |
static void efs_i_callback(struct rcu_head *head)
{
struct inode *inode = container_of(head, struct inode, i_rcu);
kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 18 | 50.00% | 1 | 50.00% |
Nicholas Piggin | 18 | 50.00% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static void efs_destroy_inode(struct inode *inode)
{
call_rcu(&inode->i_rcu, efs_i_callback);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nicholas Piggin | 21 | 100.00% | 1 | 100.00% |
Total | 21 | 100.00% | 1 | 100.00% |
static void init_once(void *foo)
{
struct efs_inode_info *ei = (struct efs_inode_info *) foo;
inode_init_once(&ei->vfs_inode);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 27 | 90.00% | 1 | 50.00% |
Christoph Lameter | 3 | 10.00% | 1 | 50.00% |
Total | 30 | 100.00% | 2 | 100.00% |
static int __init init_inodecache(void)
{
efs_inode_cachep = kmem_cache_create("efs_inode_cache",
sizeof(struct efs_inode_info), 0,
SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
SLAB_ACCOUNT, init_once);
if (efs_inode_cachep == NULL)
return -ENOMEM;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 39 | 86.67% | 1 | 20.00% |
Vladimir Davydov | 2 | 4.44% | 1 | 20.00% |
Paul Jackson | 2 | 4.44% | 1 | 20.00% |
Andrew Morton | 1 | 2.22% | 1 | 20.00% |
Fabian Frederick | 1 | 2.22% | 1 | 20.00% |
Total | 45 | 100.00% | 5 | 100.00% |
static void destroy_inodecache(void)
{
/*
* Make sure all delayed rcu free inodes are flushed before we
* destroy cache.
*/
rcu_barrier();
kmem_cache_destroy(efs_inode_cachep);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 13 | 76.47% | 1 | 50.00% |
Kirill A. Shutemov | 4 | 23.53% | 1 | 50.00% |
Total | 17 | 100.00% | 2 | 100.00% |
static int efs_remount(struct super_block *sb, int *flags, char *data)
{
sync_filesystem(sb);
*flags |= MS_RDONLY;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Al Viro | 27 | 84.38% | 1 | 50.00% |
Theodore Y. Ts'o | 5 | 15.62% | 1 | 50.00% |
Total | 32 | 100.00% | 2 | 100.00% |
static const struct super_operations efs_superblock_operations = {
.alloc_inode = efs_alloc_inode,
.destroy_inode = efs_destroy_inode,
.statfs = efs_statfs,
.remount_fs = efs_remount,
};
static const struct export_operations efs_export_ops = {
.fh_to_dentry = efs_fh_to_dentry,
.fh_to_parent = efs_fh_to_parent,
.get_parent = efs_get_parent,
};
static int __init init_efs_fs(void) {
int err;
pr_info(EFS_VERSION" - http://aeschi.ch.eu.org/efs/\n");
err = init_inodecache();
if (err)
goto out1;
err = register_filesystem(&efs_fs_type);
if (err)
goto out;
return 0;
out:
destroy_inodecache();
out1:
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 37 | 63.79% | 1 | 20.00% |
Linus Torvalds (pre-git) | 20 | 34.48% | 3 | 60.00% |
Fabian Frederick | 1 | 1.72% | 1 | 20.00% |
Total | 58 | 100.00% | 5 | 100.00% |
static void __exit exit_efs_fs(void) {
unregister_filesystem(&efs_fs_type);
destroy_inodecache();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 15 | 83.33% | 2 | 66.67% |
Linus Torvalds | 3 | 16.67% | 1 | 33.33% |
Total | 18 | 100.00% | 3 | 100.00% |
module_init(init_efs_fs)
module_exit(exit_efs_fs)
static efs_block_t efs_validate_vh(struct volume_header *vh) {
int i;
__be32 cs, *ui;
int csum;
efs_block_t sblock = 0; /* shuts up gcc */
struct pt_types *pt_entry;
int pt_type, slice = -1;
if (be32_to_cpu(vh->vh_magic) != VHMAGIC) {
/*
* assume that we're dealing with a partition and allow
* read_super() to try and detect a valid superblock
* on the next block.
*/
return 0;
}
ui = ((__be32 *) (vh + 1)) - 1;
for(csum = 0; ui >= ((__be32 *) vh);) {
cs = *ui--;
csum += be32_to_cpu(cs);
}
if (csum) {
pr_warn("SGI disklabel: checksum bad, label corrupted\n");
return 0;
}
#ifdef DEBUG
pr_debug("bf: \"%16s\"\n", vh->vh_bootfile);
for(i = 0; i < NVDIR; i++) {
int j;
char name[VDNAMESIZE+1];
for(j = 0; j < VDNAMESIZE; j++) {
name[j] = vh->vh_vd[i].vd_name[j];
}
name[j] = (char) 0;
if (name[0]) {
pr_debug("vh: %8s block: 0x%08x size: 0x%08x\n",
name, (int) be32_to_cpu(vh->vh_vd[i].vd_lbn),
(int) be32_to_cpu(vh->vh_vd[i].vd_nbytes));
}
}
#endif
for(i = 0; i < NPARTAB; i++) {
pt_type = (int) be32_to_cpu(vh->vh_pt[i].pt_type);
for(pt_entry = sgi_pt_types; pt_entry->pt_name; pt_entry++) {
if (pt_type == pt_entry->pt_type) break;
}
#ifdef DEBUG
if (be32_to_cpu(vh->vh_pt[i].pt_nblks)) {
pr_debug("pt %2d: start: %08d size: %08d type: 0x%02x (%s)\n",
i, (int)be32_to_cpu(vh->vh_pt[i].pt_firstlbn),
(int)be32_to_cpu(vh->vh_pt[i].pt_nblks),
pt_type, (pt_entry->pt_name) ?
pt_entry->pt_name : "unknown");
}
#endif
if (IS_EFS(pt_type)) {
sblock = be32_to_cpu(vh->vh_pt[i].pt_firstlbn);
slice = i;
}
}
if (slice == -1) {
pr_notice("partition table contained no EFS partitions\n");
#ifdef DEBUG
} else {
pr_info("using slice %d (type %s, offset 0x%x)\n", slice,
(pt_entry->pt_name) ? pt_entry->pt_name : "unknown",
sblock);
#endif
}
return sblock;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 432 | 96.00% | 2 | 33.33% |
Fabian Frederick | 12 | 2.67% | 3 | 50.00% |
Al Viro | 6 | 1.33% | 1 | 16.67% |
Total | 450 | 100.00% | 6 | 100.00% |
static int efs_validate_super(struct efs_sb_info *sb, struct efs_super *super) {
if (!IS_EFS_MAGIC(be32_to_cpu(super->fs_magic)))
return -1;
sb->fs_magic = be32_to_cpu(super->fs_magic);
sb->total_blocks = be32_to_cpu(super->fs_size);
sb->first_block = be32_to_cpu(super->fs_firstcg);
sb->group_size = be32_to_cpu(super->fs_cgfsize);
sb->data_free = be32_to_cpu(super->fs_tfree);
sb->inode_free = be32_to_cpu(super->fs_tinode);
sb->inode_blocks = be16_to_cpu(super->fs_cgisize);
sb->total_groups = be16_to_cpu(super->fs_ncg);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 124 | 100.00% | 1 | 100.00% |
Total | 124 | 100.00% | 1 | 100.00% |
static int efs_fill_super(struct super_block *s, void *d, int silent)
{
struct efs_sb_info *sb;
struct buffer_head *bh;
struct inode *root;
sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
if (!sb)
return -ENOMEM;
s->s_fs_info = sb;
s->s_magic = EFS_SUPER_MAGIC;
if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
pr_err("device does not support %d byte blocks\n",
EFS_BLOCKSIZE);
return -EINVAL;
}
/* read the vh (volume header) block */
bh = sb_bread(s, 0);
if (!bh) {
pr_err("cannot read volume header\n");
return -EIO;
}
/*
* if this returns zero then we didn't find any partition table.
* this isn't (yet) an error - just assume for the moment that
* the device is valid and go on to search for a superblock.
*/
sb->fs_start = efs_validate_vh((struct volume_header *) bh->b_data);
brelse(bh);
if (sb->fs_start == -1) {
return -EINVAL;
}
bh = sb_bread(s, sb->fs_start + EFS_SUPER);
if (!bh) {
pr_err("cannot read superblock\n");
return -EIO;
}
if (efs_validate_super(sb, (struct efs_super *) bh->b_data)) {
#ifdef DEBUG
pr_warn("invalid superblock at block %u\n",
sb->fs_start + EFS_SUPER);
#endif
brelse(bh);
return -EINVAL;
}
brelse(bh);
if (!(s->s_flags & MS_RDONLY)) {
#ifdef DEBUG
pr_info("forcing read-only mode\n");
#endif
s->s_flags |= MS_RDONLY;
}
s->s_op = &efs_superblock_operations;
s->s_export_op = &efs_export_ops;
root = efs_iget(s, EFS_ROOTINODE);
if (IS_ERR(root)) {
pr_err("get root inode failed\n");
return PTR_ERR(root);
}
s->s_root = d_make_root(root);
if (!(s->s_root)) {
pr_err("get root dentry failed\n");
return -ENOMEM;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 206 | 61.68% | 2 | 11.11% |
Al Viro | 49 | 14.67% | 5 | 27.78% |
Brian Gerst | 23 | 6.89% | 2 | 11.11% |
David Howells | 19 | 5.69% | 1 | 5.56% |
Fabian Frederick | 14 | 4.19% | 2 | 11.11% |
Linus Torvalds | 12 | 3.59% | 2 | 11.11% |
Christoph Hellwig | 7 | 2.10% | 1 | 5.56% |
Heloise | 2 | 0.60% | 1 | 5.56% |
Panagiotis Issaris | 1 | 0.30% | 1 | 5.56% |
Andries E. Brouwer | 1 | 0.30% | 1 | 5.56% |
Total | 334 | 100.00% | 18 | 100.00% |
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) {
struct super_block *sb = dentry->d_sb;
struct efs_sb_info *sbi = SUPER_INFO(sb);
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
buf->f_type = EFS_SUPER_MAGIC; /* efs magic number */
buf->f_bsize = EFS_BLOCKSIZE; /* blocksize */
buf->f_blocks = sbi->total_groups * /* total data blocks */
(sbi->group_size - sbi->inode_blocks);
buf->f_bfree = sbi->data_free; /* free data blocks */
buf->f_bavail = sbi->data_free; /* free blocks for non-root */
buf->f_files = sbi->total_groups * /* total inodes */
sbi->inode_blocks *
(EFS_BLOCKSIZE / sizeof(struct efs_dinode));
buf->f_ffree = sbi->inode_free; /* free inodes */
buf->f_fsid.val[0] = (u32)id;
buf->f_fsid.val[1] = (u32)(id >> 32);
buf->f_namelen = EFS_MAXNAMELEN; /* max filename length */
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 103 | 59.88% | 2 | 33.33% |
Coly Li | 62 | 36.05% | 1 | 16.67% |
David Howells | 5 | 2.91% | 1 | 16.67% |
Andries E. Brouwer | 1 | 0.58% | 1 | 16.67% |
Andrew Morton | 1 | 0.58% | 1 | 16.67% |
Total | 172 | 100.00% | 6 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 936 | 54.61% | 7 | 12.96% |
Linus Torvalds | 201 | 11.73% | 3 | 5.56% |
Al Viro | 173 | 10.09% | 9 | 16.67% |
Adrian Bunk | 104 | 6.07% | 1 | 1.85% |
Coly Li | 62 | 3.62% | 1 | 1.85% |
Christoph Hellwig | 43 | 2.51% | 8 | 14.81% |
Nicholas Piggin | 39 | 2.28% | 1 | 1.85% |
Andries E. Brouwer | 33 | 1.93% | 2 | 3.70% |
Fabian Frederick | 28 | 1.63% | 4 | 7.41% |
David Howells | 26 | 1.52% | 2 | 3.70% |
Brian Gerst | 23 | 1.34% | 2 | 3.70% |
Art Haas | 16 | 0.93% | 1 | 1.85% |
Christoph Lameter | 6 | 0.35% | 3 | 5.56% |
Theodore Y. Ts'o | 5 | 0.29% | 1 | 1.85% |
Eric W. Biedermann | 5 | 0.29% | 1 | 1.85% |
Kirill A. Shutemov | 4 | 0.23% | 1 | 1.85% |
Heloise | 2 | 0.12% | 1 | 1.85% |
Vladimir Davydov | 2 | 0.12% | 1 | 1.85% |
Andrew Morton | 2 | 0.12% | 2 | 3.70% |
Paul Jackson | 2 | 0.12% | 1 | 1.85% |
Panagiotis Issaris | 1 | 0.06% | 1 | 1.85% |
Josef 'Jeff' Sipek | 1 | 0.06% | 1 | 1.85% |
Total | 1714 | 100.00% | 54 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.