mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 06:12:08 +00:00
b24413180f
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>
333 lines
7.3 KiB
C
333 lines
7.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Super block/filesystem wide operations
|
|
*
|
|
* Copyright (C) 1996 Peter J. Braam <braam@maths.ox.ac.uk> and
|
|
* Michael Callahan <callahan@maths.ox.ac.uk>
|
|
*
|
|
* Rewritten for Linux 2.1. Peter Braam <braam@cs.cmu.edu>
|
|
* Copyright (C) Carnegie Mellon University
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/string.h>
|
|
#include <linux/stat.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/unistd.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/file.h>
|
|
#include <linux/vfs.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/pid_namespace.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/coda.h>
|
|
#include <linux/coda_psdev.h>
|
|
#include "coda_linux.h"
|
|
#include "coda_cache.h"
|
|
|
|
#include "coda_int.h"
|
|
|
|
/* VFS super_block ops */
|
|
static void coda_evict_inode(struct inode *);
|
|
static void coda_put_super(struct super_block *);
|
|
static int coda_statfs(struct dentry *dentry, struct kstatfs *buf);
|
|
|
|
static struct kmem_cache * coda_inode_cachep;
|
|
|
|
static struct inode *coda_alloc_inode(struct super_block *sb)
|
|
{
|
|
struct coda_inode_info *ei;
|
|
ei = kmem_cache_alloc(coda_inode_cachep, GFP_KERNEL);
|
|
if (!ei)
|
|
return NULL;
|
|
memset(&ei->c_fid, 0, sizeof(struct CodaFid));
|
|
ei->c_flags = 0;
|
|
ei->c_uid = GLOBAL_ROOT_UID;
|
|
ei->c_cached_perm = 0;
|
|
spin_lock_init(&ei->c_lock);
|
|
return &ei->vfs_inode;
|
|
}
|
|
|
|
static void coda_i_callback(struct rcu_head *head)
|
|
{
|
|
struct inode *inode = container_of(head, struct inode, i_rcu);
|
|
kmem_cache_free(coda_inode_cachep, ITOC(inode));
|
|
}
|
|
|
|
static void coda_destroy_inode(struct inode *inode)
|
|
{
|
|
call_rcu(&inode->i_rcu, coda_i_callback);
|
|
}
|
|
|
|
static void init_once(void *foo)
|
|
{
|
|
struct coda_inode_info *ei = (struct coda_inode_info *) foo;
|
|
|
|
inode_init_once(&ei->vfs_inode);
|
|
}
|
|
|
|
int __init coda_init_inodecache(void)
|
|
{
|
|
coda_inode_cachep = kmem_cache_create("coda_inode_cache",
|
|
sizeof(struct coda_inode_info), 0,
|
|
SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
|
|
SLAB_ACCOUNT, init_once);
|
|
if (coda_inode_cachep == NULL)
|
|
return -ENOMEM;
|
|
return 0;
|
|
}
|
|
|
|
void coda_destroy_inodecache(void)
|
|
{
|
|
/*
|
|
* Make sure all delayed rcu free inodes are flushed before we
|
|
* destroy cache.
|
|
*/
|
|
rcu_barrier();
|
|
kmem_cache_destroy(coda_inode_cachep);
|
|
}
|
|
|
|
static int coda_remount(struct super_block *sb, int *flags, char *data)
|
|
{
|
|
sync_filesystem(sb);
|
|
*flags |= MS_NOATIME;
|
|
return 0;
|
|
}
|
|
|
|
/* exported operations */
|
|
static const struct super_operations coda_super_operations =
|
|
{
|
|
.alloc_inode = coda_alloc_inode,
|
|
.destroy_inode = coda_destroy_inode,
|
|
.evict_inode = coda_evict_inode,
|
|
.put_super = coda_put_super,
|
|
.statfs = coda_statfs,
|
|
.remount_fs = coda_remount,
|
|
};
|
|
|
|
static int get_device_index(struct coda_mount_data *data)
|
|
{
|
|
struct fd f;
|
|
struct inode *inode;
|
|
int idx;
|
|
|
|
if (data == NULL) {
|
|
pr_warn("%s: Bad mount data\n", __func__);
|
|
return -1;
|
|
}
|
|
|
|
if (data->version != CODA_MOUNT_VERSION) {
|
|
pr_warn("%s: Bad mount version\n", __func__);
|
|
return -1;
|
|
}
|
|
|
|
f = fdget(data->fd);
|
|
if (!f.file)
|
|
goto Ebadf;
|
|
inode = file_inode(f.file);
|
|
if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) {
|
|
fdput(f);
|
|
goto Ebadf;
|
|
}
|
|
|
|
idx = iminor(inode);
|
|
fdput(f);
|
|
|
|
if (idx < 0 || idx >= MAX_CODADEVS) {
|
|
pr_warn("%s: Bad minor number\n", __func__);
|
|
return -1;
|
|
}
|
|
|
|
return idx;
|
|
Ebadf:
|
|
pr_warn("%s: Bad file\n", __func__);
|
|
return -1;
|
|
}
|
|
|
|
static int coda_fill_super(struct super_block *sb, void *data, int silent)
|
|
{
|
|
struct inode *root = NULL;
|
|
struct venus_comm *vc;
|
|
struct CodaFid fid;
|
|
int error;
|
|
int idx;
|
|
|
|
if (task_active_pid_ns(current) != &init_pid_ns)
|
|
return -EINVAL;
|
|
|
|
idx = get_device_index((struct coda_mount_data *) data);
|
|
|
|
/* Ignore errors in data, for backward compatibility */
|
|
if(idx == -1)
|
|
idx = 0;
|
|
|
|
pr_info("%s: device index: %i\n", __func__, idx);
|
|
|
|
vc = &coda_comms[idx];
|
|
mutex_lock(&vc->vc_mutex);
|
|
|
|
if (!vc->vc_inuse) {
|
|
pr_warn("%s: No pseudo device\n", __func__);
|
|
error = -EINVAL;
|
|
goto unlock_out;
|
|
}
|
|
|
|
if (vc->vc_sb) {
|
|
pr_warn("%s: Device already mounted\n", __func__);
|
|
error = -EBUSY;
|
|
goto unlock_out;
|
|
}
|
|
|
|
vc->vc_sb = sb;
|
|
mutex_unlock(&vc->vc_mutex);
|
|
|
|
sb->s_fs_info = vc;
|
|
sb->s_flags |= MS_NOATIME;
|
|
sb->s_blocksize = 4096; /* XXXXX what do we put here?? */
|
|
sb->s_blocksize_bits = 12;
|
|
sb->s_magic = CODA_SUPER_MAGIC;
|
|
sb->s_op = &coda_super_operations;
|
|
sb->s_d_op = &coda_dentry_operations;
|
|
|
|
error = super_setup_bdi(sb);
|
|
if (error)
|
|
goto error;
|
|
|
|
/* get root fid from Venus: this needs the root inode */
|
|
error = venus_rootfid(sb, &fid);
|
|
if ( error ) {
|
|
pr_warn("%s: coda_get_rootfid failed with %d\n",
|
|
__func__, error);
|
|
goto error;
|
|
}
|
|
pr_info("%s: rootfid is %s\n", __func__, coda_f2s(&fid));
|
|
|
|
/* make root inode */
|
|
root = coda_cnode_make(&fid, sb);
|
|
if (IS_ERR(root)) {
|
|
error = PTR_ERR(root);
|
|
pr_warn("Failure of coda_cnode_make for root: error %d\n",
|
|
error);
|
|
goto error;
|
|
}
|
|
|
|
pr_info("%s: rootinode is %ld dev %s\n",
|
|
__func__, root->i_ino, root->i_sb->s_id);
|
|
sb->s_root = d_make_root(root);
|
|
if (!sb->s_root) {
|
|
error = -EINVAL;
|
|
goto error;
|
|
}
|
|
return 0;
|
|
|
|
error:
|
|
mutex_lock(&vc->vc_mutex);
|
|
vc->vc_sb = NULL;
|
|
sb->s_fs_info = NULL;
|
|
unlock_out:
|
|
mutex_unlock(&vc->vc_mutex);
|
|
return error;
|
|
}
|
|
|
|
static void coda_put_super(struct super_block *sb)
|
|
{
|
|
struct venus_comm *vcp = coda_vcp(sb);
|
|
mutex_lock(&vcp->vc_mutex);
|
|
vcp->vc_sb = NULL;
|
|
sb->s_fs_info = NULL;
|
|
mutex_unlock(&vcp->vc_mutex);
|
|
|
|
pr_info("Bye bye.\n");
|
|
}
|
|
|
|
static void coda_evict_inode(struct inode *inode)
|
|
{
|
|
truncate_inode_pages_final(&inode->i_data);
|
|
clear_inode(inode);
|
|
coda_cache_clear_inode(inode);
|
|
}
|
|
|
|
int coda_getattr(const struct path *path, struct kstat *stat,
|
|
u32 request_mask, unsigned int flags)
|
|
{
|
|
int err = coda_revalidate_inode(d_inode(path->dentry));
|
|
if (!err)
|
|
generic_fillattr(d_inode(path->dentry), stat);
|
|
return err;
|
|
}
|
|
|
|
int coda_setattr(struct dentry *de, struct iattr *iattr)
|
|
{
|
|
struct inode *inode = d_inode(de);
|
|
struct coda_vattr vattr;
|
|
int error;
|
|
|
|
memset(&vattr, 0, sizeof(vattr));
|
|
|
|
inode->i_ctime = current_time(inode);
|
|
coda_iattr_to_vattr(iattr, &vattr);
|
|
vattr.va_type = C_VNON; /* cannot set type */
|
|
|
|
/* Venus is responsible for truncating the container-file!!! */
|
|
error = venus_setattr(inode->i_sb, coda_i2f(inode), &vattr);
|
|
|
|
if (!error) {
|
|
coda_vattr_to_iattr(inode, &vattr);
|
|
coda_cache_clear_inode(inode);
|
|
}
|
|
return error;
|
|
}
|
|
|
|
const struct inode_operations coda_file_inode_operations = {
|
|
.permission = coda_permission,
|
|
.getattr = coda_getattr,
|
|
.setattr = coda_setattr,
|
|
};
|
|
|
|
static int coda_statfs(struct dentry *dentry, struct kstatfs *buf)
|
|
{
|
|
int error;
|
|
|
|
error = venus_statfs(dentry, buf);
|
|
|
|
if (error) {
|
|
/* fake something like AFS does */
|
|
buf->f_blocks = 9000000;
|
|
buf->f_bfree = 9000000;
|
|
buf->f_bavail = 9000000;
|
|
buf->f_files = 9000000;
|
|
buf->f_ffree = 9000000;
|
|
}
|
|
|
|
/* and fill in the rest */
|
|
buf->f_type = CODA_SUPER_MAGIC;
|
|
buf->f_bsize = 4096;
|
|
buf->f_namelen = CODA_MAXNAMLEN;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* init_coda: used by filesystems.c to register coda */
|
|
|
|
static struct dentry *coda_mount(struct file_system_type *fs_type,
|
|
int flags, const char *dev_name, void *data)
|
|
{
|
|
return mount_nodev(fs_type, flags, data, coda_fill_super);
|
|
}
|
|
|
|
struct file_system_type coda_fs_type = {
|
|
.owner = THIS_MODULE,
|
|
.name = "coda",
|
|
.mount = coda_mount,
|
|
.kill_sb = kill_anon_super,
|
|
.fs_flags = FS_BINARY_MOUNTDATA,
|
|
};
|
|
MODULE_ALIAS_FS("coda");
|
|
|