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
|
|
|
/*
|
|
|
|
* Wrapper functions for accessing the file_struct fd array.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_FILE_H
|
|
|
|
#define __LINUX_FILE_H
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
[PATCH] Shrinks sizeof(files_struct) and better layout
1) Reduce the size of (struct fdtable) to exactly 64 bytes on 32bits
platforms, lowering kmalloc() allocated space by 50%.
2) Reduce the size of (files_struct), using a special 32 bits (or
64bits) embedded_fd_set, instead of a 1024 bits fd_set for the
close_on_exec_init and open_fds_init fields. This save some ram (248
bytes per task) as most tasks dont open more than 32 files. D-Cache
footprint for such tasks is also reduced to the minimum.
3) Reduce size of allocated fdset. Currently two full pages are
allocated, that is 32768 bits on x86 for example, and way too much. The
minimum is now L1_CACHE_BYTES.
UP and SMP should benefit from this patch, because most tasks will touch
only one cache line when open()/close() stdin/stdout/stderr (0/1/2),
(next_fd, close_on_exec_init, open_fds_init, fd_array[0 .. 2] being in the
same cache line)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-23 19:00:12 +08:00
|
|
|
#include <linux/types.h>
|
2008-04-24 19:44:08 +08:00
|
|
|
#include <linux/posix_types.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-24 19:44:08 +08:00
|
|
|
struct file;
|
2006-12-07 12:32:52 +08:00
|
|
|
|
2008-02-14 07:03:15 +08:00
|
|
|
extern void fput(struct file *);
|
2018-11-22 01:32:39 +08:00
|
|
|
extern void fput_many(struct file *, unsigned int);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:31:13 +08:00
|
|
|
struct file_operations;
|
2020-01-08 01:59:24 +08:00
|
|
|
struct task_struct;
|
2007-10-17 14:31:13 +08:00
|
|
|
struct vfsmount;
|
|
|
|
struct dentry;
|
2018-06-09 21:40:05 +08:00
|
|
|
struct inode;
|
2009-08-09 04:52:35 +08:00
|
|
|
struct path;
|
2018-06-09 21:40:05 +08:00
|
|
|
extern struct file *alloc_file_pseudo(struct inode *, struct vfsmount *,
|
|
|
|
const char *, int flags, const struct file_operations *);
|
2018-06-18 02:15:10 +08:00
|
|
|
extern struct file *alloc_file_clone(struct file *, int flags,
|
|
|
|
const struct file_operations *);
|
2007-10-17 14:31:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline void fput_light(struct file *file, int fput_needed)
|
|
|
|
{
|
2010-12-14 08:38:08 +08:00
|
|
|
if (fput_needed)
|
2005-04-17 06:20:36 +08:00
|
|
|
fput(file);
|
|
|
|
}
|
|
|
|
|
2012-08-28 07:55:01 +08:00
|
|
|
struct fd {
|
|
|
|
struct file *file;
|
2014-03-04 01:36:58 +08:00
|
|
|
unsigned int flags;
|
2012-08-28 07:55:01 +08:00
|
|
|
};
|
2014-03-04 01:36:58 +08:00
|
|
|
#define FDPUT_FPUT 1
|
|
|
|
#define FDPUT_POS_UNLOCK 2
|
2012-08-28 07:55:01 +08:00
|
|
|
|
|
|
|
static inline void fdput(struct fd fd)
|
|
|
|
{
|
2014-03-04 01:36:58 +08:00
|
|
|
if (fd.flags & FDPUT_FPUT)
|
2012-08-28 07:55:01 +08:00
|
|
|
fput(fd.file);
|
|
|
|
}
|
|
|
|
|
2008-02-14 07:03:15 +08:00
|
|
|
extern struct file *fget(unsigned int fd);
|
2018-11-22 01:32:39 +08:00
|
|
|
extern struct file *fget_many(unsigned int fd, unsigned int refs);
|
2014-03-05 03:54:22 +08:00
|
|
|
extern struct file *fget_raw(unsigned int fd);
|
2020-01-08 01:59:24 +08:00
|
|
|
extern struct file *fget_task(struct task_struct *task, unsigned int fd);
|
2014-03-05 03:54:22 +08:00
|
|
|
extern unsigned long __fdget(unsigned int fd);
|
|
|
|
extern unsigned long __fdget_raw(unsigned int fd);
|
|
|
|
extern unsigned long __fdget_pos(unsigned int fd);
|
2016-04-21 05:08:21 +08:00
|
|
|
extern void __f_unlock_pos(struct file *);
|
2012-08-28 07:55:01 +08:00
|
|
|
|
2014-03-05 03:54:22 +08:00
|
|
|
static inline struct fd __to_fd(unsigned long v)
|
2012-08-28 07:55:01 +08:00
|
|
|
{
|
2014-03-05 03:54:22 +08:00
|
|
|
return (struct fd){(struct file *)(v & ~3),v & 3};
|
2012-08-28 07:55:01 +08:00
|
|
|
}
|
|
|
|
|
2014-03-05 03:54:22 +08:00
|
|
|
static inline struct fd fdget(unsigned int fd)
|
|
|
|
{
|
|
|
|
return __to_fd(__fdget(fd));
|
|
|
|
}
|
2012-08-29 00:52:22 +08:00
|
|
|
|
2012-08-28 07:55:01 +08:00
|
|
|
static inline struct fd fdget_raw(unsigned int fd)
|
|
|
|
{
|
2014-03-05 03:54:22 +08:00
|
|
|
return __to_fd(__fdget_raw(fd));
|
2012-08-28 07:55:01 +08:00
|
|
|
}
|
|
|
|
|
2016-04-21 05:08:21 +08:00
|
|
|
static inline struct fd fdget_pos(int fd)
|
|
|
|
{
|
|
|
|
return __to_fd(__fdget_pos(fd));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void fdput_pos(struct fd f)
|
|
|
|
{
|
|
|
|
if (f.flags & FDPUT_POS_UNLOCK)
|
|
|
|
__f_unlock_pos(f.file);
|
|
|
|
fdput(f);
|
|
|
|
}
|
|
|
|
|
2012-08-21 23:48:11 +08:00
|
|
|
extern int f_dupfd(unsigned int from, struct file *file, unsigned flags);
|
2012-08-22 00:11:46 +08:00
|
|
|
extern int replace_fd(unsigned fd, struct file *file, unsigned flags);
|
2008-02-14 07:03:15 +08:00
|
|
|
extern void set_close_on_exec(unsigned int fd, int flag);
|
2012-08-21 23:48:11 +08:00
|
|
|
extern bool get_close_on_exec(unsigned int fd);
|
2012-08-13 05:18:05 +08:00
|
|
|
extern int get_unused_fd_flags(unsigned flags);
|
2008-02-14 07:03:15 +08:00
|
|
|
extern void put_unused_fd(unsigned int fd);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-14 07:03:15 +08:00
|
|
|
extern void fd_install(unsigned int fd, struct file *file);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-06-24 13:56:45 +08:00
|
|
|
extern void flush_delayed_fput(void);
|
|
|
|
extern void __fput_sync(struct file *);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* __LINUX_FILE_H */
|