1 /* $Id: sys_sunos.c,v 1.137 2002/02/08 03:57:14 davem Exp $
2 * sys_sunos.c: SunOS specific syscall compatibility support.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
7 * Based upon preliminary work which is:
9 * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu)
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/types.h>
16 #include <linux/mman.h>
18 #include <linux/swap.h>
20 #include <linux/file.h>
21 #include <linux/resource.h>
22 #include <linux/ipc.h>
23 #include <linux/shm.h>
24 #include <linux/msg.h>
25 #include <linux/sem.h>
26 #include <linux/signal.h>
27 #include <linux/uio.h>
28 #include <linux/utsname.h>
29 #include <linux/major.h>
30 #include <linux/stat.h>
31 #include <linux/slab.h>
32 #include <linux/pagemap.h>
33 #include <linux/capability.h>
34 #include <linux/errno.h>
35 #include <linux/smp.h>
36 #include <linux/smp_lock.h>
37 #include <linux/syscalls.h>
38 #include <linux/vs_cvirt.h>
42 #include <asm/uaccess.h>
44 #include <linux/segment.h>
48 #include <asm/pgtable.h>
49 #include <asm/pconf.h>
50 #include <asm/idprom.h> /* for gethostid() */
51 #include <asm/unistd.h>
52 #include <asm/system.h>
54 /* For the nfs mount emulation */
55 #include <linux/socket.h>
57 #include <linux/nfs.h>
58 #include <linux/nfs2.h>
59 #include <linux/nfs_mount.h>
61 /* for sunos_select */
62 #include <linux/time.h>
63 #include <linux/personality.h>
65 /* NR_OPEN is now larger and dynamic in recent kernels. */
66 #define SUNOS_NR_OPEN 256
68 /* We use the SunOS mmap() semantics. */
69 asmlinkage unsigned long sunos_mmap(unsigned long addr, unsigned long len,
70 unsigned long prot, unsigned long flags,
71 unsigned long fd, unsigned long off)
73 struct file * file = NULL;
74 unsigned long retval, ret_type;
76 if (flags & MAP_NORESERVE) {
79 printk("%s: unimplemented SunOS MAP_NORESERVE mmap() flag\n",
81 flags &= ~MAP_NORESERVE;
84 if (!(flags & MAP_ANONYMOUS)) {
85 if (fd >= SUNOS_NR_OPEN)
93 /* If this is ld.so or a shared library doing an mmap
94 * of /dev/zero, transform it into an anonymous mapping.
95 * SunOS is so stupid some times... hmph!
98 if (imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
99 iminor(file->f_dentry->d_inode) == 5) {
100 flags |= MAP_ANONYMOUS;
105 ret_type = flags & _MAP_NEW;
108 if (!(flags & MAP_FIXED))
111 if (ARCH_SUN4C_SUN4 &&
113 ((flags & MAP_FIXED) &&
114 addr < 0xe0000000 && addr + len > 0x20000000)))
117 /* See asm-sparc/uaccess.h */
118 if (len > TASK_SIZE - PAGE_SIZE ||
119 addr + len > TASK_SIZE - PAGE_SIZE)
123 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
124 down_write(¤t->mm->mmap_sem);
125 retval = do_mmap(file, addr, len, prot, flags, off);
126 up_write(¤t->mm->mmap_sem);
128 retval = ((retval < PAGE_OFFSET) ? 0 : retval);
137 /* lmbench calls this, just say "yeah, ok" */
138 asmlinkage int sunos_mctl(unsigned long addr, unsigned long len, int function, char *arg)
143 /* SunOS is completely broken... it returns 0 on success, otherwise
144 * ENOMEM. For sys_sbrk() it wants the old brk value as a return
145 * on success and ENOMEM as before on failure.
147 asmlinkage int sunos_brk(unsigned long brk)
149 int freepages, retval = -ENOMEM;
151 unsigned long newbrk, oldbrk;
153 down_write(¤t->mm->mmap_sem);
154 if (ARCH_SUN4C_SUN4) {
155 if (brk >= 0x20000000 && brk < 0xe0000000) {
160 if (brk < current->mm->end_code)
163 newbrk = PAGE_ALIGN(brk);
164 oldbrk = PAGE_ALIGN(current->mm->brk);
166 if (oldbrk == newbrk) {
167 current->mm->brk = brk;
172 * Always allow shrinking brk
174 if (brk <= current->mm->brk) {
175 current->mm->brk = brk;
176 do_munmap(current->mm, newbrk, oldbrk-newbrk);
180 * Check against rlimit and stack..
183 rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
184 if (rlim >= RLIM_INFINITY)
186 if (brk - current->mm->end_code > rlim)
190 * Check against existing mmap mappings.
192 if (find_vma_intersection(current->mm, oldbrk, newbrk+PAGE_SIZE))
196 * stupid algorithm to decide if we have enough memory: while
197 * simple, it hopefully works in most obvious cases.. Easy to
198 * fool it, but this should catch most mistakes.
200 freepages = get_page_cache_size();
202 freepages += nr_free_pages();
203 freepages += nr_swap_pages;
204 freepages -= num_physpages >> 4;
205 freepages -= (newbrk-oldbrk) >> PAGE_SHIFT;
209 * Ok, we have probably got enough memory - let it rip.
211 current->mm->brk = brk;
212 do_brk(oldbrk, newbrk-oldbrk);
215 up_write(¤t->mm->mmap_sem);
219 asmlinkage unsigned long sunos_sbrk(int increment)
222 unsigned long oldbrk;
224 /* This should do it hopefully... */
226 oldbrk = current->mm->brk;
227 error = sunos_brk(((int) current->mm->brk) + increment);
234 /* XXX Completely undocumented, and completely magic...
235 * XXX I believe it is to increase the size of the stack by
236 * XXX argument 'increment' and return the new end of stack
239 asmlinkage unsigned long sunos_sstk(int increment)
242 printk("%s: Call to sunos_sstk(increment<%d>) is unsupported\n",
243 current->comm, increment);
248 /* Give hints to the kernel as to what paging strategy to use...
249 * Completely bogus, don't remind me.
251 #define VA_NORMAL 0 /* Normal vm usage expected */
252 #define VA_ABNORMAL 1 /* Abnormal/random vm usage probable */
253 #define VA_SEQUENTIAL 2 /* Accesses will be of a sequential nature */
254 #define VA_INVALIDATE 3 /* Page table entries should be flushed ??? */
255 static char *vstrings[] = {
262 asmlinkage void sunos_vadvise(unsigned long strategy)
264 /* I wanna see who uses this... */
266 printk("%s: Advises us to use %s paging strategy\n",
268 strategy <= 3 ? vstrings[strategy] : "BOGUS");
272 /* This just wants the soft limit (ie. rlim_cur element) of the RLIMIT_NOFILE
273 * resource limit and is for backwards compatibility with older sunos
276 asmlinkage long sunos_getdtablesize(void)
278 return SUNOS_NR_OPEN;
281 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
283 asmlinkage unsigned long sunos_sigblock(unsigned long blk_mask)
287 spin_lock_irq(¤t->sighand->siglock);
288 old = current->blocked.sig[0];
289 current->blocked.sig[0] |= (blk_mask & _BLOCKABLE);
291 spin_unlock_irq(¤t->sighand->siglock);
295 asmlinkage unsigned long sunos_sigsetmask(unsigned long newmask)
297 unsigned long retval;
299 spin_lock_irq(¤t->sighand->siglock);
300 retval = current->blocked.sig[0];
301 current->blocked.sig[0] = (newmask & _BLOCKABLE);
303 spin_unlock_irq(¤t->sighand->siglock);
307 /* SunOS getdents is very similar to the newer Linux (iBCS2 compliant) */
308 /* getdents system call, the format of the structure just has a different */
309 /* layout (d_off+d_ino instead of d_ino+d_off) */
310 struct sunos_dirent {
313 unsigned short d_reclen;
314 unsigned short d_namlen;
318 struct sunos_dirent_callback {
319 struct sunos_dirent __user *curr;
320 struct sunos_dirent __user *previous;
325 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
326 #define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
328 static int sunos_filldir(void * __buf, const char * name, int namlen,
329 loff_t offset, ino_t ino, unsigned int d_type)
331 struct sunos_dirent __user *dirent;
332 struct sunos_dirent_callback * buf = __buf;
333 int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
335 buf->error = -EINVAL; /* only used if we fail.. */
336 if (reclen > buf->count)
338 dirent = buf->previous;
340 put_user(offset, &dirent->d_off);
342 buf->previous = dirent;
343 put_user(ino, &dirent->d_ino);
344 put_user(namlen, &dirent->d_namlen);
345 put_user(reclen, &dirent->d_reclen);
346 copy_to_user(dirent->d_name, name, namlen);
347 put_user(0, dirent->d_name + namlen);
348 dirent = (void __user *) dirent + reclen;
350 buf->count -= reclen;
354 asmlinkage int sunos_getdents(unsigned int fd, void __user *dirent, int cnt)
357 struct sunos_dirent __user *lastdirent;
358 struct sunos_dirent_callback buf;
361 if (fd >= SUNOS_NR_OPEN)
369 if (cnt < (sizeof(struct sunos_dirent) + 255))
372 buf.curr = (struct sunos_dirent __user *) dirent;
377 error = vfs_readdir(file, sunos_filldir, &buf);
381 lastdirent = buf.previous;
384 put_user(file->f_pos, &lastdirent->d_off);
385 error = cnt - buf.count;
394 /* Old sunos getdirentries, severely broken compatibility stuff here. */
395 struct sunos_direntry {
397 unsigned short d_reclen;
398 unsigned short d_namlen;
402 struct sunos_direntry_callback {
403 struct sunos_direntry __user *curr;
404 struct sunos_direntry __user *previous;
409 static int sunos_filldirentry(void * __buf, const char * name, int namlen,
410 loff_t offset, ino_t ino, unsigned int d_type)
412 struct sunos_direntry __user *dirent;
413 struct sunos_direntry_callback *buf = __buf;
414 int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
416 buf->error = -EINVAL; /* only used if we fail.. */
417 if (reclen > buf->count)
419 dirent = buf->previous;
421 buf->previous = dirent;
422 put_user(ino, &dirent->d_ino);
423 put_user(namlen, &dirent->d_namlen);
424 put_user(reclen, &dirent->d_reclen);
425 copy_to_user(dirent->d_name, name, namlen);
426 put_user(0, dirent->d_name + namlen);
427 dirent = (void __user *) dirent + reclen;
429 buf->count -= reclen;
433 asmlinkage int sunos_getdirentries(unsigned int fd, void __user *dirent,
434 int cnt, unsigned int __user *basep)
437 struct sunos_direntry __user *lastdirent;
438 struct sunos_direntry_callback buf;
441 if (fd >= SUNOS_NR_OPEN)
449 if (cnt < (sizeof(struct sunos_direntry) + 255))
452 buf.curr = (struct sunos_direntry __user *) dirent;
457 error = vfs_readdir(file, sunos_filldirentry, &buf);
461 lastdirent = buf.previous;
464 put_user(file->f_pos, basep);
465 error = cnt - buf.count;
474 struct sunos_utsname {
483 asmlinkage int sunos_uname(struct sunos_utsname __user *name)
486 struct new_utsname *ptr;
488 ptr = vx_new_utsname();
489 ret = copy_to_user(&name->sname[0], ptr->sysname, sizeof(name->sname) - 1);
491 ret |= __copy_to_user(&name->nname[0], ptr->nodename, sizeof(name->nname) - 1);
492 ret |= __put_user('\0', &name->nname[8]);
493 ret |= __copy_to_user(&name->rel[0], ptr->release, sizeof(name->rel) - 1);
494 ret |= __copy_to_user(&name->ver[0], ptr->version, sizeof(name->ver) - 1);
495 ret |= __copy_to_user(&name->mach[0], ptr->machine, sizeof(name->mach) - 1);
498 return ret ? -EFAULT : 0;
501 asmlinkage int sunos_nosys(void)
503 struct pt_regs *regs;
508 regs = current->thread.kregs;
509 info.si_signo = SIGSYS;
511 info.si_code = __SI_FAULT|0x100;
512 info.si_addr = (void __user *)regs->pc;
513 info.si_trapno = regs->u_regs[UREG_G1];
514 send_sig_info(SIGSYS, &info, current);
516 printk("Process makes ni_syscall number %d, register dump:\n",
517 (int) regs->u_regs[UREG_G1]);
524 /* This is not a real and complete implementation yet, just to keep
525 * the easy SunOS binaries happy.
527 asmlinkage int sunos_fpathconf(int fd, int name)
550 case _PCONF_CHRESTRICT: /* XXX Investigate XXX */
553 case _PCONF_NOTRUNC: /* XXX Investigate XXX */
554 case _PCONF_VDISABLE:
564 asmlinkage int sunos_pathconf(char __user *path, int name)
568 ret = sunos_fpathconf(0, name); /* XXX cheese XXX */
572 /* SunOS mount system call emulation */
574 asmlinkage int sunos_select(int width, fd_set __user *inp, fd_set __user *outp,
575 fd_set __user *exp, struct timeval __user *tvp)
579 /* SunOS binaries expect that select won't change the tvp contents */
580 ret = sys_select (width, inp, outp, exp, tvp);
581 if (ret == -EINTR && tvp) {
584 __get_user(sec, &tvp->tv_sec);
585 __get_user(usec, &tvp->tv_usec);
587 if (sec == 0 && usec == 0)
593 asmlinkage void sunos_nop(void)
598 /* SunOS mount/umount. */
599 #define SMNT_RDONLY 1
600 #define SMNT_NOSUID 2
601 #define SMNT_NEWTYPE 4
603 #define SMNT_REMOUNT 16
604 #define SMNT_NOSUB 32
605 #define SMNT_MULTI 64
606 #define SMNT_SYS5 128
609 char fh_data [NFS_FHSIZE];
612 struct sunos_nfs_mount_args {
613 struct sockaddr_in __user *addr; /* file server address */
614 struct nfs_fh __user *fh; /* File handle to be mounted */
615 int flags; /* flags */
616 int wsize; /* write size in bytes */
617 int rsize; /* read size in bytes */
618 int timeo; /* initial timeout in .1 secs */
619 int retrans; /* times to retry send */
620 char __user *hostname; /* server's hostname */
621 int acregmin; /* attr cache file min secs */
622 int acregmax; /* attr cache file max secs */
623 int acdirmin; /* attr cache dir min secs */
624 int acdirmax; /* attr cache dir max secs */
625 char __user *netname; /* server's netname */
629 /* Bind the socket on a local reserved port and connect it to the
630 * remote server. This on Linux/i386 is done by the mount program,
634 sunos_nfs_get_server_fd (int fd, struct sockaddr_in *addr)
636 struct sockaddr_in local;
637 struct sockaddr_in server;
639 struct socket *socket;
648 inode = file->f_dentry->d_inode;
650 socket = SOCKET_I(inode);
651 local.sin_family = AF_INET;
652 local.sin_addr.s_addr = INADDR_ANY;
654 /* IPPORT_RESERVED = 1024, can't find the definition in the kernel */
657 local.sin_port = htons (--try_port);
658 ret = socket->ops->bind(socket, (struct sockaddr*)&local,
660 } while (ret && try_port > (1024 / 2));
665 server.sin_family = AF_INET;
666 server.sin_addr = addr->sin_addr;
667 server.sin_port = NFS_PORT;
669 /* Call sys_connect */
670 ret = socket->ops->connect (socket, (struct sockaddr *) &server,
671 sizeof (server), file->f_flags);
681 static int get_default (int value, int def_value)
689 static int sunos_nfs_mount(char *dir_name, int linux_flags, void __user *data)
692 char *the_name, *mount_page;
693 struct nfs_mount_data linux_nfs_mount;
694 struct sunos_nfs_mount_args sunos_mount;
696 /* Ok, here comes the fun part: Linux's nfs mount needs a
697 * socket connection to the server, but SunOS mount does not
698 * require this, so we use the information on the destination
699 * address to create a socket and bind it to a reserved
700 * port on this system
702 if (copy_from_user(&sunos_mount, data, sizeof(sunos_mount)))
705 server_fd = sys_socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
709 if (copy_from_user(&linux_nfs_mount.addr,sunos_mount.addr,
710 sizeof(*sunos_mount.addr)) ||
711 copy_from_user(&linux_nfs_mount.root,sunos_mount.fh,
712 sizeof(*sunos_mount.fh))) {
713 sys_close (server_fd);
717 if (!sunos_nfs_get_server_fd (server_fd, &linux_nfs_mount.addr)){
718 sys_close (server_fd);
722 /* Now, bind it to a locally reserved port */
723 linux_nfs_mount.version = NFS_MOUNT_VERSION;
724 linux_nfs_mount.flags = sunos_mount.flags;
725 linux_nfs_mount.fd = server_fd;
727 linux_nfs_mount.rsize = get_default (sunos_mount.rsize, 8192);
728 linux_nfs_mount.wsize = get_default (sunos_mount.wsize, 8192);
729 linux_nfs_mount.timeo = get_default (sunos_mount.timeo, 10);
730 linux_nfs_mount.retrans = sunos_mount.retrans;
732 linux_nfs_mount.acregmin = sunos_mount.acregmin;
733 linux_nfs_mount.acregmax = sunos_mount.acregmax;
734 linux_nfs_mount.acdirmin = sunos_mount.acdirmin;
735 linux_nfs_mount.acdirmax = sunos_mount.acdirmax;
737 the_name = getname(sunos_mount.hostname);
738 if (IS_ERR(the_name))
739 return PTR_ERR(the_name);
741 strlcpy(linux_nfs_mount.hostname, the_name,
742 sizeof(linux_nfs_mount.hostname));
745 mount_page = (char *) get_zeroed_page(GFP_KERNEL);
749 memcpy(mount_page, &linux_nfs_mount, sizeof(linux_nfs_mount));
751 err = do_mount("", dir_name, "nfs", linux_flags, mount_page);
753 free_page((unsigned long) mount_page);
758 sunos_mount(char __user *type, char __user *dir, int flags, void __user *data)
762 char *dev_fname = NULL;
763 char *dir_page, *type_page;
765 if (!capable (CAP_SYS_ADMIN))
769 /* We don't handle the integer fs type */
770 if ((flags & SMNT_NEWTYPE) == 0)
773 /* Do not allow for those flags we don't support */
774 if (flags & (SMNT_GRPID|SMNT_NOSUB|SMNT_MULTI|SMNT_SYS5))
777 if (flags & SMNT_REMOUNT)
778 linux_flags |= MS_REMOUNT;
779 if (flags & SMNT_RDONLY)
780 linux_flags |= MS_RDONLY;
781 if (flags & SMNT_NOSUID)
782 linux_flags |= MS_NOSUID;
784 dir_page = getname(dir);
785 ret = PTR_ERR(dir_page);
786 if (IS_ERR(dir_page))
789 type_page = getname(type);
790 ret = PTR_ERR(type_page);
791 if (IS_ERR(type_page))
794 if (strcmp(type_page, "ext2") == 0) {
795 dev_fname = getname(data);
796 } else if (strcmp(type_page, "iso9660") == 0) {
797 dev_fname = getname(data);
798 } else if (strcmp(type_page, "minix") == 0) {
799 dev_fname = getname(data);
800 } else if (strcmp(type_page, "nfs") == 0) {
801 ret = sunos_nfs_mount (dir_page, flags, data);
803 } else if (strcmp(type_page, "ufs") == 0) {
804 printk("Warning: UFS filesystem mounts unsupported.\n");
807 } else if (strcmp(type_page, "proc")) {
811 ret = PTR_ERR(dev_fname);
812 if (IS_ERR(dev_fname))
814 ret = do_mount(dev_fname, dir_page, type_page, linux_flags, NULL);
827 asmlinkage int sunos_setpgrp(pid_t pid, pid_t pgid)
832 if ((!pid || pid == current->pid) &&
837 ret = sys_setpgid(pid, pgid);
843 asmlinkage int sunos_wait4(pid_t pid, unsigned int __user *stat_addr,
844 int options, struct rusage __user*ru)
848 ret = sys_wait4((pid ? pid : -1), stat_addr, options, ru);
852 extern int kill_pg(int, int, int);
853 asmlinkage int sunos_killpg(int pgrp, int sig)
858 ret = kill_pg(pgrp, sig, 0);
863 asmlinkage int sunos_audit(void)
866 printk ("sys_audit\n");
871 asmlinkage unsigned long sunos_gethostid(void)
876 ret = ((unsigned long)idprom->id_machtype << 24) |
877 (unsigned long)idprom->id_sernum;
882 /* sysconf options, for SunOS compatibility */
883 #define _SC_ARG_MAX 1
884 #define _SC_CHILD_MAX 2
885 #define _SC_CLK_TCK 3
886 #define _SC_NGROUPS_MAX 4
887 #define _SC_OPEN_MAX 5
888 #define _SC_JOB_CONTROL 6
889 #define _SC_SAVED_IDS 7
890 #define _SC_VERSION 8
892 asmlinkage long sunos_sysconf (int name)
901 ret = -1; /* no limit */
906 case _SC_NGROUPS_MAX:
912 case _SC_JOB_CONTROL:
913 ret = 1; /* yes, we do support job control */
916 ret = 1; /* yes, we do support saved uids */
919 /* mhm, POSIX_VERSION is in /usr/include/unistd.h
920 * should it go on /usr/include/linux?
931 asmlinkage int sunos_semsys(int op, unsigned long arg1, unsigned long arg2,
932 unsigned long arg3, void *ptr)
939 /* Most arguments match on a 1:1 basis but cmd doesn't */
957 /* value to modify semaphore to */
958 arg4.__pad = (void __user *) ptr;
959 ret = sys_semctl((int)arg1, (int)arg2, (int)arg3, arg4 );
963 ret = sys_semget((key_t)arg1, (int)arg2, (int)arg3);
967 ret = sys_semop((int)arg1, (struct sembuf __user *)arg2, (unsigned)arg3);
976 asmlinkage int sunos_msgsys(int op, unsigned long arg1, unsigned long arg2,
977 unsigned long arg3, unsigned long arg4)
979 struct sparc_stackf *sp;
985 rval = sys_msgget((key_t)arg1, (int)arg2);
988 rval = sys_msgctl((int)arg1, (int)arg2,
989 (struct msqid_ds __user *)arg3);
993 sp = (struct sparc_stackf *)current->thread.kregs->u_regs[UREG_FP];
994 arg5 = sp->xxargs[0];
996 rval = sys_msgrcv((int)arg1, (struct msgbuf __user *)arg2,
997 (size_t)arg3, (long)arg4, (int)arg5);
1000 rval = sys_msgsnd((int)arg1, (struct msgbuf __user *)arg2,
1001 (size_t)arg3, (int)arg4);
1010 asmlinkage int sunos_shmsys(int op, unsigned long arg1, unsigned long arg2,
1013 unsigned long raddr;
1018 /* do_shmat(): attach a shared memory area */
1019 rval = do_shmat((int)arg1,(char __user *)arg2,(int)arg3,&raddr);
1024 /* sys_shmctl(): modify shared memory area attr. */
1025 rval = sys_shmctl((int)arg1,(int)arg2,(struct shmid_ds __user *)arg3);
1028 /* sys_shmdt(): detach a shared memory area */
1029 rval = sys_shmdt((char __user *)arg1);
1032 /* sys_shmget(): get a shared memory area */
1033 rval = sys_shmget((key_t)arg1,(int)arg2,(int)arg3);
1042 #define SUNOS_EWOULDBLOCK 35
1044 /* see the sunos man page read(2v) for an explanation
1045 of this garbage. We use O_NDELAY to mark
1046 file descriptors that have been set non-blocking
1047 using 4.2BSD style calls. (tridge) */
1049 static inline int check_nonblock(int ret, int fd)
1051 if (ret == -EAGAIN) {
1052 struct file * file = fget(fd);
1054 if (file->f_flags & O_NDELAY)
1055 ret = -SUNOS_EWOULDBLOCK;
1062 asmlinkage int sunos_read(unsigned int fd, char __user *buf, int count)
1066 ret = check_nonblock(sys_read(fd,buf,count),fd);
1070 asmlinkage int sunos_readv(unsigned long fd, const struct iovec __user *vector,
1075 ret = check_nonblock(sys_readv(fd,vector,count),fd);
1079 asmlinkage int sunos_write(unsigned int fd, char __user *buf, int count)
1083 ret = check_nonblock(sys_write(fd,buf,count),fd);
1087 asmlinkage int sunos_writev(unsigned long fd,
1088 const struct iovec __user *vector, long count)
1092 ret = check_nonblock(sys_writev(fd,vector,count),fd);
1096 asmlinkage int sunos_recv(int fd, void __user *ubuf, int size, unsigned flags)
1100 ret = check_nonblock(sys_recv(fd,ubuf,size,flags),fd);
1104 asmlinkage int sunos_send(int fd, void __user *buff, int len, unsigned flags)
1108 ret = check_nonblock(sys_send(fd,buff,len,flags),fd);
1112 asmlinkage int sunos_accept(int fd, struct sockaddr __user *sa,
1113 int __user *addrlen)
1118 ret = check_nonblock(sys_accept(fd,sa,addrlen),fd);
1119 if (ret != -ENETUNREACH && ret != -EHOSTUNREACH)
1126 #define SUNOS_SV_INTERRUPT 2
1129 sunos_sigaction(int sig, const struct old_sigaction __user *act,
1130 struct old_sigaction __user *oact)
1132 struct k_sigaction new_ka, old_ka;
1138 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
1139 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
1140 __get_user(new_ka.sa.sa_flags, &act->sa_flags))
1142 __get_user(mask, &act->sa_mask);
1143 new_ka.sa.sa_restorer = NULL;
1144 new_ka.ka_restorer = NULL;
1145 siginitset(&new_ka.sa.sa_mask, mask);
1146 new_ka.sa.sa_flags ^= SUNOS_SV_INTERRUPT;
1149 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
1152 /* In the clone() case we could copy half consistent
1153 * state to the user, however this could sleep and
1154 * deadlock us if we held the signal lock on SMP. So for
1155 * now I take the easy way out and do no locking.
1156 * But then again we don't support SunOS lwp's anyways ;-)
1158 old_ka.sa.sa_flags ^= SUNOS_SV_INTERRUPT;
1159 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
1160 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
1161 __put_user(old_ka.sa.sa_flags, &oact->sa_flags))
1163 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
1170 asmlinkage int sunos_setsockopt(int fd, int level, int optname,
1171 char __user *optval, int optlen)
1173 int tr_opt = optname;
1176 if (level == SOL_IP) {
1177 /* Multicast socketopts (ttl, membership) */
1178 if (tr_opt >=2 && tr_opt <= 6)
1181 ret = sys_setsockopt(fd, level, tr_opt, optval, optlen);
1185 asmlinkage int sunos_getsockopt(int fd, int level, int optname,
1186 char __user *optval, int __user *optlen)
1188 int tr_opt = optname;
1191 if (level == SOL_IP) {
1192 /* Multicast socketopts (ttl, membership) */
1193 if (tr_opt >=2 && tr_opt <= 6)
1196 ret = sys_getsockopt(fd, level, tr_opt, optval, optlen);