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 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/fs/hpfs/file.c
|
|
|
|
*
|
|
|
|
* Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
|
|
|
|
*
|
|
|
|
* file VFS functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hpfs_fn.h"
|
2013-07-05 00:44:27 +08:00
|
|
|
#include <linux/mpage.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define BLOCKS(size) (((size) + 511) >> 9)
|
|
|
|
|
|
|
|
static int hpfs_file_release(struct inode *inode, struct file *file)
|
|
|
|
{
|
2011-01-23 03:26:12 +08:00
|
|
|
hpfs_lock(inode->i_sb);
|
2005-04-17 06:20:36 +08:00
|
|
|
hpfs_write_if_changed(inode);
|
2011-01-23 03:26:12 +08:00
|
|
|
hpfs_unlock(inode->i_sb);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-17 08:44:56 +08:00
|
|
|
int hpfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2011-05-09 02:44:19 +08:00
|
|
|
struct inode *inode = file->f_mapping->host;
|
2011-07-17 08:44:56 +08:00
|
|
|
int ret;
|
|
|
|
|
2017-07-08 03:20:52 +08:00
|
|
|
ret = file_write_and_wait_range(file, start, end);
|
2011-07-17 08:44:56 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2011-05-09 02:44:19 +08:00
|
|
|
return sync_blockdev(inode->i_sb->s_bdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* generic_file_read often calls bmap with non-existing sector,
|
|
|
|
* so we must ignore such errors.
|
|
|
|
*/
|
|
|
|
|
2013-07-05 00:44:27 +08:00
|
|
|
static secno hpfs_bmap(struct inode *inode, unsigned file_secno, unsigned *n_secs)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
|
|
|
|
unsigned n, disk_secno;
|
|
|
|
struct fnode *fnode;
|
|
|
|
struct buffer_head *bh;
|
|
|
|
if (BLOCKS(hpfs_i(inode)->mmu_private) <= file_secno) return 0;
|
|
|
|
n = file_secno - hpfs_inode->i_file_sec;
|
2013-07-05 00:44:27 +08:00
|
|
|
if (n < hpfs_inode->i_n_secs) {
|
|
|
|
*n_secs = hpfs_inode->i_n_secs - n;
|
|
|
|
return hpfs_inode->i_disk_sec + n;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0;
|
|
|
|
disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh);
|
|
|
|
if (disk_secno == -1) return 0;
|
|
|
|
if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0;
|
2013-07-05 00:44:27 +08:00
|
|
|
n = file_secno - hpfs_inode->i_file_sec;
|
|
|
|
if (n < hpfs_inode->i_n_secs) {
|
|
|
|
*n_secs = hpfs_inode->i_n_secs - n;
|
|
|
|
return hpfs_inode->i_disk_sec + n;
|
|
|
|
}
|
|
|
|
*n_secs = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
return disk_secno;
|
|
|
|
}
|
|
|
|
|
2012-12-15 18:53:50 +08:00
|
|
|
void hpfs_truncate(struct inode *i)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
if (IS_IMMUTABLE(i)) return /*-EPERM*/;
|
2011-05-09 02:42:54 +08:00
|
|
|
hpfs_lock_assert(i->i_sb);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
hpfs_i(i)->i_n_secs = 0;
|
|
|
|
i->i_blocks = 1 + ((i->i_size + 511) >> 9);
|
|
|
|
hpfs_i(i)->mmu_private = i->i_size;
|
|
|
|
hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9));
|
|
|
|
hpfs_write_inode(i);
|
|
|
|
hpfs_i(i)->i_n_secs = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
|
|
|
|
{
|
2011-05-09 02:42:54 +08:00
|
|
|
int r;
|
2005-04-17 06:20:36 +08:00
|
|
|
secno s;
|
2013-07-05 00:44:27 +08:00
|
|
|
unsigned n_secs;
|
2011-05-09 02:42:54 +08:00
|
|
|
hpfs_lock(inode->i_sb);
|
2013-07-05 00:44:27 +08:00
|
|
|
s = hpfs_bmap(inode, iblock, &n_secs);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (s) {
|
2013-07-05 00:44:27 +08:00
|
|
|
if (bh_result->b_size >> 9 < n_secs)
|
|
|
|
n_secs = bh_result->b_size >> 9;
|
2015-09-03 04:50:12 +08:00
|
|
|
n_secs = hpfs_search_hotfix_map_for_range(inode->i_sb, s, n_secs);
|
|
|
|
if (unlikely(!n_secs)) {
|
|
|
|
s = hpfs_search_hotfix_map(inode->i_sb, s);
|
|
|
|
n_secs = 1;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
map_bh(bh_result, inode->i_sb, s);
|
2013-07-05 00:44:27 +08:00
|
|
|
bh_result->b_size = n_secs << 9;
|
2011-05-09 02:42:54 +08:00
|
|
|
goto ret_0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2011-05-09 02:42:54 +08:00
|
|
|
if (!create) goto ret_0;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (iblock<<9 != hpfs_i(inode)->mmu_private) {
|
|
|
|
BUG();
|
2011-05-09 02:42:54 +08:00
|
|
|
r = -EIO;
|
|
|
|
goto ret_r;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if ((s = hpfs_add_sector_to_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1)) == -1) {
|
|
|
|
hpfs_truncate_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1);
|
2011-05-09 02:42:54 +08:00
|
|
|
r = -ENOSPC;
|
|
|
|
goto ret_r;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
inode->i_blocks++;
|
|
|
|
hpfs_i(inode)->mmu_private += 512;
|
|
|
|
set_buffer_new(bh_result);
|
2015-09-03 04:50:12 +08:00
|
|
|
map_bh(bh_result, inode->i_sb, hpfs_search_hotfix_map(inode->i_sb, s));
|
2011-05-09 02:42:54 +08:00
|
|
|
ret_0:
|
|
|
|
r = 0;
|
|
|
|
ret_r:
|
|
|
|
hpfs_unlock(inode->i_sb);
|
|
|
|
return r;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-07-05 00:44:27 +08:00
|
|
|
static int hpfs_readpage(struct file *file, struct page *page)
|
|
|
|
{
|
|
|
|
return mpage_readpage(page, hpfs_get_block);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static int hpfs_writepage(struct page *page, struct writeback_control *wbc)
|
|
|
|
{
|
2013-07-05 00:44:27 +08:00
|
|
|
return block_write_full_page(page, hpfs_get_block, wbc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-16 16:25:10 +08:00
|
|
|
|
2013-07-05 00:44:27 +08:00
|
|
|
static int hpfs_readpages(struct file *file, struct address_space *mapping,
|
|
|
|
struct list_head *pages, unsigned nr_pages)
|
|
|
|
{
|
|
|
|
return mpage_readpages(mapping, pages, nr_pages, hpfs_get_block);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hpfs_writepages(struct address_space *mapping,
|
|
|
|
struct writeback_control *wbc)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-07-05 00:44:27 +08:00
|
|
|
return mpage_writepages(mapping, wbc, hpfs_get_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-16 16:25:10 +08:00
|
|
|
|
2012-12-15 18:53:50 +08:00
|
|
|
static void hpfs_write_failed(struct address_space *mapping, loff_t to)
|
|
|
|
{
|
|
|
|
struct inode *inode = mapping->host;
|
|
|
|
|
2013-06-09 07:25:57 +08:00
|
|
|
hpfs_lock(inode->i_sb);
|
|
|
|
|
2012-12-15 18:53:50 +08:00
|
|
|
if (to > inode->i_size) {
|
2013-09-13 06:13:56 +08:00
|
|
|
truncate_pagecache(inode, inode->i_size);
|
2012-12-15 18:53:50 +08:00
|
|
|
hpfs_truncate(inode);
|
|
|
|
}
|
2013-06-09 07:25:57 +08:00
|
|
|
|
|
|
|
hpfs_unlock(inode->i_sb);
|
2012-12-15 18:53:50 +08:00
|
|
|
}
|
|
|
|
|
2007-10-16 16:25:10 +08:00
|
|
|
static int hpfs_write_begin(struct file *file, struct address_space *mapping,
|
|
|
|
loff_t pos, unsigned len, unsigned flags,
|
|
|
|
struct page **pagep, void **fsdata)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-06-04 17:29:55 +08:00
|
|
|
int ret;
|
|
|
|
|
2007-10-16 16:25:10 +08:00
|
|
|
*pagep = NULL;
|
2010-06-04 17:29:55 +08:00
|
|
|
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
|
2007-10-16 16:25:10 +08:00
|
|
|
hpfs_get_block,
|
|
|
|
&hpfs_i(mapping->host)->mmu_private);
|
2012-12-15 18:53:50 +08:00
|
|
|
if (unlikely(ret))
|
|
|
|
hpfs_write_failed(mapping, pos + len);
|
2010-06-04 17:29:55 +08:00
|
|
|
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-16 16:25:10 +08:00
|
|
|
|
2013-03-20 08:35:00 +08:00
|
|
|
static int hpfs_write_end(struct file *file, struct address_space *mapping,
|
|
|
|
loff_t pos, unsigned len, unsigned copied,
|
|
|
|
struct page *pagep, void *fsdata)
|
|
|
|
{
|
|
|
|
struct inode *inode = mapping->host;
|
|
|
|
int err;
|
|
|
|
err = generic_write_end(file, mapping, pos, len, copied, pagep, fsdata);
|
|
|
|
if (err < len)
|
|
|
|
hpfs_write_failed(mapping, pos + len);
|
|
|
|
if (!(err < 0)) {
|
|
|
|
/* make sure we write it on close, if not earlier */
|
|
|
|
hpfs_lock(inode->i_sb);
|
|
|
|
hpfs_i(inode)->i_dirty = 1;
|
|
|
|
hpfs_unlock(inode->i_sb);
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block)
|
|
|
|
{
|
2015-09-03 04:50:12 +08:00
|
|
|
return generic_block_bmap(mapping, block, hpfs_get_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-16 16:25:10 +08:00
|
|
|
|
2016-10-04 05:00:19 +08:00
|
|
|
static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len)
|
|
|
|
{
|
|
|
|
return generic_block_fiemap(inode, fieinfo, start, len, hpfs_get_block);
|
|
|
|
}
|
|
|
|
|
2006-06-28 19:26:44 +08:00
|
|
|
const struct address_space_operations hpfs_aops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.readpage = hpfs_readpage,
|
|
|
|
.writepage = hpfs_writepage,
|
2013-07-05 00:44:27 +08:00
|
|
|
.readpages = hpfs_readpages,
|
|
|
|
.writepages = hpfs_writepages,
|
2007-10-16 16:25:10 +08:00
|
|
|
.write_begin = hpfs_write_begin,
|
2013-03-20 08:35:00 +08:00
|
|
|
.write_end = hpfs_write_end,
|
2005-04-17 06:20:36 +08:00
|
|
|
.bmap = _hpfs_bmap
|
|
|
|
};
|
|
|
|
|
2006-03-28 17:56:42 +08:00
|
|
|
const struct file_operations hpfs_file_ops =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.llseek = generic_file_llseek,
|
2014-04-03 02:33:16 +08:00
|
|
|
.read_iter = generic_file_read_iter,
|
2014-04-03 15:17:43 +08:00
|
|
|
.write_iter = generic_file_write_iter,
|
2005-04-17 06:20:36 +08:00
|
|
|
.mmap = generic_file_mmap,
|
|
|
|
.release = hpfs_file_release,
|
|
|
|
.fsync = hpfs_file_fsync,
|
2007-06-01 17:49:19 +08:00
|
|
|
.splice_read = generic_file_splice_read,
|
2015-06-28 21:16:57 +08:00
|
|
|
.unlocked_ioctl = hpfs_ioctl,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2007-02-12 16:55:39 +08:00
|
|
|
const struct inode_operations hpfs_file_iops =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-08-11 06:27:59 +08:00
|
|
|
.setattr = hpfs_setattr,
|
2016-10-04 05:00:19 +08:00
|
|
|
.fiemap = hpfs_fiemap,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|