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
|
|
|
/*
|
|
|
|
* linux/arch/alpha/kernel/osf_sys.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Linus Torvalds
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file handles some of the stranger OSF/1 system call interfaces.
|
|
|
|
* Some of the system calls expect a non-C calling standard, others have
|
|
|
|
* special parameter blocks..
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/errno.h>
|
2017-02-08 17:51:30 +00:00
|
|
|
#include <linux/sched/signal.h>
|
2017-02-08 17:51:31 +00:00
|
|
|
#include <linux/sched/mm.h>
|
2017-02-08 17:51:37 +00:00
|
|
|
#include <linux/sched/task_stack.h>
|
2017-02-05 10:48:36 +00:00
|
|
|
#include <linux/sched/cputime.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/user.h>
|
|
|
|
#include <linux/utsname.h>
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/timex.h>
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/mman.h>
|
|
|
|
#include <linux/shm.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/ipc.h>
|
|
|
|
#include <linux/namei.h>
|
|
|
|
#include <linux/uio.h>
|
|
|
|
#include <linux/vfs.h>
|
2005-09-17 02:28:13 +00:00
|
|
|
#include <linux/rcupdate.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/fpu.h>
|
|
|
|
#include <asm/io.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/sysinfo.h>
|
alpha: unbreak osf_setsysinfo(SSI_NVPAIRS, [SSIN_UACPROC, UAC_SIGBUS])
The bug was accidentally found by the following program:
#include <asm/sysinfo.h>
#include <asm/unistd.h>
#include <sys/syscall.h>
static int setsysinfo(unsigned long op, void *buffer, unsigned long size,
int *start, void *arg, unsigned long flag) {
return syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);
}
int main(int argc, char **argv) {
short x[10];
unsigned int buf[2] = { SSIN_UACPROC, UAC_SIGBUS, };
setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);
int *y = (int*) (x+1);
*y = 0;
return 0;
}
The program shoud fail on SIGBUS, but didn't.
The patch is a second part of userspace flag fix (commit 745dd2405e28
"Alpha: Rearrange thread info flags fixing two regressions").
Deleted outdated out-of-sync 'UAC_SHIFT' (the cause of bug) in favour of
'ALPHA_UAC_SHIFT'.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Acked-by: Michael Cree <mcree@orcon.net.nz>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-08-25 22:59:02 +00:00
|
|
|
#include <asm/thread_info.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/hwrpb.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Brk needs to return an error. Still support Linux's brk(0) query idiom,
|
|
|
|
* which OSF programs just shouldn't be doing. We're still not quite
|
|
|
|
* identical to OSF as we don't return 0 on success, but doing otherwise
|
|
|
|
* would require changes to libc. Hopefully this is good enough.
|
|
|
|
*/
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE1(osf_brk, unsigned long, brk)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned long retval = sys_brk(brk);
|
|
|
|
if (brk && brk != retval)
|
|
|
|
retval = -ENOMEM;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is pure guess-work..
|
|
|
|
*/
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
|
|
|
|
unsigned long, text_len, unsigned long, bss_start,
|
|
|
|
unsigned long, bss_len)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct mm_struct *mm;
|
|
|
|
|
|
|
|
mm = current->mm;
|
|
|
|
mm->end_code = bss_start + bss_len;
|
2008-04-24 12:54:50 +00:00
|
|
|
mm->start_brk = bss_start + bss_len;
|
2005-04-16 22:20:36 +00:00
|
|
|
mm->brk = bss_start + bss_len;
|
|
|
|
#if 0
|
|
|
|
printk("set_program_attributes(%lx %lx %lx %lx)\n",
|
|
|
|
text_start, text_len, bss_start, bss_len);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OSF/1 directory handling functions...
|
|
|
|
*
|
|
|
|
* The "getdents()" interface is much more sane: the "basep" stuff is
|
|
|
|
* braindamage (it can't really handle filesystems where the directory
|
|
|
|
* offset differences aren't the same as "d_reclen").
|
|
|
|
*/
|
|
|
|
#define NAME_OFFSET offsetof (struct osf_dirent, d_name)
|
|
|
|
|
|
|
|
struct osf_dirent {
|
|
|
|
unsigned int d_ino;
|
|
|
|
unsigned short d_reclen;
|
|
|
|
unsigned short d_namlen;
|
|
|
|
char d_name[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osf_dirent_callback {
|
2013-05-15 17:52:59 +00:00
|
|
|
struct dir_context ctx;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct osf_dirent __user *dirent;
|
|
|
|
long __user *basep;
|
|
|
|
unsigned int count;
|
|
|
|
int error;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2014-10-30 16:37:34 +00:00
|
|
|
osf_filldir(struct dir_context *ctx, const char *name, int namlen,
|
|
|
|
loff_t offset, u64 ino, unsigned int d_type)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct osf_dirent __user *dirent;
|
2014-10-30 16:37:34 +00:00
|
|
|
struct osf_dirent_callback *buf =
|
|
|
|
container_of(ctx, struct osf_dirent_callback, ctx);
|
2007-05-06 21:50:36 +00:00
|
|
|
unsigned int reclen = ALIGN(NAME_OFFSET + namlen + 1, sizeof(u32));
|
2006-10-03 08:13:46 +00:00
|
|
|
unsigned int d_ino;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
buf->error = -EINVAL; /* only used if we fail */
|
|
|
|
if (reclen > buf->count)
|
|
|
|
return -EINVAL;
|
2006-10-03 08:13:46 +00:00
|
|
|
d_ino = ino;
|
2008-08-12 03:51:22 +00:00
|
|
|
if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) {
|
|
|
|
buf->error = -EOVERFLOW;
|
2006-10-03 08:13:46 +00:00
|
|
|
return -EOVERFLOW;
|
2008-08-12 03:51:22 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
if (buf->basep) {
|
|
|
|
if (put_user(offset, buf->basep))
|
2008-08-12 03:51:22 +00:00
|
|
|
goto Efault;
|
2005-04-16 22:20:36 +00:00
|
|
|
buf->basep = NULL;
|
|
|
|
}
|
|
|
|
dirent = buf->dirent;
|
2008-08-12 03:51:22 +00:00
|
|
|
if (put_user(d_ino, &dirent->d_ino) ||
|
|
|
|
put_user(namlen, &dirent->d_namlen) ||
|
|
|
|
put_user(reclen, &dirent->d_reclen) ||
|
|
|
|
copy_to_user(dirent->d_name, name, namlen) ||
|
2005-04-16 22:20:36 +00:00
|
|
|
put_user(0, dirent->d_name + namlen))
|
2008-08-12 03:51:22 +00:00
|
|
|
goto Efault;
|
2005-04-16 22:20:36 +00:00
|
|
|
dirent = (void __user *)dirent + reclen;
|
|
|
|
buf->dirent = dirent;
|
|
|
|
buf->count -= reclen;
|
|
|
|
return 0;
|
2008-08-12 03:51:22 +00:00
|
|
|
Efault:
|
|
|
|
buf->error = -EFAULT;
|
|
|
|
return -EFAULT;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
|
|
|
|
struct osf_dirent __user *, dirent, unsigned int, count,
|
|
|
|
long __user *, basep)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int error;
|
2016-04-20 21:08:21 +00:00
|
|
|
struct fd arg = fdget_pos(fd);
|
2013-05-23 02:22:04 +00:00
|
|
|
struct osf_dirent_callback buf = {
|
|
|
|
.ctx.actor = osf_filldir,
|
|
|
|
.dirent = dirent,
|
|
|
|
.basep = basep,
|
|
|
|
.count = count
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-08-28 16:52:22 +00:00
|
|
|
if (!arg.file)
|
|
|
|
return -EBADF;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-05-15 17:52:59 +00:00
|
|
|
error = iterate_dir(arg.file, &buf.ctx);
|
2008-08-24 11:29:52 +00:00
|
|
|
if (error >= 0)
|
|
|
|
error = buf.error;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (count != buf.count)
|
|
|
|
error = count - buf.count;
|
|
|
|
|
2016-04-20 21:08:21 +00:00
|
|
|
fdput_pos(arg);
|
2005-04-16 22:20:36 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NAME_OFFSET
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len,
|
|
|
|
unsigned long, prot, unsigned long, flags, unsigned long, fd,
|
|
|
|
unsigned long, off)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-11-30 22:37:04 +00:00
|
|
|
unsigned long ret = -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (flags & (_MAP_HASSEMAPHORE | _MAP_INHERIT | _MAP_UNALIGNED))
|
|
|
|
printk("%s: unimplemented OSF mmap flags %04lx\n",
|
|
|
|
current->comm, flags);
|
|
|
|
#endif
|
2009-11-30 22:37:04 +00:00
|
|
|
if ((off + PAGE_ALIGN(len)) < off)
|
|
|
|
goto out;
|
|
|
|
if (off & ~PAGE_MASK)
|
|
|
|
goto out;
|
2018-03-11 10:34:46 +00:00
|
|
|
ret = ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
|
2005-04-16 22:20:36 +00:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-08-26 18:06:29 +00:00
|
|
|
struct osf_stat {
|
|
|
|
int st_dev;
|
|
|
|
int st_pad1;
|
|
|
|
unsigned st_mode;
|
|
|
|
unsigned short st_nlink;
|
|
|
|
short st_nlink_reserved;
|
|
|
|
unsigned st_uid;
|
|
|
|
unsigned st_gid;
|
|
|
|
int st_rdev;
|
|
|
|
int st_ldev;
|
|
|
|
long st_size;
|
|
|
|
int st_pad2;
|
|
|
|
int st_uatime;
|
|
|
|
int st_pad3;
|
|
|
|
int st_umtime;
|
|
|
|
int st_pad4;
|
|
|
|
int st_uctime;
|
|
|
|
int st_pad5;
|
|
|
|
int st_pad6;
|
|
|
|
unsigned st_flags;
|
|
|
|
unsigned st_gen;
|
|
|
|
long st_spare[4];
|
|
|
|
unsigned st_ino;
|
|
|
|
int st_ino_reserved;
|
|
|
|
int st_atime;
|
|
|
|
int st_atime_reserved;
|
|
|
|
int st_mtime;
|
|
|
|
int st_mtime_reserved;
|
|
|
|
int st_ctime;
|
|
|
|
int st_ctime_reserved;
|
|
|
|
long st_blksize;
|
|
|
|
long st_blocks;
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The OSF/1 statfs structure is much larger, but this should
|
|
|
|
* match the beginning, at least.
|
|
|
|
*/
|
|
|
|
struct osf_statfs {
|
|
|
|
short f_type;
|
|
|
|
short f_flags;
|
|
|
|
int f_fsize;
|
|
|
|
int f_bsize;
|
|
|
|
int f_blocks;
|
|
|
|
int f_bfree;
|
|
|
|
int f_bavail;
|
|
|
|
int f_files;
|
|
|
|
int f_ffree;
|
|
|
|
__kernel_fsid_t f_fsid;
|
|
|
|
};
|
|
|
|
|
2011-08-26 18:06:29 +00:00
|
|
|
struct osf_statfs64 {
|
|
|
|
short f_type;
|
|
|
|
short f_flags;
|
|
|
|
int f_pad1;
|
|
|
|
int f_pad2;
|
|
|
|
int f_pad3;
|
|
|
|
int f_pad4;
|
|
|
|
int f_pad5;
|
|
|
|
int f_pad6;
|
|
|
|
int f_pad7;
|
|
|
|
__kernel_fsid_t f_fsid;
|
|
|
|
u_short f_namemax;
|
|
|
|
short f_reserved1;
|
|
|
|
int f_spare[8];
|
|
|
|
char f_pad8[90];
|
|
|
|
char f_pad9[90];
|
|
|
|
long mount_info[10];
|
|
|
|
u_long f_flags2;
|
|
|
|
long f_spare2[14];
|
|
|
|
long f_fsize;
|
|
|
|
long f_bsize;
|
|
|
|
long f_blocks;
|
|
|
|
long f_bfree;
|
|
|
|
long f_bavail;
|
|
|
|
long f_files;
|
|
|
|
long f_ffree;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
linux_to_osf_stat(struct kstat *lstat, struct osf_stat __user *osf_stat)
|
|
|
|
{
|
|
|
|
struct osf_stat tmp = { 0 };
|
|
|
|
|
|
|
|
tmp.st_dev = lstat->dev;
|
|
|
|
tmp.st_mode = lstat->mode;
|
|
|
|
tmp.st_nlink = lstat->nlink;
|
2012-08-11 19:07:24 +00:00
|
|
|
tmp.st_uid = from_kuid_munged(current_user_ns(), lstat->uid);
|
|
|
|
tmp.st_gid = from_kgid_munged(current_user_ns(), lstat->gid);
|
2011-08-26 18:06:29 +00:00
|
|
|
tmp.st_rdev = lstat->rdev;
|
|
|
|
tmp.st_ldev = lstat->rdev;
|
|
|
|
tmp.st_size = lstat->size;
|
|
|
|
tmp.st_uatime = lstat->atime.tv_nsec / 1000;
|
|
|
|
tmp.st_umtime = lstat->mtime.tv_nsec / 1000;
|
|
|
|
tmp.st_uctime = lstat->ctime.tv_nsec / 1000;
|
|
|
|
tmp.st_ino = lstat->ino;
|
|
|
|
tmp.st_atime = lstat->atime.tv_sec;
|
|
|
|
tmp.st_mtime = lstat->mtime.tv_sec;
|
|
|
|
tmp.st_ctime = lstat->ctime.tv_sec;
|
|
|
|
tmp.st_blksize = lstat->blksize;
|
|
|
|
tmp.st_blocks = lstat->blocks;
|
|
|
|
|
|
|
|
return copy_to_user(osf_stat, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int
|
|
|
|
linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_stat,
|
|
|
|
unsigned long bufsiz)
|
|
|
|
{
|
|
|
|
struct osf_statfs tmp_stat;
|
|
|
|
|
|
|
|
tmp_stat.f_type = linux_stat->f_type;
|
|
|
|
tmp_stat.f_flags = 0; /* mount flags */
|
|
|
|
tmp_stat.f_fsize = linux_stat->f_frsize;
|
|
|
|
tmp_stat.f_bsize = linux_stat->f_bsize;
|
|
|
|
tmp_stat.f_blocks = linux_stat->f_blocks;
|
|
|
|
tmp_stat.f_bfree = linux_stat->f_bfree;
|
|
|
|
tmp_stat.f_bavail = linux_stat->f_bavail;
|
|
|
|
tmp_stat.f_files = linux_stat->f_files;
|
|
|
|
tmp_stat.f_ffree = linux_stat->f_ffree;
|
|
|
|
tmp_stat.f_fsid = linux_stat->f_fsid;
|
|
|
|
if (bufsiz > sizeof(tmp_stat))
|
|
|
|
bufsiz = sizeof(tmp_stat);
|
|
|
|
return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
|
|
|
|
}
|
|
|
|
|
2011-08-26 18:06:29 +00:00
|
|
|
static int
|
|
|
|
linux_to_osf_statfs64(struct kstatfs *linux_stat, struct osf_statfs64 __user *osf_stat,
|
|
|
|
unsigned long bufsiz)
|
|
|
|
{
|
|
|
|
struct osf_statfs64 tmp_stat = { 0 };
|
|
|
|
|
|
|
|
tmp_stat.f_type = linux_stat->f_type;
|
|
|
|
tmp_stat.f_fsize = linux_stat->f_frsize;
|
|
|
|
tmp_stat.f_bsize = linux_stat->f_bsize;
|
|
|
|
tmp_stat.f_blocks = linux_stat->f_blocks;
|
|
|
|
tmp_stat.f_bfree = linux_stat->f_bfree;
|
|
|
|
tmp_stat.f_bavail = linux_stat->f_bavail;
|
|
|
|
tmp_stat.f_files = linux_stat->f_files;
|
|
|
|
tmp_stat.f_ffree = linux_stat->f_ffree;
|
|
|
|
tmp_stat.f_fsid = linux_stat->f_fsid;
|
|
|
|
if (bufsiz > sizeof(tmp_stat))
|
|
|
|
bufsiz = sizeof(tmp_stat);
|
|
|
|
return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
|
|
|
|
}
|
|
|
|
|
2011-03-12 15:41:39 +00:00
|
|
|
SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname,
|
|
|
|
struct osf_statfs __user *, buffer, unsigned long, bufsiz)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct kstatfs linux_stat;
|
2011-03-12 15:41:39 +00:00
|
|
|
int error = user_statfs(pathname, &linux_stat);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!error)
|
|
|
|
error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2011-08-26 18:06:29 +00:00
|
|
|
SYSCALL_DEFINE2(osf_stat, char __user *, name, struct osf_stat __user *, buf)
|
|
|
|
{
|
|
|
|
struct kstat stat;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = vfs_stat(name, &stat);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return linux_to_osf_stat(&stat, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE2(osf_lstat, char __user *, name, struct osf_stat __user *, buf)
|
|
|
|
{
|
|
|
|
struct kstat stat;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = vfs_lstat(name, &stat);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return linux_to_osf_stat(&stat, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE2(osf_fstat, int, fd, struct osf_stat __user *, buf)
|
|
|
|
{
|
|
|
|
struct kstat stat;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = vfs_fstat(fd, &stat);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return linux_to_osf_stat(&stat, buf);
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd,
|
|
|
|
struct osf_statfs __user *, buffer, unsigned long, bufsiz)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-03-12 15:41:39 +00:00
|
|
|
struct kstatfs linux_stat;
|
|
|
|
int error = fd_statfs(fd, &linux_stat);
|
|
|
|
if (!error)
|
|
|
|
error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
|
|
|
|
return error;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 18:06:29 +00:00
|
|
|
SYSCALL_DEFINE3(osf_statfs64, char __user *, pathname,
|
|
|
|
struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
|
|
|
|
{
|
|
|
|
struct kstatfs linux_stat;
|
|
|
|
int error = user_statfs(pathname, &linux_stat);
|
|
|
|
if (!error)
|
|
|
|
error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd,
|
|
|
|
struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
|
|
|
|
{
|
|
|
|
struct kstatfs linux_stat;
|
|
|
|
int error = fd_statfs(fd, &linux_stat);
|
|
|
|
if (!error)
|
|
|
|
error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Uhh.. OSF/1 mount parameters aren't exactly obvious..
|
|
|
|
*
|
|
|
|
* Although to be frank, neither are the native Linux/i386 ones..
|
|
|
|
*/
|
|
|
|
struct ufs_args {
|
|
|
|
char __user *devname;
|
|
|
|
int flags;
|
|
|
|
uid_t exroot;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cdfs_args {
|
|
|
|
char __user *devname;
|
|
|
|
int flags;
|
|
|
|
uid_t exroot;
|
|
|
|
|
|
|
|
/* This has lots more here, which Linux handles with the option block
|
|
|
|
but I'm too lazy to do the translation into ASCII. */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct procfs_args {
|
|
|
|
char __user *devname;
|
|
|
|
int flags;
|
|
|
|
uid_t exroot;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We can't actually handle ufs yet, so we translate UFS mounts to
|
|
|
|
* ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
|
|
|
|
* layout is so braindead it's a major headache doing it.
|
|
|
|
*
|
|
|
|
* Just how long ago was it written? OTOH our UFS driver may be still
|
|
|
|
* unhappy with OSF UFS. [CHECKME]
|
|
|
|
*/
|
|
|
|
static int
|
2014-09-14 13:15:10 +00:00
|
|
|
osf_ufs_mount(const char __user *dirname,
|
|
|
|
struct ufs_args __user *args, int flags)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
struct cdfs_args tmp;
|
2012-10-10 19:25:28 +00:00
|
|
|
struct filename *devname;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
retval = -EFAULT;
|
|
|
|
if (copy_from_user(&tmp, args, sizeof(tmp)))
|
|
|
|
goto out;
|
|
|
|
devname = getname(tmp.devname);
|
|
|
|
retval = PTR_ERR(devname);
|
|
|
|
if (IS_ERR(devname))
|
|
|
|
goto out;
|
2012-10-10 19:25:28 +00:00
|
|
|
retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
putname(devname);
|
|
|
|
out:
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-14 13:15:10 +00:00
|
|
|
osf_cdfs_mount(const char __user *dirname,
|
|
|
|
struct cdfs_args __user *args, int flags)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
struct cdfs_args tmp;
|
2012-10-10 19:25:28 +00:00
|
|
|
struct filename *devname;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
retval = -EFAULT;
|
|
|
|
if (copy_from_user(&tmp, args, sizeof(tmp)))
|
|
|
|
goto out;
|
|
|
|
devname = getname(tmp.devname);
|
|
|
|
retval = PTR_ERR(devname);
|
|
|
|
if (IS_ERR(devname))
|
|
|
|
goto out;
|
2012-10-10 19:25:28 +00:00
|
|
|
retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
putname(devname);
|
|
|
|
out:
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-14 13:15:10 +00:00
|
|
|
osf_procfs_mount(const char __user *dirname,
|
|
|
|
struct procfs_args __user *args, int flags)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct procfs_args tmp;
|
|
|
|
|
|
|
|
if (copy_from_user(&tmp, args, sizeof(tmp)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return do_mount("", dirname, "proc", flags, NULL);
|
|
|
|
}
|
|
|
|
|
2010-08-11 10:26:22 +00:00
|
|
|
SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
|
2009-01-29 22:25:18 +00:00
|
|
|
int, flag, void __user *, data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-03-05 21:42:28 +00:00
|
|
|
int retval;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
switch (typenr) {
|
|
|
|
case 1:
|
2014-09-14 13:15:10 +00:00
|
|
|
retval = osf_ufs_mount(path, data, flag);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2014-09-14 13:15:10 +00:00
|
|
|
retval = osf_cdfs_mount(path, data, flag);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 9:
|
2014-09-14 13:15:10 +00:00
|
|
|
retval = osf_procfs_mount(path, data, flag);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-03-05 21:42:28 +00:00
|
|
|
retval = -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
printk("osf_mount(%ld, %x)\n", typenr, flag);
|
|
|
|
}
|
2014-09-14 13:15:10 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE1(osf_utsname, char __user *, name)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-06-25 16:34:10 +00:00
|
|
|
char tmp[5 * 32];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
down_read(&uts_sem);
|
2018-06-25 16:34:10 +00:00
|
|
|
memcpy(tmp + 0 * 32, utsname()->sysname, 32);
|
|
|
|
memcpy(tmp + 1 * 32, utsname()->nodename, 32);
|
|
|
|
memcpy(tmp + 2 * 32, utsname()->release, 32);
|
|
|
|
memcpy(tmp + 3 * 32, utsname()->version, 32);
|
|
|
|
memcpy(tmp + 4 * 32, utsname()->machine, 32);
|
|
|
|
up_read(&uts_sem);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-06-25 16:34:10 +00:00
|
|
|
if (copy_to_user(name, tmp, sizeof(tmp)))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE0(getpagesize)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return PAGE_SIZE;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE0(getdtablesize)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-02-06 09:37:16 +00:00
|
|
|
return sysctl_nr_open;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For compatibility with OSF/1 only. Use utsname(2) instead.
|
|
|
|
*/
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-12-21 19:17:55 +00:00
|
|
|
int len;
|
2017-05-14 01:39:49 +00:00
|
|
|
char *kname;
|
2018-06-25 16:34:10 +00:00
|
|
|
char tmp[32];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-06-25 16:34:10 +00:00
|
|
|
if (namelen < 0 || namelen > 32)
|
2017-05-14 01:39:49 +00:00
|
|
|
namelen = 32;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
down_read(&uts_sem);
|
2017-05-14 01:39:49 +00:00
|
|
|
kname = utsname()->domainname;
|
|
|
|
len = strnlen(kname, namelen);
|
2018-06-25 16:34:10 +00:00
|
|
|
len = min(len + 1, namelen);
|
|
|
|
memcpy(tmp, kname, len);
|
2005-04-16 22:20:36 +00:00
|
|
|
up_read(&uts_sem);
|
|
|
|
|
2018-06-25 16:34:10 +00:00
|
|
|
if (copy_to_user(name, tmp, len))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following stuff should move into a header file should it ever
|
|
|
|
* be labeled "officially supported." Right now, there is just enough
|
|
|
|
* support to avoid applications (such as tar) printing error
|
|
|
|
* messages. The attributes are not really implemented.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Values for Property list entry flag
|
|
|
|
*/
|
|
|
|
#define PLE_PROPAGATE_ON_COPY 0x1 /* cp(1) will copy entry
|
|
|
|
by default */
|
|
|
|
#define PLE_FLAG_MASK 0x1 /* Valid flag values */
|
|
|
|
#define PLE_FLAG_ALL -1 /* All flag value */
|
|
|
|
|
|
|
|
struct proplistname_args {
|
|
|
|
unsigned int pl_mask;
|
|
|
|
unsigned int pl_numnames;
|
|
|
|
char **pl_names;
|
|
|
|
};
|
|
|
|
|
|
|
|
union pl_args {
|
|
|
|
struct setargs {
|
|
|
|
char __user *path;
|
|
|
|
long follow;
|
|
|
|
long nbytes;
|
|
|
|
char __user *buf;
|
|
|
|
} set;
|
|
|
|
struct fsetargs {
|
|
|
|
long fd;
|
|
|
|
long nbytes;
|
|
|
|
char __user *buf;
|
|
|
|
} fset;
|
|
|
|
struct getargs {
|
|
|
|
char __user *path;
|
|
|
|
long follow;
|
|
|
|
struct proplistname_args __user *name_args;
|
|
|
|
long nbytes;
|
|
|
|
char __user *buf;
|
|
|
|
int __user *min_buf_size;
|
|
|
|
} get;
|
|
|
|
struct fgetargs {
|
|
|
|
long fd;
|
|
|
|
struct proplistname_args __user *name_args;
|
|
|
|
long nbytes;
|
|
|
|
char __user *buf;
|
|
|
|
int __user *min_buf_size;
|
|
|
|
} fget;
|
|
|
|
struct delargs {
|
|
|
|
char __user *path;
|
|
|
|
long follow;
|
|
|
|
struct proplistname_args __user *name_args;
|
|
|
|
} del;
|
|
|
|
struct fdelargs {
|
|
|
|
long fd;
|
|
|
|
struct proplistname_args __user *name_args;
|
|
|
|
} fdel;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum pl_code {
|
|
|
|
PL_SET = 1, PL_FSET = 2,
|
|
|
|
PL_GET = 3, PL_FGET = 4,
|
|
|
|
PL_DEL = 5, PL_FDEL = 6
|
|
|
|
};
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
|
|
|
|
union pl_args __user *, args)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
long error;
|
|
|
|
int __user *min_buf_size_ptr;
|
|
|
|
|
|
|
|
switch (code) {
|
|
|
|
case PL_SET:
|
|
|
|
if (get_user(error, &args->set.nbytes))
|
|
|
|
error = -EFAULT;
|
|
|
|
break;
|
|
|
|
case PL_FSET:
|
|
|
|
if (get_user(error, &args->fset.nbytes))
|
|
|
|
error = -EFAULT;
|
|
|
|
break;
|
|
|
|
case PL_GET:
|
|
|
|
error = get_user(min_buf_size_ptr, &args->get.min_buf_size);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
error = put_user(0, min_buf_size_ptr);
|
|
|
|
break;
|
|
|
|
case PL_FGET:
|
|
|
|
error = get_user(min_buf_size_ptr, &args->fget.min_buf_size);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
error = put_user(0, min_buf_size_ptr);
|
|
|
|
break;
|
|
|
|
case PL_DEL:
|
|
|
|
case PL_FDEL:
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_sigstack, struct sigstack __user *, uss,
|
|
|
|
struct sigstack __user *, uoss)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned long usp = rdusp();
|
|
|
|
unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size;
|
|
|
|
unsigned long oss_os = on_sig_stack(usp);
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (uss) {
|
|
|
|
void __user *ss_sp;
|
|
|
|
|
|
|
|
error = -EFAULT;
|
|
|
|
if (get_user(ss_sp, &uss->ss_sp))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* If the current stack was set with sigaltstack, don't
|
|
|
|
swap stacks while we are on it. */
|
|
|
|
error = -EPERM;
|
|
|
|
if (current->sas_ss_sp && on_sig_stack(usp))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Since we don't know the extent of the stack, and we don't
|
|
|
|
track onstack-ness, but rather calculate it, we must
|
|
|
|
presume a size. Ho hum this interface is lossy. */
|
|
|
|
current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
|
|
|
|
current->sas_ss_size = SIGSTKSZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uoss) {
|
|
|
|
error = -EFAULT;
|
2017-05-27 20:38:39 +00:00
|
|
|
if (put_user(oss_sp, &uoss->ss_sp) ||
|
|
|
|
put_user(oss_os, &uoss->ss_onstack))
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-09-14 08:23:47 +00:00
|
|
|
const char *sysinfo_table[] = {
|
2006-10-02 09:18:11 +00:00
|
|
|
utsname()->sysname,
|
|
|
|
utsname()->nodename,
|
|
|
|
utsname()->release,
|
|
|
|
utsname()->version,
|
|
|
|
utsname()->machine,
|
2005-04-16 22:20:36 +00:00
|
|
|
"alpha", /* instruction set architecture */
|
|
|
|
"dummy", /* hardware serial number */
|
|
|
|
"dummy", /* hardware manufacturer */
|
|
|
|
"dummy", /* secure RPC domain */
|
|
|
|
};
|
|
|
|
unsigned long offset;
|
2010-09-14 08:23:47 +00:00
|
|
|
const char *res;
|
2018-06-25 16:34:10 +00:00
|
|
|
long len;
|
|
|
|
char tmp[__NEW_UTS_LEN + 1];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
offset = command-1;
|
2006-07-30 10:03:23 +00:00
|
|
|
if (offset >= ARRAY_SIZE(sysinfo_table)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Digital UNIX has a few unpublished interfaces here */
|
|
|
|
printk("sysinfo(%d)", command);
|
2018-06-25 16:34:10 +00:00
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2006-07-30 10:03:23 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
down_read(&uts_sem);
|
|
|
|
res = sysinfo_table[offset];
|
|
|
|
len = strlen(res)+1;
|
2011-06-15 22:09:01 +00:00
|
|
|
if ((unsigned long)len > (unsigned long)count)
|
2005-04-16 22:20:36 +00:00
|
|
|
len = count;
|
2018-06-25 16:34:10 +00:00
|
|
|
memcpy(tmp, res, len);
|
2005-04-16 22:20:36 +00:00
|
|
|
up_read(&uts_sem);
|
2018-06-25 16:34:10 +00:00
|
|
|
if (copy_to_user(buf, tmp, len))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
|
|
|
|
unsigned long, nbytes, int __user *, start, void __user *, arg)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned long w;
|
|
|
|
struct percpu_struct *cpu;
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case GSI_IEEE_FP_CONTROL:
|
|
|
|
/* Return current software fp control & status bits. */
|
|
|
|
/* Note that DU doesn't verify available space here. */
|
|
|
|
|
|
|
|
w = current_thread_info()->ieee_state & IEEE_SW_MASK;
|
|
|
|
w = swcr_update_status(w, rdfpcr());
|
|
|
|
if (put_user(w, (unsigned long __user *) buffer))
|
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case GSI_IEEE_STATE_AT_SIGNAL:
|
|
|
|
/*
|
|
|
|
* Not sure anybody will ever use this weird stuff. These
|
|
|
|
* ops can be used (under OSF/1) to set the fpcr that should
|
|
|
|
* be used when a signal handler starts executing.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSI_UACPROC:
|
|
|
|
if (nbytes < sizeof(unsigned int))
|
|
|
|
return -EINVAL;
|
2012-10-20 14:52:23 +00:00
|
|
|
w = current_thread_info()->status & UAC_BITMASK;
|
alpha: unbreak osf_setsysinfo(SSI_NVPAIRS, [SSIN_UACPROC, UAC_SIGBUS])
The bug was accidentally found by the following program:
#include <asm/sysinfo.h>
#include <asm/unistd.h>
#include <sys/syscall.h>
static int setsysinfo(unsigned long op, void *buffer, unsigned long size,
int *start, void *arg, unsigned long flag) {
return syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);
}
int main(int argc, char **argv) {
short x[10];
unsigned int buf[2] = { SSIN_UACPROC, UAC_SIGBUS, };
setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);
int *y = (int*) (x+1);
*y = 0;
return 0;
}
The program shoud fail on SIGBUS, but didn't.
The patch is a second part of userspace flag fix (commit 745dd2405e28
"Alpha: Rearrange thread info flags fixing two regressions").
Deleted outdated out-of-sync 'UAC_SHIFT' (the cause of bug) in favour of
'ALPHA_UAC_SHIFT'.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Acked-by: Michael Cree <mcree@orcon.net.nz>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-08-25 22:59:02 +00:00
|
|
|
if (put_user(w, (unsigned int __user *)buffer))
|
|
|
|
return -EFAULT;
|
2005-04-16 22:20:36 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
case GSI_PROC_TYPE:
|
|
|
|
if (nbytes < sizeof(unsigned long))
|
|
|
|
return -EINVAL;
|
|
|
|
cpu = (struct percpu_struct*)
|
|
|
|
((char*)hwrpb + hwrpb->processor_offset);
|
|
|
|
w = cpu->type;
|
|
|
|
if (put_user(w, (unsigned long __user*)buffer))
|
|
|
|
return -EFAULT;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case GSI_GET_HWRPB:
|
2011-06-15 22:09:01 +00:00
|
|
|
if (nbytes > sizeof(*hwrpb))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
if (copy_to_user(buffer, hwrpb, nbytes) != 0)
|
|
|
|
return -EFAULT;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
|
|
|
|
unsigned long, nbytes, int __user *, start, void __user *, arg)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case SSI_IEEE_FP_CONTROL: {
|
|
|
|
unsigned long swcr, fpcr;
|
|
|
|
unsigned int *state;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Alpha Architecture Handbook 4.7.7.3:
|
|
|
|
* To be fully IEEE compiant, we must track the current IEEE
|
2007-10-19 23:04:37 +00:00
|
|
|
* exception state in software, because spurious bits can be
|
2005-04-16 22:20:36 +00:00
|
|
|
* set in the trap shadow of a software-complete insn.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (get_user(swcr, (unsigned long __user *)buffer))
|
|
|
|
return -EFAULT;
|
|
|
|
state = ¤t_thread_info()->ieee_state;
|
|
|
|
|
|
|
|
/* Update softare trap enable bits. */
|
|
|
|
*state = (*state & ~IEEE_SW_MASK) | (swcr & IEEE_SW_MASK);
|
|
|
|
|
|
|
|
/* Update the real fpcr. */
|
|
|
|
fpcr = rdfpcr() & FPCR_DYN_MASK;
|
|
|
|
fpcr |= ieee_swcr_to_fpcr(swcr);
|
|
|
|
wrfpcr(fpcr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SSI_IEEE_RAISE_EXCEPTION: {
|
|
|
|
unsigned long exc, swcr, fpcr, fex;
|
|
|
|
unsigned int *state;
|
|
|
|
|
|
|
|
if (get_user(exc, (unsigned long __user *)buffer))
|
|
|
|
return -EFAULT;
|
|
|
|
state = ¤t_thread_info()->ieee_state;
|
|
|
|
exc &= IEEE_STATUS_MASK;
|
|
|
|
|
|
|
|
/* Update softare trap enable bits. */
|
|
|
|
swcr = (*state & IEEE_SW_MASK) | exc;
|
|
|
|
*state |= exc;
|
|
|
|
|
|
|
|
/* Update the real fpcr. */
|
|
|
|
fpcr = rdfpcr();
|
|
|
|
fpcr |= ieee_swcr_to_fpcr(swcr);
|
|
|
|
wrfpcr(fpcr);
|
|
|
|
|
|
|
|
/* If any exceptions set by this call, and are unmasked,
|
|
|
|
send a signal. Old exceptions are not signaled. */
|
|
|
|
fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr;
|
|
|
|
if (fex) {
|
2018-04-17 21:04:57 +00:00
|
|
|
int si_code = FPE_FLTUNK;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND;
|
|
|
|
if (fex & IEEE_TRAP_ENABLE_INE) si_code = FPE_FLTRES;
|
|
|
|
if (fex & IEEE_TRAP_ENABLE_UNF) si_code = FPE_FLTUND;
|
|
|
|
if (fex & IEEE_TRAP_ENABLE_OVF) si_code = FPE_FLTOVF;
|
|
|
|
if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
|
|
|
|
if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
|
|
|
|
|
2018-04-17 22:37:49 +00:00
|
|
|
send_sig_fault(SIGFPE, si_code,
|
|
|
|
(void __user *)NULL, /* FIXME */
|
|
|
|
0, current);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SSI_IEEE_STATE_AT_SIGNAL:
|
|
|
|
case SSI_IEEE_IGNORE_STATE_AT_SIGNAL:
|
|
|
|
/*
|
|
|
|
* Not sure anybody will ever use this weird stuff. These
|
|
|
|
* ops can be used (under OSF/1) to set the fpcr that should
|
|
|
|
* be used when a signal handler starts executing.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SSI_NVPAIRS: {
|
2012-10-20 14:52:23 +00:00
|
|
|
unsigned __user *p = buffer;
|
|
|
|
unsigned i;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-10-20 14:52:23 +00:00
|
|
|
for (i = 0, p = buffer; i < nbytes; ++i, p += 2) {
|
|
|
|
unsigned v, w, status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-10-20 14:52:23 +00:00
|
|
|
if (get_user(v, p) || get_user(w, p + 1))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
|
|
|
switch (v) {
|
|
|
|
case SSIN_UACPROC:
|
2012-10-20 14:52:23 +00:00
|
|
|
w &= UAC_BITMASK;
|
|
|
|
status = current_thread_info()->status;
|
|
|
|
status = (status & ~UAC_BITMASK) | w;
|
|
|
|
current_thread_info()->status = status;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-26 17:52:14 +00:00
|
|
|
case SSI_LMF:
|
|
|
|
return 0;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translations due to the fact that OSF's time_t is an int. Which
|
|
|
|
affects all sorts of things, like timeval and itimerval. */
|
|
|
|
|
|
|
|
extern struct timezone sys_tz;
|
|
|
|
|
|
|
|
struct timeval32
|
|
|
|
{
|
|
|
|
int tv_sec, tv_usec;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct itimerval32
|
|
|
|
{
|
|
|
|
struct timeval32 it_interval;
|
|
|
|
struct timeval32 it_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline long
|
2017-11-08 15:02:14 +00:00
|
|
|
get_tv32(struct timespec64 *o, struct timeval32 __user *i)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-27 20:36:12 +00:00
|
|
|
struct timeval32 tv;
|
|
|
|
if (copy_from_user(&tv, i, sizeof(struct timeval32)))
|
|
|
|
return -EFAULT;
|
|
|
|
o->tv_sec = tv.tv_sec;
|
2017-11-08 15:02:14 +00:00
|
|
|
o->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
|
2017-05-27 20:36:12 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline long
|
2017-11-08 15:02:14 +00:00
|
|
|
put_tv32(struct timeval32 __user *o, struct timespec64 *i)
|
|
|
|
{
|
|
|
|
return copy_to_user(o, &(struct timeval32){
|
|
|
|
.tv_sec = i->tv_sec,
|
|
|
|
.tv_usec = i->tv_nsec / NSEC_PER_USEC},
|
|
|
|
sizeof(struct timeval32));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long
|
|
|
|
put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-27 20:36:12 +00:00
|
|
|
return copy_to_user(o, &(struct timeval32){
|
2017-11-08 15:02:13 +00:00
|
|
|
.tv_sec = i->tv_sec,
|
|
|
|
.tv_usec = i->tv_usec},
|
2017-05-27 20:36:12 +00:00
|
|
|
sizeof(struct timeval32));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline long
|
|
|
|
get_it32(struct itimerval *o, struct itimerval32 __user *i)
|
|
|
|
{
|
2017-05-27 20:36:12 +00:00
|
|
|
struct itimerval32 itv;
|
|
|
|
if (copy_from_user(&itv, i, sizeof(struct itimerval32)))
|
|
|
|
return -EFAULT;
|
|
|
|
o->it_interval.tv_sec = itv.it_interval.tv_sec;
|
|
|
|
o->it_interval.tv_usec = itv.it_interval.tv_usec;
|
|
|
|
o->it_value.tv_sec = itv.it_value.tv_sec;
|
|
|
|
o->it_value.tv_usec = itv.it_value.tv_usec;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline long
|
|
|
|
put_it32(struct itimerval32 __user *o, struct itimerval *i)
|
|
|
|
{
|
2017-05-27 20:36:12 +00:00
|
|
|
return copy_to_user(o, &(struct itimerval32){
|
|
|
|
.it_interval.tv_sec = o->it_interval.tv_sec,
|
|
|
|
.it_interval.tv_usec = o->it_interval.tv_usec,
|
|
|
|
.it_value.tv_sec = o->it_value.tv_sec,
|
|
|
|
.it_value.tv_usec = o->it_value.tv_usec},
|
|
|
|
sizeof(struct itimerval32));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
|
|
|
|
{
|
|
|
|
value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
|
|
|
|
value->tv_sec = jiffies / HZ;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
|
|
|
|
struct timezone __user *, tz)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if (tv) {
|
2017-11-08 15:02:14 +00:00
|
|
|
struct timespec64 kts;
|
|
|
|
|
|
|
|
ktime_get_real_ts64(&kts);
|
|
|
|
if (put_tv32(tv, &kts))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
if (tz) {
|
|
|
|
if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
|
|
|
|
struct timezone __user *, tz)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-11-08 15:02:14 +00:00
|
|
|
struct timespec64 kts;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct timezone ktz;
|
|
|
|
|
|
|
|
if (tv) {
|
2017-11-08 15:02:14 +00:00
|
|
|
if (get_tv32(&kts, tv))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
if (tz) {
|
|
|
|
if (copy_from_user(&ktz, tz, sizeof(*tz)))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2017-11-08 15:02:14 +00:00
|
|
|
return do_sys_settimeofday64(tv ? &kts : NULL, tz ? &ktz : NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
posix-timers: Make them configurable
Some embedded systems have no use for them. This removes about
25KB from the kernel binary size when configured out.
Corresponding syscalls are routed to a stub logging the attempt to
use those syscalls which should be enough of a clue if they were
disabled without proper consideration. They are: timer_create,
timer_gettime: timer_getoverrun, timer_settime, timer_delete,
clock_adjtime, setitimer, getitimer, alarm.
The clock_settime, clock_gettime, clock_getres and clock_nanosleep
syscalls are replaced by simple wrappers compatible with CLOCK_REALTIME,
CLOCK_MONOTONIC and CLOCK_BOOTTIME only which should cover the vast
majority of use cases with very little code.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Cc: Paul Bolle <pebolle@tiscali.nl>
Cc: linux-kbuild@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: Michal Marek <mmarek@suse.com>
Cc: Edward Cree <ecree@solarflare.com>
Link: http://lkml.kernel.org/r/1478841010-28605-7-git-send-email-nicolas.pitre@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2016-11-11 05:10:10 +00:00
|
|
|
asmlinkage long sys_ni_posix_timers(void);
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct itimerval kit;
|
|
|
|
int error;
|
|
|
|
|
posix-timers: Make them configurable
Some embedded systems have no use for them. This removes about
25KB from the kernel binary size when configured out.
Corresponding syscalls are routed to a stub logging the attempt to
use those syscalls which should be enough of a clue if they were
disabled without proper consideration. They are: timer_create,
timer_gettime: timer_getoverrun, timer_settime, timer_delete,
clock_adjtime, setitimer, getitimer, alarm.
The clock_settime, clock_gettime, clock_getres and clock_nanosleep
syscalls are replaced by simple wrappers compatible with CLOCK_REALTIME,
CLOCK_MONOTONIC and CLOCK_BOOTTIME only which should cover the vast
majority of use cases with very little code.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Cc: Paul Bolle <pebolle@tiscali.nl>
Cc: linux-kbuild@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: Michal Marek <mmarek@suse.com>
Cc: Edward Cree <ecree@solarflare.com>
Link: http://lkml.kernel.org/r/1478841010-28605-7-git-send-email-nicolas.pitre@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2016-11-11 05:10:10 +00:00
|
|
|
if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
|
|
|
|
return sys_ni_posix_timers();
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
error = do_getitimer(which, &kit);
|
|
|
|
if (!error && put_it32(it, &kit))
|
|
|
|
error = -EFAULT;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
|
|
|
|
struct itimerval32 __user *, out)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct itimerval kin, kout;
|
|
|
|
int error;
|
|
|
|
|
posix-timers: Make them configurable
Some embedded systems have no use for them. This removes about
25KB from the kernel binary size when configured out.
Corresponding syscalls are routed to a stub logging the attempt to
use those syscalls which should be enough of a clue if they were
disabled without proper consideration. They are: timer_create,
timer_gettime: timer_getoverrun, timer_settime, timer_delete,
clock_adjtime, setitimer, getitimer, alarm.
The clock_settime, clock_gettime, clock_getres and clock_nanosleep
syscalls are replaced by simple wrappers compatible with CLOCK_REALTIME,
CLOCK_MONOTONIC and CLOCK_BOOTTIME only which should cover the vast
majority of use cases with very little code.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Cc: Paul Bolle <pebolle@tiscali.nl>
Cc: linux-kbuild@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: Michal Marek <mmarek@suse.com>
Cc: Edward Cree <ecree@solarflare.com>
Link: http://lkml.kernel.org/r/1478841010-28605-7-git-send-email-nicolas.pitre@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2016-11-11 05:10:10 +00:00
|
|
|
if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
|
|
|
|
return sys_ni_posix_timers();
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (in) {
|
|
|
|
if (get_it32(&kin, in))
|
|
|
|
return -EFAULT;
|
|
|
|
} else
|
|
|
|
memset(&kin, 0, sizeof(kin));
|
|
|
|
|
|
|
|
error = do_setitimer(which, &kin, out ? &kout : NULL);
|
|
|
|
if (error || !out)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if (put_it32(out, &kout))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-11 10:26:22 +00:00
|
|
|
SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
|
2009-01-29 22:25:18 +00:00
|
|
|
struct timeval32 __user *, tvs)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-11-08 15:02:14 +00:00
|
|
|
struct timespec64 tv[2];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (tvs) {
|
2017-11-08 15:02:14 +00:00
|
|
|
if (get_tv32(&tv[0], &tvs[0]) ||
|
|
|
|
get_tv32(&tv[1], &tvs[1]))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
utimensat implementation
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines
of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to
accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime
which already use do_utimes instead of duplicating the work.
Also, the completely missing futimensat() functionality is added. We have
such a function in glibc but we have to resort to using /proc/self/fd/* which
not everybody likes (chroot etc).
Test application (the syscall number will need per-arch editing):
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <stddef.h>
#include <syscall.h>
#define __NR_utimensat 280
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
int
main(void)
{
int status = 0;
int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
error (1, errno, "failed to create test file \"ttt\"");
struct stat64 st1;
if (fstat64 (fd, &st1) != 0)
error (1, errno, "fstat failed");
struct timespec t[2];
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
struct stat64 st2;
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0] = st1.st_atim;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_OMIT;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("atim not set");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim changed from zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_OMIT;
t[1] = st1.st_mtim;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("mtim changed from original time");
status = 1;
}
if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
|| st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
{
puts ("mtim not set");
status = 1;
}
if (status != 0)
goto out;
sleep (2);
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_NOW;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_NOW;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
struct timeval tv;
gettimeofday(&tv,NULL);
if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
|| st2.st_atim.tv_sec > tv.tv_sec)
{
puts ("atim not set to NOW");
status = 1;
}
if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
|| st2.st_mtim.tv_sec > tv.tv_sec)
{
puts ("mtim not set to NOW");
status = 1;
}
if (symlink ("ttt", "tttsym") != 0)
error (1, errno, "cannot create symlink");
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
error (1, errno, "utimensat failed");
if (lstat64 ("tttsym", &st2) != 0)
error (1, errno, "lstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("symlink atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("symlink mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 1;
t[0].tv_nsec = 0;
t[1].tv_sec = 1;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to one");
status = 1;
}
if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to one");
status = 1;
}
if (status == 0)
puts ("all OK");
out:
close (fd);
unlink ("ttt");
unlink ("tttsym");
return status;
}
[akpm@linux-foundation.org: add missing i386 syscall table entry]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 07:33:25 +00:00
|
|
|
|
2017-11-08 15:02:14 +00:00
|
|
|
if (tv[0].tv_nsec < 0 || tv[0].tv_nsec >= 1000000000 ||
|
|
|
|
tv[1].tv_nsec < 0 || tv[1].tv_nsec >= 1000000000)
|
utimensat implementation
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines
of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to
accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime
which already use do_utimes instead of duplicating the work.
Also, the completely missing futimensat() functionality is added. We have
such a function in glibc but we have to resort to using /proc/self/fd/* which
not everybody likes (chroot etc).
Test application (the syscall number will need per-arch editing):
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <stddef.h>
#include <syscall.h>
#define __NR_utimensat 280
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
int
main(void)
{
int status = 0;
int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
error (1, errno, "failed to create test file \"ttt\"");
struct stat64 st1;
if (fstat64 (fd, &st1) != 0)
error (1, errno, "fstat failed");
struct timespec t[2];
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
struct stat64 st2;
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0] = st1.st_atim;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_OMIT;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("atim not set");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim changed from zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_OMIT;
t[1] = st1.st_mtim;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("mtim changed from original time");
status = 1;
}
if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
|| st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
{
puts ("mtim not set");
status = 1;
}
if (status != 0)
goto out;
sleep (2);
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_NOW;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_NOW;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
struct timeval tv;
gettimeofday(&tv,NULL);
if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
|| st2.st_atim.tv_sec > tv.tv_sec)
{
puts ("atim not set to NOW");
status = 1;
}
if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
|| st2.st_mtim.tv_sec > tv.tv_sec)
{
puts ("mtim not set to NOW");
status = 1;
}
if (symlink ("ttt", "tttsym") != 0)
error (1, errno, "cannot create symlink");
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
error (1, errno, "utimensat failed");
if (lstat64 ("tttsym", &st2) != 0)
error (1, errno, "lstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("symlink atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("symlink mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 1;
t[0].tv_nsec = 0;
t[1].tv_sec = 1;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to one");
status = 1;
}
if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to one");
status = 1;
}
if (status == 0)
puts ("all OK");
out:
close (fd);
unlink ("ttt");
unlink ("tttsym");
return status;
}
[akpm@linux-foundation.org: add missing i386 syscall table entry]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 07:33:25 +00:00
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
utimensat implementation
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines
of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to
accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime
which already use do_utimes instead of duplicating the work.
Also, the completely missing futimensat() functionality is added. We have
such a function in glibc but we have to resort to using /proc/self/fd/* which
not everybody likes (chroot etc).
Test application (the syscall number will need per-arch editing):
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <stddef.h>
#include <syscall.h>
#define __NR_utimensat 280
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
int
main(void)
{
int status = 0;
int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
error (1, errno, "failed to create test file \"ttt\"");
struct stat64 st1;
if (fstat64 (fd, &st1) != 0)
error (1, errno, "fstat failed");
struct timespec t[2];
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
struct stat64 st2;
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0] = st1.st_atim;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_OMIT;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("atim not set");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim changed from zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_OMIT;
t[1] = st1.st_mtim;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("mtim changed from original time");
status = 1;
}
if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
|| st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
{
puts ("mtim not set");
status = 1;
}
if (status != 0)
goto out;
sleep (2);
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_NOW;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_NOW;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
struct timeval tv;
gettimeofday(&tv,NULL);
if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
|| st2.st_atim.tv_sec > tv.tv_sec)
{
puts ("atim not set to NOW");
status = 1;
}
if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
|| st2.st_mtim.tv_sec > tv.tv_sec)
{
puts ("mtim not set to NOW");
status = 1;
}
if (symlink ("ttt", "tttsym") != 0)
error (1, errno, "cannot create symlink");
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
error (1, errno, "utimensat failed");
if (lstat64 ("tttsym", &st2) != 0)
error (1, errno, "lstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("symlink atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("symlink mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 1;
t[0].tv_nsec = 0;
t[1].tv_sec = 1;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to one");
status = 1;
}
if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to one");
status = 1;
}
if (status == 0)
puts ("all OK");
out:
close (fd);
unlink ("ttt");
unlink ("tttsym");
return status;
}
[akpm@linux-foundation.org: add missing i386 syscall table entry]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 07:33:25 +00:00
|
|
|
return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,
|
|
|
|
fd_set __user *, exp, struct timeval32 __user *, tvp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-11-08 15:02:14 +00:00
|
|
|
struct timespec64 end_time, *to = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (tvp) {
|
2017-11-08 15:02:14 +00:00
|
|
|
struct timespec64 tv;
|
2008-10-06 20:01:53 +00:00
|
|
|
to = &end_time;
|
|
|
|
|
2017-05-27 20:36:12 +00:00
|
|
|
if (get_tv32(&tv, tvp))
|
2008-04-23 18:05:15 +00:00
|
|
|
return -EFAULT;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-11-08 15:02:14 +00:00
|
|
|
if (tv.tv_sec < 0 || tv.tv_nsec < 0)
|
2008-04-23 18:05:15 +00:00
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-11-08 15:02:14 +00:00
|
|
|
if (poll_select_set_timeout(to, tv.tv_sec, tv.tv_nsec))
|
2008-10-06 20:01:53 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* OSF does not copy back the remaining time. */
|
2008-10-06 20:01:53 +00:00
|
|
|
return core_sys_select(n, inp, outp, exp, to);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct rusage32 {
|
|
|
|
struct timeval32 ru_utime; /* user time used */
|
|
|
|
struct timeval32 ru_stime; /* system time used */
|
|
|
|
long ru_maxrss; /* maximum resident set size */
|
|
|
|
long ru_ixrss; /* integral shared memory size */
|
|
|
|
long ru_idrss; /* integral unshared data size */
|
|
|
|
long ru_isrss; /* integral unshared stack size */
|
|
|
|
long ru_minflt; /* page reclaims */
|
|
|
|
long ru_majflt; /* page faults */
|
|
|
|
long ru_nswap; /* swaps */
|
|
|
|
long ru_inblock; /* block input operations */
|
|
|
|
long ru_oublock; /* block output operations */
|
|
|
|
long ru_msgsnd; /* messages sent */
|
|
|
|
long ru_msgrcv; /* messages received */
|
|
|
|
long ru_nsignals; /* signals received */
|
|
|
|
long ru_nvcsw; /* voluntary context switches */
|
|
|
|
long ru_nivcsw; /* involuntary " */
|
|
|
|
};
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct rusage32 r;
|
2017-01-31 03:09:24 +00:00
|
|
|
u64 utime, stime;
|
2014-10-27 16:20:35 +00:00
|
|
|
unsigned long utime_jiffies, stime_jiffies;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memset(&r, 0, sizeof(r));
|
|
|
|
switch (who) {
|
|
|
|
case RUSAGE_SELF:
|
2017-01-31 03:09:24 +00:00
|
|
|
task_cputime(current, &utime, &stime);
|
|
|
|
utime_jiffies = nsecs_to_jiffies(utime);
|
|
|
|
stime_jiffies = nsecs_to_jiffies(stime);
|
2014-10-27 16:20:35 +00:00
|
|
|
jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
|
|
|
|
jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
|
2005-04-16 22:20:36 +00:00
|
|
|
r.ru_minflt = current->min_flt;
|
|
|
|
r.ru_majflt = current->maj_flt;
|
|
|
|
break;
|
|
|
|
case RUSAGE_CHILDREN:
|
2017-01-31 03:09:23 +00:00
|
|
|
utime_jiffies = nsecs_to_jiffies(current->signal->cutime);
|
|
|
|
stime_jiffies = nsecs_to_jiffies(current->signal->cstime);
|
2014-10-27 16:20:35 +00:00
|
|
|
jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
|
|
|
|
jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
|
2005-04-16 22:20:36 +00:00
|
|
|
r.ru_minflt = current->signal->cmin_flt;
|
|
|
|
r.ru_majflt = current->signal->cmaj_flt;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
|
|
|
|
struct rusage32 __user *, ur)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-15 03:54:33 +00:00
|
|
|
struct rusage r;
|
2018-07-22 14:07:11 +00:00
|
|
|
long err = kernel_wait4(pid, ustatus, options, &r);
|
2017-05-15 03:54:33 +00:00
|
|
|
if (err <= 0)
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!ur)
|
2017-05-15 03:54:33 +00:00
|
|
|
return err;
|
2017-11-08 15:02:14 +00:00
|
|
|
if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
2017-11-08 15:02:14 +00:00
|
|
|
if (put_tv_to_tv32(&ur->ru_stime, &r.ru_stime))
|
2017-05-15 03:54:33 +00:00
|
|
|
return -EFAULT;
|
|
|
|
if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss,
|
|
|
|
sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss)))
|
|
|
|
return -EFAULT;
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* I don't know what the parameters are: the first one
|
|
|
|
* seems to be a timeval pointer, and I suspect the second
|
|
|
|
* one is the time remaining.. Ho humm.. No documentation.
|
|
|
|
*/
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep,
|
|
|
|
struct timeval32 __user *, remain)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-11-08 15:02:14 +00:00
|
|
|
struct timespec64 tmp;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long ticks;
|
|
|
|
|
|
|
|
if (get_tv32(&tmp, sleep))
|
|
|
|
goto fault;
|
|
|
|
|
2017-11-08 15:02:14 +00:00
|
|
|
ticks = timespec64_to_jiffies(&tmp);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-10 07:27:25 +00:00
|
|
|
ticks = schedule_timeout_interruptible(ticks);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (remain) {
|
2017-11-08 15:02:14 +00:00
|
|
|
jiffies_to_timespec64(ticks, &tmp);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (put_tv32(remain, &tmp))
|
|
|
|
goto fault;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
fault:
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct timex32 {
|
|
|
|
unsigned int modes; /* mode selector */
|
|
|
|
long offset; /* time offset (usec) */
|
|
|
|
long freq; /* frequency offset (scaled ppm) */
|
|
|
|
long maxerror; /* maximum error (usec) */
|
|
|
|
long esterror; /* estimated error (usec) */
|
|
|
|
int status; /* clock command/status */
|
|
|
|
long constant; /* pll time constant */
|
|
|
|
long precision; /* clock precision (usec) (read only) */
|
|
|
|
long tolerance; /* clock frequency tolerance (ppm)
|
|
|
|
* (read only)
|
|
|
|
*/
|
|
|
|
struct timeval32 time; /* (read only) */
|
|
|
|
long tick; /* (modified) usecs between clock ticks */
|
|
|
|
|
|
|
|
long ppsfreq; /* pps frequency (scaled ppm) (ro) */
|
|
|
|
long jitter; /* pps jitter (us) (ro) */
|
|
|
|
int shift; /* interval duration (s) (shift) (ro) */
|
|
|
|
long stabil; /* pps stability (scaled ppm) (ro) */
|
|
|
|
long jitcnt; /* jitter limit exceeded (ro) */
|
|
|
|
long calcnt; /* calibration intervals (ro) */
|
|
|
|
long errcnt; /* calibration errors (ro) */
|
|
|
|
long stbcnt; /* stability limit exceeded (ro) */
|
|
|
|
|
|
|
|
int :32; int :32; int :32; int :32;
|
|
|
|
int :32; int :32; int :32; int :32;
|
|
|
|
int :32; int :32; int :32; int :32;
|
|
|
|
};
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct timex txc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* copy relevant bits of struct timex. */
|
|
|
|
if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) ||
|
|
|
|
copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) -
|
2017-03-25 04:43:43 +00:00
|
|
|
offsetof(struct timex32, tick)))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
ret = do_adjtimex(&txc);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* copy back to timex32 */
|
|
|
|
if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
|
|
|
|
(copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) -
|
|
|
|
offsetof(struct timex32, tick))) ||
|
2017-11-08 15:02:14 +00:00
|
|
|
(put_tv_to_tv32(&txc_p->time, &txc.time)))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get an address range which is currently unmapped. Similar to the
|
|
|
|
generic version except that we know how to honor ADDR_LIMIT_32BIT. */
|
|
|
|
|
|
|
|
static unsigned long
|
|
|
|
arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
|
|
|
|
unsigned long limit)
|
|
|
|
{
|
2013-02-22 00:43:01 +00:00
|
|
|
struct vm_unmapped_area_info info;
|
|
|
|
|
|
|
|
info.flags = 0;
|
|
|
|
info.length = len;
|
|
|
|
info.low_limit = addr;
|
|
|
|
info.high_limit = limit;
|
|
|
|
info.align_mask = 0;
|
|
|
|
info.align_offset = 0;
|
|
|
|
return vm_unmapped_area(&info);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long
|
|
|
|
arch_get_unmapped_area(struct file *filp, unsigned long addr,
|
|
|
|
unsigned long len, unsigned long pgoff,
|
|
|
|
unsigned long flags)
|
|
|
|
{
|
|
|
|
unsigned long limit;
|
|
|
|
|
|
|
|
/* "32 bit" actually means 31 bit, since pointers sign extend. */
|
|
|
|
if (current->personality & ADDR_LIMIT_32BIT)
|
|
|
|
limit = 0x80000000;
|
|
|
|
else
|
|
|
|
limit = TASK_SIZE;
|
|
|
|
|
|
|
|
if (len > limit)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-05-06 21:50:06 +00:00
|
|
|
if (flags & MAP_FIXED)
|
|
|
|
return addr;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* First, see if the given suggestion fits.
|
|
|
|
|
|
|
|
The OSF/1 loader (/sbin/loader) relies on us returning an
|
|
|
|
address larger than the requested if one exists, which is
|
|
|
|
a terribly broken way to program.
|
|
|
|
|
|
|
|
That said, I can see the use in being able to suggest not
|
|
|
|
merely specific addresses, but regions of memory -- perhaps
|
|
|
|
this feature should be incorporated into all ports? */
|
|
|
|
|
|
|
|
if (addr) {
|
|
|
|
addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
|
|
|
|
if (addr != (unsigned long) -ENOMEM)
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Next, try allocating at TASK_UNMAPPED_BASE. */
|
|
|
|
addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
|
|
|
|
len, limit);
|
|
|
|
if (addr != (unsigned long) -ENOMEM)
|
|
|
|
return addr;
|
|
|
|
|
|
|
|
/* Finally, try allocating in low memory. */
|
|
|
|
addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_OSF4_COMPAT
|
|
|
|
/* Clear top 32 bits of iov_len in the user's buffer for
|
|
|
|
compatibility with old versions of OSF/1 where iov_len
|
|
|
|
was defined as int. */
|
|
|
|
static int
|
|
|
|
osf_fix_iov_len(const struct iovec __user *iov, unsigned long count)
|
|
|
|
{
|
|
|
|
unsigned long i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < count ; i++) {
|
|
|
|
int __user *iov_len_high = (int __user *)&iov[i].iov_len + 1;
|
|
|
|
|
|
|
|
if (put_user(0, iov_len_high))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-13 09:31:50 +00:00
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE3(osf_readv, unsigned long, fd,
|
|
|
|
const struct iovec __user *, vector, unsigned long, count)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-11-13 09:31:50 +00:00
|
|
|
#ifdef CONFIG_OSF4_COMPAT
|
2005-04-16 22:20:36 +00:00
|
|
|
if (unlikely(personality(current->personality) == PER_OSF4))
|
|
|
|
if (osf_fix_iov_len(vector, count))
|
|
|
|
return -EFAULT;
|
2018-11-13 09:31:50 +00:00
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return sys_readv(fd, vector, count);
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:25:18 +00:00
|
|
|
SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
|
|
|
|
const struct iovec __user *, vector, unsigned long, count)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-11-13 09:31:50 +00:00
|
|
|
#ifdef CONFIG_OSF4_COMPAT
|
2005-04-16 22:20:36 +00:00
|
|
|
if (unlikely(personality(current->personality) == PER_OSF4))
|
|
|
|
if (osf_fix_iov_len(vector, count))
|
|
|
|
return -EFAULT;
|
2018-11-13 09:31:50 +00:00
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
return sys_writev(fd, vector, count);
|
|
|
|
}
|
|
|
|
|
2012-08-19 02:40:59 +00:00
|
|
|
SYSCALL_DEFINE2(osf_getpriority, int, which, int, who)
|
|
|
|
{
|
|
|
|
int prio = sys_getpriority(which, who);
|
|
|
|
if (prio >= 0) {
|
|
|
|
/* Return value is the unbiased priority, i.e. 20 - prio.
|
|
|
|
This does result in negative return values, so signal
|
|
|
|
no error */
|
|
|
|
force_successful_syscall_return();
|
|
|
|
prio = 20 - prio;
|
|
|
|
}
|
|
|
|
return prio;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE0(getxuid)
|
|
|
|
{
|
|
|
|
current_pt_regs()->r20 = sys_geteuid();
|
|
|
|
return sys_getuid();
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE0(getxgid)
|
|
|
|
{
|
|
|
|
current_pt_regs()->r20 = sys_getegid();
|
|
|
|
return sys_getgid();
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE0(getxpid)
|
|
|
|
{
|
|
|
|
current_pt_regs()->r20 = sys_getppid();
|
|
|
|
return sys_getpid();
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE0(alpha_pipe)
|
|
|
|
{
|
|
|
|
int fd[2];
|
|
|
|
int res = do_pipe_flags(fd, 0);
|
|
|
|
if (!res) {
|
|
|
|
/* The return values are in $0 and $20. */
|
|
|
|
current_pt_regs()->r20 = fd[1];
|
|
|
|
res = fd[0];
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE1(sethae, unsigned long, val)
|
|
|
|
{
|
|
|
|
current_pt_regs()->hae = val;
|
|
|
|
return 0;
|
|
|
|
}
|