Skip to content

Commit

Permalink
Add generic sys_olduname()
Browse files Browse the repository at this point in the history
Add generic implementations of the old and really old uname system calls.
Note that sh only implements sys_olduname but not sys_oldolduname, but I'm
not going to bother with another ifdef for that special case.

m32r implemented an old uname but never wired it up, so kill it, too.

Signed-off-by: Christoph Hellwig <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: "Luck, Tony" <[email protected]>
Cc: James Morris <[email protected]>
Cc: Andreas Schwab <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Hellwig authored and torvalds committed Mar 12, 2010
1 parent e28cbf2 commit 5cacdb4
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 284 deletions.
11 changes: 0 additions & 11 deletions arch/m32r/kernel/sys_m32r.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ asmlinkage int sys_tas(int __user *addr)
return oldval;
}

asmlinkage int sys_uname(struct old_utsname __user * name)
{
int err;
if (!name)
return -EFAULT;
down_read(&uts_sem);
err = copy_to_user(name, utsname(), sizeof (*name));
up_read(&uts_sem);
return err?-EFAULT:0;
}

asmlinkage int sys_cacheflush(void *addr, int bytes, int cache)
{
/* This should flush more selectively ... */
Expand Down
1 change: 1 addition & 0 deletions arch/mips/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_UNAME
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
42 changes: 0 additions & 42 deletions arch/mips/kernel/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,48 +215,6 @@ asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs)
return error;
}

/*
* Compacrapability ...
*/
SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
{
if (name && !copy_to_user(name, utsname(), sizeof (*name)))
return 0;
return -EFAULT;
}

/*
* Compacrapability ...
*/
SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
{
int error;

if (!name)
return -EFAULT;
if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))
return -EFAULT;

error = __copy_to_user(&name->sysname, &utsname()->sysname,
__OLD_UTS_LEN);
error -= __put_user(0, name->sysname + __OLD_UTS_LEN);
error -= __copy_to_user(&name->nodename, &utsname()->nodename,
__OLD_UTS_LEN);
error -= __put_user(0, name->nodename + __OLD_UTS_LEN);
error -= __copy_to_user(&name->release, &utsname()->release,
__OLD_UTS_LEN);
error -= __put_user(0, name->release + __OLD_UTS_LEN);
error -= __copy_to_user(&name->version, &utsname()->version,
__OLD_UTS_LEN);
error -= __put_user(0, name->version + __OLD_UTS_LEN);
error -= __copy_to_user(&name->machine, &utsname()->machine,
__OLD_UTS_LEN);
error = __put_user(0, name->machine + __OLD_UTS_LEN);
error = error ? -EFAULT : 0;

return error;
}

SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
{
struct thread_info *ti = task_thread_info(current);
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_UNAME
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
57 changes: 0 additions & 57 deletions arch/powerpc/kernel/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,63 +116,6 @@ long ppc64_personality(unsigned long personality)
}
#endif

#ifdef CONFIG_PPC64
#define OVERRIDE_MACHINE (personality(current->personality) == PER_LINUX32)
#else
#define OVERRIDE_MACHINE 0
#endif

static inline int override_machine(char __user *mach)
{
if (OVERRIDE_MACHINE) {
/* change ppc64 to ppc */
if (__put_user(0, mach+3) || __put_user(0, mach+4))
return -EFAULT;
}
return 0;
}

int sys_uname(struct old_utsname __user *name)
{
int err = 0;

down_read(&uts_sem);
if (copy_to_user(name, utsname(), sizeof(*name)))
err = -EFAULT;
up_read(&uts_sem);
if (!err)
err = override_machine(name->machine);
return err;
}

int sys_olduname(struct oldold_utsname __user *name)
{
int error;

if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))
return -EFAULT;

down_read(&uts_sem);
error = __copy_to_user(&name->sysname, &utsname()->sysname,
__OLD_UTS_LEN);
error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
error |= __copy_to_user(&name->nodename, &utsname()->nodename,
__OLD_UTS_LEN);
error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
error |= __copy_to_user(&name->release, &utsname()->release,
__OLD_UTS_LEN);
error |= __put_user(0, name->release + __OLD_UTS_LEN);
error |= __copy_to_user(&name->version, &utsname()->version,
__OLD_UTS_LEN);
error |= __put_user(0, name->version + __OLD_UTS_LEN);
error |= __copy_to_user(&name->machine, &utsname()->machine,
__OLD_UTS_LEN);
error |= override_machine(name->machine);
up_read(&uts_sem);

return error? -EFAULT: 0;
}

long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
u32 len_high, u32 len_low)
{
Expand Down
3 changes: 0 additions & 3 deletions arch/sh/include/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

#ifdef __KERNEL__

struct old_utsname;

asmlinkage int old_mmap(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags,
int fd, unsigned long off);
asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags,
unsigned long fd, unsigned long pgoff);
asmlinkage int sys_uname(struct old_utsname __user *name);

#ifdef CONFIG_SUPERH32
# include "syscalls_32.h"
Expand Down
1 change: 1 addition & 0 deletions arch/sh/include/asm/unistd_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_UNAME
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
1 change: 1 addition & 0 deletions arch/sh/include/asm/unistd_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_UNAME
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
11 changes: 0 additions & 11 deletions arch/sh/kernel/sys_sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,3 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
up_read(&current->mm->mmap_sem);
return 0;
}

asmlinkage int sys_uname(struct old_utsname __user *name)
{
int err;
if (!name)
return -EFAULT;
down_read(&uts_sem);
err = copy_to_user(name, utsname(), sizeof(*name));
up_read(&uts_sem);
return err?-EFAULT:0;
}
45 changes: 0 additions & 45 deletions arch/um/kernel/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,51 +51,6 @@ long old_mmap(unsigned long addr, unsigned long len,
return err;
}

long sys_uname(struct old_utsname __user * name)
{
long err;
if (!name)
return -EFAULT;
down_read(&uts_sem);
err = copy_to_user(name, utsname(), sizeof (*name));
up_read(&uts_sem);
return err?-EFAULT:0;
}

long sys_olduname(struct oldold_utsname __user * name)
{
long error;

if (!name)
return -EFAULT;
if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
return -EFAULT;

down_read(&uts_sem);

error = __copy_to_user(&name->sysname, &utsname()->sysname,
__OLD_UTS_LEN);
error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
error |= __copy_to_user(&name->nodename, &utsname()->nodename,
__OLD_UTS_LEN);
error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
error |= __copy_to_user(&name->release, &utsname()->release,
__OLD_UTS_LEN);
error |= __put_user(0, name->release + __OLD_UTS_LEN);
error |= __copy_to_user(&name->version, &utsname()->version,
__OLD_UTS_LEN);
error |= __put_user(0, name->version + __OLD_UTS_LEN);
error |= __copy_to_user(&name->machine, &utsname()->machine,
__OLD_UTS_LEN);
error |= __put_user(0, name->machine + __OLD_UTS_LEN);

up_read(&uts_sem);

error = error ? -EFAULT : 0;

return error;
}

int kernel_execve(const char *filename, char *const argv[], char *const envp[])
{
mm_segment_t fs;
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/ia32/ia32entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ ia32_sys_call_table:
.quad quiet_ni_syscall /* old mpx syscall holder */
.quad sys_setpgid
.quad quiet_ni_syscall /* old ulimit syscall holder */
.quad sys32_olduname
.quad sys_olduname
.quad sys_umask /* 60 */
.quad sys_chroot
.quad compat_sys_ustat
Expand Down Expand Up @@ -613,7 +613,7 @@ ia32_sys_call_table:
.quad compat_sys_newstat
.quad compat_sys_newlstat
.quad compat_sys_newfstat
.quad sys32_uname
.quad sys_uname
.quad stub32_iopl /* 110 */
.quad sys_vhangup
.quad quiet_ni_syscall /* old "idle" system call */
Expand Down
52 changes: 0 additions & 52 deletions arch/x86/ia32/sys_ia32.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,58 +448,6 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
return ret;
}

asmlinkage long sys32_olduname(struct oldold_utsname __user *name)
{
char *arch = "x86_64";
int err;

if (!name)
return -EFAULT;
if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))
return -EFAULT;

down_read(&uts_sem);

err = __copy_to_user(&name->sysname, &utsname()->sysname,
__OLD_UTS_LEN);
err |= __put_user(0, name->sysname+__OLD_UTS_LEN);
err |= __copy_to_user(&name->nodename, &utsname()->nodename,
__OLD_UTS_LEN);
err |= __put_user(0, name->nodename+__OLD_UTS_LEN);
err |= __copy_to_user(&name->release, &utsname()->release,
__OLD_UTS_LEN);
err |= __put_user(0, name->release+__OLD_UTS_LEN);
err |= __copy_to_user(&name->version, &utsname()->version,
__OLD_UTS_LEN);
err |= __put_user(0, name->version+__OLD_UTS_LEN);

if (personality(current->personality) == PER_LINUX32)
arch = "i686";

err |= __copy_to_user(&name->machine, arch, strlen(arch) + 1);

up_read(&uts_sem);

err = err ? -EFAULT : 0;

return err;
}

long sys32_uname(struct old_utsname __user *name)
{
int err;

if (!name)
return -EFAULT;
down_read(&uts_sem);
err = copy_to_user(name, utsname(), sizeof(*name));
up_read(&uts_sem);
if (personality(current->personality) == PER_LINUX32)
err |= copy_to_user(&name->machine, "i686", 5);

return err ? -EFAULT : 0;
}

asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
compat_uptr_t __user *envp, struct pt_regs *regs)
{
Expand Down
5 changes: 0 additions & 5 deletions arch/x86/include/asm/sys_ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ asmlinkage long sys32_pwrite(unsigned int, char __user *, u32, u32, u32);
asmlinkage long sys32_personality(unsigned long);
asmlinkage long sys32_sendfile(int, int, compat_off_t __user *, s32);

struct oldold_utsname;
struct old_utsname;
asmlinkage long sys32_olduname(struct oldold_utsname __user *);
long sys32_uname(struct old_utsname __user *);

asmlinkage long sys32_execve(char __user *, compat_uptr_t __user *,
compat_uptr_t __user *, struct pt_regs *);
asmlinkage long sys32_clone(unsigned int, unsigned int, struct pt_regs *);
Expand Down
7 changes: 0 additions & 7 deletions arch/x86/include/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ asmlinkage int sys_sigaction(int, const struct old_sigaction __user *,
struct old_sigaction __user *);
unsigned long sys_sigreturn(struct pt_regs *);

/* kernel/sys_i386_32.c */
struct oldold_utsname;
struct old_utsname;

asmlinkage int sys_uname(struct old_utsname __user *);
asmlinkage int sys_olduname(struct oldold_utsname __user *);

/* kernel/vm86_32.c */
int sys_vm86old(struct vm86_struct __user *, struct pt_regs *);
int sys_vm86(unsigned long, unsigned long, struct pt_regs *);
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/unistd_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_UNAME
#define __ARCH_WANT_SYS_OLD_MMAP
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_OLDUMOUNT
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/unistd_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ __SYSCALL(__NR_recvmmsg, sys_recvmmsg)
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_UNAME
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
Loading

0 comments on commit 5cacdb4

Please sign in to comment.