2019-05-19 12:08:20 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-16 22:20:36 +00: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>
|
2024-09-17 14:53:09 +00:00
|
|
|
#include <linux/fs_parser.h>
|
|
|
|
#include <linux/fs_context.h>
|
2006-09-24 15:13:19 +00: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 21:22:52 +00:00
|
|
|
#include <linux/sched.h>
|
2017-02-02 16:54:15 +00:00
|
|
|
#include <linux/cred.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2012-06-06 15:56:57 +00:00
|
|
|
#include <linux/writeback.h>
|
2015-09-09 22:39:09 +00:00
|
|
|
#include <linux/blkdev.h>
|
2017-07-05 15:25:16 +00:00
|
|
|
#include <linux/seq_file.h>
|
2017-12-11 11:35:10 +00:00
|
|
|
#include <linux/iversion.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "affs.h"
|
|
|
|
|
2006-06-23 09:02:58 +00:00
|
|
|
static int affs_statfs(struct dentry *dentry, struct kstatfs *buf);
|
2017-07-05 15:25:16 +00:00
|
|
|
static int affs_show_options(struct seq_file *m, struct dentry *root);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-08 08:03:15 +00:00
|
|
|
static void
|
affs: stop setting bm_flags
AFFS stores values '1' and '2' in 'bm_flags', and I fail to see any logic when
it prefers one or another. AFFS writes '1' only from '->put_super()', while
'->sync_fs()' and '->write_super()' store value '2'. So on the first glance,
it looks like we want to have '1' if we unmount. However, this does not really
happen in these cases:
1. superblock is written via 'write_super()' then we unmount;
2. we re-mount R/O, then unmount.
which are quite typical.
I could not find good documentation describing this field, except of one random
piece of documentation in the internet which says that -1 means that the root
block is valid, which is not consistent with what we have in the Linux AFFS
driver.
Jan Kara commented on this: "I have some vague recollection that on Amiga
boolean was usually encoded as: 0 == false, ~0 == -1 == true. But it has been
ages..."
Thus, my conclusion is that value of '1' is as good as value of '2' and we can
just always use '2'. An Jan Kara suggested to go further: "generally bm_flags
handling looks strange. If they are 0, we mount fs read only and thus cannot
change them. If they are != 0, we write 2 there. So IMHO if you just removed
bm_flags setting, nothing will really happen."
So this patch removes the bm_flags setting completely. This makes the "clean"
argument of the 'affs_commit_super()' function unneeded, so it is also removed.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-06-06 15:56:51 +00:00
|
|
|
affs_commit_super(struct super_block *sb, int wait)
|
2009-06-08 08:03:15 +00:00
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
struct buffer_head *bh = sbi->s_root_bh;
|
|
|
|
struct affs_root_tail *tail = AFFS_ROOT_TAIL(sb, bh);
|
|
|
|
|
2012-06-06 15:56:55 +00:00
|
|
|
lock_buffer(bh);
|
2017-02-27 22:27:54 +00:00
|
|
|
affs_secs_to_datestamp(ktime_get_real_seconds(), &tail->disk_change);
|
2009-06-08 08:03:15 +00:00
|
|
|
affs_fix_checksum(sb, bh);
|
2012-06-06 15:56:55 +00:00
|
|
|
unlock_buffer(bh);
|
|
|
|
|
2009-06-08 08:03:15 +00:00
|
|
|
mark_buffer_dirty(bh);
|
2010-07-05 12:15:00 +00:00
|
|
|
if (wait)
|
|
|
|
sync_dirty_buffer(bh);
|
2009-06-08 08:03:15 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static void
|
|
|
|
affs_put_super(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
2014-06-06 21:37:25 +00:00
|
|
|
pr_debug("%s()\n", __func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-06-06 15:56:57 +00:00
|
|
|
cancel_delayed_work_sync(&sbi->sb_work);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 08:03:15 +00:00
|
|
|
static int
|
|
|
|
affs_sync_fs(struct super_block *sb, int wait)
|
|
|
|
{
|
affs: stop setting bm_flags
AFFS stores values '1' and '2' in 'bm_flags', and I fail to see any logic when
it prefers one or another. AFFS writes '1' only from '->put_super()', while
'->sync_fs()' and '->write_super()' store value '2'. So on the first glance,
it looks like we want to have '1' if we unmount. However, this does not really
happen in these cases:
1. superblock is written via 'write_super()' then we unmount;
2. we re-mount R/O, then unmount.
which are quite typical.
I could not find good documentation describing this field, except of one random
piece of documentation in the internet which says that -1 means that the root
block is valid, which is not consistent with what we have in the Linux AFFS
driver.
Jan Kara commented on this: "I have some vague recollection that on Amiga
boolean was usually encoded as: 0 == false, ~0 == -1 == true. But it has been
ages..."
Thus, my conclusion is that value of '1' is as good as value of '2' and we can
just always use '2'. An Jan Kara suggested to go further: "generally bm_flags
handling looks strange. If they are 0, we mount fs read only and thus cannot
change them. If they are != 0, we write 2 there. So IMHO if you just removed
bm_flags setting, nothing will really happen."
So this patch removes the bm_flags setting completely. This makes the "clean"
argument of the 'affs_commit_super()' function unneeded, so it is also removed.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-06-06 15:56:51 +00:00
|
|
|
affs_commit_super(sb, wait);
|
2009-06-08 08:03:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-06 15:56:57 +00:00
|
|
|
static void flush_superblock(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi;
|
|
|
|
struct super_block *sb;
|
|
|
|
|
|
|
|
sbi = container_of(work, struct affs_sb_info, sb_work.work);
|
|
|
|
sb = sbi->sb;
|
|
|
|
|
|
|
|
spin_lock(&sbi->work_lock);
|
|
|
|
sbi->work_queued = 0;
|
|
|
|
spin_unlock(&sbi->work_lock);
|
|
|
|
|
|
|
|
affs_commit_super(sb, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void affs_mark_sb_dirty(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
unsigned long delay;
|
|
|
|
|
2017-07-17 07:45:34 +00:00
|
|
|
if (sb_rdonly(sb))
|
2012-06-06 15:56:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock(&sbi->work_lock);
|
|
|
|
if (!sbi->work_queued) {
|
|
|
|
delay = msecs_to_jiffies(dirty_writeback_interval * 10);
|
|
|
|
queue_delayed_work(system_long_wq, &sbi->sb_work, delay);
|
|
|
|
sbi->work_queued = 1;
|
|
|
|
}
|
|
|
|
spin_unlock(&sbi->work_lock);
|
|
|
|
}
|
|
|
|
|
2006-12-07 04:33:20 +00:00
|
|
|
static struct kmem_cache * affs_inode_cachep;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static struct inode *affs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
2008-04-29 15:02:20 +00:00
|
|
|
struct affs_inode_info *i;
|
|
|
|
|
2022-03-22 21:41:03 +00:00
|
|
|
i = alloc_inode_sb(sb, affs_inode_cachep, GFP_KERNEL);
|
2008-04-29 15:02:20 +00:00
|
|
|
if (!i)
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
2008-04-29 15:02:20 +00:00
|
|
|
|
2017-12-11 11:35:10 +00:00
|
|
|
inode_set_iversion(&i->vfs_inode, 1);
|
2008-04-29 15:02:20 +00:00
|
|
|
i->i_lc = NULL;
|
|
|
|
i->i_ext_bh = NULL;
|
|
|
|
i->i_pa_cnt = 0;
|
|
|
|
|
|
|
|
return &i->vfs_inode;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2019-04-10 19:02:41 +00:00
|
|
|
static void affs_free_inode(struct inode *inode)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
|
|
|
|
}
|
|
|
|
|
2008-07-26 02:45:34 +00:00
|
|
|
static void init_once(void *foo)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct affs_inode_info *ei = (struct affs_inode_info *) foo;
|
|
|
|
|
2019-10-27 22:01:43 +00:00
|
|
|
mutex_init(&ei->i_link_lock);
|
|
|
|
mutex_init(&ei->i_ext_lock);
|
2007-05-17 05:10:57 +00:00
|
|
|
inode_init_once(&ei->vfs_inode);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 22:38:59 +00:00
|
|
|
static int __init init_inodecache(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
affs_inode_cachep = kmem_cache_create("affs_inode_cache",
|
|
|
|
sizeof(struct affs_inode_info),
|
2024-02-24 13:46:37 +00:00
|
|
|
0, (SLAB_RECLAIM_ACCOUNT | SLAB_ACCOUNT),
|
2007-07-20 01:11:58 +00:00
|
|
|
init_once);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (affs_inode_cachep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_inodecache(void)
|
|
|
|
{
|
2012-09-26 01:33:07 +00:00
|
|
|
/*
|
|
|
|
* Make sure all delayed rcu free inodes are flushed before we
|
|
|
|
* destroy cache.
|
|
|
|
*/
|
|
|
|
rcu_barrier();
|
2006-09-27 08:49:40 +00:00
|
|
|
kmem_cache_destroy(affs_inode_cachep);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 08:55:41 +00:00
|
|
|
static const struct super_operations affs_sops = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.alloc_inode = affs_alloc_inode,
|
2019-04-10 19:02:41 +00:00
|
|
|
.free_inode = affs_free_inode,
|
2005-04-16 22:20:36 +00:00
|
|
|
.write_inode = affs_write_inode,
|
2010-06-06 14:16:41 +00:00
|
|
|
.evict_inode = affs_evict_inode,
|
2005-04-16 22:20:36 +00:00
|
|
|
.put_super = affs_put_super,
|
2009-06-08 08:03:15 +00:00
|
|
|
.sync_fs = affs_sync_fs,
|
2005-04-16 22:20:36 +00:00
|
|
|
.statfs = affs_statfs,
|
2017-07-05 15:25:16 +00:00
|
|
|
.show_options = affs_show_options,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2014-04-07 22:39:01 +00:00
|
|
|
Opt_bs, Opt_mode, Opt_mufs, Opt_notruncate, Opt_prefix, Opt_protect,
|
2005-04-16 22:20:36 +00:00
|
|
|
Opt_reserved, Opt_root, Opt_setgid, Opt_setuid,
|
2024-09-17 14:53:09 +00:00
|
|
|
Opt_verbose, Opt_volume, Opt_ignore,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
struct affs_context {
|
|
|
|
kuid_t uid; /* uid to override */
|
|
|
|
kgid_t gid; /* gid to override */
|
|
|
|
unsigned int mode; /* mode to override */
|
|
|
|
unsigned int reserved; /* Number of reserved blocks */
|
|
|
|
int root_block; /* FFS root block number */
|
|
|
|
int blocksize; /* Initial device blksize */
|
|
|
|
char *prefix; /* Prefix for volumes and assigns */
|
|
|
|
char volume[32]; /* Vol. prefix for absolute symlinks */
|
|
|
|
unsigned long mount_flags; /* Options */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
static const struct fs_parameter_spec affs_param_spec[] = {
|
|
|
|
fsparam_u32 ("bs", Opt_bs),
|
|
|
|
fsparam_u32oct ("mode", Opt_mode),
|
|
|
|
fsparam_flag ("mufs", Opt_mufs),
|
|
|
|
fsparam_flag ("nofilenametruncate", Opt_notruncate),
|
|
|
|
fsparam_string ("prefix", Opt_prefix),
|
|
|
|
fsparam_flag ("protect", Opt_protect),
|
|
|
|
fsparam_u32 ("reserved", Opt_reserved),
|
|
|
|
fsparam_u32 ("root", Opt_root),
|
|
|
|
fsparam_gid ("setgid", Opt_setgid),
|
|
|
|
fsparam_uid ("setuid", Opt_setuid),
|
|
|
|
fsparam_flag ("verbose", Opt_verbose),
|
|
|
|
fsparam_string ("volume", Opt_volume),
|
|
|
|
fsparam_flag ("grpquota", Opt_ignore),
|
|
|
|
fsparam_flag ("noquota", Opt_ignore),
|
|
|
|
fsparam_flag ("quota", Opt_ignore),
|
|
|
|
fsparam_flag ("usrquota", Opt_ignore),
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int affs_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2024-09-17 14:53:09 +00:00
|
|
|
struct affs_context *ctx = fc->fs_private;
|
|
|
|
struct fs_parse_result result;
|
|
|
|
int n;
|
|
|
|
int opt;
|
|
|
|
|
|
|
|
opt = fs_parse(fc, affs_param_spec, param, &result);
|
|
|
|
if (opt < 0)
|
|
|
|
return opt;
|
|
|
|
|
|
|
|
switch (opt) {
|
|
|
|
case Opt_bs:
|
|
|
|
n = result.uint_32;
|
|
|
|
if (n != 512 && n != 1024 && n != 2048
|
|
|
|
&& n != 4096) {
|
|
|
|
pr_warn("Invalid blocksize (512, 1024, 2048, 4096 allowed)\n");
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2024-09-17 14:53:09 +00:00
|
|
|
ctx->blocksize = n;
|
|
|
|
break;
|
|
|
|
case Opt_mode:
|
|
|
|
ctx->mode = result.uint_32 & 0777;
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_SETMODE);
|
|
|
|
break;
|
|
|
|
case Opt_mufs:
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_MUFS);
|
|
|
|
break;
|
|
|
|
case Opt_notruncate:
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_NO_TRUNCATE);
|
|
|
|
break;
|
|
|
|
case Opt_prefix:
|
|
|
|
kfree(ctx->prefix);
|
|
|
|
ctx->prefix = param->string;
|
|
|
|
param->string = NULL;
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_PREFIX);
|
|
|
|
break;
|
|
|
|
case Opt_protect:
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_IMMUTABLE);
|
|
|
|
break;
|
|
|
|
case Opt_reserved:
|
|
|
|
ctx->reserved = result.uint_32;
|
|
|
|
break;
|
|
|
|
case Opt_root:
|
|
|
|
ctx->root_block = result.uint_32;
|
|
|
|
break;
|
|
|
|
case Opt_setgid:
|
|
|
|
ctx->gid = result.gid;
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_SETGID);
|
|
|
|
break;
|
|
|
|
case Opt_setuid:
|
|
|
|
ctx->uid = result.uid;
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_SETUID);
|
|
|
|
break;
|
|
|
|
case Opt_verbose:
|
|
|
|
affs_set_opt(ctx->mount_flags, SF_VERBOSE);
|
|
|
|
break;
|
|
|
|
case Opt_volume:
|
|
|
|
strscpy(ctx->volume, param->string, 32);
|
|
|
|
break;
|
|
|
|
case Opt_ignore:
|
|
|
|
/* Silently ignore the quota options */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2024-09-17 14:53:09 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 15:25:16 +00:00
|
|
|
static int affs_show_options(struct seq_file *m, struct dentry *root)
|
|
|
|
{
|
|
|
|
struct super_block *sb = root->d_sb;
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
|
|
|
|
if (sb->s_blocksize)
|
|
|
|
seq_printf(m, ",bs=%lu", sb->s_blocksize);
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_SETMODE))
|
|
|
|
seq_printf(m, ",mode=%o", sbi->s_mode);
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_MUFS))
|
|
|
|
seq_puts(m, ",mufs");
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_NO_TRUNCATE))
|
|
|
|
seq_puts(m, ",nofilenametruncate");
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_PREFIX))
|
|
|
|
seq_printf(m, ",prefix=%s", sbi->s_prefix);
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_IMMUTABLE))
|
|
|
|
seq_puts(m, ",protect");
|
|
|
|
if (sbi->s_reserved != 2)
|
|
|
|
seq_printf(m, ",reserved=%u", sbi->s_reserved);
|
|
|
|
if (sbi->s_root_block != (sbi->s_reserved + sbi->s_partition_size - 1) / 2)
|
|
|
|
seq_printf(m, ",root=%u", sbi->s_root_block);
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_SETGID))
|
|
|
|
seq_printf(m, ",setgid=%u",
|
|
|
|
from_kgid_munged(&init_user_ns, sbi->s_gid));
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_SETUID))
|
|
|
|
seq_printf(m, ",setuid=%u",
|
|
|
|
from_kuid_munged(&init_user_ns, sbi->s_uid));
|
|
|
|
if (affs_test_opt(sbi->s_flags, SF_VERBOSE))
|
|
|
|
seq_puts(m, ",verbose");
|
|
|
|
if (sbi->s_volume[0])
|
|
|
|
seq_printf(m, ",volume=%s", sbi->s_volume);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
static int affs_fill_super(struct super_block *sb, struct fs_context *fc)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi;
|
2024-09-17 14:53:09 +00:00
|
|
|
struct affs_context *ctx = fc->fs_private;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct buffer_head *root_bh = NULL;
|
|
|
|
struct buffer_head *boot_bh;
|
|
|
|
struct inode *root_inode = NULL;
|
2024-09-17 14:53:09 +00:00
|
|
|
int silent = fc->sb_flags & SB_SILENT;
|
2005-04-16 22:20:36 +00:00
|
|
|
int size, blocksize;
|
|
|
|
u32 chksum;
|
|
|
|
int num_bm;
|
|
|
|
int i, j;
|
|
|
|
int tmp_flags; /* fix remount prototype... */
|
2006-06-25 12:49:08 +00:00
|
|
|
u8 sig[4];
|
2013-12-10 19:43:54 +00:00
|
|
|
int ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sb->s_magic = AFFS_SUPER_MAGIC;
|
|
|
|
sb->s_op = &affs_sops;
|
2017-11-27 21:05:09 +00:00
|
|
|
sb->s_flags |= SB_NODIRATIME;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-03-21 21:05:12 +00:00
|
|
|
sb->s_time_gran = NSEC_PER_SEC;
|
|
|
|
sb->s_time_min = sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA;
|
|
|
|
sb->s_time_max = 86400LL * U32_MAX + 86400 + sb->s_time_min;
|
|
|
|
|
2006-09-27 08:49:37 +00:00
|
|
|
sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!sbi)
|
|
|
|
return -ENOMEM;
|
2010-08-15 20:52:36 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
sb->s_fs_info = sbi;
|
2012-06-06 15:56:56 +00:00
|
|
|
sbi->sb = sb;
|
2008-07-26 02:44:51 +00:00
|
|
|
mutex_init(&sbi->s_bmlock);
|
2010-01-24 05:04:07 +00:00
|
|
|
spin_lock_init(&sbi->symlink_lock);
|
2012-06-06 15:56:57 +00:00
|
|
|
spin_lock_init(&sbi->work_lock);
|
|
|
|
INIT_DELAYED_WORK(&sbi->sb_work, flush_superblock);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
sbi->s_flags = ctx->mount_flags;
|
|
|
|
sbi->s_mode = ctx->mode;
|
|
|
|
sbi->s_uid = ctx->uid;
|
|
|
|
sbi->s_gid = ctx->gid;
|
|
|
|
sbi->s_reserved = ctx->reserved;
|
|
|
|
sbi->s_prefix = ctx->prefix;
|
|
|
|
ctx->prefix = NULL;
|
|
|
|
memcpy(sbi->s_volume, ctx->volume, 32);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
/* N.B. after this point s_prefix must be released */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2021-10-18 10:11:11 +00:00
|
|
|
size = bdev_nr_sectors(sb->s_bdev);
|
2014-06-06 21:37:25 +00:00
|
|
|
pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
affs_set_blocksize(sb, PAGE_SIZE);
|
|
|
|
/* Try to find root block. Its location depends on the block size. */
|
|
|
|
|
2015-09-09 22:39:09 +00:00
|
|
|
i = bdev_logical_block_size(sb->s_bdev);
|
|
|
|
j = PAGE_SIZE;
|
2024-09-17 14:53:09 +00:00
|
|
|
blocksize = ctx->blocksize;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (blocksize > 0) {
|
|
|
|
i = j = blocksize;
|
|
|
|
size = size / (blocksize / 512);
|
|
|
|
}
|
2015-09-09 22:39:09 +00:00
|
|
|
|
2014-10-13 22:53:50 +00:00
|
|
|
for (blocksize = i; blocksize <= j; blocksize <<= 1, size >>= 1) {
|
2024-09-17 14:53:09 +00:00
|
|
|
sbi->s_root_block = ctx->root_block;
|
|
|
|
if (ctx->root_block < 0)
|
|
|
|
sbi->s_root_block = (ctx->reserved + size - 1) / 2;
|
2014-06-06 21:37:25 +00:00
|
|
|
pr_debug("setting blocksize to %d\n", blocksize);
|
2005-04-16 22:20:36 +00:00
|
|
|
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++) {
|
2014-06-06 21:37:25 +00:00
|
|
|
pr_debug("Dev %s, trying root=%u, bs=%d, "
|
2005-04-16 22:20:36 +00:00
|
|
|
"size=%d, reserved=%d\n",
|
|
|
|
sb->s_id,
|
|
|
|
sbi->s_root_block + num_bm,
|
2024-09-17 14:53:09 +00:00
|
|
|
ctx->blocksize, size, ctx->reserved);
|
2005-04-16 22:20:36 +00:00
|
|
|
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;
|
|
|
|
goto got_root;
|
|
|
|
}
|
|
|
|
affs_brelse(root_bh);
|
|
|
|
root_bh = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!silent)
|
2014-06-06 21:37:24 +00:00
|
|
|
pr_err("No valid root block on device %s\n", sb->s_id);
|
2013-12-10 19:43:54 +00:00
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* N.B. after this point bh must be released */
|
|
|
|
got_root:
|
2013-12-10 19:43:54 +00:00
|
|
|
/* Keep super block in cache */
|
|
|
|
sbi->s_root_bh = root_bh;
|
2024-09-17 14:53:09 +00:00
|
|
|
ctx->root_block = sbi->s_root_block;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Find out which kind of FS we have */
|
|
|
|
boot_bh = sb_bread(sb, 0);
|
|
|
|
if (!boot_bh) {
|
2014-06-06 21:37:24 +00:00
|
|
|
pr_err("Cannot read boot block\n");
|
2013-12-10 19:43:54 +00:00
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2006-06-25 12:49:08 +00:00
|
|
|
memcpy(sig, boot_bh->b_data, 4);
|
2005-04-16 22:20:36 +00:00
|
|
|
brelse(boot_bh);
|
2006-06-25 12:49:08 +00:00
|
|
|
chksum = be32_to_cpu(*(__be32 *)sig);
|
2005-04-16 22:20:36 +00: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
|
2017-07-17 07:45:34 +00:00
|
|
|
|| chksum == MUFS_DCOFS) && !sb_rdonly(sb)) {
|
2014-06-06 21:37:24 +00:00
|
|
|
pr_notice("Dircache FS - mounting %s read only\n", sb->s_id);
|
2017-11-27 21:05:09 +00:00
|
|
|
sb->s_flags |= SB_RDONLY;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
switch (chksum) {
|
2015-02-17 21:46:33 +00:00
|
|
|
case MUFS_FS:
|
|
|
|
case MUFS_INTLFFS:
|
|
|
|
case MUFS_DCFFS:
|
2015-04-16 19:48:21 +00:00
|
|
|
affs_set_opt(sbi->s_flags, SF_MUFS);
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2015-02-17 21:46:33 +00:00
|
|
|
case FS_INTLFFS:
|
|
|
|
case FS_DCFFS:
|
2015-04-16 19:48:21 +00:00
|
|
|
affs_set_opt(sbi->s_flags, SF_INTL);
|
2015-02-17 21:46:33 +00:00
|
|
|
break;
|
|
|
|
case MUFS_FFS:
|
2015-04-16 19:48:21 +00:00
|
|
|
affs_set_opt(sbi->s_flags, SF_MUFS);
|
2015-02-17 21:46:33 +00:00
|
|
|
break;
|
|
|
|
case FS_FFS:
|
|
|
|
break;
|
|
|
|
case MUFS_OFS:
|
2015-04-16 19:48:21 +00:00
|
|
|
affs_set_opt(sbi->s_flags, SF_MUFS);
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2015-02-17 21:46:33 +00:00
|
|
|
case FS_OFS:
|
2015-04-16 19:48:21 +00:00
|
|
|
affs_set_opt(sbi->s_flags, SF_OFS);
|
2017-11-27 21:05:09 +00:00
|
|
|
sb->s_flags |= SB_NOEXEC;
|
2015-02-17 21:46:33 +00:00
|
|
|
break;
|
|
|
|
case MUFS_DCOFS:
|
|
|
|
case MUFS_INTLOFS:
|
2015-04-16 19:48:21 +00:00
|
|
|
affs_set_opt(sbi->s_flags, SF_MUFS);
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2015-02-17 21:46:33 +00:00
|
|
|
case FS_DCOFS:
|
|
|
|
case FS_INTLOFS:
|
2015-04-16 19:48:21 +00:00
|
|
|
affs_set_opt(sbi->s_flags, SF_INTL);
|
|
|
|
affs_set_opt(sbi->s_flags, SF_OFS);
|
2017-11-27 21:05:09 +00:00
|
|
|
sb->s_flags |= SB_NOEXEC;
|
2015-02-17 21:46:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_err("Unknown filesystem on device %s: %08X\n",
|
|
|
|
sb->s_id, chksum);
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
if (affs_test_opt(ctx->mount_flags, SF_VERBOSE)) {
|
2006-06-25 12:49:08 +00:00
|
|
|
u8 len = AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0];
|
2014-06-06 21:37:24 +00:00
|
|
|
pr_notice("Mounting volume \"%.*s\": Type=%.3s\\%c, Blocksize=%d\n",
|
2006-06-25 12:49:08 +00:00
|
|
|
len > 31 ? 31 : len,
|
2005-04-16 22:20:36 +00:00
|
|
|
AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1,
|
2006-06-25 12:49:08 +00:00
|
|
|
sig, sig[3] + '0', blocksize);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-11-27 21:05:09 +00:00
|
|
|
sb->s_flags |= SB_NODEV | SB_NOSUID;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sbi->s_data_blksize = sb->s_blocksize;
|
2015-04-16 19:48:24 +00:00
|
|
|
if (affs_test_opt(sbi->s_flags, SF_OFS))
|
2005-04-16 22:20:36 +00:00
|
|
|
sbi->s_data_blksize -= 24;
|
|
|
|
|
|
|
|
tmp_flags = sb->s_flags;
|
2013-12-10 19:43:54 +00:00
|
|
|
ret = affs_init_bitmap(sb, &tmp_flags);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
sb->s_flags = tmp_flags;
|
|
|
|
|
|
|
|
/* set up enough so that it can read an inode */
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
root_inode = affs_iget(sb, ctx->root_block);
|
2013-12-10 19:43:54 +00:00
|
|
|
if (IS_ERR(root_inode))
|
|
|
|
return PTR_ERR(root_inode);
|
2008-02-07 08:15:29 +00:00
|
|
|
|
2015-04-16 19:48:24 +00:00
|
|
|
if (affs_test_opt(AFFS_SB(sb)->s_flags, SF_INTL))
|
2011-01-12 21:45:19 +00:00
|
|
|
sb->s_d_op = &affs_intl_dentry_operations;
|
|
|
|
else
|
|
|
|
sb->s_d_op = &affs_dentry_operations;
|
|
|
|
|
2012-01-09 03:15:13 +00:00
|
|
|
sb->s_root = d_make_root(root_inode);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!sb->s_root) {
|
2014-06-06 21:37:24 +00:00
|
|
|
pr_err("AFFS: Get root inode failed\n");
|
2013-12-10 19:43:54 +00:00
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-02-27 22:27:49 +00:00
|
|
|
sb->s_export_op = &affs_export_ops;
|
2014-06-06 21:37:25 +00:00
|
|
|
pr_debug("s_flags=%lX\n", sb->s_flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
static int affs_reconfigure(struct fs_context *fc)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2024-09-17 14:53:09 +00:00
|
|
|
struct super_block *sb = fc->root->d_sb;
|
|
|
|
struct affs_context *ctx = fc->fs_private;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
int res = 0;
|
|
|
|
|
2014-03-13 14:14:33 +00:00
|
|
|
sync_filesystem(sb);
|
2024-09-17 14:53:09 +00:00
|
|
|
fc->sb_flags |= SB_NODIRATIME;
|
2010-08-15 20:52:36 +00:00
|
|
|
|
2012-08-20 21:51:24 +00:00
|
|
|
flush_delayed_work(&sbi->sb_work);
|
2008-02-08 12:21:36 +00:00
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
/*
|
|
|
|
* NB: Historically, only mount_flags, mode, uid, gic, prefix,
|
|
|
|
* and volume are accepted during remount.
|
|
|
|
*/
|
|
|
|
sbi->s_flags = ctx->mount_flags;
|
|
|
|
sbi->s_mode = ctx->mode;
|
|
|
|
sbi->s_uid = ctx->uid;
|
|
|
|
sbi->s_gid = ctx->gid;
|
2010-01-24 05:04:07 +00:00
|
|
|
/* protect against readers */
|
|
|
|
spin_lock(&sbi->symlink_lock);
|
2024-09-17 14:53:09 +00:00
|
|
|
if (ctx->prefix) {
|
2010-01-24 05:04:07 +00:00
|
|
|
kfree(sbi->s_prefix);
|
2024-09-17 14:53:09 +00:00
|
|
|
sbi->s_prefix = ctx->prefix;
|
|
|
|
ctx->prefix = NULL;
|
2010-01-24 05:04:07 +00:00
|
|
|
}
|
2024-09-17 14:53:09 +00:00
|
|
|
memcpy(sbi->s_volume, ctx->volume, 32);
|
2010-01-24 05:04:07 +00:00
|
|
|
spin_unlock(&sbi->symlink_lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
if ((bool)(fc->sb_flags & SB_RDONLY) == sb_rdonly(sb))
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
2010-08-15 20:52:36 +00:00
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
if (fc->sb_flags & SB_RDONLY)
|
2005-04-16 22:20:36 +00:00
|
|
|
affs_free_bitmap(sb);
|
2012-06-06 15:56:53 +00:00
|
|
|
else
|
2024-09-17 14:53:09 +00:00
|
|
|
res = affs_init_bitmap(sb, &fc->sb_flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-06-23 09:02:58 +00:00
|
|
|
affs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-06-23 09:02:58 +00:00
|
|
|
struct super_block *sb = dentry->d_sb;
|
2005-04-16 22:20:36 +00:00
|
|
|
int free;
|
2009-04-02 23:59:32 +00:00
|
|
|
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-06-06 21:37:25 +00:00
|
|
|
pr_debug("%s() partsize=%d, reserved=%d\n",
|
|
|
|
__func__, AFFS_SB(sb)->s_partition_size,
|
|
|
|
AFFS_SB(sb)->s_reserved);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
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;
|
2020-09-18 20:45:50 +00:00
|
|
|
buf->f_fsid = u64_to_fsid(id);
|
2015-02-17 21:46:23 +00:00
|
|
|
buf->f_namelen = AFFSNAMEMAX;
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
static int affs_get_tree(struct fs_context *fc)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2024-09-17 14:53:09 +00:00
|
|
|
return get_tree_bdev(fc, affs_fill_super);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:43:54 +00:00
|
|
|
static void affs_kill_sb(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
kill_block_super(sb);
|
|
|
|
if (sbi) {
|
|
|
|
affs_free_bitmap(sb);
|
|
|
|
affs_brelse(sbi->s_root_bh);
|
|
|
|
kfree(sbi->s_prefix);
|
2015-02-17 21:46:17 +00:00
|
|
|
mutex_destroy(&sbi->s_bmlock);
|
2023-09-19 23:36:07 +00:00
|
|
|
kfree_rcu(sbi, rcu);
|
2013-12-10 19:43:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-17 14:53:09 +00:00
|
|
|
static void affs_free_fc(struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct affs_context *ctx = fc->fs_private;
|
|
|
|
|
|
|
|
kfree(ctx->prefix);
|
|
|
|
kfree(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct fs_context_operations affs_context_ops = {
|
|
|
|
.parse_param = affs_parse_param,
|
|
|
|
.get_tree = affs_get_tree,
|
|
|
|
.reconfigure = affs_reconfigure,
|
|
|
|
.free = affs_free_fc,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int affs_init_fs_context(struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct affs_context *ctx;
|
|
|
|
|
|
|
|
ctx = kzalloc(sizeof(struct affs_context), GFP_KERNEL);
|
|
|
|
if (!ctx)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
|
|
|
|
struct super_block *sb = fc->root->d_sb;
|
|
|
|
struct affs_sb_info *sbi = AFFS_SB(sb);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: historically, no options other than volume were
|
|
|
|
* preserved across a remount unless they were explicitly
|
|
|
|
* passed in.
|
|
|
|
*/
|
|
|
|
memcpy(ctx->volume, sbi->s_volume, 32);
|
|
|
|
} else {
|
|
|
|
ctx->uid = current_uid();
|
|
|
|
ctx->gid = current_gid();
|
|
|
|
ctx->reserved = 2;
|
|
|
|
ctx->root_block = -1;
|
|
|
|
ctx->blocksize = -1;
|
|
|
|
ctx->volume[0] = ':';
|
|
|
|
}
|
|
|
|
|
|
|
|
fc->ops = &affs_context_ops;
|
|
|
|
fc->fs_private = ctx;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct file_system_type affs_fs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "affs",
|
2013-12-10 19:43:54 +00:00
|
|
|
.kill_sb = affs_kill_sb,
|
2005-04-16 22:20:36 +00:00
|
|
|
.fs_flags = FS_REQUIRES_DEV,
|
2024-09-17 14:53:09 +00:00
|
|
|
.init_fs_context = affs_init_fs_context,
|
|
|
|
.parameters = affs_param_spec,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
2013-03-03 03:39:14 +00:00
|
|
|
MODULE_ALIAS_FS("affs");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
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)
|