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/smp_lock.h>
19 #include <linux/stddef.h>
20 #include <linux/unistd.h>
21 #include <linux/ptrace.h>
22 #include <linux/malloc.h>
23 #include <linux/user.h>
24 #include <linux/a.out.h>
25 #include <linux/utsname.h>
26 #include <linux/time.h>
27 #include <linux/timex.h>
28 #include <linux/major.h>
29 #include <linux/stat.h>
30 #include <linux/mman.h>
31 #include <linux/shm.h>
32 #include <linux/poll.h>
33 #include <linux/file.h>
37 #include <asm/uaccess.h>
38 #include <asm/system.h>
39 #include <asm/sysinfo.h>
41 extern int do_mount(kdev_t
, const char *, const char *, char *, int, void *);
42 extern int do_pipe(int *);
44 extern struct file_operations
*get_blkfops(unsigned int);
45 extern struct file_operations
*get_chrfops(unsigned int);
47 extern kdev_t
get_unnamed_dev(void);
48 extern void put_unnamed_dev(kdev_t
);
50 extern asmlinkage
int sys_swapon(const char *specialfile
, int swap_flags
);
51 extern asmlinkage
unsigned long sys_brk(unsigned long);
54 * Brk needs to return an error. Still support Linux's brk(0) query idiom,
55 * which OSF programs just shouldn't be doing. We're still not quite
56 * identical to OSF as we don't return 0 on success, but doing otherwise
57 * would require changes to libc. Hopefully this is good enough.
59 asmlinkage
unsigned long osf_brk(unsigned long brk
)
61 unsigned long retval
= sys_brk(brk
);
62 if (brk
&& brk
!= retval
)
68 * This is pure guess-work..
70 asmlinkage
int osf_set_program_attributes(
71 unsigned long text_start
, unsigned long text_len
,
72 unsigned long bss_start
, unsigned long bss_len
)
78 mm
->end_code
= bss_start
+ bss_len
;
79 mm
->brk
= bss_start
+ bss_len
;
80 printk("set_program_attributes(%lx %lx %lx %lx)\n",
81 text_start
, text_len
, bss_start
, bss_len
);
87 * OSF/1 directory handling functions...
89 * The "getdents()" interface is much more sane: the "basep" stuff is
90 * braindamage (it can't really handle filesystems where the directory
91 * offset differences aren't the same as "d_reclen").
93 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
94 #define ROUND_UP(x) (((x)+3) & ~3)
98 unsigned short d_reclen
;
99 unsigned short d_namlen
;
103 struct osf_dirent_callback
{
104 struct osf_dirent
*dirent
;
110 static int osf_filldir(void *__buf
, const char *name
, int namlen
, off_t offset
, ino_t ino
)
112 struct osf_dirent
*dirent
;
113 struct osf_dirent_callback
*buf
= (struct osf_dirent_callback
*) __buf
;
114 int reclen
= ROUND_UP(NAME_OFFSET(dirent
) + namlen
+ 1);
116 buf
->error
= -EINVAL
; /* only used if we fail */
117 if (reclen
> buf
->count
)
120 put_user(offset
, buf
->basep
);
123 dirent
= buf
->dirent
;
124 put_user(ino
, &dirent
->d_ino
);
125 put_user(namlen
, &dirent
->d_namlen
);
126 put_user(reclen
, &dirent
->d_reclen
);
127 copy_to_user(dirent
->d_name
, name
, namlen
);
128 put_user(0, dirent
->d_name
+ namlen
);
129 ((char *) dirent
) += reclen
;
130 buf
->dirent
= dirent
;
131 buf
->count
-= reclen
;
135 asmlinkage
int osf_getdirentries(unsigned int fd
, struct osf_dirent
*dirent
,
136 unsigned int count
, long *basep
)
141 struct osf_dirent_callback buf
;
154 if (!file
->f_op
|| !file
->f_op
->readdir
)
158 * Get the inode's semaphore to prevent changes
159 * to the directory while we read it.
161 inode
= file
->f_dentry
->d_inode
;
163 error
= file
->f_op
->readdir(file
, &buf
, osf_filldir
);
169 if (count
!= buf
.count
)
170 error
= count
- buf
.count
;
182 * Alpha syscall convention has no problem returning negative
185 asmlinkage
int osf_getpriority(int which
, int who
, int a2
, int a3
, int a4
,
186 int a5
, struct pt_regs regs
)
188 extern int sys_getpriority(int, int);
192 * We don't need to acquire the kernel lock here, because
193 * all of these operations are local. sys_getpriority
194 * will get the lock as required..
196 prio
= sys_getpriority(which
, who
);
198 regs
.r0
= 0; /* special return: no errors */
206 * Heh. As documented by DEC..
208 asmlinkage
unsigned long sys_madvise(void)
214 * No need to acquire the kernel lock, we're local..
216 asmlinkage
unsigned long sys_getxuid(int a0
, int a1
, int a2
, int a3
, int a4
,
217 int a5
, struct pt_regs regs
)
219 struct task_struct
* tsk
= current
;
220 (®s
)->r20
= tsk
->euid
;
224 asmlinkage
unsigned long sys_getxgid(int a0
, int a1
, int a2
, int a3
, int a4
,
225 int a5
, struct pt_regs regs
)
227 struct task_struct
* tsk
= current
;
228 (®s
)->r20
= tsk
->egid
;
232 asmlinkage
unsigned long sys_getxpid(int a0
, int a1
, int a2
, int a3
, int a4
,
233 int a5
, struct pt_regs regs
)
235 struct task_struct
*tsk
= current
;
238 * This isn't strictly "local" any more and we should actually
239 * acquire the kernel lock. The "p_opptr" pointer might change
240 * if the parent goes away (or due to ptrace). But any race
241 * isn't actually going to matter, as if the parent happens
242 * to change we can happily return either of the pids.
244 (®s
)->r20
= tsk
->p_opptr
->pid
;
248 asmlinkage
unsigned long osf_mmap(unsigned long addr
, unsigned long len
,
249 unsigned long prot
, unsigned long flags
, unsigned long fd
,
252 struct file
*file
= NULL
;
253 unsigned long ret
= -EBADF
;
257 if (flags
& (_MAP_HASSEMAPHORE
| _MAP_INHERIT
| _MAP_UNALIGNED
))
258 printk("%s: unimplemented OSF mmap flags %04lx\n",
259 current
->comm
, flags
);
261 if (!(flags
& MAP_ANONYMOUS
)) {
266 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
267 ret
= do_mmap(file
, addr
, len
, prot
, flags
, off
);
277 * The OSF/1 statfs structure is much larger, but this should
278 * match the beginning, at least.
290 __kernel_fsid_t f_fsid
;
293 static int linux_to_osf_statfs(struct statfs
*linux_stat
, struct osf_statfs
*osf_stat
, unsigned long bufsiz
)
295 struct osf_statfs tmp_stat
;
297 tmp_stat
.f_type
= linux_stat
->f_type
;
298 tmp_stat
.f_flags
= 0; /* mount flags */
299 /* Linux doesn't provide a "fundamental filesystem block size": */
300 tmp_stat
.f_fsize
= linux_stat
->f_bsize
;
301 tmp_stat
.f_bsize
= linux_stat
->f_bsize
;
302 tmp_stat
.f_blocks
= linux_stat
->f_blocks
;
303 tmp_stat
.f_bfree
= linux_stat
->f_bfree
;
304 tmp_stat
.f_bavail
= linux_stat
->f_bavail
;
305 tmp_stat
.f_files
= linux_stat
->f_files
;
306 tmp_stat
.f_ffree
= linux_stat
->f_ffree
;
307 tmp_stat
.f_fsid
= linux_stat
->f_fsid
;
308 if (bufsiz
> sizeof(tmp_stat
))
309 bufsiz
= sizeof(tmp_stat
);
310 return copy_to_user(osf_stat
, &tmp_stat
, bufsiz
) ? -EFAULT
: 0;
313 static int do_osf_statfs(struct dentry
* dentry
, struct osf_statfs
*buffer
, unsigned long bufsiz
)
315 struct statfs linux_stat
;
316 struct inode
* inode
= dentry
->d_inode
;
317 struct super_block
* sb
= inode
->i_sb
;
321 if (sb
->s_op
->statfs
) {
323 error
= sb
->s_op
->statfs(sb
, &linux_stat
, sizeof(linux_stat
));
326 error
= linux_to_osf_statfs(&linux_stat
, buffer
, bufsiz
);
331 asmlinkage
int osf_statfs(char *path
, struct osf_statfs
*buffer
, unsigned long bufsiz
)
333 struct dentry
*dentry
;
337 dentry
= namei(path
);
338 retval
= PTR_ERR(dentry
);
339 if (!IS_ERR(dentry
)) {
340 retval
= do_osf_statfs(dentry
, buffer
, bufsiz
);
347 asmlinkage
int osf_fstatfs(unsigned long fd
, struct osf_statfs
*buffer
, unsigned long bufsiz
)
350 struct dentry
*dentry
;
358 dentry
= file
->f_dentry
;
360 retval
= do_osf_statfs(dentry
, buffer
, bufsiz
);
368 * Uhh.. OSF/1 mount parameters aren't exactly obvious..
370 * Although to be frank, neither are the native Linux/i386 ones..
383 * This has lots more here, which Linux handles with the option block
384 * but I'm too lazy to do the translation into ASCII.
394 static int getdev(const char *name
, int rdonly
, struct dentry
**dp
)
397 struct dentry
*dentry
;
399 struct file_operations
*fops
;
402 dentry
= namei(name
);
403 retval
= PTR_ERR(dentry
);
408 inode
= dentry
->d_inode
;
409 if (!S_ISBLK(inode
->i_mode
))
418 if (MAJOR(dev
) >= MAX_BLKDEV
)
422 fops
= get_blkfops(MAJOR(dev
));
427 memset(&dummy
, 0, sizeof(dummy
));
428 dummy
.f_dentry
= dentry
;
429 dummy
.f_mode
= rdonly
? 1 : 3;
430 retval
= fops
->open(inode
, &dummy
);
444 static void putdev(struct dentry
*dentry
)
446 struct file_operations
*fops
;
448 fops
= get_blkfops(MAJOR(dentry
->d_inode
->i_rdev
));
450 fops
->release(dentry
->d_inode
, NULL
);
454 * We can't actually handle ufs yet, so we translate UFS mounts to
455 * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
456 * layout is so braindead it's a major headache doing it.
458 static int osf_ufs_mount(char *dirname
, struct ufs_args
*args
, int flags
)
461 struct dentry
*dentry
;
462 struct cdfs_args tmp
;
465 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
468 retval
= getdev(tmp
.devname
, 0, &dentry
);
471 retval
= do_mount(dentry
->d_inode
->i_rdev
, tmp
.devname
, dirname
,
472 "ext2", flags
, NULL
);
480 static int osf_cdfs_mount(char *dirname
, struct cdfs_args
*args
, int flags
)
483 struct dentry
* dentry
;
484 struct cdfs_args tmp
;
487 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
490 retval
= getdev(tmp
.devname
, 1, &dentry
);
493 retval
= do_mount(dentry
->d_inode
->i_rdev
, tmp
.devname
, dirname
,
494 "iso9660", flags
, NULL
);
502 static int osf_procfs_mount(char *dirname
, struct procfs_args
*args
, int flags
)
506 struct procfs_args tmp
;
508 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
510 dev
= get_unnamed_dev();
513 retval
= do_mount(dev
, "", dirname
, "proc", flags
, NULL
);
515 put_unnamed_dev(dev
);
519 asmlinkage
int osf_mount(unsigned long typenr
, char *path
, int flag
, void *data
)
521 int retval
= -EINVAL
;
526 retval
= osf_ufs_mount(path
, (struct ufs_args
*) data
, flag
);
529 retval
= osf_cdfs_mount(path
, (struct cdfs_args
*) data
, flag
);
532 retval
= osf_procfs_mount(path
, (struct procfs_args
*) data
, flag
);
535 printk("osf_mount(%ld, %x)\n", typenr
, flag
);
541 asmlinkage
int osf_utsname(char *name
)
547 if (copy_to_user(name
+ 0, system_utsname
.sysname
, 32))
549 if (copy_to_user(name
+ 32, system_utsname
.nodename
, 32))
551 if (copy_to_user(name
+ 64, system_utsname
.release
, 32))
553 if (copy_to_user(name
+ 96, system_utsname
.version
, 32))
555 if (copy_to_user(name
+ 128, system_utsname
.machine
, 32))
564 asmlinkage
int osf_swapon(const char *path
, int flags
, int lowat
, int hiwat
)
568 /* for now, simply ignore lowat and hiwat... */
570 ret
= sys_swapon(path
, flags
);
575 asmlinkage
unsigned long sys_getpagesize(void)
580 asmlinkage
unsigned long sys_getdtablesize(void)
585 asmlinkage
int sys_pipe(int a0
, int a1
, int a2
, int a3
, int a4
, int a5
,
595 (®s
)->r20
= fd
[1];
603 * For compatibility with OSF/1 only. Use utsname(2) instead.
605 asmlinkage
int osf_getdomainname(char *name
, int namelen
)
611 error
= verify_area(VERIFY_WRITE
, name
, namelen
);
620 for (i
= 0; i
< len
; ++i
) {
621 __put_user(system_utsname
.domainname
[i
], name
+ i
);
622 if (system_utsname
.domainname
[i
] == '\0')
632 asmlinkage
long osf_shmat(int shmid
, void *shmaddr
, int shmflg
)
638 err
= sys_shmat(shmid
, shmaddr
, shmflg
, &raddr
);
642 * This works because all user-level addresses are
643 * non-negative longs!
653 * The following stuff should move into a header file should it ever
654 * be labeled "officially supported." Right now, there is just enough
655 * support to avoid applications (such as tar) printing error
656 * messages. The attributes are not really implemented.
660 * Values for Property list entry flag
662 #define PLE_PROPAGATE_ON_COPY 0x1 /* cp(1) will copy entry
664 #define PLE_FLAG_MASK 0x1 /* Valid flag values */
665 #define PLE_FLAG_ALL -1 /* All flag value */
667 struct proplistname_args
{
668 unsigned int pl_mask
;
669 unsigned int pl_numnames
;
688 struct proplistname_args
*name_args
;
695 struct proplistname_args
*name_args
;
703 struct proplistname_args
*name_args
;
707 struct proplistname_args
*name_args
;
712 PL_SET
= 1, PL_FSET
= 2,
713 PL_GET
= 3, PL_FGET
= 4,
714 PL_DEL
= 5, PL_FDEL
= 6
717 asmlinkage
long osf_proplist_syscall(enum pl_code code
, union pl_args
*args
)
720 int *min_buf_size_ptr
;
725 error
= verify_area(VERIFY_READ
, &args
->set
.nbytes
,
726 sizeof(args
->set
.nbytes
));
728 error
= args
->set
.nbytes
;
731 error
= verify_area(VERIFY_READ
, &args
->fset
.nbytes
,
732 sizeof(args
->fset
.nbytes
));
734 error
= args
->fset
.nbytes
;
737 get_user(min_buf_size_ptr
, &args
->get
.min_buf_size
);
738 error
= verify_area(VERIFY_WRITE
, min_buf_size_ptr
,
739 sizeof(*min_buf_size_ptr
));
741 put_user(0, min_buf_size_ptr
);
744 get_user(min_buf_size_ptr
, &args
->fget
.min_buf_size
);
745 error
= verify_area(VERIFY_WRITE
, min_buf_size_ptr
,
746 sizeof(*min_buf_size_ptr
));
748 put_user(0, min_buf_size_ptr
);
762 asmlinkage
int osf_sigstack(struct sigstack
*uss
, struct sigstack
*uoss
)
764 unsigned long usp
= rdusp();
765 unsigned long oss_sp
, oss_os
;
769 oss_sp
= current
->sas_ss_sp
+ current
->sas_ss_size
;
770 oss_os
= on_sig_stack(usp
);
777 if (get_user(ss_sp
, &uss
->ss_sp
))
780 /* If the current stack was set with sigaltstack, don't
781 swap stacks while we are on it. */
783 if (current
->sas_ss_sp
&& on_sig_stack(usp
))
786 /* Since we don't know the extent of the stack, and we don't
787 track onstack-ness, but rather calculate it, we must
788 presume a size. Ho hum this interface is lossy. */
789 current
->sas_ss_sp
= (unsigned long)ss_sp
- SIGSTKSZ
;
790 current
->sas_ss_size
= SIGSTKSZ
;
795 if (! access_ok(VERIFY_WRITE
, uoss
, sizeof(*uoss
))
796 || __put_user(oss_sp
, &uoss
->ss_sp
)
797 || __put_user(oss_os
, &uoss
->ss_onstack
))
807 * The Linux kernel isn't good at returning values that look
808 * like negative longs (they are mistaken as error values).
809 * Until that is fixed, we need this little workaround for
810 * create_module() because it's one of the few system calls
811 * that return kernel addresses (which are negative).
813 asmlinkage
unsigned long alpha_create_module(char *module_name
, unsigned long size
,
814 int a3
, int a4
, int a5
, int a6
,
817 asmlinkage
unsigned long sys_create_module(char *, unsigned long);
821 retval
= sys_create_module(module_name
, size
);
823 * we get either a module address or an error number,
824 * and we know the error number is a small negative
825 * number, while the address is always negative but
828 if (retval
+ 1000 > 0)
831 /* tell entry.S:syscall_error that this is NOT an error: */
838 asmlinkage
long osf_sysinfo(int command
, char *buf
, long count
)
840 static char * sysinfo_table
[] = {
841 system_utsname
.sysname
,
842 system_utsname
.nodename
,
843 system_utsname
.release
,
844 system_utsname
.version
,
845 system_utsname
.machine
,
846 "alpha", /* instruction set architecture */
847 "dummy", /* hardware serial number */
848 "dummy", /* hardware manufacturer */
849 "dummy", /* secure RPC domain */
851 unsigned long offset
;
853 long len
, err
= -EINVAL
;
857 if (offset
>= sizeof(sysinfo_table
)/sizeof(char *)) {
858 /* Digital UNIX has a few unpublished interfaces here */
859 printk("sysinfo(%d)", command
);
864 res
= sysinfo_table
[offset
];
868 if (copy_to_user(buf
, res
, len
))
878 asmlinkage
unsigned long osf_getsysinfo(unsigned long op
, void *buffer
,
879 unsigned long nbytes
,
880 int *start
, void *arg
)
885 case GSI_IEEE_FP_CONTROL
:
886 /* Return current software fp control & status bits. */
887 w
= current
->tss
.flags
& IEEE_SW_MASK
;
888 if (put_user(w
, (unsigned long *) buffer
))
892 case GSI_IEEE_STATE_AT_SIGNAL
:
894 * Not sure anybody will ever use this weird stuff. These
895 * ops can be used (under OSF/1) to set the fpcr that should
896 * be used when a signal handler starts executing.
901 w
= (current
->tss
.flags
>> UAC_SHIFT
) & UAC_BITMASK
;
902 if (put_user(w
, (unsigned int *)buffer
))
913 asmlinkage
unsigned long osf_setsysinfo(unsigned long op
, void *buffer
,
914 unsigned long nbytes
,
915 int *start
, void *arg
)
918 case SSI_IEEE_FP_CONTROL
: {
919 unsigned long swcr
, fpcr
;
922 * Alpha Architecture Handbook 4.7.7.3:
923 * To be fully IEEE compiant, we must track the current IEEE
924 * exception state in software, because spurrious bits can be
925 * set in the trap shadow of a software-complete insn.
928 /* Update softare trap enable bits. */
929 if (get_user(swcr
, (unsigned long *)buffer
))
931 current
->tss
.flags
&= ~IEEE_SW_MASK
;
932 current
->tss
.flags
|= swcr
& IEEE_SW_MASK
;
934 /* Update the real fpcr. For exceptions that are disabled in
935 software but have not been seen, enable the exception in
936 hardware so that we can update our software status mask. */
937 fpcr
= rdfpcr() & (~FPCR_MASK
| FPCR_DYN_MASK
);
938 fpcr
|= ieee_swcr_to_fpcr(swcr
| (~swcr
& IEEE_STATUS_MASK
)>>16);
944 case SSI_IEEE_STATE_AT_SIGNAL
:
945 case SSI_IEEE_IGNORE_STATE_AT_SIGNAL
:
947 * Not sure anybody will ever use this weird stuff. These
948 * ops can be used (under OSF/1) to set the fpcr that should
949 * be used when a signal handler starts executing.
954 unsigned long v
, w
, i
;
956 for (i
= 0; i
< nbytes
; ++i
) {
957 if (get_user(v
, 2*i
+ (unsigned int *)buffer
))
959 if (get_user(w
, 2*i
+ 1 + (unsigned int *)buffer
))
963 current
->tss
.flags
&=
964 ~(UAC_BITMASK
<< UAC_SHIFT
);
965 current
->tss
.flags
|=
966 (w
& UAC_BITMASK
) << UAC_SHIFT
;
983 /* Translations due to the fact that OSF's time_t is an int. Which
984 affects all sorts of things, like timeval and itimerval. */
986 extern struct timezone sys_tz
;
987 extern int do_sys_settimeofday(struct timeval
*tv
, struct timezone
*tz
);
988 extern int do_getitimer(int which
, struct itimerval
*value
);
989 extern int do_setitimer(int which
, struct itimerval
*, struct itimerval
*);
990 asmlinkage
int sys_utimes(char *, struct timeval
*);
991 extern int sys_wait4(pid_t
, int *, int, struct rusage
*);
992 extern int do_adjtimex(struct timex
*);
1001 struct timeval32 it_interval
;
1002 struct timeval32 it_value
;
1005 static inline long get_tv32(struct timeval
*o
, struct timeval32
*i
)
1007 return (!access_ok(VERIFY_READ
, i
, sizeof(*i
)) ||
1008 (__get_user(o
->tv_sec
, &i
->tv_sec
) |
1009 __get_user(o
->tv_usec
, &i
->tv_usec
)));
1012 static inline long put_tv32(struct timeval32
*o
, struct timeval
*i
)
1014 return (!access_ok(VERIFY_WRITE
, o
, sizeof(*o
)) ||
1015 (__put_user(i
->tv_sec
, &o
->tv_sec
) |
1016 __put_user(i
->tv_usec
, &o
->tv_usec
)));
1019 static inline long get_it32(struct itimerval
*o
, struct itimerval32
*i
)
1021 return (!access_ok(VERIFY_READ
, i
, sizeof(*i
)) ||
1022 (__get_user(o
->it_interval
.tv_sec
, &i
->it_interval
.tv_sec
) |
1023 __get_user(o
->it_interval
.tv_usec
, &i
->it_interval
.tv_usec
) |
1024 __get_user(o
->it_value
.tv_sec
, &i
->it_value
.tv_sec
) |
1025 __get_user(o
->it_value
.tv_usec
, &i
->it_value
.tv_usec
)));
1028 static inline long put_it32(struct itimerval32
*o
, struct itimerval
*i
)
1030 return (!access_ok(VERIFY_WRITE
, o
, sizeof(*o
)) ||
1031 (__put_user(i
->it_interval
.tv_sec
, &o
->it_interval
.tv_sec
) |
1032 __put_user(i
->it_interval
.tv_usec
, &o
->it_interval
.tv_usec
) |
1033 __put_user(i
->it_value
.tv_sec
, &o
->it_value
.tv_sec
) |
1034 __put_user(i
->it_value
.tv_usec
, &o
->it_value
.tv_usec
)));
1037 asmlinkage
int osf_gettimeofday(struct timeval32
*tv
, struct timezone
*tz
)
1041 do_gettimeofday(&ktv
);
1042 if (put_tv32(tv
, &ktv
))
1046 if (copy_to_user(tz
, &sys_tz
, sizeof(sys_tz
)))
1052 asmlinkage
int osf_settimeofday(struct timeval32
*tv
, struct timezone
*tz
)
1055 struct timezone ktz
;
1058 if (get_tv32(&ktv
, tv
))
1062 if (copy_from_user(&ktz
, tz
, sizeof(*tz
)))
1066 return do_sys_settimeofday(tv
? &ktv
: NULL
, tz
? &ktz
: NULL
);
1069 asmlinkage
int osf_getitimer(int which
, struct itimerval32
*it
)
1071 struct itimerval kit
;
1074 error
= do_getitimer(which
, &kit
);
1075 if (!error
&& put_it32(it
, &kit
))
1081 asmlinkage
int osf_setitimer(int which
, struct itimerval32
*in
,
1082 struct itimerval32
*out
)
1084 struct itimerval kin
, kout
;
1088 if (get_it32(&kin
, in
))
1091 memset(&kin
, 0, sizeof(kin
));
1093 error
= do_setitimer(which
, &kin
, out
? &kout
: NULL
);
1097 if (put_it32(out
, &kout
))
1104 asmlinkage
int osf_utimes(const char *filename
, struct timeval32
*tvs
)
1107 struct timeval ktvs
[2];
1108 mm_segment_t old_fs
;
1111 kfilename
= getname(filename
);
1112 if (IS_ERR(kfilename
))
1113 return PTR_ERR(kfilename
);
1116 if (get_tv32(&ktvs
[0], &tvs
[0]) ||
1117 get_tv32(&ktvs
[1], &tvs
[1]))
1123 ret
= sys_utimes(kfilename
, tvs
? ktvs
: 0);
1131 #define MAX_SELECT_SECONDS \
1132 ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1)
1135 osf_select(int n
, fd_set
*inp
, fd_set
*outp
, fd_set
*exp
,
1136 struct timeval32
*tvp
)
1141 unsigned long timeout
;
1144 timeout
= MAX_SCHEDULE_TIMEOUT
;
1148 if ((ret
= verify_area(VERIFY_READ
, tvp
, sizeof(*tvp
)))
1149 || (ret
= __get_user(sec
, &tvp
->tv_sec
))
1150 || (ret
= __get_user(usec
, &tvp
->tv_usec
)))
1154 if (sec
< 0 || usec
< 0)
1157 if ((unsigned long) sec
< MAX_SELECT_SECONDS
) {
1158 timeout
= (usec
+ 1000000/HZ
- 1) / (1000000/HZ
);
1159 timeout
+= sec
* (unsigned long) HZ
;
1164 if (n
< 0 || n
> KFDS_NR
)
1168 * We need 6 bitmaps (in/out/ex for both incoming and outgoing),
1169 * since we used fdset we need to allocate memory in units of
1173 size
= FDS_BYTES(n
);
1174 bits
= kmalloc(6 * size
, GFP_KERNEL
);
1177 fds
.in
= (unsigned long *) bits
;
1178 fds
.out
= (unsigned long *) (bits
+ size
);
1179 fds
.ex
= (unsigned long *) (bits
+ 2*size
);
1180 fds
.res_in
= (unsigned long *) (bits
+ 3*size
);
1181 fds
.res_out
= (unsigned long *) (bits
+ 4*size
);
1182 fds
.res_ex
= (unsigned long *) (bits
+ 5*size
);
1184 if ((ret
= get_fd_set(n
, inp
->fds_bits
, fds
.in
)) ||
1185 (ret
= get_fd_set(n
, outp
->fds_bits
, fds
.out
)) ||
1186 (ret
= get_fd_set(n
, exp
->fds_bits
, fds
.ex
)))
1188 zero_fd_set(n
, fds
.res_in
);
1189 zero_fd_set(n
, fds
.res_out
);
1190 zero_fd_set(n
, fds
.res_ex
);
1192 ret
= do_select(n
, &fds
, &timeout
);
1194 /* OSF does not copy back the remaining time. */
1199 ret
= -ERESTARTNOHAND
;
1200 if (signal_pending(current
))
1205 set_fd_set(n
, inp
->fds_bits
, fds
.res_in
);
1206 set_fd_set(n
, outp
->fds_bits
, fds
.res_out
);
1207 set_fd_set(n
, exp
->fds_bits
, fds
.res_ex
);
1216 struct timeval32 ru_utime
; /* user time used */
1217 struct timeval32 ru_stime
; /* system time used */
1218 long ru_maxrss
; /* maximum resident set size */
1219 long ru_ixrss
; /* integral shared memory size */
1220 long ru_idrss
; /* integral unshared data size */
1221 long ru_isrss
; /* integral unshared stack size */
1222 long ru_minflt
; /* page reclaims */
1223 long ru_majflt
; /* page faults */
1224 long ru_nswap
; /* swaps */
1225 long ru_inblock
; /* block input operations */
1226 long ru_oublock
; /* block output operations */
1227 long ru_msgsnd
; /* messages sent */
1228 long ru_msgrcv
; /* messages received */
1229 long ru_nsignals
; /* signals received */
1230 long ru_nvcsw
; /* voluntary context switches */
1231 long ru_nivcsw
; /* involuntary " */
1234 asmlinkage
int osf_getrusage(int who
, struct rusage32
*ru
)
1238 if (who
!= RUSAGE_SELF
&& who
!= RUSAGE_CHILDREN
)
1241 memset(&r
, 0, sizeof(r
));
1244 r
.ru_utime
.tv_sec
= CT_TO_SECS(current
->times
.tms_utime
);
1245 r
.ru_utime
.tv_usec
= CT_TO_USECS(current
->times
.tms_utime
);
1246 r
.ru_stime
.tv_sec
= CT_TO_SECS(current
->times
.tms_stime
);
1247 r
.ru_stime
.tv_usec
= CT_TO_USECS(current
->times
.tms_stime
);
1248 r
.ru_minflt
= current
->min_flt
;
1249 r
.ru_majflt
= current
->maj_flt
;
1250 r
.ru_nswap
= current
->nswap
;
1252 case RUSAGE_CHILDREN
:
1253 r
.ru_utime
.tv_sec
= CT_TO_SECS(current
->times
.tms_cutime
);
1254 r
.ru_utime
.tv_usec
= CT_TO_USECS(current
->times
.tms_cutime
);
1255 r
.ru_stime
.tv_sec
= CT_TO_SECS(current
->times
.tms_cstime
);
1256 r
.ru_stime
.tv_usec
= CT_TO_USECS(current
->times
.tms_cstime
);
1257 r
.ru_minflt
= current
->cmin_flt
;
1258 r
.ru_majflt
= current
->cmaj_flt
;
1259 r
.ru_nswap
= current
->cnswap
;
1262 r
.ru_utime
.tv_sec
= CT_TO_SECS(current
->times
.tms_utime
+
1263 current
->times
.tms_cutime
);
1264 r
.ru_utime
.tv_usec
= CT_TO_USECS(current
->times
.tms_utime
+
1265 current
->times
.tms_cutime
);
1266 r
.ru_stime
.tv_sec
= CT_TO_SECS(current
->times
.tms_stime
+
1267 current
->times
.tms_cstime
);
1268 r
.ru_stime
.tv_usec
= CT_TO_USECS(current
->times
.tms_stime
+
1269 current
->times
.tms_cstime
);
1270 r
.ru_minflt
= current
->min_flt
+ current
->cmin_flt
;
1271 r
.ru_majflt
= current
->maj_flt
+ current
->cmaj_flt
;
1272 r
.ru_nswap
= current
->nswap
+ current
->cnswap
;
1276 return copy_to_user(ru
, &r
, sizeof(r
)) ? -EFAULT
: 0;
1279 asmlinkage
int osf_wait4(pid_t pid
, int *ustatus
, int options
,
1280 struct rusage32
*ur
)
1283 return sys_wait4(pid
, ustatus
, options
, NULL
);
1287 mm_segment_t old_fs
= get_fs();
1290 ret
= sys_wait4(pid
, &status
, options
, &r
);
1293 if (!access_ok(VERIFY_WRITE
, ur
, sizeof(*ur
)))
1295 __put_user(r
.ru_utime
.tv_sec
, &ur
->ru_utime
.tv_sec
);
1296 __put_user(r
.ru_utime
.tv_usec
, &ur
->ru_utime
.tv_usec
);
1297 __put_user(r
.ru_stime
.tv_sec
, &ur
->ru_stime
.tv_sec
);
1298 __put_user(r
.ru_stime
.tv_usec
, &ur
->ru_stime
.tv_usec
);
1299 __put_user(r
.ru_maxrss
, &ur
->ru_maxrss
);
1300 __put_user(r
.ru_ixrss
, &ur
->ru_ixrss
);
1301 __put_user(r
.ru_idrss
, &ur
->ru_idrss
);
1302 __put_user(r
.ru_isrss
, &ur
->ru_isrss
);
1303 __put_user(r
.ru_minflt
, &ur
->ru_minflt
);
1304 __put_user(r
.ru_majflt
, &ur
->ru_majflt
);
1305 __put_user(r
.ru_nswap
, &ur
->ru_nswap
);
1306 __put_user(r
.ru_inblock
, &ur
->ru_inblock
);
1307 __put_user(r
.ru_oublock
, &ur
->ru_oublock
);
1308 __put_user(r
.ru_msgsnd
, &ur
->ru_msgsnd
);
1309 __put_user(r
.ru_msgrcv
, &ur
->ru_msgrcv
);
1310 __put_user(r
.ru_nsignals
, &ur
->ru_nsignals
);
1311 __put_user(r
.ru_nvcsw
, &ur
->ru_nvcsw
);
1312 if (__put_user(r
.ru_nivcsw
, &ur
->ru_nivcsw
))
1315 if (ustatus
&& put_user(status
, ustatus
))
1322 * I don't know what the parameters are: the first one
1323 * seems to be a timeval pointer, and I suspect the second
1324 * one is the time remaining.. Ho humm.. No documentation.
1326 asmlinkage
int osf_usleep_thread(struct timeval32
*sleep
, struct timeval32
*remain
)
1329 unsigned long ticks
;
1331 if (get_tv32(&tmp
, sleep
))
1334 ticks
= tmp
.tv_usec
;
1335 ticks
= (ticks
+ (1000000 / HZ
) - 1) / (1000000 / HZ
);
1336 ticks
+= tmp
.tv_sec
* HZ
;
1338 current
->state
= TASK_INTERRUPTIBLE
;
1339 ticks
= schedule_timeout(ticks
);
1342 tmp
.tv_sec
= ticks
/ HZ
;
1343 tmp
.tv_usec
= ticks
% HZ
;
1344 if (put_tv32(remain
, &tmp
))
1355 unsigned int modes
; /* mode selector */
1356 long offset
; /* time offset (usec) */
1357 long freq
; /* frequency offset (scaled ppm) */
1358 long maxerror
; /* maximum error (usec) */
1359 long esterror
; /* estimated error (usec) */
1360 int status
; /* clock command/status */
1361 long constant
; /* pll time constant */
1362 long precision
; /* clock precision (usec) (read only) */
1363 long tolerance
; /* clock frequency tolerance (ppm)
1366 struct timeval32 time
; /* (read only) */
1367 long tick
; /* (modified) usecs between clock ticks */
1369 long ppsfreq
; /* pps frequency (scaled ppm) (ro) */
1370 long jitter
; /* pps jitter (us) (ro) */
1371 int shift
; /* interval duration (s) (shift) (ro) */
1372 long stabil
; /* pps stability (scaled ppm) (ro) */
1373 long jitcnt
; /* jitter limit exceeded (ro) */
1374 long calcnt
; /* calibration intervals (ro) */
1375 long errcnt
; /* calibration errors (ro) */
1376 long stbcnt
; /* stability limit exceeded (ro) */
1378 int :32; int :32; int :32; int :32;
1379 int :32; int :32; int :32; int :32;
1380 int :32; int :32; int :32; int :32;
1383 asmlinkage
int sys_old_adjtimex(struct timex32
*txc_p
)
1388 /* copy relevant bits of struct timex. */
1389 if (copy_from_user(&txc
, txc_p
, offsetof(struct timex32
, time
)) ||
1390 copy_from_user(&txc
.tick
, &txc_p
->tick
, sizeof(struct timex32
) -
1391 offsetof(struct timex32
, time
)))
1394 if ((ret
= do_adjtimex(&txc
)))
1397 /* copy back to timex32 */
1398 if (copy_to_user(txc_p
, &txc
, offsetof(struct timex32
, time
)) ||
1399 (copy_to_user(&txc_p
->tick
, &txc
.tick
, sizeof(struct timex32
) -
1400 offsetof(struct timex32
, tick
))) ||
1401 (put_tv32(&txc_p
->time
, &txc
.time
)))