2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* 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/efs_fs.h>
|
|
|
|
#include <linux/efs_vh.h>
|
|
|
|
#include <linux/efs_fs_sb.h>
|
2007-07-17 11:04:28 +00:00
|
|
|
#include <linux/exportfs.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/buffer_head.h>
|
|
|
|
#include <linux/vfs.h>
|
|
|
|
|
2006-06-23 09:02:58 +00:00
|
|
|
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int efs_fill_super(struct super_block *s, void *d, int silent);
|
|
|
|
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 09:02:57 +00:00
|
|
|
static int efs_get_sb(struct file_system_type *fs_type,
|
|
|
|
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 09:02:57 +00:00
|
|
|
return get_sb_bdev(fs_type, flags, dev_name, data, efs_fill_super, mnt);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct file_system_type efs_fs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "efs",
|
|
|
|
.get_sb = efs_get_sb,
|
|
|
|
.kill_sb = kill_block_super,
|
|
|
|
.fs_flags = FS_REQUIRES_DEV,
|
|
|
|
};
|
|
|
|
|
|
|
|
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}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-12-07 04:33:20 +00:00
|
|
|
static struct kmem_cache * efs_inode_cachep;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static struct inode *efs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct efs_inode_info *ei;
|
2006-12-07 04:33:17 +00:00
|
|
|
ei = (struct efs_inode_info *)kmem_cache_alloc(efs_inode_cachep, GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!ei)
|
|
|
|
return NULL;
|
|
|
|
return &ei->vfs_inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void efs_destroy_inode(struct inode *inode)
|
|
|
|
{
|
|
|
|
kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
|
|
|
|
}
|
|
|
|
|
2007-10-17 06:25:51 +00:00
|
|
|
static void init_once(struct kmem_cache *cachep, void *foo)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct efs_inode_info *ei = (struct efs_inode_info *) foo;
|
|
|
|
|
2007-05-17 05:10:57 +00:00
|
|
|
inode_init_once(&ei->vfs_inode);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-07-20 01:11:58 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int init_inodecache(void)
|
|
|
|
{
|
|
|
|
efs_inode_cachep = kmem_cache_create("efs_inode_cache",
|
|
|
|
sizeof(struct efs_inode_info),
|
[PATCH] cpuset memory spread: slab cache filesystems
Mark file system inode and similar slab caches subject to SLAB_MEM_SPREAD
memory spreading.
If a slab cache is marked SLAB_MEM_SPREAD, then anytime that a task that's
in a cpuset with the 'memory_spread_slab' option enabled goes to allocate
from such a slab cache, the allocations are spread evenly over all the
memory nodes (task->mems_allowed) allowed to that task, instead of favoring
allocation on the node local to the current cpu.
The following inode and similar caches are marked SLAB_MEM_SPREAD:
file cache
==== =====
fs/adfs/super.c adfs_inode_cache
fs/affs/super.c affs_inode_cache
fs/befs/linuxvfs.c befs_inode_cache
fs/bfs/inode.c bfs_inode_cache
fs/block_dev.c bdev_cache
fs/cifs/cifsfs.c cifs_inode_cache
fs/coda/inode.c coda_inode_cache
fs/dquot.c dquot
fs/efs/super.c efs_inode_cache
fs/ext2/super.c ext2_inode_cache
fs/ext2/xattr.c (fs/mbcache.c) ext2_xattr
fs/ext3/super.c ext3_inode_cache
fs/ext3/xattr.c (fs/mbcache.c) ext3_xattr
fs/fat/cache.c fat_cache
fs/fat/inode.c fat_inode_cache
fs/freevxfs/vxfs_super.c vxfs_inode
fs/hpfs/super.c hpfs_inode_cache
fs/isofs/inode.c isofs_inode_cache
fs/jffs/inode-v23.c jffs_fm
fs/jffs2/super.c jffs2_i
fs/jfs/super.c jfs_ip
fs/minix/inode.c minix_inode_cache
fs/ncpfs/inode.c ncp_inode_cache
fs/nfs/direct.c nfs_direct_cache
fs/nfs/inode.c nfs_inode_cache
fs/ntfs/super.c ntfs_big_inode_cache_name
fs/ntfs/super.c ntfs_inode_cache
fs/ocfs2/dlm/dlmfs.c dlmfs_inode_cache
fs/ocfs2/super.c ocfs2_inode_cache
fs/proc/inode.c proc_inode_cache
fs/qnx4/inode.c qnx4_inode_cache
fs/reiserfs/super.c reiser_inode_cache
fs/romfs/inode.c romfs_inode_cache
fs/smbfs/inode.c smb_inode_cache
fs/sysv/inode.c sysv_inode_cache
fs/udf/super.c udf_inode_cache
fs/ufs/super.c ufs_inode_cache
net/socket.c sock_inode_cache
net/sunrpc/rpc_pipe.c rpc_inode_cache
The choice of which slab caches to so mark was quite simple. I marked
those already marked SLAB_RECLAIM_ACCOUNT, except for fs/xfs, dentry_cache,
inode_cache, and buffer_head, which were marked in a previous patch. Even
though SLAB_RECLAIM_ACCOUNT is for a different purpose, it marks the same
potentially large file system i/o related slab caches as we need for memory
spreading.
Given that the rule now becomes "wherever you would have used a
SLAB_RECLAIM_ACCOUNT slab cache flag before (usually the inode cache), use
the SLAB_MEM_SPREAD flag too", this should be easy enough to maintain.
Future file system writers will just copy one of the existing file system
slab cache setups and tend to get it right without thinking.
Signed-off-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-24 11:16:05 +00:00
|
|
|
0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
|
2007-07-20 01:11:58 +00:00
|
|
|
init_once);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (efs_inode_cachep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_inodecache(void)
|
|
|
|
{
|
2006-09-27 08:49:40 +00:00
|
|
|
kmem_cache_destroy(efs_inode_cachep);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void efs_put_super(struct super_block *s)
|
|
|
|
{
|
|
|
|
kfree(s->s_fs_info);
|
|
|
|
s->s_fs_info = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int efs_remount(struct super_block *sb, int *flags, char *data)
|
|
|
|
{
|
|
|
|
*flags |= MS_RDONLY;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-12 08:55:41 +00:00
|
|
|
static const struct super_operations efs_superblock_operations = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.alloc_inode = efs_alloc_inode,
|
|
|
|
.destroy_inode = efs_destroy_inode,
|
|
|
|
.put_super = efs_put_super,
|
|
|
|
.statfs = efs_statfs,
|
|
|
|
.remount_fs = efs_remount,
|
|
|
|
};
|
|
|
|
|
2007-10-21 23:42:17 +00:00
|
|
|
static const struct export_operations efs_export_ops = {
|
2007-10-21 23:42:09 +00:00
|
|
|
.fh_to_dentry = efs_fh_to_dentry,
|
|
|
|
.fh_to_parent = efs_fh_to_parent,
|
2005-04-16 22:20:36 +00:00
|
|
|
.get_parent = efs_get_parent,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_efs_fs(void) {
|
|
|
|
int err;
|
|
|
|
printk("EFS: "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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_efs_fs(void) {
|
|
|
|
unregister_filesystem(&efs_fs_type);
|
|
|
|
destroy_inodecache();
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
printk(KERN_INFO "EFS: SGI disklabel: checksum bad, label corrupted\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printk(KERN_DEBUG "EFS: 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]) {
|
|
|
|
printk(KERN_DEBUG "EFS: 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)) {
|
|
|
|
printk(KERN_DEBUG "EFS: 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) {
|
|
|
|
printk(KERN_NOTICE "EFS: partition table contained no EFS partitions\n");
|
|
|
|
#ifdef DEBUG
|
|
|
|
} else {
|
|
|
|
printk(KERN_INFO "EFS: using slice %d (type %s, offset 0x%x)\n",
|
|
|
|
slice,
|
|
|
|
(pt_entry->pt_name) ? pt_entry->pt_name : "unknown",
|
|
|
|
sblock);
|
|
|
|
#endif
|
|
|
|
}
|
2006-01-15 01:37:08 +00:00
|
|
|
return sblock;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int efs_validate_super(struct efs_sb_info *sb, struct efs_super *super) {
|
|
|
|
|
2006-01-15 01:37:08 +00:00
|
|
|
if (!IS_EFS_MAGIC(be32_to_cpu(super->fs_magic)))
|
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2008-02-07 08:15:34 +00:00
|
|
|
int ret = -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-27 08:49:37 +00:00
|
|
|
sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!sb)
|
|
|
|
return -ENOMEM;
|
|
|
|
s->s_fs_info = sb;
|
|
|
|
|
|
|
|
s->s_magic = EFS_SUPER_MAGIC;
|
|
|
|
if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
|
|
|
|
printk(KERN_ERR "EFS: device does not support %d byte blocks\n",
|
|
|
|
EFS_BLOCKSIZE);
|
|
|
|
goto out_no_fs_ul;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read the vh (volume header) block */
|
|
|
|
bh = sb_bread(s, 0);
|
|
|
|
|
|
|
|
if (!bh) {
|
|
|
|
printk(KERN_ERR "EFS: cannot read volume header\n");
|
|
|
|
goto out_no_fs_ul;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) {
|
|
|
|
goto out_no_fs_ul;
|
|
|
|
}
|
|
|
|
|
|
|
|
bh = sb_bread(s, sb->fs_start + EFS_SUPER);
|
|
|
|
if (!bh) {
|
|
|
|
printk(KERN_ERR "EFS: cannot read superblock\n");
|
|
|
|
goto out_no_fs_ul;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (efs_validate_super(sb, (struct efs_super *) bh->b_data)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printk(KERN_WARNING "EFS: invalid superblock at block %u\n", sb->fs_start + EFS_SUPER);
|
|
|
|
#endif
|
|
|
|
brelse(bh);
|
|
|
|
goto out_no_fs_ul;
|
|
|
|
}
|
|
|
|
brelse(bh);
|
|
|
|
|
|
|
|
if (!(s->s_flags & MS_RDONLY)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printk(KERN_INFO "EFS: forcing read-only mode\n");
|
|
|
|
#endif
|
|
|
|
s->s_flags |= MS_RDONLY;
|
|
|
|
}
|
|
|
|
s->s_op = &efs_superblock_operations;
|
|
|
|
s->s_export_op = &efs_export_ops;
|
2008-02-07 08:15:34 +00:00
|
|
|
root = efs_iget(s, EFS_ROOTINODE);
|
|
|
|
if (IS_ERR(root)) {
|
|
|
|
printk(KERN_ERR "EFS: get root inode failed\n");
|
|
|
|
ret = PTR_ERR(root);
|
|
|
|
goto out_no_fs;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
s->s_root = d_alloc_root(root);
|
|
|
|
if (!(s->s_root)) {
|
2008-02-07 08:15:34 +00:00
|
|
|
printk(KERN_ERR "EFS: get root dentry failed\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
iput(root);
|
2008-02-07 08:15:34 +00:00
|
|
|
ret = -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out_no_fs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_no_fs_ul:
|
|
|
|
out_no_fs:
|
|
|
|
s->s_fs_info = NULL;
|
|
|
|
kfree(sb);
|
2008-02-07 08:15:34 +00:00
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-06-23 09:02:58 +00:00
|
|
|
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) {
|
|
|
|
struct efs_sb_info *sb = SUPER_INFO(dentry->d_sb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
buf->f_type = EFS_SUPER_MAGIC; /* efs magic number */
|
|
|
|
buf->f_bsize = EFS_BLOCKSIZE; /* blocksize */
|
|
|
|
buf->f_blocks = sb->total_groups * /* total data blocks */
|
|
|
|
(sb->group_size - sb->inode_blocks);
|
|
|
|
buf->f_bfree = sb->data_free; /* free data blocks */
|
|
|
|
buf->f_bavail = sb->data_free; /* free blocks for non-root */
|
|
|
|
buf->f_files = sb->total_groups * /* total inodes */
|
|
|
|
sb->inode_blocks *
|
|
|
|
(EFS_BLOCKSIZE / sizeof(struct efs_dinode));
|
|
|
|
buf->f_ffree = sb->inode_free; /* free inodes */
|
|
|
|
buf->f_fsid.val[0] = (sb->fs_magic >> 16) & 0xffff; /* fs ID */
|
|
|
|
buf->f_fsid.val[1] = sb->fs_magic & 0xffff; /* fs ID */
|
|
|
|
buf->f_namelen = EFS_MAXNAMELEN; /* max filename length */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|