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
|
|
|
/*
|
|
|
|
* fs/partitions/amiga.c
|
|
|
|
*
|
|
|
|
* Code extracted from drivers/block/genhd.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1991-1998 Linus Torvalds
|
|
|
|
* Re-organised Feb 1998 Russell King
|
|
|
|
*/
|
|
|
|
|
2014-06-13 02:04:52 +08:00
|
|
|
#define pr_fmt(fmt) fmt
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/types.h>
|
2023-06-21 04:17:25 +08:00
|
|
|
#include <linux/mm_types.h>
|
|
|
|
#include <linux/overflow.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/affs_hardblocks.h>
|
|
|
|
|
|
|
|
#include "check.h"
|
|
|
|
|
2023-06-21 04:17:25 +08:00
|
|
|
/* magic offsets in partition DosEnvVec */
|
|
|
|
#define NR_HD 3
|
|
|
|
#define NR_SECT 5
|
|
|
|
#define LO_CYL 9
|
|
|
|
#define HI_CYL 10
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static __inline__ u32
|
|
|
|
checksum_block(__be32 *m, int size)
|
|
|
|
{
|
|
|
|
u32 sum = 0;
|
|
|
|
|
|
|
|
while (size--)
|
|
|
|
sum += be32_to_cpu(*m++);
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
2010-05-16 02:09:30 +08:00
|
|
|
int amiga_partition(struct parsed_partitions *state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
Sector sect;
|
|
|
|
unsigned char *data;
|
|
|
|
struct RigidDiskBlock *rdb;
|
|
|
|
struct PartitionBlock *pb;
|
2023-06-21 04:17:25 +08:00
|
|
|
u64 start_sect, nr_sects;
|
|
|
|
sector_t blk, end_sect;
|
|
|
|
u32 cylblk; /* rdb_CylBlocks = nr_heads*sect_per_track */
|
|
|
|
u32 nr_hd, nr_sect, lo_cyl, hi_cyl;
|
|
|
|
int part, res = 0;
|
|
|
|
unsigned int blksize = 1; /* Multiplier for disk block size */
|
2005-04-17 06:20:36 +08:00
|
|
|
int slot = 1;
|
|
|
|
|
|
|
|
for (blk = 0; ; blk++, put_dev_sector(sect)) {
|
|
|
|
if (blk == RDB_ALLOCATION_LIMIT)
|
|
|
|
goto rdb_done;
|
2010-05-16 02:09:30 +08:00
|
|
|
data = read_part_sector(state, blk, §);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!data) {
|
2023-06-21 04:17:25 +08:00
|
|
|
pr_err("Dev %s: unable to read RDB block %llu\n",
|
2021-08-10 23:45:09 +08:00
|
|
|
state->disk->disk_name, blk);
|
2006-12-07 12:35:16 +08:00
|
|
|
res = -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto rdb_done;
|
|
|
|
}
|
|
|
|
if (*(__be32 *)data != cpu_to_be32(IDNAME_RIGIDDISK))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rdb = (struct RigidDiskBlock *)data;
|
|
|
|
if (checksum_block((__be32 *)data, be32_to_cpu(rdb->rdb_SummedLongs) & 0x7F) == 0)
|
|
|
|
break;
|
|
|
|
/* Try again with 0xdc..0xdf zeroed, Windows might have
|
|
|
|
* trashed it.
|
|
|
|
*/
|
|
|
|
*(__be32 *)(data+0xdc) = 0;
|
|
|
|
if (checksum_block((__be32 *)data,
|
|
|
|
be32_to_cpu(rdb->rdb_SummedLongs) & 0x7F)==0) {
|
2023-06-21 04:17:25 +08:00
|
|
|
pr_err("Trashed word at 0xd0 in block %llu ignored in checksum calculation\n",
|
2014-06-13 02:04:52 +08:00
|
|
|
blk);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-06-21 04:17:25 +08:00
|
|
|
pr_err("Dev %s: RDB in block %llu has bad checksum\n",
|
2021-08-10 23:45:09 +08:00
|
|
|
state->disk->disk_name, blk);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* blksize is blocks per 512 byte standard block */
|
|
|
|
blksize = be32_to_cpu( rdb->rdb_BlockBytes ) / 512;
|
|
|
|
|
2010-08-11 09:03:14 +08:00
|
|
|
{
|
|
|
|
char tmp[7 + 10 + 1 + 1];
|
|
|
|
|
|
|
|
/* Be more informative */
|
|
|
|
snprintf(tmp, sizeof(tmp), " RDSK (%d)", blksize * 512);
|
|
|
|
strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
blk = be32_to_cpu(rdb->rdb_PartitionList);
|
|
|
|
put_dev_sector(sect);
|
2023-07-05 07:38:08 +08:00
|
|
|
for (part = 1; (s32) blk>0 && part<=16; part++, put_dev_sector(sect)) {
|
2023-06-21 04:17:25 +08:00
|
|
|
/* Read in terms partition table understands */
|
|
|
|
if (check_mul_overflow(blk, (sector_t) blksize, &blk)) {
|
|
|
|
pr_err("Dev %s: overflow calculating partition block %llu! Skipping partitions %u and beyond\n",
|
|
|
|
state->disk->disk_name, blk, part);
|
|
|
|
break;
|
|
|
|
}
|
2010-05-16 02:09:30 +08:00
|
|
|
data = read_part_sector(state, blk, §);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!data) {
|
2023-06-21 04:17:25 +08:00
|
|
|
pr_err("Dev %s: unable to read partition block %llu\n",
|
2021-08-10 23:45:09 +08:00
|
|
|
state->disk->disk_name, blk);
|
2006-12-07 12:35:16 +08:00
|
|
|
res = -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto rdb_done;
|
|
|
|
}
|
|
|
|
pb = (struct PartitionBlock *)data;
|
|
|
|
blk = be32_to_cpu(pb->pb_Next);
|
|
|
|
if (pb->pb_ID != cpu_to_be32(IDNAME_PARTITION))
|
|
|
|
continue;
|
|
|
|
if (checksum_block((__be32 *)pb, be32_to_cpu(pb->pb_SummedLongs) & 0x7F) != 0 )
|
|
|
|
continue;
|
|
|
|
|
2023-06-21 04:17:25 +08:00
|
|
|
/* RDB gives us more than enough rope to hang ourselves with,
|
|
|
|
* many times over (2^128 bytes if all fields max out).
|
|
|
|
* Some careful checks are in order, so check for potential
|
|
|
|
* overflows.
|
|
|
|
* We are multiplying four 32 bit numbers to one sector_t!
|
|
|
|
*/
|
|
|
|
|
|
|
|
nr_hd = be32_to_cpu(pb->pb_Environment[NR_HD]);
|
|
|
|
nr_sect = be32_to_cpu(pb->pb_Environment[NR_SECT]);
|
|
|
|
|
|
|
|
/* CylBlocks is total number of blocks per cylinder */
|
|
|
|
if (check_mul_overflow(nr_hd, nr_sect, &cylblk)) {
|
|
|
|
pr_err("Dev %s: heads*sects %u overflows u32, skipping partition!\n",
|
|
|
|
state->disk->disk_name, cylblk);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for consistency with RDB defined CylBlocks */
|
|
|
|
if (cylblk > be32_to_cpu(rdb->rdb_CylBlocks)) {
|
|
|
|
pr_warn("Dev %s: cylblk %u > rdb_CylBlocks %u!\n",
|
|
|
|
state->disk->disk_name, cylblk,
|
|
|
|
be32_to_cpu(rdb->rdb_CylBlocks));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RDB allows for variable logical block size -
|
|
|
|
* normalize to 512 byte blocks and check result.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (check_mul_overflow(cylblk, blksize, &cylblk)) {
|
|
|
|
pr_err("Dev %s: partition %u bytes per cyl. overflows u32, skipping partition!\n",
|
|
|
|
state->disk->disk_name, part);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate partition start and end. Limit of 32 bit on cylblk
|
|
|
|
* guarantees no overflow occurs if LBD support is enabled.
|
|
|
|
*/
|
|
|
|
|
|
|
|
lo_cyl = be32_to_cpu(pb->pb_Environment[LO_CYL]);
|
|
|
|
start_sect = ((u64) lo_cyl * cylblk);
|
|
|
|
|
|
|
|
hi_cyl = be32_to_cpu(pb->pb_Environment[HI_CYL]);
|
|
|
|
nr_sects = (((u64) hi_cyl - lo_cyl + 1) * cylblk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!nr_sects)
|
|
|
|
continue;
|
2023-06-21 04:17:25 +08:00
|
|
|
|
|
|
|
/* Warn user if partition end overflows u32 (AmigaDOS limit) */
|
|
|
|
|
|
|
|
if ((start_sect + nr_sects) > UINT_MAX) {
|
|
|
|
pr_warn("Dev %s: partition %u (%llu-%llu) needs 64 bit device support!\n",
|
|
|
|
state->disk->disk_name, part,
|
|
|
|
start_sect, start_sect + nr_sects);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (check_add_overflow(start_sect, nr_sects, &end_sect)) {
|
|
|
|
pr_err("Dev %s: partition %u (%llu-%llu) needs LBD device support, skipping partition!\n",
|
|
|
|
state->disk->disk_name, part,
|
|
|
|
start_sect, end_sect);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tell Kernel about it */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
put_partition(state,slot++,start_sect,nr_sects);
|
|
|
|
{
|
|
|
|
/* Be even more informative to aid mounting */
|
|
|
|
char dostype[4];
|
2010-08-11 09:03:14 +08:00
|
|
|
char tmp[42];
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
__be32 *dt = (__be32 *)dostype;
|
|
|
|
*dt = pb->pb_Environment[16];
|
|
|
|
if (dostype[3] < ' ')
|
2010-08-11 09:03:14 +08:00
|
|
|
snprintf(tmp, sizeof(tmp), " (%c%c%c^%c)",
|
2005-04-17 06:20:36 +08:00
|
|
|
dostype[0], dostype[1],
|
|
|
|
dostype[2], dostype[3] + '@' );
|
|
|
|
else
|
2010-08-11 09:03:14 +08:00
|
|
|
snprintf(tmp, sizeof(tmp), " (%c%c%c%c)",
|
2005-04-17 06:20:36 +08:00
|
|
|
dostype[0], dostype[1],
|
|
|
|
dostype[2], dostype[3]);
|
2010-08-11 09:03:14 +08:00
|
|
|
strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
|
|
|
snprintf(tmp, sizeof(tmp), "(res %d spb %d)",
|
2005-04-17 06:20:36 +08:00
|
|
|
be32_to_cpu(pb->pb_Environment[6]),
|
|
|
|
be32_to_cpu(pb->pb_Environment[4]));
|
2010-08-11 09:03:14 +08:00
|
|
|
strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
res = 1;
|
|
|
|
}
|
2010-08-11 09:03:14 +08:00
|
|
|
strlcat(state->pp_buf, "\n", PAGE_SIZE);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
rdb_done:
|
|
|
|
return res;
|
|
|
|
}
|