License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 02:20:36 +04: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>
|
2007-07-17 15:04:28 +04:00
|
|
|
#include <linux/exportfs.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/buffer_head.h>
|
|
|
|
#include <linux/vfs.h>
|
2020-06-20 10:16:44 +03:00
|
|
|
#include <linux/blkdev.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-02-24 02:23:51 +03:00
|
|
|
#include "efs.h"
|
|
|
|
#include <linux/efs_vh.h>
|
|
|
|
#include <linux/efs_fs_sb.h>
|
|
|
|
|
2006-06-23 13:02:58 +04:00
|
|
|
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf);
|
2005-04-17 02:20:36 +04:00
|
|
|
static int efs_fill_super(struct super_block *s, void *d, int silent);
|
|
|
|
|
2010-07-25 00:46:55 +04:00
|
|
|
static struct dentry *efs_mount(struct file_system_type *fs_type,
|
|
|
|
int flags, const char *dev_name, void *data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2010-07-25 00:46:55 +04:00
|
|
|
return mount_bdev(fs_type, flags, dev_name, data, efs_fill_super);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2013-12-11 02:05:05 +04:00
|
|
|
static void efs_kill_sb(struct super_block *s)
|
|
|
|
{
|
|
|
|
struct efs_sb_info *sbi = SUPER_INFO(s);
|
|
|
|
kill_block_super(s);
|
|
|
|
kfree(sbi);
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static struct file_system_type efs_fs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "efs",
|
2010-07-25 00:46:55 +04:00
|
|
|
.mount = efs_mount,
|
2013-12-11 02:05:05 +04:00
|
|
|
.kill_sb = efs_kill_sb,
|
2005-04-17 02:20:36 +04:00
|
|
|
.fs_flags = FS_REQUIRES_DEV,
|
|
|
|
};
|
2013-03-03 07:39:14 +04:00
|
|
|
MODULE_ALIAS_FS("efs");
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
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 07:33:20 +03:00
|
|
|
static struct kmem_cache * efs_inode_cachep;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
static struct inode *efs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct efs_inode_info *ei;
|
2022-03-23 00:41:03 +03:00
|
|
|
ei = alloc_inode_sb(sb, efs_inode_cachep, GFP_KERNEL);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!ei)
|
|
|
|
return NULL;
|
|
|
|
return &ei->vfs_inode;
|
|
|
|
}
|
|
|
|
|
2019-04-15 06:29:41 +03:00
|
|
|
static void efs_free_inode(struct inode *inode)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
|
|
|
|
}
|
|
|
|
|
2008-07-26 06:45:34 +04:00
|
|
|
static void init_once(void *foo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct efs_inode_info *ei = (struct efs_inode_info *) foo;
|
|
|
|
|
2007-05-17 09:10:57 +04:00
|
|
|
inode_init_once(&ei->vfs_inode);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2007-07-20 05:11:58 +04:00
|
|
|
|
2014-04-04 01:49:33 +04:00
|
|
|
static int __init init_inodecache(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
efs_inode_cachep = kmem_cache_create("efs_inode_cache",
|
2016-01-15 02:18:21 +03:00
|
|
|
sizeof(struct efs_inode_info), 0,
|
|
|
|
SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
|
|
|
|
SLAB_ACCOUNT, init_once);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (efs_inode_cachep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_inodecache(void)
|
|
|
|
{
|
2012-09-26 05:33:07 +04:00
|
|
|
/*
|
|
|
|
* Make sure all delayed rcu free inodes are flushed before we
|
|
|
|
* destroy cache.
|
|
|
|
*/
|
|
|
|
rcu_barrier();
|
2006-09-27 12:49:40 +04:00
|
|
|
kmem_cache_destroy(efs_inode_cachep);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int efs_remount(struct super_block *sb, int *flags, char *data)
|
|
|
|
{
|
2014-03-13 18:14:33 +04:00
|
|
|
sync_filesystem(sb);
|
2017-11-28 00:05:09 +03:00
|
|
|
*flags |= SB_RDONLY;
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-12 11:55:41 +03:00
|
|
|
static const struct super_operations efs_superblock_operations = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.alloc_inode = efs_alloc_inode,
|
2019-04-15 06:29:41 +03:00
|
|
|
.free_inode = efs_free_inode,
|
2005-04-17 02:20:36 +04:00
|
|
|
.statfs = efs_statfs,
|
|
|
|
.remount_fs = efs_remount,
|
|
|
|
};
|
|
|
|
|
2007-10-22 03:42:17 +04:00
|
|
|
static const struct export_operations efs_export_ops = {
|
2007-10-22 03:42:09 +04:00
|
|
|
.fh_to_dentry = efs_fh_to_dentry,
|
|
|
|
.fh_to_parent = efs_fh_to_parent,
|
2005-04-17 02:20:36 +04:00
|
|
|
.get_parent = efs_get_parent,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_efs_fs(void) {
|
|
|
|
int err;
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_info(EFS_VERSION" - http://aeschi.ch.eu.org/efs/\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
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) {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_warn("SGI disklabel: checksum bad, label corrupted\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-06-05 03:12:13 +04:00
|
|
|
pr_debug("bf: \"%16s\"\n", vh->vh_bootfile);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
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]) {
|
2014-06-05 03:12:13 +04:00
|
|
|
pr_debug("vh: %8s block: 0x%08x size: 0x%08x\n",
|
|
|
|
name, (int) be32_to_cpu(vh->vh_vd[i].vd_lbn),
|
2005-04-17 02:20:36 +04:00
|
|
|
(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)) {
|
2014-06-05 03:12:13 +04:00
|
|
|
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");
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (IS_EFS(pt_type)) {
|
|
|
|
sblock = be32_to_cpu(vh->vh_pt[i].pt_firstlbn);
|
|
|
|
slice = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slice == -1) {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_notice("partition table contained no EFS partitions\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
} else {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_info("using slice %d (type %s, offset 0x%x)\n", slice,
|
2005-04-17 02:20:36 +04:00
|
|
|
(pt_entry->pt_name) ? pt_entry->pt_name : "unknown",
|
|
|
|
sblock);
|
|
|
|
#endif
|
|
|
|
}
|
2006-01-15 04:37:08 +03:00
|
|
|
return sblock;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int efs_validate_super(struct efs_sb_info *sb, struct efs_super *super) {
|
|
|
|
|
2006-01-15 04:37:08 +03:00
|
|
|
if (!IS_EFS_MAGIC(be32_to_cpu(super->fs_magic)))
|
|
|
|
return -1;
|
2005-04-17 02:20:36 +04: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;
|
|
|
|
|
2006-09-27 12:49:37 +04:00
|
|
|
sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!sb)
|
|
|
|
return -ENOMEM;
|
|
|
|
s->s_fs_info = sb;
|
2019-07-30 18:22:29 +03:00
|
|
|
s->s_time_min = 0;
|
|
|
|
s->s_time_max = U32_MAX;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
s->s_magic = EFS_SUPER_MAGIC;
|
|
|
|
if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_err("device does not support %d byte blocks\n",
|
2005-04-17 02:20:36 +04:00
|
|
|
EFS_BLOCKSIZE);
|
2013-12-11 02:05:05 +04:00
|
|
|
return -EINVAL;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* read the vh (volume header) block */
|
|
|
|
bh = sb_bread(s, 0);
|
|
|
|
|
|
|
|
if (!bh) {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_err("cannot read volume header\n");
|
2016-05-21 03:04:25 +03:00
|
|
|
return -EIO;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) {
|
2013-12-11 02:05:05 +04:00
|
|
|
return -EINVAL;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bh = sb_bread(s, sb->fs_start + EFS_SUPER);
|
|
|
|
if (!bh) {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_err("cannot read superblock\n");
|
2016-05-21 03:04:25 +03:00
|
|
|
return -EIO;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (efs_validate_super(sb, (struct efs_super *) bh->b_data)) {
|
|
|
|
#ifdef DEBUG
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_warn("invalid superblock at block %u\n",
|
|
|
|
sb->fs_start + EFS_SUPER);
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
brelse(bh);
|
2013-12-11 02:05:05 +04:00
|
|
|
return -EINVAL;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
brelse(bh);
|
|
|
|
|
2017-07-17 10:45:34 +03:00
|
|
|
if (!sb_rdonly(s)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef DEBUG
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_info("forcing read-only mode\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
2017-11-28 00:05:09 +03:00
|
|
|
s->s_flags |= SB_RDONLY;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
s->s_op = &efs_superblock_operations;
|
|
|
|
s->s_export_op = &efs_export_ops;
|
2008-02-07 11:15:34 +03:00
|
|
|
root = efs_iget(s, EFS_ROOTINODE);
|
|
|
|
if (IS_ERR(root)) {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_err("get root inode failed\n");
|
2013-12-11 02:05:05 +04:00
|
|
|
return PTR_ERR(root);
|
2008-02-07 11:15:34 +03:00
|
|
|
}
|
|
|
|
|
2012-01-09 07:15:13 +04:00
|
|
|
s->s_root = d_make_root(root);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!(s->s_root)) {
|
2014-06-05 03:12:12 +04:00
|
|
|
pr_err("get root dentry failed\n");
|
2013-12-11 02:05:05 +04:00
|
|
|
return -ENOMEM;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-06-23 13:02:58 +04:00
|
|
|
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) {
|
2009-04-03 03:59:34 +04:00
|
|
|
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);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
buf->f_type = EFS_SUPER_MAGIC; /* efs magic number */
|
|
|
|
buf->f_bsize = EFS_BLOCKSIZE; /* blocksize */
|
2009-04-03 03:59:34 +04:00
|
|
|
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 *
|
2005-04-17 02:20:36 +04:00
|
|
|
(EFS_BLOCKSIZE / sizeof(struct efs_dinode));
|
2009-04-03 03:59:34 +04:00
|
|
|
buf->f_ffree = sbi->inode_free; /* free inodes */
|
2020-09-18 23:45:50 +03:00
|
|
|
buf->f_fsid = u64_to_fsid(id);
|
2005-04-17 02:20:36 +04:00
|
|
|
buf->f_namelen = EFS_MAXNAMELEN; /* max filename length */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|