#include <linux/stat.h>
#include <linux/slab.h>
#include <linux/pagemap.h>
+#include <linux/capability.h>
#include <linux/errno.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/syscalls.h>
+#include <linux/vs_cvirt.h>
#include <net/sock.h>
struct file * file = NULL;
unsigned long retval, ret_type;
- if(flags & MAP_NORESERVE) {
+ if (flags & MAP_NORESERVE) {
static int cnt;
if (cnt++ < 10)
printk("%s: unimplemented SunOS MAP_NORESERVE mmap() flag\n",
flags &= ~MAP_NORESERVE;
}
retval = -EBADF;
- if(!(flags & MAP_ANONYMOUS)) {
+ if (!(flags & MAP_ANONYMOUS)) {
if (fd >= SUNOS_NR_OPEN)
goto out;
file = fget(fd);
* SunOS is so stupid some times... hmph!
*/
if (file) {
- if(imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
- iminor(file->f_dentry->d_inode) == 5) {
+ if (imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
+ iminor(file->f_dentry->d_inode) == 5) {
flags |= MAP_ANONYMOUS;
fput(file);
- file = 0;
+ file = NULL;
}
}
ret_type = flags & _MAP_NEW;
flags &= ~_MAP_NEW;
- if(!(flags & MAP_FIXED))
+ if (!(flags & MAP_FIXED))
addr = 0;
else {
if (ARCH_SUN4C_SUN4 &&
down_write(¤t->mm->mmap_sem);
retval = do_mmap(file, addr, len, prot, flags, off);
up_write(¤t->mm->mmap_sem);
- if(!ret_type)
+ if (!ret_type)
retval = ((retval < PAGE_OFFSET) ? 0 : retval);
out_putf:
unsigned long newbrk, oldbrk;
down_write(¤t->mm->mmap_sem);
- if(ARCH_SUN4C_SUN4) {
- if(brk >= 0x20000000 && brk < 0xe0000000) {
+ if (ARCH_SUN4C_SUN4) {
+ if (brk >= 0x20000000 && brk < 0xe0000000) {
goto out;
}
}
* Check against rlimit and stack..
*/
retval = -ENOMEM;
- rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+ rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
if (rlim >= RLIM_INFINITY)
rlim = ~0;
if (brk - current->mm->end_code > rlim)
lock_kernel();
oldbrk = current->mm->brk;
error = sunos_brk(((int) current->mm->brk) + increment);
- if(!error)
+ if (!error)
error = oldbrk;
unlock_kernel();
return error;
};
struct sunos_dirent_callback {
- struct sunos_dirent *curr;
- struct sunos_dirent *previous;
+ struct sunos_dirent __user *curr;
+ struct sunos_dirent __user *previous;
int count;
int error;
};
-#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
+#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
static int sunos_filldir(void * __buf, const char * name, int namlen,
loff_t offset, ino_t ino, unsigned int d_type)
{
- struct sunos_dirent * dirent;
- struct sunos_dirent_callback * buf = (struct sunos_dirent_callback *) __buf;
+ struct sunos_dirent __user *dirent;
+ struct sunos_dirent_callback * buf = __buf;
int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
buf->error = -EINVAL; /* only used if we fail.. */
put_user(reclen, &dirent->d_reclen);
copy_to_user(dirent->d_name, name, namlen);
put_user(0, dirent->d_name + namlen);
- dirent = (void *)dirent + reclen;
+ dirent = (void __user *) dirent + reclen;
buf->curr = dirent;
buf->count -= reclen;
return 0;
}
-asmlinkage int sunos_getdents(unsigned int fd, void * dirent, int cnt)
+asmlinkage int sunos_getdents(unsigned int fd, void __user *dirent, int cnt)
{
struct file * file;
- struct sunos_dirent * lastdirent;
+ struct sunos_dirent __user *lastdirent;
struct sunos_dirent_callback buf;
int error = -EBADF;
if (cnt < (sizeof(struct sunos_dirent) + 255))
goto out_putf;
- buf.curr = (struct sunos_dirent *) dirent;
+ buf.curr = (struct sunos_dirent __user *) dirent;
buf.previous = NULL;
buf.count = cnt;
buf.error = 0;
};
struct sunos_direntry_callback {
- struct sunos_direntry *curr;
- struct sunos_direntry *previous;
+ struct sunos_direntry __user *curr;
+ struct sunos_direntry __user *previous;
int count;
int error;
};
static int sunos_filldirentry(void * __buf, const char * name, int namlen,
loff_t offset, ino_t ino, unsigned int d_type)
{
- struct sunos_direntry * dirent;
- struct sunos_direntry_callback * buf = (struct sunos_direntry_callback *) __buf;
+ struct sunos_direntry __user *dirent;
+ struct sunos_direntry_callback *buf = __buf;
int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
buf->error = -EINVAL; /* only used if we fail.. */
put_user(reclen, &dirent->d_reclen);
copy_to_user(dirent->d_name, name, namlen);
put_user(0, dirent->d_name + namlen);
- dirent = (void *)dirent + reclen;
+ dirent = (void __user *) dirent + reclen;
buf->curr = dirent;
buf->count -= reclen;
return 0;
}
-asmlinkage int sunos_getdirentries(unsigned int fd, void * dirent, int cnt, unsigned int *basep)
+asmlinkage int sunos_getdirentries(unsigned int fd, void __user *dirent,
+ int cnt, unsigned int __user *basep)
{
struct file * file;
- struct sunos_direntry * lastdirent;
+ struct sunos_direntry __user *lastdirent;
struct sunos_direntry_callback buf;
int error = -EBADF;
goto out;
error = -EINVAL;
- if(cnt < (sizeof(struct sunos_direntry) + 255))
+ if (cnt < (sizeof(struct sunos_direntry) + 255))
goto out_putf;
- buf.curr = (struct sunos_direntry *) dirent;
+ buf.curr = (struct sunos_direntry __user *) dirent;
buf.previous = NULL;
buf.count = cnt;
buf.error = 0;
char mach[9];
};
-asmlinkage int sunos_uname(struct sunos_utsname *name)
+asmlinkage int sunos_uname(struct sunos_utsname __user *name)
{
int ret;
+ struct new_utsname *ptr;
down_read(&uts_sem);
- ret = copy_to_user(&name->sname[0], &system_utsname.sysname[0], sizeof(name->sname) - 1);
+ ptr = vx_new_utsname();
+ ret = copy_to_user(&name->sname[0], ptr->sysname, sizeof(name->sname) - 1);
if (!ret) {
- ret |= __copy_to_user(&name->nname[0], &system_utsname.nodename[0], sizeof(name->nname) - 1);
+ ret |= __copy_to_user(&name->nname[0], ptr->nodename, sizeof(name->nname) - 1);
ret |= __put_user('\0', &name->nname[8]);
- ret |= __copy_to_user(&name->rel[0], &system_utsname.release[0], sizeof(name->rel) - 1);
- ret |= __copy_to_user(&name->ver[0], &system_utsname.version[0], sizeof(name->ver) - 1);
- ret |= __copy_to_user(&name->mach[0], &system_utsname.machine[0], sizeof(name->mach) - 1);
+ ret |= __copy_to_user(&name->rel[0], ptr->release, sizeof(name->rel) - 1);
+ ret |= __copy_to_user(&name->ver[0], ptr->version, sizeof(name->ver) - 1);
+ ret |= __copy_to_user(&name->mach[0], ptr->machine, sizeof(name->mach) - 1);
}
up_read(&uts_sem);
return ret ? -EFAULT : 0;
info.si_signo = SIGSYS;
info.si_errno = 0;
info.si_code = __SI_FAULT|0x100;
- info.si_addr = (void *)regs->pc;
+ info.si_addr = (void __user *)regs->pc;
info.si_trapno = regs->u_regs[UREG_G1];
send_sig_info(SIGSYS, &info, current);
if (cnt++ < 4) {
return ret;
}
-asmlinkage int sunos_pathconf(char *path, int name)
+asmlinkage int sunos_pathconf(char __user *path, int name)
{
int ret;
/* SunOS mount system call emulation */
-asmlinkage int sunos_select(int width, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp)
+asmlinkage int sunos_select(int width, fd_set __user *inp, fd_set __user *outp,
+ fd_set __user *exp, struct timeval __user *tvp)
{
int ret;
};
struct sunos_nfs_mount_args {
- struct sockaddr_in *addr; /* file server address */
- struct nfs_fh *fh; /* File handle to be mounted */
+ struct sockaddr_in __user *addr; /* file server address */
+ struct nfs_fh __user *fh; /* File handle to be mounted */
int flags; /* flags */
int wsize; /* write size in bytes */
int rsize; /* read size in bytes */
int timeo; /* initial timeout in .1 secs */
int retrans; /* times to retry send */
- char *hostname; /* server's hostname */
+ char __user *hostname; /* server's hostname */
int acregmin; /* attr cache file min secs */
int acregmax; /* attr cache file max secs */
int acdirmin; /* attr cache dir min secs */
int acdirmax; /* attr cache dir max secs */
- char *netname; /* server's netname */
+ char __user *netname; /* server's netname */
};
return def_value;
}
-static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data)
+static int sunos_nfs_mount(char *dir_name, int linux_flags, void __user *data)
{
int server_fd, err;
char *the_name, *mount_page;
linux_nfs_mount.acdirmax = sunos_mount.acdirmax;
the_name = getname(sunos_mount.hostname);
- if(IS_ERR(the_name))
+ if (IS_ERR(the_name))
return PTR_ERR(the_name);
strlcpy(linux_nfs_mount.hostname, the_name,
}
asmlinkage int
-sunos_mount(char *type, char *dir, int flags, void *data)
+sunos_mount(char __user *type, char __user *dir, int flags, void __user *data)
{
int linux_flags = 0;
int ret = -EINVAL;
- char *dev_fname = 0;
+ char *dev_fname = NULL;
char *dir_page, *type_page;
if (!capable (CAP_SYS_ADMIN))
if (flags & (SMNT_GRPID|SMNT_NOSUB|SMNT_MULTI|SMNT_SYS5))
goto out;
- if(flags & SMNT_REMOUNT)
+ if (flags & SMNT_REMOUNT)
linux_flags |= MS_REMOUNT;
- if(flags & SMNT_RDONLY)
+ if (flags & SMNT_RDONLY)
linux_flags |= MS_RDONLY;
- if(flags & SMNT_NOSUID)
+ if (flags & SMNT_NOSUID)
linux_flags |= MS_NOSUID;
dir_page = getname(dir);
if (IS_ERR(type_page))
goto out1;
- if(strcmp(type_page, "ext2") == 0) {
+ if (strcmp(type_page, "ext2") == 0) {
dev_fname = getname(data);
- } else if(strcmp(type_page, "iso9660") == 0) {
+ } else if (strcmp(type_page, "iso9660") == 0) {
dev_fname = getname(data);
- } else if(strcmp(type_page, "minix") == 0) {
+ } else if (strcmp(type_page, "minix") == 0) {
dev_fname = getname(data);
- } else if(strcmp(type_page, "nfs") == 0) {
+ } else if (strcmp(type_page, "nfs") == 0) {
ret = sunos_nfs_mount (dir_page, flags, data);
goto out2;
- } else if(strcmp(type_page, "ufs") == 0) {
+ } else if (strcmp(type_page, "ufs") == 0) {
printk("Warning: UFS filesystem mounts unsupported.\n");
ret = -ENODEV;
goto out2;
- } else if(strcmp(type_page, "proc")) {
+ } else if (strcmp(type_page, "proc")) {
ret = -ENODEV;
goto out2;
}
int ret;
/* So stupid... */
- if((!pid || pid == current->pid) &&
- !pgid) {
+ if ((!pid || pid == current->pid) &&
+ !pgid) {
sys_setsid();
ret = 0;
} else {
}
/* So stupid... */
-asmlinkage int sunos_wait4(pid_t pid, unsigned int *stat_addr, int options, struct rusage *ru)
+asmlinkage int sunos_wait4(pid_t pid, unsigned int __user *stat_addr,
+ int options, struct rusage __user*ru)
{
int ret;
return -1;
}
-extern asmlinkage unsigned long sunos_gethostid(void)
+asmlinkage unsigned long sunos_gethostid(void)
{
unsigned long ret;
#define _SC_SAVED_IDS 7
#define _SC_VERSION 8
-extern asmlinkage long sunos_sysconf (int name)
+asmlinkage long sunos_sysconf (int name)
{
long ret;
ret = ARG_MAX;
break;
case _SC_CHILD_MAX:
- ret = CHILD_MAX;
+ ret = -1; /* no limit */
break;
case _SC_CLK_TCK:
ret = HZ;
arg3=SETALL; break;
}
/* sys_semctl(): */
- arg4.__pad=ptr; /* value to modify semaphore to */
+ /* value to modify semaphore to */
+ arg4.__pad = (void __user *) ptr;
ret = sys_semctl((int)arg1, (int)arg2, (int)arg3, arg4 );
break;
case 1:
break;
case 2:
/* sys_semop(): */
- ret = sys_semop((int)arg1, (struct sembuf *)arg2, (unsigned)arg3);
+ ret = sys_semop((int)arg1, (struct sembuf __user *)arg2, (unsigned)arg3);
break;
default:
ret = -EINVAL;
break;
case 1:
rval = sys_msgctl((int)arg1, (int)arg2,
- (struct msqid_ds *)arg3);
+ (struct msqid_ds __user *)arg3);
break;
case 2:
lock_kernel();
sp = (struct sparc_stackf *)current->thread.kregs->u_regs[UREG_FP];
arg5 = sp->xxargs[0];
unlock_kernel();
- rval = sys_msgrcv((int)arg1, (struct msgbuf *)arg2,
+ rval = sys_msgrcv((int)arg1, (struct msgbuf __user *)arg2,
(size_t)arg3, (long)arg4, (int)arg5);
break;
case 3:
- rval = sys_msgsnd((int)arg1, (struct msgbuf *)arg2,
+ rval = sys_msgsnd((int)arg1, (struct msgbuf __user *)arg2,
(size_t)arg3, (int)arg4);
break;
default:
switch(op) {
case 0:
/* do_shmat(): attach a shared memory area */
- rval = do_shmat((int)arg1,(char *)arg2,(int)arg3,&raddr);
- if(!rval)
+ rval = do_shmat((int)arg1,(char __user *)arg2,(int)arg3,&raddr);
+ if (!rval)
rval = (int) raddr;
break;
case 1:
/* sys_shmctl(): modify shared memory area attr. */
- rval = sys_shmctl((int)arg1,(int)arg2,(struct shmid_ds *)arg3);
+ rval = sys_shmctl((int)arg1,(int)arg2,(struct shmid_ds __user *)arg3);
break;
case 2:
/* sys_shmdt(): detach a shared memory area */
- rval = sys_shmdt((char *)arg1);
+ rval = sys_shmdt((char __user *)arg1);
break;
case 3:
/* sys_shmget(): get a shared memory area */
return ret;
}
-asmlinkage int sunos_read(unsigned int fd,char *buf,int count)
+asmlinkage int sunos_read(unsigned int fd, char __user *buf, int count)
{
int ret;
return ret;
}
-asmlinkage int sunos_readv(unsigned long fd, const struct iovec * vector, long count)
+asmlinkage int sunos_readv(unsigned long fd, const struct iovec __user *vector,
+ long count)
{
int ret;
return ret;
}
-asmlinkage int sunos_write(unsigned int fd,char *buf,int count)
+asmlinkage int sunos_write(unsigned int fd, char __user *buf, int count)
{
int ret;
return ret;
}
-asmlinkage int sunos_writev(unsigned long fd, const struct iovec * vector, long count)
+asmlinkage int sunos_writev(unsigned long fd,
+ const struct iovec __user *vector, long count)
{
int ret;
return ret;
}
-asmlinkage int sunos_recv(int fd, void * ubuf, int size, unsigned flags)
+asmlinkage int sunos_recv(int fd, void __user *ubuf, int size, unsigned flags)
{
int ret;
return ret;
}
-asmlinkage int sunos_send(int fd, void * buff, int len, unsigned flags)
+asmlinkage int sunos_send(int fd, void __user *buff, int len, unsigned flags)
{
int ret;
return ret;
}
-asmlinkage int sunos_accept(int fd, struct sockaddr *sa, int *addrlen)
+asmlinkage int sunos_accept(int fd, struct sockaddr __user *sa,
+ int __user *addrlen)
{
int ret;
#define SUNOS_SV_INTERRUPT 2
asmlinkage int
-sunos_sigaction(int sig, const struct old_sigaction *act,
- struct old_sigaction *oact)
+sunos_sigaction(int sig, const struct old_sigaction __user *act,
+ struct old_sigaction __user *oact)
{
struct k_sigaction new_ka, old_ka;
int ret;
- if(act) {
+ if (act) {
old_sigset_t mask;
- if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
+ if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags))
return -EFAULT;
* But then again we don't support SunOS lwp's anyways ;-)
*/
old_ka.sa.sa_flags ^= SUNOS_SV_INTERRUPT;
- if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
+ if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags))
return -EFAULT;
}
-asmlinkage int sunos_setsockopt(int fd, int level, int optname, char *optval,
- int optlen)
+asmlinkage int sunos_setsockopt(int fd, int level, int optname,
+ char __user *optval, int optlen)
{
int tr_opt = optname;
int ret;
return ret;
}
-asmlinkage int sunos_getsockopt(int fd, int level, int optname, char *optval,
- int *optlen)
+asmlinkage int sunos_getsockopt(int fd, int level, int optname,
+ char __user *optval, int __user *optlen)
{
int tr_opt = optname;
int ret;