2 * linux/arch/alpha/kernel/osf_sys.c
4 * Copyright (C) 1995 Linus Torvalds
8 * This file handles some of the stranger OSF/1 system call interfaces.
9 * Some of the system calls expect a non-C calling standard, others have
10 * special parameter blocks..
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
17 #include <linux/smp.h>
18 #include <linux/stddef.h>
19 #include <linux/syscalls.h>
20 #include <linux/unistd.h>
21 #include <linux/ptrace.h>
22 #include <linux/user.h>
23 #include <linux/utsname.h>
24 #include <linux/time.h>
25 #include <linux/timex.h>
26 #include <linux/major.h>
27 #include <linux/stat.h>
28 #include <linux/mman.h>
29 #include <linux/shm.h>
30 #include <linux/poll.h>
31 #include <linux/file.h>
32 #include <linux/types.h>
33 #include <linux/ipc.h>
34 #include <linux/namei.h>
35 #include <linux/uio.h>
36 #include <linux/vfs.h>
37 #include <linux/rcupdate.h>
38 #include <linux/slab.h>
42 #include <asm/uaccess.h>
43 #include <asm/sysinfo.h>
44 #include <asm/thread_info.h>
45 #include <asm/hwrpb.h>
46 #include <asm/processor.h>
49 * Brk needs to return an error. Still support Linux's brk(0) query idiom,
50 * which OSF programs just shouldn't be doing. We're still not quite
51 * identical to OSF as we don't return 0 on success, but doing otherwise
52 * would require changes to libc. Hopefully this is good enough.
54 SYSCALL_DEFINE1(osf_brk, unsigned long, brk)
56 unsigned long retval = sys_brk(brk);
57 if (brk && brk != retval)
63 * This is pure guess-work..
65 SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
66 unsigned long, text_len, unsigned long, bss_start,
67 unsigned long, bss_len)
72 mm->end_code = bss_start + bss_len;
73 mm->start_brk = bss_start + bss_len;
74 mm->brk = bss_start + bss_len;
76 printk("set_program_attributes(%lx %lx %lx %lx)\n",
77 text_start, text_len, bss_start, bss_len);
83 * OSF/1 directory handling functions...
85 * The "getdents()" interface is much more sane: the "basep" stuff is
86 * braindamage (it can't really handle filesystems where the directory
87 * offset differences aren't the same as "d_reclen").
89 #define NAME_OFFSET offsetof (struct osf_dirent, d_name)
93 unsigned short d_reclen;
94 unsigned short d_namlen;
98 struct osf_dirent_callback {
99 struct osf_dirent __user *dirent;
106 osf_filldir(void *__buf, const char *name, int namlen, loff_t offset,
107 u64 ino, unsigned int d_type)
109 struct osf_dirent __user *dirent;
110 struct osf_dirent_callback *buf = (struct osf_dirent_callback *) __buf;
111 unsigned int reclen = ALIGN(NAME_OFFSET + namlen + 1, sizeof(u32));
114 buf->error = -EINVAL; /* only used if we fail */
115 if (reclen > buf->count)
118 if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) {
119 buf->error = -EOVERFLOW;
123 if (put_user(offset, buf->basep))
127 dirent = buf->dirent;
128 if (put_user(d_ino, &dirent->d_ino) ||
129 put_user(namlen, &dirent->d_namlen) ||
130 put_user(reclen, &dirent->d_reclen) ||
131 copy_to_user(dirent->d_name, name, namlen) ||
132 put_user(0, dirent->d_name + namlen))
134 dirent = (void __user *)dirent + reclen;
135 buf->dirent = dirent;
136 buf->count -= reclen;
139 buf->error = -EFAULT;
143 SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
144 struct osf_dirent __user *, dirent, unsigned int, count,
145 long __user *, basep)
149 struct osf_dirent_callback buf;
161 error = vfs_readdir(file, osf_filldir, &buf);
164 if (count != buf.count)
165 error = count - buf.count;
174 SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len,
175 unsigned long, prot, unsigned long, flags, unsigned long, fd,
178 unsigned long ret = -EINVAL;
181 if (flags & (_MAP_HASSEMAPHORE | _MAP_INHERIT | _MAP_UNALIGNED))
182 printk("%s: unimplemented OSF mmap flags %04lx\n",
183 current->comm, flags);
185 if ((off + PAGE_ALIGN(len)) < off)
187 if (off & ~PAGE_MASK)
189 ret = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
196 * The OSF/1 statfs structure is much larger, but this should
197 * match the beginning, at least.
209 __kernel_fsid_t f_fsid;
213 linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_stat,
214 unsigned long bufsiz)
216 struct osf_statfs tmp_stat;
218 tmp_stat.f_type = linux_stat->f_type;
219 tmp_stat.f_flags = 0; /* mount flags */
220 tmp_stat.f_fsize = linux_stat->f_frsize;
221 tmp_stat.f_bsize = linux_stat->f_bsize;
222 tmp_stat.f_blocks = linux_stat->f_blocks;
223 tmp_stat.f_bfree = linux_stat->f_bfree;
224 tmp_stat.f_bavail = linux_stat->f_bavail;
225 tmp_stat.f_files = linux_stat->f_files;
226 tmp_stat.f_ffree = linux_stat->f_ffree;
227 tmp_stat.f_fsid = linux_stat->f_fsid;
228 if (bufsiz > sizeof(tmp_stat))
229 bufsiz = sizeof(tmp_stat);
230 return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
233 SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname,
234 struct osf_statfs __user *, buffer, unsigned long, bufsiz)
236 struct kstatfs linux_stat;
237 int error = user_statfs(pathname, &linux_stat);
239 error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
243 SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd,
244 struct osf_statfs __user *, buffer, unsigned long, bufsiz)
246 struct kstatfs linux_stat;
247 int error = fd_statfs(fd, &linux_stat);
249 error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
254 * Uhh.. OSF/1 mount parameters aren't exactly obvious..
256 * Although to be frank, neither are the native Linux/i386 ones..
259 char __user *devname;
265 char __user *devname;
269 /* This has lots more here, which Linux handles with the option block
270 but I'm too lazy to do the translation into ASCII. */
274 char __user *devname;
280 * We can't actually handle ufs yet, so we translate UFS mounts to
281 * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
282 * layout is so braindead it's a major headache doing it.
284 * Just how long ago was it written? OTOH our UFS driver may be still
285 * unhappy with OSF UFS. [CHECKME]
288 osf_ufs_mount(char *dirname, struct ufs_args __user *args, int flags)
291 struct cdfs_args tmp;
295 if (copy_from_user(&tmp, args, sizeof(tmp)))
297 devname = getname(tmp.devname);
298 retval = PTR_ERR(devname);
301 retval = do_mount(devname, dirname, "ext2", flags, NULL);
308 osf_cdfs_mount(char *dirname, struct cdfs_args __user *args, int flags)
311 struct cdfs_args tmp;
315 if (copy_from_user(&tmp, args, sizeof(tmp)))
317 devname = getname(tmp.devname);
318 retval = PTR_ERR(devname);
321 retval = do_mount(devname, dirname, "iso9660", flags, NULL);
328 osf_procfs_mount(char *dirname, struct procfs_args __user *args, int flags)
330 struct procfs_args tmp;
332 if (copy_from_user(&tmp, args, sizeof(tmp)))
335 return do_mount("", dirname, "proc", flags, NULL);
338 SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
339 int, flag, void __user *, data)
344 name = getname(path);
345 retval = PTR_ERR(name);
350 retval = osf_ufs_mount(name, data, flag);
353 retval = osf_cdfs_mount(name, data, flag);
356 retval = osf_procfs_mount(name, data, flag);
360 printk("osf_mount(%ld, %x)\n", typenr, flag);
367 SYSCALL_DEFINE1(osf_utsname, char __user *, name)
373 if (copy_to_user(name + 0, utsname()->sysname, 32))
375 if (copy_to_user(name + 32, utsname()->nodename, 32))
377 if (copy_to_user(name + 64, utsname()->release, 32))
379 if (copy_to_user(name + 96, utsname()->version, 32))
381 if (copy_to_user(name + 128, utsname()->machine, 32))
390 SYSCALL_DEFINE0(getpagesize)
395 SYSCALL_DEFINE0(getdtablesize)
397 return sysctl_nr_open;
401 * For compatibility with OSF/1 only. Use utsname(2) instead.
403 SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
408 if (!access_ok(VERIFY_WRITE, name, namelen))
416 for (i = 0; i < len; ++i) {
417 __put_user(utsname()->domainname[i], name + i);
418 if (utsname()->domainname[i] == '\0')
427 * The following stuff should move into a header file should it ever
428 * be labeled "officially supported." Right now, there is just enough
429 * support to avoid applications (such as tar) printing error
430 * messages. The attributes are not really implemented.
434 * Values for Property list entry flag
436 #define PLE_PROPAGATE_ON_COPY 0x1 /* cp(1) will copy entry
438 #define PLE_FLAG_MASK 0x1 /* Valid flag values */
439 #define PLE_FLAG_ALL -1 /* All flag value */
441 struct proplistname_args {
442 unsigned int pl_mask;
443 unsigned int pl_numnames;
462 struct proplistname_args __user *name_args;
465 int __user *min_buf_size;
469 struct proplistname_args __user *name_args;
472 int __user *min_buf_size;
477 struct proplistname_args __user *name_args;
481 struct proplistname_args __user *name_args;
486 PL_SET = 1, PL_FSET = 2,
487 PL_GET = 3, PL_FGET = 4,
488 PL_DEL = 5, PL_FDEL = 6
491 SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
492 union pl_args __user *, args)
495 int __user *min_buf_size_ptr;
499 if (get_user(error, &args->set.nbytes))
503 if (get_user(error, &args->fset.nbytes))
507 error = get_user(min_buf_size_ptr, &args->get.min_buf_size);
510 error = put_user(0, min_buf_size_ptr);
513 error = get_user(min_buf_size_ptr, &args->fget.min_buf_size);
516 error = put_user(0, min_buf_size_ptr);
529 SYSCALL_DEFINE2(osf_sigstack, struct sigstack __user *, uss,
530 struct sigstack __user *, uoss)
532 unsigned long usp = rdusp();
533 unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size;
534 unsigned long oss_os = on_sig_stack(usp);
541 if (get_user(ss_sp, &uss->ss_sp))
544 /* If the current stack was set with sigaltstack, don't
545 swap stacks while we are on it. */
547 if (current->sas_ss_sp && on_sig_stack(usp))
550 /* Since we don't know the extent of the stack, and we don't
551 track onstack-ness, but rather calculate it, we must
552 presume a size. Ho hum this interface is lossy. */
553 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
554 current->sas_ss_size = SIGSTKSZ;
559 if (! access_ok(VERIFY_WRITE, uoss, sizeof(*uoss))
560 || __put_user(oss_sp, &uoss->ss_sp)
561 || __put_user(oss_os, &uoss->ss_onstack))
570 SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)
572 const char *sysinfo_table[] = {
578 "alpha", /* instruction set architecture */
579 "dummy", /* hardware serial number */
580 "dummy", /* hardware manufacturer */
581 "dummy", /* secure RPC domain */
583 unsigned long offset;
585 long len, err = -EINVAL;
588 if (offset >= ARRAY_SIZE(sysinfo_table)) {
589 /* Digital UNIX has a few unpublished interfaces here */
590 printk("sysinfo(%d)", command);
595 res = sysinfo_table[offset];
597 if ((unsigned long)len > (unsigned long)count)
599 if (copy_to_user(buf, res, len))
608 SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
609 unsigned long, nbytes, int __user *, start, void __user *, arg)
612 struct percpu_struct *cpu;
615 case GSI_IEEE_FP_CONTROL:
616 /* Return current software fp control & status bits. */
617 /* Note that DU doesn't verify available space here. */
619 w = current_thread_info()->ieee_state & IEEE_SW_MASK;
620 w = swcr_update_status(w, rdfpcr());
621 if (put_user(w, (unsigned long __user *) buffer))
625 case GSI_IEEE_STATE_AT_SIGNAL:
627 * Not sure anybody will ever use this weird stuff. These
628 * ops can be used (under OSF/1) to set the fpcr that should
629 * be used when a signal handler starts executing.
634 if (nbytes < sizeof(unsigned int))
636 w = (current_thread_info()->flags >> ALPHA_UAC_SHIFT) &
638 if (put_user(w, (unsigned int __user *)buffer))
643 if (nbytes < sizeof(unsigned long))
645 cpu = (struct percpu_struct*)
646 ((char*)hwrpb + hwrpb->processor_offset);
648 if (put_user(w, (unsigned long __user*)buffer))
653 if (nbytes > sizeof(*hwrpb))
655 if (copy_to_user(buffer, hwrpb, nbytes) != 0)
666 SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
667 unsigned long, nbytes, int __user *, start, void __user *, arg)
670 case SSI_IEEE_FP_CONTROL: {
671 unsigned long swcr, fpcr;
675 * Alpha Architecture Handbook 4.7.7.3:
676 * To be fully IEEE compiant, we must track the current IEEE
677 * exception state in software, because spurious bits can be
678 * set in the trap shadow of a software-complete insn.
681 if (get_user(swcr, (unsigned long __user *)buffer))
683 state = ¤t_thread_info()->ieee_state;
685 /* Update softare trap enable bits. */
686 *state = (*state & ~IEEE_SW_MASK) | (swcr & IEEE_SW_MASK);
688 /* Update the real fpcr. */
689 fpcr = rdfpcr() & FPCR_DYN_MASK;
690 fpcr |= ieee_swcr_to_fpcr(swcr);
696 case SSI_IEEE_RAISE_EXCEPTION: {
697 unsigned long exc, swcr, fpcr, fex;
700 if (get_user(exc, (unsigned long __user *)buffer))
702 state = ¤t_thread_info()->ieee_state;
703 exc &= IEEE_STATUS_MASK;
705 /* Update softare trap enable bits. */
706 swcr = (*state & IEEE_SW_MASK) | exc;
709 /* Update the real fpcr. */
711 fpcr |= ieee_swcr_to_fpcr(swcr);
714 /* If any exceptions set by this call, and are unmasked,
715 send a signal. Old exceptions are not signaled. */
716 fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr;
721 if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND;
722 if (fex & IEEE_TRAP_ENABLE_INE) si_code = FPE_FLTRES;
723 if (fex & IEEE_TRAP_ENABLE_UNF) si_code = FPE_FLTUND;
724 if (fex & IEEE_TRAP_ENABLE_OVF) si_code = FPE_FLTOVF;
725 if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
726 if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
728 info.si_signo = SIGFPE;
730 info.si_code = si_code;
731 info.si_addr = NULL; /* FIXME */
732 send_sig_info(SIGFPE, &info, current);
737 case SSI_IEEE_STATE_AT_SIGNAL:
738 case SSI_IEEE_IGNORE_STATE_AT_SIGNAL:
740 * Not sure anybody will ever use this weird stuff. These
741 * ops can be used (under OSF/1) to set the fpcr that should
742 * be used when a signal handler starts executing.
747 unsigned long v, w, i;
748 unsigned int old, new;
750 for (i = 0; i < nbytes; ++i) {
752 if (get_user(v, 2*i + (unsigned int __user *)buffer))
754 if (get_user(w, 2*i + 1 + (unsigned int __user *)buffer))
759 old = current_thread_info()->flags;
760 new = old & ~(UAC_BITMASK << ALPHA_UAC_SHIFT);
761 new = new | (w & UAC_BITMASK) << ALPHA_UAC_SHIFT;
762 if (cmpxchg(¤t_thread_info()->flags,
781 /* Translations due to the fact that OSF's time_t is an int. Which
782 affects all sorts of things, like timeval and itimerval. */
784 extern struct timezone sys_tz;
793 struct timeval32 it_interval;
794 struct timeval32 it_value;
798 get_tv32(struct timeval *o, struct timeval32 __user *i)
800 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
801 (__get_user(o->tv_sec, &i->tv_sec) |
802 __get_user(o->tv_usec, &i->tv_usec)));
806 put_tv32(struct timeval32 __user *o, struct timeval *i)
808 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
809 (__put_user(i->tv_sec, &o->tv_sec) |
810 __put_user(i->tv_usec, &o->tv_usec)));
814 get_it32(struct itimerval *o, struct itimerval32 __user *i)
816 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
817 (__get_user(o->it_interval.tv_sec, &i->it_interval.tv_sec) |
818 __get_user(o->it_interval.tv_usec, &i->it_interval.tv_usec) |
819 __get_user(o->it_value.tv_sec, &i->it_value.tv_sec) |
820 __get_user(o->it_value.tv_usec, &i->it_value.tv_usec)));
824 put_it32(struct itimerval32 __user *o, struct itimerval *i)
826 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
827 (__put_user(i->it_interval.tv_sec, &o->it_interval.tv_sec) |
828 __put_user(i->it_interval.tv_usec, &o->it_interval.tv_usec) |
829 __put_user(i->it_value.tv_sec, &o->it_value.tv_sec) |
830 __put_user(i->it_value.tv_usec, &o->it_value.tv_usec)));
834 jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
836 value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
837 value->tv_sec = jiffies / HZ;
840 SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
841 struct timezone __user *, tz)
845 do_gettimeofday(&ktv);
846 if (put_tv32(tv, &ktv))
850 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
856 SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
857 struct timezone __user *, tz)
863 if (get_tv32((struct timeval *)&kts, tv))
867 if (copy_from_user(&ktz, tz, sizeof(*tz)))
873 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
876 SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
878 struct itimerval kit;
881 error = do_getitimer(which, &kit);
882 if (!error && put_it32(it, &kit))
888 SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
889 struct itimerval32 __user *, out)
891 struct itimerval kin, kout;
895 if (get_it32(&kin, in))
898 memset(&kin, 0, sizeof(kin));
900 error = do_setitimer(which, &kin, out ? &kout : NULL);
904 if (put_it32(out, &kout))
911 SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
912 struct timeval32 __user *, tvs)
914 struct timespec tv[2];
917 struct timeval ktvs[2];
918 if (get_tv32(&ktvs[0], &tvs[0]) ||
919 get_tv32(&ktvs[1], &tvs[1]))
922 if (ktvs[0].tv_usec < 0 || ktvs[0].tv_usec >= 1000000 ||
923 ktvs[1].tv_usec < 0 || ktvs[1].tv_usec >= 1000000)
926 tv[0].tv_sec = ktvs[0].tv_sec;
927 tv[0].tv_nsec = 1000 * ktvs[0].tv_usec;
928 tv[1].tv_sec = ktvs[1].tv_sec;
929 tv[1].tv_nsec = 1000 * ktvs[1].tv_usec;
932 return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
935 SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,
936 fd_set __user *, exp, struct timeval32 __user *, tvp)
938 struct timespec end_time, *to = NULL;
944 if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp))
945 || __get_user(sec, &tvp->tv_sec)
946 || __get_user(usec, &tvp->tv_usec)) {
950 if (sec < 0 || usec < 0)
953 if (poll_select_set_timeout(to, sec, usec * NSEC_PER_USEC))
958 /* OSF does not copy back the remaining time. */
959 return core_sys_select(n, inp, outp, exp, to);
963 struct timeval32 ru_utime; /* user time used */
964 struct timeval32 ru_stime; /* system time used */
965 long ru_maxrss; /* maximum resident set size */
966 long ru_ixrss; /* integral shared memory size */
967 long ru_idrss; /* integral unshared data size */
968 long ru_isrss; /* integral unshared stack size */
969 long ru_minflt; /* page reclaims */
970 long ru_majflt; /* page faults */
971 long ru_nswap; /* swaps */
972 long ru_inblock; /* block input operations */
973 long ru_oublock; /* block output operations */
974 long ru_msgsnd; /* messages sent */
975 long ru_msgrcv; /* messages received */
976 long ru_nsignals; /* signals received */
977 long ru_nvcsw; /* voluntary context switches */
978 long ru_nivcsw; /* involuntary " */
981 SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
985 if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
988 memset(&r, 0, sizeof(r));
991 jiffies_to_timeval32(current->utime, &r.ru_utime);
992 jiffies_to_timeval32(current->stime, &r.ru_stime);
993 r.ru_minflt = current->min_flt;
994 r.ru_majflt = current->maj_flt;
996 case RUSAGE_CHILDREN:
997 jiffies_to_timeval32(current->signal->cutime, &r.ru_utime);
998 jiffies_to_timeval32(current->signal->cstime, &r.ru_stime);
999 r.ru_minflt = current->signal->cmin_flt;
1000 r.ru_majflt = current->signal->cmaj_flt;
1004 return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
1007 SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1008 struct rusage32 __user *, ur)
1012 unsigned int status = 0;
1013 mm_segment_t old_fs;
1016 return sys_wait4(pid, ustatus, options, NULL);
1021 ret = sys_wait4(pid, (unsigned int __user *) &status, options,
1022 (struct rusage __user *) &r);
1025 if (!access_ok(VERIFY_WRITE, ur, sizeof(*ur)))
1029 err |= put_user(status, ustatus);
1030 err |= __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec);
1031 err |= __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec);
1032 err |= __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec);
1033 err |= __put_user(r.ru_stime.tv_usec, &ur->ru_stime.tv_usec);
1034 err |= __put_user(r.ru_maxrss, &ur->ru_maxrss);
1035 err |= __put_user(r.ru_ixrss, &ur->ru_ixrss);
1036 err |= __put_user(r.ru_idrss, &ur->ru_idrss);
1037 err |= __put_user(r.ru_isrss, &ur->ru_isrss);
1038 err |= __put_user(r.ru_minflt, &ur->ru_minflt);
1039 err |= __put_user(r.ru_majflt, &ur->ru_majflt);
1040 err |= __put_user(r.ru_nswap, &ur->ru_nswap);
1041 err |= __put_user(r.ru_inblock, &ur->ru_inblock);
1042 err |= __put_user(r.ru_oublock, &ur->ru_oublock);
1043 err |= __put_user(r.ru_msgsnd, &ur->ru_msgsnd);
1044 err |= __put_user(r.ru_msgrcv, &ur->ru_msgrcv);
1045 err |= __put_user(r.ru_nsignals, &ur->ru_nsignals);
1046 err |= __put_user(r.ru_nvcsw, &ur->ru_nvcsw);
1047 err |= __put_user(r.ru_nivcsw, &ur->ru_nivcsw);
1049 return err ? err : ret;
1053 * I don't know what the parameters are: the first one
1054 * seems to be a timeval pointer, and I suspect the second
1055 * one is the time remaining.. Ho humm.. No documentation.
1057 SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep,
1058 struct timeval32 __user *, remain)
1061 unsigned long ticks;
1063 if (get_tv32(&tmp, sleep))
1066 ticks = timeval_to_jiffies(&tmp);
1068 ticks = schedule_timeout_interruptible(ticks);
1071 jiffies_to_timeval(ticks, &tmp);
1072 if (put_tv32(remain, &tmp))
1083 unsigned int modes; /* mode selector */
1084 long offset; /* time offset (usec) */
1085 long freq; /* frequency offset (scaled ppm) */
1086 long maxerror; /* maximum error (usec) */
1087 long esterror; /* estimated error (usec) */
1088 int status; /* clock command/status */
1089 long constant; /* pll time constant */
1090 long precision; /* clock precision (usec) (read only) */
1091 long tolerance; /* clock frequency tolerance (ppm)
1094 struct timeval32 time; /* (read only) */
1095 long tick; /* (modified) usecs between clock ticks */
1097 long ppsfreq; /* pps frequency (scaled ppm) (ro) */
1098 long jitter; /* pps jitter (us) (ro) */
1099 int shift; /* interval duration (s) (shift) (ro) */
1100 long stabil; /* pps stability (scaled ppm) (ro) */
1101 long jitcnt; /* jitter limit exceeded (ro) */
1102 long calcnt; /* calibration intervals (ro) */
1103 long errcnt; /* calibration errors (ro) */
1104 long stbcnt; /* stability limit exceeded (ro) */
1106 int :32; int :32; int :32; int :32;
1107 int :32; int :32; int :32; int :32;
1108 int :32; int :32; int :32; int :32;
1111 SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
1116 /* copy relevant bits of struct timex. */
1117 if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) ||
1118 copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) -
1119 offsetof(struct timex32, time)))
1122 ret = do_adjtimex(&txc);
1126 /* copy back to timex32 */
1127 if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
1128 (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) -
1129 offsetof(struct timex32, tick))) ||
1130 (put_tv32(&txc_p->time, &txc.time)))
1136 /* Get an address range which is currently unmapped. Similar to the
1137 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
1139 static unsigned long
1140 arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
1141 unsigned long limit)
1143 struct vm_area_struct *vma = find_vma(current->mm, addr);
1146 /* At this point: (!vma || addr < vma->vm_end). */
1147 if (limit - len < addr)
1149 if (!vma || addr + len <= vma->vm_start)
1157 arch_get_unmapped_area(struct file *filp, unsigned long addr,
1158 unsigned long len, unsigned long pgoff,
1159 unsigned long flags)
1161 unsigned long limit;
1163 /* "32 bit" actually means 31 bit, since pointers sign extend. */
1164 if (current->personality & ADDR_LIMIT_32BIT)
1172 if (flags & MAP_FIXED)
1175 /* First, see if the given suggestion fits.
1177 The OSF/1 loader (/sbin/loader) relies on us returning an
1178 address larger than the requested if one exists, which is
1179 a terribly broken way to program.
1181 That said, I can see the use in being able to suggest not
1182 merely specific addresses, but regions of memory -- perhaps
1183 this feature should be incorporated into all ports? */
1186 addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
1187 if (addr != (unsigned long) -ENOMEM)
1191 /* Next, try allocating at TASK_UNMAPPED_BASE. */
1192 addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
1194 if (addr != (unsigned long) -ENOMEM)
1197 /* Finally, try allocating in low memory. */
1198 addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
1203 #ifdef CONFIG_OSF4_COMPAT
1205 /* Clear top 32 bits of iov_len in the user's buffer for
1206 compatibility with old versions of OSF/1 where iov_len
1207 was defined as int. */
1209 osf_fix_iov_len(const struct iovec __user *iov, unsigned long count)
1213 for (i = 0 ; i < count ; i++) {
1214 int __user *iov_len_high = (int __user *)&iov[i].iov_len + 1;
1216 if (put_user(0, iov_len_high))
1222 SYSCALL_DEFINE3(osf_readv, unsigned long, fd,
1223 const struct iovec __user *, vector, unsigned long, count)
1225 if (unlikely(personality(current->personality) == PER_OSF4))
1226 if (osf_fix_iov_len(vector, count))
1228 return sys_readv(fd, vector, count);
1231 SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
1232 const struct iovec __user *, vector, unsigned long, count)
1234 if (unlikely(personality(current->personality) == PER_OSF4))
1235 if (osf_fix_iov_len(vector, count))
1237 return sys_writev(fd, vector, count);