mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-22 04:03:58 +08: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>
266 lines
7.0 KiB
C
266 lines
7.0 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* linux/fs/hfsplus/wrapper.c
|
|
*
|
|
* Copyright (C) 2001
|
|
* Brad Boyer (flar@allandria.com)
|
|
* (C) 2003 Ardis Technologies <roman@ardistech.com>
|
|
*
|
|
* Handling of HFS wrappers around HFS+ volumes
|
|
*/
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/blkdev.h>
|
|
#include <linux/cdrom.h>
|
|
#include <linux/genhd.h>
|
|
#include <asm/unaligned.h>
|
|
|
|
#include "hfsplus_fs.h"
|
|
#include "hfsplus_raw.h"
|
|
|
|
struct hfsplus_wd {
|
|
u32 ablk_size;
|
|
u16 ablk_start;
|
|
u16 embed_start;
|
|
u16 embed_count;
|
|
};
|
|
|
|
/**
|
|
* hfsplus_submit_bio - Perform block I/O
|
|
* @sb: super block of volume for I/O
|
|
* @sector: block to read or write, for blocks of HFSPLUS_SECTOR_SIZE bytes
|
|
* @buf: buffer for I/O
|
|
* @data: output pointer for location of requested data
|
|
* @op: direction of I/O
|
|
* @op_flags: request op flags
|
|
*
|
|
* The unit of I/O is hfsplus_min_io_size(sb), which may be bigger than
|
|
* HFSPLUS_SECTOR_SIZE, and @buf must be sized accordingly. On reads
|
|
* @data will return a pointer to the start of the requested sector,
|
|
* which may not be the same location as @buf.
|
|
*
|
|
* If @sector is not aligned to the bdev logical block size it will
|
|
* be rounded down. For writes this means that @buf should contain data
|
|
* that starts at the rounded-down address. As long as the data was
|
|
* read using hfsplus_submit_bio() and the same buffer is used things
|
|
* will work correctly.
|
|
*/
|
|
int hfsplus_submit_bio(struct super_block *sb, sector_t sector,
|
|
void *buf, void **data, int op, int op_flags)
|
|
{
|
|
struct bio *bio;
|
|
int ret = 0;
|
|
u64 io_size;
|
|
loff_t start;
|
|
int offset;
|
|
|
|
/*
|
|
* Align sector to hardware sector size and find offset. We
|
|
* assume that io_size is a power of two, which _should_
|
|
* be true.
|
|
*/
|
|
io_size = hfsplus_min_io_size(sb);
|
|
start = (loff_t)sector << HFSPLUS_SECTOR_SHIFT;
|
|
offset = start & (io_size - 1);
|
|
sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1);
|
|
|
|
bio = bio_alloc(GFP_NOIO, 1);
|
|
bio->bi_iter.bi_sector = sector;
|
|
bio_set_dev(bio, sb->s_bdev);
|
|
bio_set_op_attrs(bio, op, op_flags);
|
|
|
|
if (op != WRITE && data)
|
|
*data = (u8 *)buf + offset;
|
|
|
|
while (io_size > 0) {
|
|
unsigned int page_offset = offset_in_page(buf);
|
|
unsigned int len = min_t(unsigned int, PAGE_SIZE - page_offset,
|
|
io_size);
|
|
|
|
ret = bio_add_page(bio, virt_to_page(buf), len, page_offset);
|
|
if (ret != len) {
|
|
ret = -EIO;
|
|
goto out;
|
|
}
|
|
io_size -= len;
|
|
buf = (u8 *)buf + len;
|
|
}
|
|
|
|
ret = submit_bio_wait(bio);
|
|
out:
|
|
bio_put(bio);
|
|
return ret < 0 ? ret : 0;
|
|
}
|
|
|
|
static int hfsplus_read_mdb(void *bufptr, struct hfsplus_wd *wd)
|
|
{
|
|
u32 extent;
|
|
u16 attrib;
|
|
__be16 sig;
|
|
|
|
sig = *(__be16 *)(bufptr + HFSP_WRAPOFF_EMBEDSIG);
|
|
if (sig != cpu_to_be16(HFSPLUS_VOLHEAD_SIG) &&
|
|
sig != cpu_to_be16(HFSPLUS_VOLHEAD_SIGX))
|
|
return 0;
|
|
|
|
attrib = be16_to_cpu(*(__be16 *)(bufptr + HFSP_WRAPOFF_ATTRIB));
|
|
if (!(attrib & HFSP_WRAP_ATTRIB_SLOCK) ||
|
|
!(attrib & HFSP_WRAP_ATTRIB_SPARED))
|
|
return 0;
|
|
|
|
wd->ablk_size =
|
|
be32_to_cpu(*(__be32 *)(bufptr + HFSP_WRAPOFF_ABLKSIZE));
|
|
if (wd->ablk_size < HFSPLUS_SECTOR_SIZE)
|
|
return 0;
|
|
if (wd->ablk_size % HFSPLUS_SECTOR_SIZE)
|
|
return 0;
|
|
wd->ablk_start =
|
|
be16_to_cpu(*(__be16 *)(bufptr + HFSP_WRAPOFF_ABLKSTART));
|
|
|
|
extent = get_unaligned_be32(bufptr + HFSP_WRAPOFF_EMBEDEXT);
|
|
wd->embed_start = (extent >> 16) & 0xFFFF;
|
|
wd->embed_count = extent & 0xFFFF;
|
|
|
|
return 1;
|
|
}
|
|
|
|
static int hfsplus_get_last_session(struct super_block *sb,
|
|
sector_t *start, sector_t *size)
|
|
{
|
|
struct cdrom_multisession ms_info;
|
|
struct cdrom_tocentry te;
|
|
int res;
|
|
|
|
/* default values */
|
|
*start = 0;
|
|
*size = i_size_read(sb->s_bdev->bd_inode) >> 9;
|
|
|
|
if (HFSPLUS_SB(sb)->session >= 0) {
|
|
te.cdte_track = HFSPLUS_SB(sb)->session;
|
|
te.cdte_format = CDROM_LBA;
|
|
res = ioctl_by_bdev(sb->s_bdev,
|
|
CDROMREADTOCENTRY, (unsigned long)&te);
|
|
if (!res && (te.cdte_ctrl & CDROM_DATA_TRACK) == 4) {
|
|
*start = (sector_t)te.cdte_addr.lba << 2;
|
|
return 0;
|
|
}
|
|
pr_err("invalid session number or type of track\n");
|
|
return -EINVAL;
|
|
}
|
|
ms_info.addr_format = CDROM_LBA;
|
|
res = ioctl_by_bdev(sb->s_bdev, CDROMMULTISESSION,
|
|
(unsigned long)&ms_info);
|
|
if (!res && ms_info.xa_flag)
|
|
*start = (sector_t)ms_info.addr.lba << 2;
|
|
return 0;
|
|
}
|
|
|
|
/* Find the volume header and fill in some minimum bits in superblock */
|
|
/* Takes in super block, returns true if good data read */
|
|
int hfsplus_read_wrapper(struct super_block *sb)
|
|
{
|
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
|
struct hfsplus_wd wd;
|
|
sector_t part_start, part_size;
|
|
u32 blocksize;
|
|
int error = 0;
|
|
|
|
error = -EINVAL;
|
|
blocksize = sb_min_blocksize(sb, HFSPLUS_SECTOR_SIZE);
|
|
if (!blocksize)
|
|
goto out;
|
|
|
|
if (hfsplus_get_last_session(sb, &part_start, &part_size))
|
|
goto out;
|
|
|
|
error = -ENOMEM;
|
|
sbi->s_vhdr_buf = kmalloc(hfsplus_min_io_size(sb), GFP_KERNEL);
|
|
if (!sbi->s_vhdr_buf)
|
|
goto out;
|
|
sbi->s_backup_vhdr_buf = kmalloc(hfsplus_min_io_size(sb), GFP_KERNEL);
|
|
if (!sbi->s_backup_vhdr_buf)
|
|
goto out_free_vhdr;
|
|
|
|
reread:
|
|
error = hfsplus_submit_bio(sb, part_start + HFSPLUS_VOLHEAD_SECTOR,
|
|
sbi->s_vhdr_buf, (void **)&sbi->s_vhdr,
|
|
REQ_OP_READ, 0);
|
|
if (error)
|
|
goto out_free_backup_vhdr;
|
|
|
|
error = -EINVAL;
|
|
switch (sbi->s_vhdr->signature) {
|
|
case cpu_to_be16(HFSPLUS_VOLHEAD_SIGX):
|
|
set_bit(HFSPLUS_SB_HFSX, &sbi->flags);
|
|
/*FALLTHRU*/
|
|
case cpu_to_be16(HFSPLUS_VOLHEAD_SIG):
|
|
break;
|
|
case cpu_to_be16(HFSP_WRAP_MAGIC):
|
|
if (!hfsplus_read_mdb(sbi->s_vhdr, &wd))
|
|
goto out_free_backup_vhdr;
|
|
wd.ablk_size >>= HFSPLUS_SECTOR_SHIFT;
|
|
part_start += (sector_t)wd.ablk_start +
|
|
(sector_t)wd.embed_start * wd.ablk_size;
|
|
part_size = (sector_t)wd.embed_count * wd.ablk_size;
|
|
goto reread;
|
|
default:
|
|
/*
|
|
* Check for a partition block.
|
|
*
|
|
* (should do this only for cdrom/loop though)
|
|
*/
|
|
if (hfs_part_find(sb, &part_start, &part_size))
|
|
goto out_free_backup_vhdr;
|
|
goto reread;
|
|
}
|
|
|
|
error = hfsplus_submit_bio(sb, part_start + part_size - 2,
|
|
sbi->s_backup_vhdr_buf,
|
|
(void **)&sbi->s_backup_vhdr, REQ_OP_READ,
|
|
0);
|
|
if (error)
|
|
goto out_free_backup_vhdr;
|
|
|
|
error = -EINVAL;
|
|
if (sbi->s_backup_vhdr->signature != sbi->s_vhdr->signature) {
|
|
pr_warn("invalid secondary volume header\n");
|
|
goto out_free_backup_vhdr;
|
|
}
|
|
|
|
blocksize = be32_to_cpu(sbi->s_vhdr->blocksize);
|
|
|
|
/*
|
|
* Block size must be at least as large as a sector and a multiple of 2.
|
|
*/
|
|
if (blocksize < HFSPLUS_SECTOR_SIZE || ((blocksize - 1) & blocksize))
|
|
goto out_free_backup_vhdr;
|
|
sbi->alloc_blksz = blocksize;
|
|
sbi->alloc_blksz_shift = ilog2(blocksize);
|
|
blocksize = min_t(u32, sbi->alloc_blksz, PAGE_SIZE);
|
|
|
|
/*
|
|
* Align block size to block offset.
|
|
*/
|
|
while (part_start & ((blocksize >> HFSPLUS_SECTOR_SHIFT) - 1))
|
|
blocksize >>= 1;
|
|
|
|
if (sb_set_blocksize(sb, blocksize) != blocksize) {
|
|
pr_err("unable to set blocksize to %u!\n", blocksize);
|
|
goto out_free_backup_vhdr;
|
|
}
|
|
|
|
sbi->blockoffset =
|
|
part_start >> (sb->s_blocksize_bits - HFSPLUS_SECTOR_SHIFT);
|
|
sbi->part_start = part_start;
|
|
sbi->sect_count = part_size;
|
|
sbi->fs_shift = sbi->alloc_blksz_shift - sb->s_blocksize_bits;
|
|
return 0;
|
|
|
|
out_free_backup_vhdr:
|
|
kfree(sbi->s_backup_vhdr_buf);
|
|
out_free_vhdr:
|
|
kfree(sbi->s_vhdr_buf);
|
|
out:
|
|
return error;
|
|
}
|