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 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* S/390 common I/O routines -- blacklisting of specific devices
|
|
|
|
*
|
2013-04-30 15:16:17 +00:00
|
|
|
* Copyright IBM Corp. 1999, 2013
|
2005-04-16 22:20:36 +00:00
|
|
|
* Author(s): Ingo Adlung (adlung@de.ibm.com)
|
2006-01-14 21:21:04 +00:00
|
|
|
* Cornelia Huck (cornelia.huck@de.ibm.com)
|
2005-04-16 22:20:36 +00:00
|
|
|
* Arnd Bergmann (arndb@de.ibm.com)
|
|
|
|
*/
|
|
|
|
|
2008-12-25 12:39:36 +00:00
|
|
|
#define KMSG_COMPONENT "cio"
|
|
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/proc_fs.h>
|
2006-01-06 08:19:24 +00:00
|
|
|
#include <linux/seq_file.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2013-04-30 15:16:17 +00:00
|
|
|
#include <asm/cio.h>
|
|
|
|
#include <asm/ipl.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "blacklist.h"
|
|
|
|
#include "cio.h"
|
|
|
|
#include "cio_debug.h"
|
|
|
|
#include "css.h"
|
2008-10-10 19:33:06 +00:00
|
|
|
#include "device.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* "Blacklisting" of certain devices:
|
|
|
|
* Device numbers given in the commandline as cio_ignore=... won't be known
|
|
|
|
* to Linux.
|
|
|
|
*
|
|
|
|
* These can be single devices or ranges of devices
|
|
|
|
*/
|
|
|
|
|
2006-01-06 08:19:25 +00:00
|
|
|
/* 65536 bits for each set to indicate if a devno is blacklisted or not */
|
2006-01-06 08:19:21 +00:00
|
|
|
#define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \
|
2005-04-16 22:20:36 +00:00
|
|
|
(8*sizeof(long)))
|
2006-01-06 08:19:25 +00:00
|
|
|
static unsigned long bl_dev[__MAX_SSID + 1][__BL_DEV_WORDS];
|
2005-04-16 22:20:36 +00:00
|
|
|
typedef enum {add, free} range_action;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: blacklist_range
|
|
|
|
* (Un-)blacklist the devices from-to
|
|
|
|
*/
|
2008-05-07 07:22:55 +00:00
|
|
|
static int blacklist_range(range_action action, unsigned int from_ssid,
|
|
|
|
unsigned int to_ssid, unsigned int from,
|
|
|
|
unsigned int to, int msgtrigger)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-05-07 07:22:55 +00:00
|
|
|
if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) {
|
|
|
|
if (msgtrigger)
|
2016-03-04 04:49:57 +00:00
|
|
|
pr_warn("0.%x.%04x to 0.%x.%04x is not a valid range for cio_ignore\n",
|
|
|
|
from_ssid, from, to_ssid, to);
|
2008-12-25 12:39:36 +00:00
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
return 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-05-07 07:22:55 +00:00
|
|
|
|
|
|
|
while ((from_ssid < to_ssid) || ((from_ssid == to_ssid) &&
|
|
|
|
(from <= to))) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (action == add)
|
2008-05-07 07:22:55 +00:00
|
|
|
set_bit(from, bl_dev[from_ssid]);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2008-05-07 07:22:55 +00:00
|
|
|
clear_bit(from, bl_dev[from_ssid]);
|
|
|
|
from++;
|
|
|
|
if (from > __MAX_SUBCHANNEL) {
|
|
|
|
from_ssid++;
|
|
|
|
from = 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-05-07 07:22:55 +00:00
|
|
|
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
static int pure_hex(char **cp, unsigned int *val, int min_digit,
|
|
|
|
int max_digit, int max_val)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-05-07 07:22:55 +00:00
|
|
|
int diff;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
diff = 0;
|
|
|
|
*val = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-10-25 14:10:25 +00:00
|
|
|
while (diff <= max_digit) {
|
|
|
|
int value = hex_to_bin(**cp);
|
2008-05-07 07:22:55 +00:00
|
|
|
|
2010-10-25 14:10:25 +00:00
|
|
|
if (value < 0)
|
|
|
|
break;
|
2008-05-07 07:22:55 +00:00
|
|
|
*val = *val * 16 + value;
|
|
|
|
(*cp)++;
|
|
|
|
diff++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-05-07 07:22:55 +00:00
|
|
|
|
|
|
|
if ((diff < min_digit) || (diff > max_digit) || (*val > max_val))
|
|
|
|
return 1;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 08:03:19 +00:00
|
|
|
static int parse_busid(char *str, unsigned int *cssid, unsigned int *ssid,
|
|
|
|
unsigned int *devno, int msgtrigger)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-05-07 07:22:55 +00:00
|
|
|
char *str_work;
|
|
|
|
int val, rc, ret;
|
|
|
|
|
|
|
|
rc = 1;
|
|
|
|
|
|
|
|
if (*str == '\0')
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* old style */
|
|
|
|
str_work = str;
|
|
|
|
val = simple_strtoul(str, &str_work, 16);
|
|
|
|
|
|
|
|
if (*str_work == '\0') {
|
|
|
|
if (val <= __MAX_SUBCHANNEL) {
|
|
|
|
*devno = val;
|
|
|
|
*ssid = 0;
|
|
|
|
*cssid = 0;
|
|
|
|
rc = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-05-07 07:22:55 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
/* new style */
|
|
|
|
str_work = str;
|
|
|
|
ret = pure_hex(&str_work, cssid, 1, 2, __MAX_CSSID);
|
|
|
|
if (ret || (str_work[0] != '.'))
|
|
|
|
goto out;
|
|
|
|
str_work++;
|
|
|
|
ret = pure_hex(&str_work, ssid, 1, 1, __MAX_SSID);
|
|
|
|
if (ret || (str_work[0] != '.'))
|
|
|
|
goto out;
|
|
|
|
str_work++;
|
|
|
|
ret = pure_hex(&str_work, devno, 4, 4, __MAX_SUBCHANNEL);
|
|
|
|
if (ret || (str_work[0] != '\0'))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
rc = 0;
|
|
|
|
out:
|
|
|
|
if (rc && msgtrigger)
|
2016-03-04 04:49:57 +00:00
|
|
|
pr_warn("%s is not a valid device for the cio_ignore kernel parameter\n",
|
|
|
|
str);
|
2008-05-07 07:22:55 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
static int blacklist_parse_parameters(char *str, range_action action,
|
|
|
|
int msgtrigger)
|
|
|
|
{
|
2008-06-10 08:03:19 +00:00
|
|
|
unsigned int from_cssid, to_cssid, from_ssid, to_ssid, from, to;
|
2008-05-07 07:22:55 +00:00
|
|
|
int rc, totalrc;
|
|
|
|
char *parm;
|
|
|
|
range_action ra;
|
|
|
|
|
|
|
|
totalrc = 0;
|
|
|
|
|
|
|
|
while ((parm = strsep(&str, ","))) {
|
|
|
|
rc = 0;
|
|
|
|
ra = action;
|
|
|
|
if (*parm == '!') {
|
|
|
|
if (ra == add)
|
|
|
|
ra = free;
|
|
|
|
else
|
|
|
|
ra = add;
|
|
|
|
parm++;
|
|
|
|
}
|
|
|
|
if (strcmp(parm, "all") == 0) {
|
|
|
|
from_cssid = 0;
|
|
|
|
from_ssid = 0;
|
|
|
|
from = 0;
|
|
|
|
to_cssid = __MAX_CSSID;
|
|
|
|
to_ssid = __MAX_SSID;
|
|
|
|
to = __MAX_SUBCHANNEL;
|
2013-04-30 15:16:17 +00:00
|
|
|
} else if (strcmp(parm, "ipldev") == 0) {
|
|
|
|
if (ipl_info.type == IPL_TYPE_CCW) {
|
|
|
|
from_cssid = 0;
|
|
|
|
from_ssid = ipl_info.data.ccw.dev_id.ssid;
|
|
|
|
from = ipl_info.data.ccw.dev_id.devno;
|
|
|
|
} else if (ipl_info.type == IPL_TYPE_FCP ||
|
|
|
|
ipl_info.type == IPL_TYPE_FCP_DUMP) {
|
|
|
|
from_cssid = 0;
|
|
|
|
from_ssid = ipl_info.data.fcp.dev_id.ssid;
|
|
|
|
from = ipl_info.data.fcp.dev_id.devno;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
to_cssid = from_cssid;
|
|
|
|
to_ssid = from_ssid;
|
|
|
|
to = from;
|
2013-04-30 15:17:34 +00:00
|
|
|
} else if (strcmp(parm, "condev") == 0) {
|
|
|
|
if (console_devno == -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
from_cssid = to_cssid = 0;
|
|
|
|
from_ssid = to_ssid = 0;
|
|
|
|
from = to = console_devno;
|
2008-05-07 07:22:55 +00:00
|
|
|
} else {
|
|
|
|
rc = parse_busid(strsep(&parm, "-"), &from_cssid,
|
|
|
|
&from_ssid, &from, msgtrigger);
|
|
|
|
if (!rc) {
|
|
|
|
if (parm != NULL)
|
|
|
|
rc = parse_busid(parm, &to_cssid,
|
|
|
|
&to_ssid, &to,
|
|
|
|
msgtrigger);
|
|
|
|
else {
|
|
|
|
to_cssid = from_cssid;
|
|
|
|
to_ssid = from_ssid;
|
|
|
|
to = from;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-07 07:22:55 +00:00
|
|
|
if (!rc) {
|
|
|
|
rc = blacklist_range(ra, from_ssid, to_ssid, from, to,
|
|
|
|
msgtrigger);
|
|
|
|
if (rc)
|
2008-10-10 19:33:06 +00:00
|
|
|
totalrc = -EINVAL;
|
2008-05-07 07:22:55 +00:00
|
|
|
} else
|
2008-10-10 19:33:06 +00:00
|
|
|
totalrc = -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-05-07 07:22:55 +00:00
|
|
|
|
|
|
|
return totalrc;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
blacklist_setup (char *str)
|
|
|
|
{
|
2008-05-07 07:22:55 +00:00
|
|
|
CIO_MSG_EVENT(6, "Reading blacklist parameters\n");
|
|
|
|
if (blacklist_parse_parameters(str, add, 1))
|
|
|
|
return 0;
|
|
|
|
return 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__setup ("cio_ignore=", blacklist_setup);
|
|
|
|
|
|
|
|
/* Checking if devices are blacklisted */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: is_blacklisted
|
|
|
|
* Returns 1 if the given devicenumber can be found in the blacklist,
|
|
|
|
* otherwise 0.
|
|
|
|
* Used by validate_subchannel()
|
|
|
|
*/
|
|
|
|
int
|
2006-01-06 08:19:25 +00:00
|
|
|
is_blacklisted (int ssid, int devno)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-01-06 08:19:25 +00:00
|
|
|
return test_bit (devno, bl_dev[ssid]);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
/*
|
|
|
|
* Function: blacklist_parse_proc_parameters
|
|
|
|
* parse the stuff which is piped to /proc/cio_ignore
|
|
|
|
*/
|
2008-05-07 07:22:55 +00:00
|
|
|
static int blacklist_parse_proc_parameters(char *buf)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-05-07 07:22:55 +00:00
|
|
|
int rc;
|
|
|
|
char *parm;
|
|
|
|
|
|
|
|
parm = strsep(&buf, " ");
|
|
|
|
|
2013-11-26 14:00:37 +00:00
|
|
|
if (strcmp("free", parm) == 0) {
|
2008-05-07 07:22:55 +00:00
|
|
|
rc = blacklist_parse_parameters(buf, free, 0);
|
2013-11-26 14:00:37 +00:00
|
|
|
css_schedule_eval_all_unreg(0);
|
|
|
|
} else if (strcmp("add", parm) == 0)
|
2008-05-07 07:22:55 +00:00
|
|
|
rc = blacklist_parse_parameters(buf, add, 0);
|
2008-10-10 19:33:06 +00:00
|
|
|
else if (strcmp("purge", parm) == 0)
|
|
|
|
return ccw_purge_blacklisted();
|
2008-05-07 07:22:55 +00:00
|
|
|
else
|
2008-10-10 19:33:06 +00:00
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
|
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-06 08:19:24 +00:00
|
|
|
/* Iterator struct for all devices. */
|
|
|
|
struct ccwdev_iter {
|
|
|
|
int devno;
|
2006-01-06 08:19:25 +00:00
|
|
|
int ssid;
|
2006-01-06 08:19:24 +00:00
|
|
|
int in_range;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void *
|
|
|
|
cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-10-06 08:34:00 +00:00
|
|
|
struct ccwdev_iter *iter = s->private;
|
2006-01-06 08:19:24 +00:00
|
|
|
|
2006-01-06 08:19:25 +00:00
|
|
|
if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
|
2006-01-06 08:19:24 +00:00
|
|
|
return NULL;
|
2009-10-06 08:34:00 +00:00
|
|
|
memset(iter, 0, sizeof(*iter));
|
2006-01-06 08:19:25 +00:00
|
|
|
iter->ssid = *offset / (__MAX_SUBCHANNEL + 1);
|
|
|
|
iter->devno = *offset % (__MAX_SUBCHANNEL + 1);
|
2006-01-06 08:19:24 +00:00
|
|
|
return iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cio_ignore_proc_seq_stop(struct seq_file *s, void *it)
|
|
|
|
{
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-06 08:19:24 +00:00
|
|
|
static void *
|
|
|
|
cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset)
|
|
|
|
{
|
|
|
|
struct ccwdev_iter *iter;
|
|
|
|
|
2006-01-06 08:19:25 +00:00
|
|
|
if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
|
2006-01-06 08:19:24 +00:00
|
|
|
return NULL;
|
2006-01-06 08:19:26 +00:00
|
|
|
iter = it;
|
2006-01-06 08:19:25 +00:00
|
|
|
if (iter->devno == __MAX_SUBCHANNEL) {
|
|
|
|
iter->devno = 0;
|
|
|
|
iter->ssid++;
|
|
|
|
if (iter->ssid > __MAX_SSID)
|
|
|
|
return NULL;
|
|
|
|
} else
|
|
|
|
iter->devno++;
|
2006-01-06 08:19:24 +00:00
|
|
|
(*offset)++;
|
|
|
|
return iter;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-06 08:19:24 +00:00
|
|
|
static int
|
|
|
|
cio_ignore_proc_seq_show(struct seq_file *s, void *it)
|
|
|
|
{
|
|
|
|
struct ccwdev_iter *iter;
|
|
|
|
|
2006-01-06 08:19:26 +00:00
|
|
|
iter = it;
|
2006-01-06 08:19:25 +00:00
|
|
|
if (!is_blacklisted(iter->ssid, iter->devno))
|
2006-01-06 08:19:24 +00:00
|
|
|
/* Not blacklisted, nothing to output. */
|
|
|
|
return 0;
|
|
|
|
if (!iter->in_range) {
|
|
|
|
/* First device in range. */
|
|
|
|
if ((iter->devno == __MAX_SUBCHANNEL) ||
|
2015-04-15 23:18:14 +00:00
|
|
|
!is_blacklisted(iter->ssid, iter->devno + 1)) {
|
2006-01-06 08:19:24 +00:00
|
|
|
/* Singular device. */
|
2015-04-15 23:18:14 +00:00
|
|
|
seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-01-06 08:19:24 +00:00
|
|
|
iter->in_range = 1;
|
2015-04-15 23:18:14 +00:00
|
|
|
seq_printf(s, "0.%x.%04x-", iter->ssid, iter->devno);
|
|
|
|
return 0;
|
2006-01-06 08:19:24 +00:00
|
|
|
}
|
|
|
|
if ((iter->devno == __MAX_SUBCHANNEL) ||
|
2006-01-06 08:19:25 +00:00
|
|
|
!is_blacklisted(iter->ssid, iter->devno + 1)) {
|
2006-01-06 08:19:24 +00:00
|
|
|
/* Last device in range. */
|
|
|
|
iter->in_range = 0;
|
2015-04-15 23:18:14 +00:00
|
|
|
seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno);
|
2006-01-06 08:19:24 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
cio_ignore_write(struct file *file, const char __user *user_buf,
|
|
|
|
size_t user_len, loff_t *offset)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
char *buf;
|
2009-03-26 14:24:16 +00:00
|
|
|
ssize_t rc, ret, i;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-06 08:19:24 +00:00
|
|
|
if (*offset)
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (user_len > 65536)
|
|
|
|
user_len = 65536;
|
2011-05-28 17:36:21 +00:00
|
|
|
buf = vzalloc(user_len + 1); /* maybe better use the stack? */
|
2005-04-16 22:20:36 +00:00
|
|
|
if (buf == NULL)
|
|
|
|
return -ENOMEM;
|
2008-05-07 07:22:55 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (strncpy_from_user (buf, user_buf, user_len) < 0) {
|
2008-05-07 07:22:55 +00:00
|
|
|
rc = -EFAULT;
|
|
|
|
goto out_free;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
i = user_len - 1;
|
|
|
|
while ((i >= 0) && (isspace(buf[i]) || (buf[i] == 0))) {
|
|
|
|
buf[i] = '\0';
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
ret = blacklist_parse_proc_parameters(buf);
|
|
|
|
if (ret)
|
2008-10-10 19:33:06 +00:00
|
|
|
rc = ret;
|
2008-05-07 07:22:55 +00:00
|
|
|
else
|
|
|
|
rc = user_len;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-07 07:22:55 +00:00
|
|
|
out_free:
|
2005-04-16 22:20:36 +00:00
|
|
|
vfree (buf);
|
2008-05-07 07:22:55 +00:00
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-01-26 13:11:29 +00:00
|
|
|
static const struct seq_operations cio_ignore_proc_seq_ops = {
|
2006-01-06 08:19:24 +00:00
|
|
|
.start = cio_ignore_proc_seq_start,
|
|
|
|
.stop = cio_ignore_proc_seq_stop,
|
|
|
|
.next = cio_ignore_proc_seq_next,
|
|
|
|
.show = cio_ignore_proc_seq_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
cio_ignore_proc_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2009-10-06 08:34:00 +00:00
|
|
|
return seq_open_private(file, &cio_ignore_proc_seq_ops,
|
|
|
|
sizeof(struct ccwdev_iter));
|
2006-01-06 08:19:24 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 08:55:34 +00:00
|
|
|
static const struct file_operations cio_ignore_proc_fops = {
|
2006-01-06 08:19:24 +00:00
|
|
|
.open = cio_ignore_proc_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2009-10-06 08:34:00 +00:00
|
|
|
.release = seq_release_private,
|
2006-01-06 08:19:24 +00:00
|
|
|
.write = cio_ignore_write,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int
|
|
|
|
cio_ignore_proc_init (void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *entry;
|
|
|
|
|
2008-04-29 08:02:20 +00:00
|
|
|
entry = proc_create("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, NULL,
|
|
|
|
&cio_ignore_proc_fops);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!entry)
|
2006-04-11 05:53:45 +00:00
|
|
|
return -ENOENT;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__initcall (cio_ignore_proc_init);
|
|
|
|
|
|
|
|
#endif /* CONFIG_PROC_FS */
|