2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* linux/fs/affs/inode.c
|
|
|
|
*
|
|
|
|
* (c) 1996 Hans-Joachim Widmaier - Rewritten
|
|
|
|
*
|
|
|
|
* (C) 1993 Ray Burr - Modified for Amiga FFS filesystem.
|
|
|
|
*
|
|
|
|
* (C) 1992 Eric Youngdale Modified for ISO 9660 filesystem.
|
|
|
|
*
|
|
|
|
* (C) 1991 Linus Torvalds - minix filesystem
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/statfs.h>
|
|
|
|
#include <linux/parser.h>
|
2006-09-24 11:13:19 -04:00
|
|
|
#include <linux/magic.h>
|
Detach sched.h from mm.h
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.
This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
getting them indirectly
Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
they don't need sched.h
b) sched.h stops being dependency for significant number of files:
on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
after patch it's only 3744 (-8.3%).
Cross-compile tested on
all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
alpha alpha-up
arm
i386 i386-up i386-defconfig i386-allnoconfig
ia64 ia64-up
m68k
mips
parisc parisc-up
powerpc powerpc-up
s390 s390-up
sparc sparc-up
sparc64 sparc64-up
um-x86_64
x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
as well as my two usual configs.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-20 17:22:52 -04:00
|
|
|
#include <linux/sched.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
#include "affs.h"
|
|
|
|
|
|
|
|
extern struct timezone sys_tz;
|
|
|
|
|
2006-06-23 05:02:58 -04:00
|
|
|
static int affs_statfs(struct dentry *dentry, struct kstatfs *buf);
|
2005-04-16 18:20:36 -04:00
|
|
|
static int affs_remount (struct super_block *sb, int *flags, char *data);
|
|
|
|
|
|
|
|
static void
|
|
|
|
affs_put_super(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
pr_debug("AFFS: put_super()\n");
|
|
|
|
|
|
|
|
if (!(sb->s_flags & MS_RDONLY)) {
|
|
|
|
AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = cpu_to_be32(1);
|
|
|
|
secs_to_datestamp(get_seconds(),
|
|
|
|
&AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change);
|
|
|
|
affs_fix_checksum(sb, sbi->s_root_bh);
|
|
|
|
mark_buffer_dirty(sbi->s_root_bh);
|
|
|
|
}
|
|
|
|
|
2005-11-07 04:01:34 -05:00
|
|
|
kfree(sbi->s_prefix);
|
2005-04-16 18:20:36 -04:00
|
|
|
affs_free_bitmap(sb);
|
|
|
|
affs_brelse(sbi->s_root_bh);
|
|
|
|
kfree(sbi);
|
|
|
|
sb->s_fs_info = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
affs_write_super(struct super_block *sb)
|
|
|
|
{
|
|
|
|
int clean = 2;
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
|
|
|
|
if (!(sb->s_flags & MS_RDONLY)) {
|
|
|
|
// if (sbi->s_bitmap[i].bm_bh) {
|
|
|
|
// if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) {
|
|
|
|
// clean = 0;
|
|
|
|
AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = cpu_to_be32(clean);
|
|
|
|
secs_to_datestamp(get_seconds(),
|
|
|
|
&AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change);
|
|
|
|
affs_fix_checksum(sb, sbi->s_root_bh);
|
|
|
|
mark_buffer_dirty(sbi->s_root_bh);
|
|
|
|
sb->s_dirt = !clean; /* redo until bitmap synced */
|
|
|
|
} else
|
|
|
|
sb->s_dirt = 0;
|
|
|
|
|
|
|
|
pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean);
|
|
|
|
}
|
|
|
|
|
2006-12-06 23:33:20 -05:00
|
|
|
static struct kmem_cache * affs_inode_cachep;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
static struct inode *affs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct affs_inode_info *ei;
|
2006-12-06 23:33:17 -05:00
|
|
|
ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, GFP_KERNEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (!ei)
|
|
|
|
return NULL;
|
|
|
|
ei->vfs_inode.i_version = 1;
|
|
|
|
return &ei->vfs_inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void affs_destroy_inode(struct inode *inode)
|
|
|
|
{
|
|
|
|
kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
|
|
|
|
}
|
|
|
|
|
2007-10-17 02:25:51 -04:00
|
|
|
static void init_once(struct kmem_cache *cachep, void *foo)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
|
|
|
struct affs_inode_info *ei = (struct affs_inode_info *) foo;
|
|
|
|
|
2007-05-17 01:10:57 -04:00
|
|
|
init_MUTEX(&ei->i_link_lock);
|
|
|
|
init_MUTEX(&ei->i_ext_lock);
|
|
|
|
inode_init_once(&ei->vfs_inode);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int init_inodecache(void)
|
|
|
|
{
|
|
|
|
affs_inode_cachep = kmem_cache_create("affs_inode_cache",
|
|
|
|
sizeof(struct affs_inode_info),
|
2006-03-24 06:16:06 -05:00
|
|
|
0, (SLAB_RECLAIM_ACCOUNT|
|
|
|
|
SLAB_MEM_SPREAD),
|
2007-07-19 21:11:58 -04:00
|
|
|
init_once);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (affs_inode_cachep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_inodecache(void)
|
|
|
|
{
|
2006-09-27 04:49:40 -04:00
|
|
|
kmem_cache_destroy(affs_inode_cachep);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2007-02-12 03:55:41 -05:00
|
|
|
static const struct super_operations affs_sops = {
|
2005-04-16 18:20:36 -04:00
|
|
|
.alloc_inode = affs_alloc_inode,
|
|
|
|
.destroy_inode = affs_destroy_inode,
|
|
|
|
.write_inode = affs_write_inode,
|
|
|
|
.put_inode = affs_put_inode,
|
2007-02-20 16:58:11 -05:00
|
|
|
.drop_inode = affs_drop_inode,
|
2005-04-16 18:20:36 -04:00
|
|
|
.delete_inode = affs_delete_inode,
|
|
|
|
.clear_inode = affs_clear_inode,
|
|
|
|
.put_super = affs_put_super,
|
|
|
|
.write_super = affs_write_super,
|
|
|
|
.statfs = affs_statfs,
|
|
|
|
.remount_fs = affs_remount,
|
2008-02-08 07:21:36 -05:00
|
|
|
.show_options = generic_show_options,
|
2005-04-16 18:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
Opt_bs, Opt_mode, Opt_mufs, Opt_prefix, Opt_protect,
|
|
|
|
Opt_reserved, Opt_root, Opt_setgid, Opt_setuid,
|
|
|
|
Opt_verbose, Opt_volume, Opt_ignore, Opt_err,
|
|
|
|
};
|
|
|
|
|
|
|
|
static match_table_t tokens = {
|
|
|
|
{Opt_bs, "bs=%u"},
|
|
|
|
{Opt_mode, "mode=%o"},
|
|
|
|
{Opt_mufs, "mufs"},
|
|
|
|
{Opt_prefix, "prefix=%s"},
|
|
|
|
{Opt_protect, "protect"},
|
|
|
|
{Opt_reserved, "reserved=%u"},
|
|
|
|
{Opt_root, "root=%u"},
|
|
|
|
{Opt_setgid, "setgid=%u"},
|
|
|
|
{Opt_setuid, "setuid=%u"},
|
|
|
|
{Opt_verbose, "verbose"},
|
|
|
|
{Opt_volume, "volume=%s"},
|
|
|
|
{Opt_ignore, "grpquota"},
|
|
|
|
{Opt_ignore, "noquota"},
|
|
|
|
{Opt_ignore, "quota"},
|
|
|
|
{Opt_ignore, "usrquota"},
|
|
|
|
{Opt_err, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s32 *root,
|
|
|
|
int *blocksize, char **prefix, char *volume, unsigned long *mount_opts)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
substring_t args[MAX_OPT_ARGS];
|
|
|
|
|
|
|
|
/* Fill in defaults */
|
|
|
|
|
|
|
|
*uid = current->uid;
|
|
|
|
*gid = current->gid;
|
|
|
|
*reserved = 2;
|
|
|
|
*root = -1;
|
|
|
|
*blocksize = -1;
|
|
|
|
volume[0] = ':';
|
|
|
|
volume[1] = 0;
|
|
|
|
*mount_opts = 0;
|
|
|
|
if (!options)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
while ((p = strsep(&options, ",")) != NULL) {
|
|
|
|
int token, n, option;
|
|
|
|
if (!*p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
token = match_token(p, tokens, args);
|
|
|
|
switch (token) {
|
|
|
|
case Opt_bs:
|
|
|
|
if (match_int(&args[0], &n))
|
|
|
|
return -EINVAL;
|
|
|
|
if (n != 512 && n != 1024 && n != 2048
|
|
|
|
&& n != 4096) {
|
|
|
|
printk ("AFFS: Invalid blocksize (512, 1024, 2048, 4096 allowed)\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*blocksize = n;
|
|
|
|
break;
|
|
|
|
case Opt_mode:
|
|
|
|
if (match_octal(&args[0], &option))
|
|
|
|
return 1;
|
|
|
|
*mode = option & 0777;
|
|
|
|
*mount_opts |= SF_SETMODE;
|
|
|
|
break;
|
|
|
|
case Opt_mufs:
|
|
|
|
*mount_opts |= SF_MUFS;
|
|
|
|
break;
|
|
|
|
case Opt_prefix:
|
2005-11-07 04:01:34 -05:00
|
|
|
/* Free any previous prefix */
|
|
|
|
kfree(*prefix);
|
|
|
|
*prefix = NULL;
|
2005-04-16 18:20:36 -04:00
|
|
|
*prefix = match_strdup(&args[0]);
|
|
|
|
if (!*prefix)
|
|
|
|
return 0;
|
|
|
|
*mount_opts |= SF_PREFIX;
|
|
|
|
break;
|
|
|
|
case Opt_protect:
|
|
|
|
*mount_opts |= SF_IMMUTABLE;
|
|
|
|
break;
|
|
|
|
case Opt_reserved:
|
|
|
|
if (match_int(&args[0], reserved))
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case Opt_root:
|
|
|
|
if (match_int(&args[0], root))
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case Opt_setgid:
|
|
|
|
if (match_int(&args[0], &option))
|
|
|
|
return 1;
|
|
|
|
*gid = option;
|
|
|
|
*mount_opts |= SF_SETGID;
|
|
|
|
break;
|
|
|
|
case Opt_setuid:
|
|
|
|
if (match_int(&args[0], &option))
|
|
|
|
return -EINVAL;
|
|
|
|
*uid = option;
|
|
|
|
*mount_opts |= SF_SETUID;
|
|
|
|
break;
|
|
|
|
case Opt_verbose:
|
|
|
|
*mount_opts |= SF_VERBOSE;
|
|
|
|
break;
|
|
|
|
case Opt_volume: {
|
|
|
|
char *vol = match_strdup(&args[0]);
|
|
|
|
strlcpy(volume, vol, 32);
|
|
|
|
kfree(vol);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Opt_ignore:
|
|
|
|
/* Silently ignore the quota options */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk("AFFS: Unrecognized mount option \"%s\" "
|
|
|
|
"or missing value\n", p);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function definitely needs to be split up. Some fine day I'll
|
|
|
|
* hopefully have the guts to do so. Until then: sorry for the mess.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int affs_fill_super(struct super_block *sb, void *data, int silent)
|
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi;
|
|
|
|
struct buffer_head *root_bh = NULL;
|
|
|
|
struct buffer_head *boot_bh;
|
|
|
|
struct inode *root_inode = NULL;
|
|
|
|
s32 root_block;
|
|
|
|
int size, blocksize;
|
|
|
|
u32 chksum;
|
|
|
|
int num_bm;
|
|
|
|
int i, j;
|
|
|
|
s32 key;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
int reserved;
|
|
|
|
unsigned long mount_flags;
|
|
|
|
int tmp_flags; /* fix remount prototype... */
|
2006-06-25 08:49:08 -04:00
|
|
|
u8 sig[4];
|
2008-02-07 03:15:29 -05:00
|
|
|
int ret = -EINVAL;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2008-02-08 07:21:36 -05:00
|
|
|
save_mount_options(sb, data);
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options");
|
|
|
|
|
|
|
|
sb->s_magic = AFFS_SUPER_MAGIC;
|
|
|
|
sb->s_op = &affs_sops;
|
|
|
|
sb->s_flags |= MS_NODIRATIME;
|
|
|
|
|
2006-09-27 04:49:37 -04:00
|
|
|
sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (!sbi)
|
|
|
|
return -ENOMEM;
|
|
|
|
sb->s_fs_info = sbi;
|
|
|
|
init_MUTEX(&sbi->s_bmlock);
|
|
|
|
|
|
|
|
if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
|
|
|
|
&blocksize,&sbi->s_prefix,
|
|
|
|
sbi->s_volume, &mount_flags)) {
|
|
|
|
printk(KERN_ERR "AFFS: Error parsing options\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
/* N.B. after this point s_prefix must be released */
|
|
|
|
|
|
|
|
sbi->s_flags = mount_flags;
|
|
|
|
sbi->s_mode = i;
|
|
|
|
sbi->s_uid = uid;
|
|
|
|
sbi->s_gid = gid;
|
|
|
|
sbi->s_reserved= reserved;
|
|
|
|
|
|
|
|
/* Get the size of the device in 512-byte blocks.
|
|
|
|
* If we later see that the partition uses bigger
|
|
|
|
* blocks, we will have to change it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
size = sb->s_bdev->bd_inode->i_size >> 9;
|
|
|
|
pr_debug("AFFS: initial blocksize=%d, #blocks=%d\n", 512, size);
|
|
|
|
|
|
|
|
affs_set_blocksize(sb, PAGE_SIZE);
|
|
|
|
/* Try to find root block. Its location depends on the block size. */
|
|
|
|
|
|
|
|
i = 512;
|
|
|
|
j = 4096;
|
|
|
|
if (blocksize > 0) {
|
|
|
|
i = j = blocksize;
|
|
|
|
size = size / (blocksize / 512);
|
|
|
|
}
|
|
|
|
for (blocksize = i, key = 0; blocksize <= j; blocksize <<= 1, size >>= 1) {
|
|
|
|
sbi->s_root_block = root_block;
|
|
|
|
if (root_block < 0)
|
|
|
|
sbi->s_root_block = (reserved + size - 1) / 2;
|
|
|
|
pr_debug("AFFS: setting blocksize to %d\n", blocksize);
|
|
|
|
affs_set_blocksize(sb, blocksize);
|
|
|
|
sbi->s_partition_size = size;
|
|
|
|
|
|
|
|
/* The root block location that was calculated above is not
|
|
|
|
* correct if the partition size is an odd number of 512-
|
|
|
|
* byte blocks, which will be rounded down to a number of
|
|
|
|
* 1024-byte blocks, and if there were an even number of
|
|
|
|
* reserved blocks. Ideally, all partition checkers should
|
|
|
|
* report the real number of blocks of the real blocksize,
|
|
|
|
* but since this just cannot be done, we have to try to
|
|
|
|
* find the root block anyways. In the above case, it is one
|
|
|
|
* block behind the calculated one. So we check this one, too.
|
|
|
|
*/
|
|
|
|
for (num_bm = 0; num_bm < 2; num_bm++) {
|
|
|
|
pr_debug("AFFS: Dev %s, trying root=%u, bs=%d, "
|
|
|
|
"size=%d, reserved=%d\n",
|
|
|
|
sb->s_id,
|
|
|
|
sbi->s_root_block + num_bm,
|
|
|
|
blocksize, size, reserved);
|
|
|
|
root_bh = affs_bread(sb, sbi->s_root_block + num_bm);
|
|
|
|
if (!root_bh)
|
|
|
|
continue;
|
|
|
|
if (!affs_checksum_block(sb, root_bh) &&
|
|
|
|
be32_to_cpu(AFFS_ROOT_HEAD(root_bh)->ptype) == T_SHORT &&
|
|
|
|
be32_to_cpu(AFFS_ROOT_TAIL(sb, root_bh)->stype) == ST_ROOT) {
|
|
|
|
sbi->s_hashsize = blocksize / 4 - 56;
|
|
|
|
sbi->s_root_block += num_bm;
|
|
|
|
key = 1;
|
|
|
|
goto got_root;
|
|
|
|
}
|
|
|
|
affs_brelse(root_bh);
|
|
|
|
root_bh = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!silent)
|
|
|
|
printk(KERN_ERR "AFFS: No valid root block on device %s\n",
|
|
|
|
sb->s_id);
|
|
|
|
goto out_error;
|
|
|
|
|
|
|
|
/* N.B. after this point bh must be released */
|
|
|
|
got_root:
|
|
|
|
root_block = sbi->s_root_block;
|
|
|
|
|
|
|
|
/* Find out which kind of FS we have */
|
|
|
|
boot_bh = sb_bread(sb, 0);
|
|
|
|
if (!boot_bh) {
|
|
|
|
printk(KERN_ERR "AFFS: Cannot read boot block\n");
|
|
|
|
goto out_error;
|
|
|
|
}
|
2006-06-25 08:49:08 -04:00
|
|
|
memcpy(sig, boot_bh->b_data, 4);
|
2005-04-16 18:20:36 -04:00
|
|
|
brelse(boot_bh);
|
2006-06-25 08:49:08 -04:00
|
|
|
chksum = be32_to_cpu(*(__be32 *)sig);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Dircache filesystems are compatible with non-dircache ones
|
|
|
|
* when reading. As long as they aren't supported, writing is
|
|
|
|
* not recommended.
|
|
|
|
*/
|
|
|
|
if ((chksum == FS_DCFFS || chksum == MUFS_DCFFS || chksum == FS_DCOFS
|
|
|
|
|| chksum == MUFS_DCOFS) && !(sb->s_flags & MS_RDONLY)) {
|
|
|
|
printk(KERN_NOTICE "AFFS: Dircache FS - mounting %s read only\n",
|
|
|
|
sb->s_id);
|
|
|
|
sb->s_flags |= MS_RDONLY;
|
|
|
|
}
|
|
|
|
switch (chksum) {
|
|
|
|
case MUFS_FS:
|
|
|
|
case MUFS_INTLFFS:
|
|
|
|
case MUFS_DCFFS:
|
|
|
|
sbi->s_flags |= SF_MUFS;
|
|
|
|
/* fall thru */
|
|
|
|
case FS_INTLFFS:
|
|
|
|
case FS_DCFFS:
|
|
|
|
sbi->s_flags |= SF_INTL;
|
|
|
|
break;
|
|
|
|
case MUFS_FFS:
|
|
|
|
sbi->s_flags |= SF_MUFS;
|
|
|
|
break;
|
|
|
|
case FS_FFS:
|
|
|
|
break;
|
|
|
|
case MUFS_OFS:
|
|
|
|
sbi->s_flags |= SF_MUFS;
|
|
|
|
/* fall thru */
|
|
|
|
case FS_OFS:
|
|
|
|
sbi->s_flags |= SF_OFS;
|
|
|
|
sb->s_flags |= MS_NOEXEC;
|
|
|
|
break;
|
|
|
|
case MUFS_DCOFS:
|
|
|
|
case MUFS_INTLOFS:
|
|
|
|
sbi->s_flags |= SF_MUFS;
|
|
|
|
case FS_DCOFS:
|
|
|
|
case FS_INTLOFS:
|
|
|
|
sbi->s_flags |= SF_INTL | SF_OFS;
|
|
|
|
sb->s_flags |= MS_NOEXEC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR "AFFS: Unknown filesystem on device %s: %08X\n",
|
|
|
|
sb->s_id, chksum);
|
|
|
|
goto out_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mount_flags & SF_VERBOSE) {
|
2006-06-25 08:49:08 -04:00
|
|
|
u8 len = AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0];
|
|
|
|
printk(KERN_NOTICE "AFFS: Mounting volume \"%.*s\": Type=%.3s\\%c, Blocksize=%d\n",
|
|
|
|
len > 31 ? 31 : len,
|
2005-04-16 18:20:36 -04:00
|
|
|
AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1,
|
2006-06-25 08:49:08 -04:00
|
|
|
sig, sig[3] + '0', blocksize);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sb->s_flags |= MS_NODEV | MS_NOSUID;
|
|
|
|
|
|
|
|
sbi->s_data_blksize = sb->s_blocksize;
|
|
|
|
if (sbi->s_flags & SF_OFS)
|
|
|
|
sbi->s_data_blksize -= 24;
|
|
|
|
|
|
|
|
/* Keep super block in cache */
|
|
|
|
sbi->s_root_bh = root_bh;
|
|
|
|
/* N.B. after this point s_root_bh must be released */
|
|
|
|
|
|
|
|
tmp_flags = sb->s_flags;
|
|
|
|
if (affs_init_bitmap(sb, &tmp_flags))
|
|
|
|
goto out_error;
|
|
|
|
sb->s_flags = tmp_flags;
|
|
|
|
|
|
|
|
/* set up enough so that it can read an inode */
|
|
|
|
|
2008-02-07 03:15:29 -05:00
|
|
|
root_inode = affs_iget(sb, root_block);
|
|
|
|
if (IS_ERR(root_inode)) {
|
|
|
|
ret = PTR_ERR(root_inode);
|
|
|
|
goto out_error_noinode;
|
|
|
|
}
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
sb->s_root = d_alloc_root(root_inode);
|
|
|
|
if (!sb->s_root) {
|
|
|
|
printk(KERN_ERR "AFFS: Get root inode failed\n");
|
|
|
|
goto out_error;
|
|
|
|
}
|
|
|
|
sb->s_root->d_op = &affs_dentry_operations;
|
|
|
|
|
|
|
|
pr_debug("AFFS: s_flags=%lX\n",sb->s_flags);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Begin the cascaded cleanup ...
|
|
|
|
*/
|
|
|
|
out_error:
|
|
|
|
if (root_inode)
|
|
|
|
iput(root_inode);
|
2008-02-07 03:15:29 -05:00
|
|
|
out_error_noinode:
|
2005-11-07 04:01:34 -05:00
|
|
|
kfree(sbi->s_bitmap);
|
2005-04-16 18:20:36 -04:00
|
|
|
affs_brelse(root_bh);
|
2005-11-07 04:01:34 -05:00
|
|
|
kfree(sbi->s_prefix);
|
2005-04-16 18:20:36 -04:00
|
|
|
kfree(sbi);
|
|
|
|
sb->s_fs_info = NULL;
|
2008-02-07 03:15:29 -05:00
|
|
|
return ret;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
affs_remount(struct super_block *sb, int *flags, char *data)
|
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
int blocksize;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
int mode;
|
|
|
|
int reserved;
|
|
|
|
int root_block;
|
|
|
|
unsigned long mount_flags;
|
|
|
|
int res = 0;
|
2008-02-08 07:21:36 -05:00
|
|
|
char *new_opts = kstrdup(data, GFP_KERNEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data);
|
|
|
|
|
|
|
|
*flags |= MS_NODIRATIME;
|
|
|
|
|
2008-02-08 07:21:36 -05:00
|
|
|
if (!parse_options(data, &uid, &gid, &mode, &reserved, &root_block,
|
|
|
|
&blocksize, &sbi->s_prefix, sbi->s_volume,
|
|
|
|
&mount_flags)) {
|
|
|
|
kfree(new_opts);
|
2005-04-16 18:20:36 -04:00
|
|
|
return -EINVAL;
|
2008-02-08 07:21:36 -05:00
|
|
|
}
|
|
|
|
kfree(sb->s_options);
|
|
|
|
sb->s_options = new_opts;
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
sbi->s_flags = mount_flags;
|
|
|
|
sbi->s_mode = mode;
|
|
|
|
sbi->s_uid = uid;
|
|
|
|
sbi->s_gid = gid;
|
|
|
|
|
|
|
|
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
|
|
|
|
return 0;
|
|
|
|
if (*flags & MS_RDONLY) {
|
|
|
|
sb->s_dirt = 1;
|
|
|
|
while (sb->s_dirt)
|
|
|
|
affs_write_super(sb);
|
|
|
|
affs_free_bitmap(sb);
|
|
|
|
} else
|
|
|
|
res = affs_init_bitmap(sb, flags);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-06-23 05:02:58 -04:00
|
|
|
affs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2006-06-23 05:02:58 -04:00
|
|
|
struct super_block *sb = dentry->d_sb;
|
2005-04-16 18:20:36 -04:00
|
|
|
int free;
|
|
|
|
|
|
|
|
pr_debug("AFFS: statfs() partsize=%d, reserved=%d\n",AFFS_SB(sb)->s_partition_size,
|
|
|
|
AFFS_SB(sb)->s_reserved);
|
|
|
|
|
|
|
|
free = affs_count_free_blocks(sb);
|
|
|
|
buf->f_type = AFFS_SUPER_MAGIC;
|
|
|
|
buf->f_bsize = sb->s_blocksize;
|
|
|
|
buf->f_blocks = AFFS_SB(sb)->s_partition_size - AFFS_SB(sb)->s_reserved;
|
|
|
|
buf->f_bfree = free;
|
|
|
|
buf->f_bavail = free;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[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 05:02:57 -04:00
|
|
|
static int affs_get_sb(struct file_system_type *fs_type,
|
|
|
|
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
|
2005-04-16 18:20:36 -04: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 05:02:57 -04:00
|
|
|
return get_sb_bdev(fs_type, flags, dev_name, data, affs_fill_super,
|
|
|
|
mnt);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct file_system_type affs_fs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "affs",
|
|
|
|
.get_sb = affs_get_sb,
|
|
|
|
.kill_sb = kill_block_super,
|
|
|
|
.fs_flags = FS_REQUIRES_DEV,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_affs_fs(void)
|
|
|
|
{
|
|
|
|
int err = init_inodecache();
|
|
|
|
if (err)
|
|
|
|
goto out1;
|
|
|
|
err = register_filesystem(&affs_fs_type);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
return 0;
|
|
|
|
out:
|
|
|
|
destroy_inodecache();
|
|
|
|
out1:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_affs_fs(void)
|
|
|
|
{
|
|
|
|
unregister_filesystem(&affs_fs_type);
|
|
|
|
destroy_inodecache();
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Amiga filesystem support for Linux");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_init(init_affs_fs)
|
|
|
|
module_exit(exit_affs_fs)
|