Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *  linux/arch/alpha/kernel/osf_sys.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *  Copyright (C) 1995  Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  * This file handles some of the stranger OSF/1 system call interfaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  * Some of the system calls expect a non-C calling standard, others have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  * special parameter blocks..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <linux/sched/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <linux/sched/task_stack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <linux/sched/cputime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <linux/utsname.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <linux/timex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <linux/major.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include <linux/mman.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) #include <linux/shm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #include <linux/ipc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #include <linux/namei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #include <linux/uio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #include <linux/vfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) #include <linux/rcupdate.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #include <asm/fpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #include <asm/sysinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #include <asm/thread_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #include <asm/hwrpb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53)  * Brk needs to return an error.  Still support Linux's brk(0) query idiom,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54)  * which OSF programs just shouldn't be doing.  We're still not quite
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55)  * identical to OSF as we don't return 0 on success, but doing otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56)  * would require changes to libc.  Hopefully this is good enough.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) SYSCALL_DEFINE1(osf_brk, unsigned long, brk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	unsigned long retval = sys_brk(brk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	if (brk && brk != retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 		retval = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65)  
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67)  * This is pure guess-work..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 		unsigned long, text_len, unsigned long, bss_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 		unsigned long, bss_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	struct mm_struct *mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	mm = current->mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	mm->end_code = bss_start + bss_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	mm->start_brk = bss_start + bss_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	mm->brk = bss_start + bss_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 	printk("set_program_attributes(%lx %lx %lx %lx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 		text_start, text_len, bss_start, bss_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87)  * OSF/1 directory handling functions...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89)  * The "getdents()" interface is much more sane: the "basep" stuff is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90)  * braindamage (it can't really handle filesystems where the directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91)  * offset differences aren't the same as "d_reclen").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) #define NAME_OFFSET	offsetof (struct osf_dirent, d_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) struct osf_dirent {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	unsigned int d_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	unsigned short d_reclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	unsigned short d_namlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	char d_name[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) struct osf_dirent_callback {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	struct dir_context ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 	struct osf_dirent __user *dirent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	long __user *basep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	unsigned int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) osf_filldir(struct dir_context *ctx, const char *name, int namlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	    loff_t offset, u64 ino, unsigned int d_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	struct osf_dirent __user *dirent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	struct osf_dirent_callback *buf =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 		container_of(ctx, struct osf_dirent_callback, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	unsigned int reclen = ALIGN(NAME_OFFSET + namlen + 1, sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	unsigned int d_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	buf->error = -EINVAL;	/* only used if we fail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	if (reclen > buf->count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	d_ino = ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 		buf->error = -EOVERFLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 		return -EOVERFLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 	if (buf->basep) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 		if (put_user(offset, buf->basep))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 			goto Efault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 		buf->basep = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	dirent = buf->dirent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	if (put_user(d_ino, &dirent->d_ino) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	    put_user(namlen, &dirent->d_namlen) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	    put_user(reclen, &dirent->d_reclen) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	    copy_to_user(dirent->d_name, name, namlen) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 	    put_user(0, dirent->d_name + namlen))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 		goto Efault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	dirent = (void __user *)dirent + reclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	buf->dirent = dirent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	buf->count -= reclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) Efault:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	buf->error = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 		struct osf_dirent __user *, dirent, unsigned int, count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 		long __user *, basep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	struct fd arg = fdget_pos(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	struct osf_dirent_callback buf = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 		.ctx.actor = osf_filldir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 		.dirent = dirent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 		.basep = basep,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 		.count = count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	if (!arg.file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 		return -EBADF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	error = iterate_dir(arg.file, &buf.ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	if (error >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 		error = buf.error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	if (count != buf.count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 		error = count - buf.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	fdput_pos(arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) #undef NAME_OFFSET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 		unsigned long, prot, unsigned long, flags, unsigned long, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 		unsigned long, off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	unsigned long ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	if (flags & (_MAP_HASSEMAPHORE | _MAP_INHERIT | _MAP_UNALIGNED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 		printk("%s: unimplemented OSF mmap flags %04lx\n", 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 			current->comm, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	if ((off + PAGE_ALIGN(len)) < off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	if (off & ~PAGE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	ret = ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193)  out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) struct osf_stat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	int		st_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 	int		st_pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 	unsigned	st_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	unsigned short	st_nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	short		st_nlink_reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	unsigned	st_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	unsigned	st_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 	int		st_rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	int		st_ldev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	long		st_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	int		st_pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	int		st_uatime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	int		st_pad3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	int		st_umtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	int		st_pad4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	int		st_uctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	int		st_pad5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	int		st_pad6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	unsigned	st_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	unsigned	st_gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 	long		st_spare[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	unsigned	st_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	int		st_ino_reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	int		st_atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	int		st_atime_reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	int		st_mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	int		st_mtime_reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	int		st_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	int		st_ctime_reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	long		st_blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	long		st_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232)  * The OSF/1 statfs structure is much larger, but this should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233)  * match the beginning, at least.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) struct osf_statfs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	short f_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 	short f_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	int f_fsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	int f_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	int f_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	int f_bfree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	int f_bavail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	int f_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	int f_ffree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	__kernel_fsid_t f_fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) struct osf_statfs64 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	short f_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	short f_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	int f_pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	int f_pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	int f_pad3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	int f_pad4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	int f_pad5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	int f_pad6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	int f_pad7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	__kernel_fsid_t f_fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	u_short f_namemax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	short f_reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	int f_spare[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	char f_pad8[90];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	char f_pad9[90];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	long mount_info[10];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	u_long f_flags2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	long f_spare2[14];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	long f_fsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	long f_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	long f_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	long f_bfree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	long f_bavail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	long f_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	long f_ffree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) linux_to_osf_stat(struct kstat *lstat, struct osf_stat __user *osf_stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	struct osf_stat tmp = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	tmp.st_dev	= lstat->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	tmp.st_mode	= lstat->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	tmp.st_nlink	= lstat->nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	tmp.st_uid	= from_kuid_munged(current_user_ns(), lstat->uid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	tmp.st_gid	= from_kgid_munged(current_user_ns(), lstat->gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	tmp.st_rdev	= lstat->rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	tmp.st_ldev	= lstat->rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	tmp.st_size	= lstat->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	tmp.st_uatime	= lstat->atime.tv_nsec / 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 	tmp.st_umtime	= lstat->mtime.tv_nsec / 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	tmp.st_uctime	= lstat->ctime.tv_nsec / 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	tmp.st_ino	= lstat->ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	tmp.st_atime	= lstat->atime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	tmp.st_mtime	= lstat->mtime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	tmp.st_ctime	= lstat->ctime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	tmp.st_blksize	= lstat->blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	tmp.st_blocks	= lstat->blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	return copy_to_user(osf_stat, &tmp, sizeof(tmp)) ? -EFAULT : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 		    unsigned long bufsiz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	struct osf_statfs tmp_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	tmp_stat.f_type = linux_stat->f_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	tmp_stat.f_flags = 0;	/* mount flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	tmp_stat.f_fsize = linux_stat->f_frsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	tmp_stat.f_bsize = linux_stat->f_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	tmp_stat.f_blocks = linux_stat->f_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	tmp_stat.f_bfree = linux_stat->f_bfree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	tmp_stat.f_bavail = linux_stat->f_bavail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	tmp_stat.f_files = linux_stat->f_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	tmp_stat.f_ffree = linux_stat->f_ffree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	tmp_stat.f_fsid = linux_stat->f_fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	if (bufsiz > sizeof(tmp_stat))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 		bufsiz = sizeof(tmp_stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) linux_to_osf_statfs64(struct kstatfs *linux_stat, struct osf_statfs64 __user *osf_stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 		      unsigned long bufsiz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	struct osf_statfs64 tmp_stat = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	tmp_stat.f_type = linux_stat->f_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	tmp_stat.f_fsize = linux_stat->f_frsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	tmp_stat.f_bsize = linux_stat->f_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	tmp_stat.f_blocks = linux_stat->f_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	tmp_stat.f_bfree = linux_stat->f_bfree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	tmp_stat.f_bavail = linux_stat->f_bavail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	tmp_stat.f_files = linux_stat->f_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	tmp_stat.f_ffree = linux_stat->f_ffree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	tmp_stat.f_fsid = linux_stat->f_fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	if (bufsiz > sizeof(tmp_stat))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 		bufsiz = sizeof(tmp_stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		struct osf_statfs __user *, buffer, unsigned long, bufsiz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	struct kstatfs linux_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	int error = user_statfs(pathname, &linux_stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 		error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	return error;	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) SYSCALL_DEFINE2(osf_stat, char __user *, name, struct osf_stat __user *, buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 	error = vfs_stat(name, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	return linux_to_osf_stat(&stat, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) SYSCALL_DEFINE2(osf_lstat, char __user *, name, struct osf_stat __user *, buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	error = vfs_lstat(name, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	return linux_to_osf_stat(&stat, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) SYSCALL_DEFINE2(osf_fstat, int, fd, struct osf_stat __user *, buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	error = vfs_fstat(fd, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 	return linux_to_osf_stat(&stat, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 		struct osf_statfs __user *, buffer, unsigned long, bufsiz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	struct kstatfs linux_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	int error = fd_statfs(fd, &linux_stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 		error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) SYSCALL_DEFINE3(osf_statfs64, char __user *, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 		struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	struct kstatfs linux_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	int error = user_statfs(pathname, &linux_stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 		error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	struct kstatfs linux_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	int error = fd_statfs(fd, &linux_stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 		error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420)  * Uhh.. OSF/1 mount parameters aren't exactly obvious..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422)  * Although to be frank, neither are the native Linux/i386 ones..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) struct ufs_args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	char __user *devname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	uid_t exroot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) struct cdfs_args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 	char __user *devname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	uid_t exroot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	/* This has lots more here, which Linux handles with the option block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	   but I'm too lazy to do the translation into ASCII.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) struct procfs_args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	char __user *devname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	uid_t exroot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446)  * We can't actually handle ufs yet, so we translate UFS mounts to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447)  * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448)  * layout is so braindead it's a major headache doing it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450)  * Just how long ago was it written? OTOH our UFS driver may be still
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451)  * unhappy with OSF UFS. [CHECKME]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) osf_ufs_mount(const char __user *dirname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 	      struct ufs_args __user *args, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	struct cdfs_args tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	struct filename *devname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	retval = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	if (copy_from_user(&tmp, args, sizeof(tmp)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	devname = getname(tmp.devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	retval = PTR_ERR(devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	if (IS_ERR(devname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	putname(devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470)  out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) osf_cdfs_mount(const char __user *dirname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	       struct cdfs_args __user *args, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	struct cdfs_args tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	struct filename *devname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 	retval = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	if (copy_from_user(&tmp, args, sizeof(tmp)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	devname = getname(tmp.devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	retval = PTR_ERR(devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	if (IS_ERR(devname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	putname(devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491)  out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) osf_procfs_mount(const char __user *dirname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 		 struct procfs_args __user *args, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	struct procfs_args tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	if (copy_from_user(&tmp, args, sizeof(tmp)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	return do_mount("", dirname, "proc", flags, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 		int, flag, void __user *, data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	switch (typenr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 		retval = osf_ufs_mount(path, data, flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	case 6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		retval = osf_cdfs_mount(path, data, flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	case 9:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 		retval = osf_procfs_mount(path, data, flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 		retval = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 		printk("osf_mount(%ld, %x)\n", typenr, flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) SYSCALL_DEFINE1(osf_utsname, char __user *, name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	char tmp[5 * 32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 	down_read(&uts_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	memcpy(tmp + 0 * 32, utsname()->sysname, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 	memcpy(tmp + 1 * 32, utsname()->nodename, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	memcpy(tmp + 2 * 32, utsname()->release, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	memcpy(tmp + 3 * 32, utsname()->version, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	memcpy(tmp + 4 * 32, utsname()->machine, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	up_read(&uts_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	if (copy_to_user(name, tmp, sizeof(tmp)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) SYSCALL_DEFINE0(getpagesize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	return PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) SYSCALL_DEFINE0(getdtablesize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	return sysctl_nr_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558)  * For compatibility with OSF/1 only.  Use utsname(2) instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	char *kname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	char tmp[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	if (namelen < 0 || namelen > 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		namelen = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	down_read(&uts_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	kname = utsname()->domainname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	len = strnlen(kname, namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	len = min(len + 1, namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	memcpy(tmp, kname, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	up_read(&uts_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	if (copy_to_user(name, tmp, len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582)  * The following stuff should move into a header file should it ever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583)  * be labeled "officially supported."  Right now, there is just enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584)  * support to avoid applications (such as tar) printing error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585)  * messages.  The attributes are not really implemented.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589)  * Values for Property list entry flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) #define PLE_PROPAGATE_ON_COPY		0x1	/* cp(1) will copy entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 						   by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) #define PLE_FLAG_MASK			0x1	/* Valid flag values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) #define PLE_FLAG_ALL			-1	/* All flag value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) struct proplistname_args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	unsigned int pl_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	unsigned int pl_numnames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	char **pl_names;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) union pl_args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	struct setargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		char __user *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		long follow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		long nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		char __user *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	} set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	struct fsetargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 		long fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		long nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 		char __user *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 	} fset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	struct getargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 		char __user *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 		long follow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 		struct proplistname_args __user *name_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 		long nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 		char __user *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 		int __user *min_buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	} get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	struct fgetargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 		long fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 		struct proplistname_args __user *name_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 		long nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 		char __user *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		int __user *min_buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	} fget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 	struct delargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 		char __user *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		long follow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 		struct proplistname_args __user *name_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	} del;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	struct fdelargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 		long fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 		struct proplistname_args __user *name_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	} fdel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) enum pl_code {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	PL_SET = 1, PL_FSET = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	PL_GET = 3, PL_FGET = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	PL_DEL = 5, PL_FDEL = 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 		union pl_args __user *, args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	long error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	int __user *min_buf_size_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 	switch (code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	case PL_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 		if (get_user(error, &args->set.nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 			error = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	case PL_FSET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 		if (get_user(error, &args->fset.nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 			error = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	case PL_GET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 		error = get_user(min_buf_size_ptr, &args->get.min_buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 		if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 		error = put_user(0, min_buf_size_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	case PL_FGET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		error = get_user(min_buf_size_ptr, &args->fget.min_buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 		if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 		error = put_user(0, min_buf_size_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	case PL_DEL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	case PL_FDEL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 		error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 		error = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) SYSCALL_DEFINE2(osf_sigstack, struct sigstack __user *, uss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 		struct sigstack __user *, uoss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	unsigned long usp = rdusp();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	unsigned long oss_os = on_sig_stack(usp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	if (uss) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 		void __user *ss_sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 		error = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 		if (get_user(ss_sp, &uss->ss_sp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 		/* If the current stack was set with sigaltstack, don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 		   swap stacks while we are on it.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 		error = -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 		if (current->sas_ss_sp && on_sig_stack(usp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 		/* Since we don't know the extent of the stack, and we don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 		   track onstack-ness, but rather calculate it, we must 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 		   presume a size.  Ho hum this interface is lossy.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 		current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		current->sas_ss_size = SIGSTKSZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	if (uoss) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 		error = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 		if (put_user(oss_sp, &uoss->ss_sp) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 		    put_user(oss_os, &uoss->ss_onstack))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720)  out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	const char *sysinfo_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		utsname()->sysname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 		utsname()->nodename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 		utsname()->release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 		utsname()->version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 		utsname()->machine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 		"alpha",	/* instruction set architecture */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 		"dummy",	/* hardware serial number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 		"dummy",	/* hardware manufacturer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 		"dummy",	/* secure RPC domain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	unsigned long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	const char *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	long len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	char tmp[__NEW_UTS_LEN + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	offset = command-1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	if (offset >= ARRAY_SIZE(sysinfo_table)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 		/* Digital UNIX has a few unpublished interfaces here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 		printk("sysinfo(%d)", command);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	down_read(&uts_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	res = sysinfo_table[offset];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	len = strlen(res)+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	if ((unsigned long)len > (unsigned long)count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		len = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	memcpy(tmp, res, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	up_read(&uts_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	if (copy_to_user(buf, tmp, len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		unsigned long, nbytes, int __user *, start, void __user *, arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	unsigned long w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	struct percpu_struct *cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	case GSI_IEEE_FP_CONTROL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 		/* Return current software fp control & status bits.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 		/* Note that DU doesn't verify available space here.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772)  		w = current_thread_info()->ieee_state & IEEE_SW_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773)  		w = swcr_update_status(w, rdfpcr());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 		if (put_user(w, (unsigned long __user *) buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	case GSI_IEEE_STATE_AT_SIGNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 		 * Not sure anybody will ever use this weird stuff.  These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 		 * ops can be used (under OSF/1) to set the fpcr that should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 		 * be used when a signal handler starts executing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786)  	case GSI_UACPROC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 		if (nbytes < sizeof(unsigned int))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 		w = current_thread_info()->status & UAC_BITMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 		if (put_user(w, (unsigned int __user *)buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792)  		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	case GSI_PROC_TYPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		if (nbytes < sizeof(unsigned long))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 		cpu = (struct percpu_struct*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 		  ((char*)hwrpb + hwrpb->processor_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 		w = cpu->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 		if (put_user(w, (unsigned long  __user*)buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	case GSI_GET_HWRPB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 		if (nbytes > sizeof(*hwrpb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 		if (copy_to_user(buffer, hwrpb, nbytes) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 		unsigned long, nbytes, int __user *, start, void __user *, arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	case SSI_IEEE_FP_CONTROL: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 		unsigned long swcr, fpcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 		unsigned int *state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 		/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 		 * Alpha Architecture Handbook 4.7.7.3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		 * To be fully IEEE compiant, we must track the current IEEE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 		 * exception state in software, because spurious bits can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 		 * set in the trap shadow of a software-complete insn.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 		if (get_user(swcr, (unsigned long __user *)buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 		state = &current_thread_info()->ieee_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		/* Update softare trap enable bits.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 		*state = (*state & ~IEEE_SW_MASK) | (swcr & IEEE_SW_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		/* Update the real fpcr.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		fpcr = rdfpcr() & FPCR_DYN_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 		fpcr |= ieee_swcr_to_fpcr(swcr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		wrfpcr(fpcr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	case SSI_IEEE_RAISE_EXCEPTION: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		unsigned long exc, swcr, fpcr, fex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 		unsigned int *state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 		if (get_user(exc, (unsigned long __user *)buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 		state = &current_thread_info()->ieee_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 		exc &= IEEE_STATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 		/* Update softare trap enable bits.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858)  		swcr = (*state & IEEE_SW_MASK) | exc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 		*state |= exc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 		/* Update the real fpcr.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		fpcr = rdfpcr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 		fpcr |= ieee_swcr_to_fpcr(swcr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 		wrfpcr(fpcr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866)  		/* If any exceptions set by this call, and are unmasked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 		   send a signal.  Old exceptions are not signaled.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869)  		if (fex) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 			int si_code = FPE_FLTUNK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 			if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 			if (fex & IEEE_TRAP_ENABLE_INE) si_code = FPE_FLTRES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 			if (fex & IEEE_TRAP_ENABLE_UNF) si_code = FPE_FLTUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 			if (fex & IEEE_TRAP_ENABLE_OVF) si_code = FPE_FLTOVF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 			if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 			if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 			send_sig_fault(SIGFPE, si_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 				       (void __user *)NULL,  /* FIXME */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 				       0, current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882)  		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	case SSI_IEEE_STATE_AT_SIGNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	case SSI_IEEE_IGNORE_STATE_AT_SIGNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 		 * Not sure anybody will ever use this weird stuff.  These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		 * ops can be used (under OSF/1) to set the fpcr that should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 		 * be used when a signal handler starts executing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895)  	case SSI_NVPAIRS: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 		unsigned __user *p = buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 		unsigned i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 		for (i = 0, p = buffer; i < nbytes; ++i, p += 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 			unsigned v, w, status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 			if (get_user(v, p) || get_user(w, p + 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903)  				return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904)  			switch (v) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905)  			case SSIN_UACPROC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 				w &= UAC_BITMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 				status = current_thread_info()->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 				status = (status & ~UAC_BITMASK) | w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 				current_thread_info()->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910)  				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911)  
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912)  			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913)  				return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914)  			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915)  		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916)  		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918)  
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 	case SSI_LMF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) /* Translations due to the fact that OSF's time_t is an int.  Which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930)    affects all sorts of things, like timeval and itimerval.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) extern struct timezone sys_tz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) struct timeval32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936)     int tv_sec, tv_usec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) struct itimerval32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941)     struct timeval32 it_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942)     struct timeval32 it_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) static inline long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) get_tv32(struct timespec64 *o, struct timeval32 __user *i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	struct timeval32 tv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	if (copy_from_user(&tv, i, sizeof(struct timeval32)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	o->tv_sec = tv.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	o->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) static inline long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) put_tv32(struct timeval32 __user *o, struct timespec64 *i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	return copy_to_user(o, &(struct timeval32){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 				.tv_sec = i->tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 				.tv_usec = i->tv_nsec / NSEC_PER_USEC},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 			    sizeof(struct timeval32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) static inline long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) put_tv_to_tv32(struct timeval32 __user *o, struct __kernel_old_timeval *i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	return copy_to_user(o, &(struct timeval32){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 				.tv_sec = i->tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 				.tv_usec = i->tv_usec},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 			    sizeof(struct timeval32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	value->tv_sec = jiffies / HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 		struct timezone __user *, tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	if (tv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		struct timespec64 kts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 		ktime_get_real_ts64(&kts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 		if (put_tv32(tv, &kts))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	if (tz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 		if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 		struct timezone __user *, tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	struct timespec64 kts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	struct timezone ktz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)  	if (tv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 		if (get_tv32(&kts, tv))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	if (tz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 		if (copy_from_user(&ktz, tz, sizeof(*tz)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	return do_sys_settimeofday64(tv ? &kts : NULL, tz ? &ktz : NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) asmlinkage long sys_ni_posix_timers(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 		struct timeval32 __user *, tvs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	struct timespec64 tv[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	if (tvs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 		if (get_tv32(&tv[0], &tvs[0]) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 		    get_tv32(&tv[1], &tvs[1]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 		if (tv[0].tv_nsec < 0 || tv[0].tv_nsec >= 1000000000 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 		    tv[1].tv_nsec < 0 || tv[1].tv_nsec >= 1000000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		fd_set __user *, exp, struct timeval32 __user *, tvp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	struct timespec64 end_time, *to = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	if (tvp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 		struct timespec64 tv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 		to = &end_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 		if (get_tv32(&tv, tvp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 		    	return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 		if (tv.tv_sec < 0 || tv.tv_nsec < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 		if (poll_select_set_timeout(to, tv.tv_sec, tv.tv_nsec))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 			return -EINVAL;		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	/* OSF does not copy back the remaining time.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	return core_sys_select(n, inp, outp, exp, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) struct rusage32 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	struct timeval32 ru_utime;	/* user time used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	struct timeval32 ru_stime;	/* system time used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	long	ru_maxrss;		/* maximum resident set size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	long	ru_ixrss;		/* integral shared memory size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	long	ru_idrss;		/* integral unshared data size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	long	ru_isrss;		/* integral unshared stack size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	long	ru_minflt;		/* page reclaims */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	long	ru_majflt;		/* page faults */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	long	ru_nswap;		/* swaps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	long	ru_inblock;		/* block input operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	long	ru_oublock;		/* block output operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	long	ru_msgsnd;		/* messages sent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	long	ru_msgrcv;		/* messages received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	long	ru_nsignals;		/* signals received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	long	ru_nvcsw;		/* voluntary context switches */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	long	ru_nivcsw;		/* involuntary " */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	struct rusage32 r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	u64 utime, stime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 	unsigned long utime_jiffies, stime_jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 	if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	memset(&r, 0, sizeof(r));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 	switch (who) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	case RUSAGE_SELF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		task_cputime(current, &utime, &stime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 		utime_jiffies = nsecs_to_jiffies(utime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 		stime_jiffies = nsecs_to_jiffies(stime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 		jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 		jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 		r.ru_minflt = current->min_flt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 		r.ru_majflt = current->maj_flt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	case RUSAGE_CHILDREN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 		utime_jiffies = nsecs_to_jiffies(current->signal->cutime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 		stime_jiffies = nsecs_to_jiffies(current->signal->cstime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 		jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 		jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 		r.ru_minflt = current->signal->cmin_flt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 		r.ru_majflt = current->signal->cmaj_flt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 		struct rusage32 __user *, ur)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	struct rusage r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	long err = kernel_wait4(pid, ustatus, options, &r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	if (err <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	if (!ur)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 	if (put_tv_to_tv32(&ur->ru_stime, &r.ru_stime))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	      sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)  * I don't know what the parameters are: the first one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132)  * seems to be a timeval pointer, and I suspect the second
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133)  * one is the time remaining.. Ho humm.. No documentation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 		struct timeval32 __user *, remain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 	struct timespec64 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 	unsigned long ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 	if (get_tv32(&tmp, sleep))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 		goto fault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	ticks = timespec64_to_jiffies(&tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 	ticks = schedule_timeout_interruptible(ticks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 	if (remain) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 		jiffies_to_timespec64(ticks, &tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 		if (put_tv32(remain, &tmp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 			goto fault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155)  fault:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) struct timex32 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	unsigned int modes;	/* mode selector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	long offset;		/* time offset (usec) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	long freq;		/* frequency offset (scaled ppm) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	long maxerror;		/* maximum error (usec) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 	long esterror;		/* estimated error (usec) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 	int status;		/* clock command/status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	long constant;		/* pll time constant */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	long precision;		/* clock precision (usec) (read only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	long tolerance;		/* clock frequency tolerance (ppm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 				 * (read only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	struct timeval32 time;	/* (read only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	long tick;		/* (modified) usecs between clock ticks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 	long jitter;            /* pps jitter (us) (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	int shift;              /* interval duration (s) (shift) (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	long stabil;            /* pps stability (scaled ppm) (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	long jitcnt;            /* jitter limit exceeded (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	long calcnt;            /* calibration intervals (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	long errcnt;            /* calibration errors (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 	long stbcnt;            /* stability limit exceeded (ro) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	int  :32; int  :32; int  :32; int  :32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	int  :32; int  :32; int  :32; int  :32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	int  :32; int  :32; int  :32; int  :32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	struct __kernel_timex txc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	/* copy relevant bits of struct timex. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	    copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) - 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 			   offsetof(struct timex32, tick)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	  return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	ret = do_adjtimex(&txc);	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	  return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	/* copy back to timex32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 	if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	    (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) - 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 			  offsetof(struct timex32, tick))) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	    (put_user(txc.time.tv_sec, &txc_p->time.tv_sec)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 	    (put_user(txc.time.tv_usec, &txc_p->time.tv_usec)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	  return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) /* Get an address range which is currently unmapped.  Similar to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216)    generic version except that we know how to honor ADDR_LIMIT_32BIT.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) static unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 		         unsigned long limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	struct vm_unmapped_area_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	info.flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 	info.length = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 	info.low_limit = addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	info.high_limit = limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 	info.align_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	info.align_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	return vm_unmapped_area(&info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) arch_get_unmapped_area(struct file *filp, unsigned long addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 		       unsigned long len, unsigned long pgoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 		       unsigned long flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	unsigned long limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	/* "32 bit" actually means 31 bit, since pointers sign extend.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	if (current->personality & ADDR_LIMIT_32BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 		limit = 0x80000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 		limit = TASK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	if (len > limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	if (flags & MAP_FIXED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 		return addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	/* First, see if the given suggestion fits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	   The OSF/1 loader (/sbin/loader) relies on us returning an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	   address larger than the requested if one exists, which is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	   a terribly broken way to program.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	   That said, I can see the use in being able to suggest not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	   merely specific addresses, but regions of memory -- perhaps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	   this feature should be incorporated into all ports?  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 	if (addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 		addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 		if (addr != (unsigned long) -ENOMEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 			return addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	/* Next, try allocating at TASK_UNMAPPED_BASE.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 					 len, limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 	if (addr != (unsigned long) -ENOMEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 		return addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 	/* Finally, try allocating in low memory.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 	return addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) #ifdef CONFIG_OSF4_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) /* Clear top 32 bits of iov_len in the user's buffer for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282)    compatibility with old versions of OSF/1 where iov_len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)    was defined as int. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) osf_fix_iov_len(const struct iovec __user *iov, unsigned long count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 	unsigned long i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	for (i = 0 ; i < count ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 		int __user *iov_len_high = (int __user *)&iov[i].iov_len + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 		if (put_user(0, iov_len_high))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) SYSCALL_DEFINE3(osf_readv, unsigned long, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 		const struct iovec __user *, vector, unsigned long, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) #ifdef CONFIG_OSF4_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 	if (unlikely(personality(current->personality) == PER_OSF4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 		if (osf_fix_iov_len(vector, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	return sys_readv(fd, vector, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 		const struct iovec __user *, vector, unsigned long, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) #ifdef CONFIG_OSF4_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	if (unlikely(personality(current->personality) == PER_OSF4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 		if (osf_fix_iov_len(vector, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 	return sys_writev(fd, vector, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) SYSCALL_DEFINE2(osf_getpriority, int, which, int, who)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	int prio = sys_getpriority(which, who);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	if (prio >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 		/* Return value is the unbiased priority, i.e. 20 - prio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 		   This does result in negative return values, so signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 		   no error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 		force_successful_syscall_return();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 		prio = 20 - prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	return prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) SYSCALL_DEFINE0(getxuid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	current_pt_regs()->r20 = sys_geteuid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	return sys_getuid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) SYSCALL_DEFINE0(getxgid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	current_pt_regs()->r20 = sys_getegid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	return sys_getgid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) SYSCALL_DEFINE0(getxpid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 	current_pt_regs()->r20 = sys_getppid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 	return sys_getpid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) SYSCALL_DEFINE0(alpha_pipe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	int fd[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	int res = do_pipe_flags(fd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	if (!res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 		/* The return values are in $0 and $20.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 		current_pt_regs()->r20 = fd[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 		res = fd[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) SYSCALL_DEFINE1(sethae, unsigned long, val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	current_pt_regs()->hae = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) }