mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 12:16:20 +00:00
2bcd57ab61
* remove asm/atomic.h inclusion from linux/utsname.h -- not needed after kref conversion * remove linux/utsname.h inclusion from files which do not need it NOTE: it looks like fs/binfmt_elf.c do not need utsname.h, however due to some personality stuff it _is_ needed -- cowardly leave ELF-related headers and files alone. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
124 lines
3.1 KiB
C
124 lines
3.1 KiB
C
/*
|
|
* Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
|
|
* Copyright (C) 2007-2009 PetaLogix
|
|
* Copyright (C) 2007 John Williams <john.williams@petalogix.com>
|
|
*
|
|
* Copyright (C) 2006 Atmark Techno, Inc.
|
|
* Yasushi SHOJI <yashi@atmark-techno.com>
|
|
* Tetsuya OHKAWA <tetsuya@atmark-techno.com>
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
* for more details.
|
|
*/
|
|
|
|
#include <linux/errno.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/syscalls.h>
|
|
#include <linux/sem.h>
|
|
#include <linux/msg.h>
|
|
#include <linux/shm.h>
|
|
#include <linux/stat.h>
|
|
#include <linux/mman.h>
|
|
#include <linux/sys.h>
|
|
#include <linux/ipc.h>
|
|
#include <linux/file.h>
|
|
#include <linux/module.h>
|
|
#include <linux/err.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/semaphore.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/unistd.h>
|
|
|
|
#include <asm/syscalls.h>
|
|
|
|
asmlinkage long microblaze_vfork(struct pt_regs *regs)
|
|
{
|
|
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->r1,
|
|
regs, 0, NULL, NULL);
|
|
}
|
|
|
|
asmlinkage long microblaze_clone(int flags, unsigned long stack, struct pt_regs *regs)
|
|
{
|
|
if (!stack)
|
|
stack = regs->r1;
|
|
return do_fork(flags, stack, regs, 0, NULL, NULL);
|
|
}
|
|
|
|
asmlinkage long microblaze_execve(char __user *filenamei, char __user *__user *argv,
|
|
char __user *__user *envp, struct pt_regs *regs)
|
|
{
|
|
int error;
|
|
char *filename;
|
|
|
|
filename = getname(filenamei);
|
|
error = PTR_ERR(filename);
|
|
if (IS_ERR(filename))
|
|
goto out;
|
|
error = do_execve(filename, argv, envp, regs);
|
|
putname(filename);
|
|
out:
|
|
return error;
|
|
}
|
|
|
|
asmlinkage long
|
|
sys_mmap2(unsigned long addr, unsigned long len,
|
|
unsigned long prot, unsigned long flags,
|
|
unsigned long fd, unsigned long pgoff)
|
|
{
|
|
struct file *file = NULL;
|
|
int ret = -EBADF;
|
|
|
|
flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
|
|
if (!(flags & MAP_ANONYMOUS)) {
|
|
file = fget(fd);
|
|
if (!file) {
|
|
printk(KERN_INFO "no fd in mmap\r\n");
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
down_write(¤t->mm->mmap_sem);
|
|
ret = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
|
|
up_write(¤t->mm->mmap_sem);
|
|
if (file)
|
|
fput(file);
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
|
|
unsigned long prot, unsigned long flags,
|
|
unsigned long fd, off_t pgoff)
|
|
{
|
|
int err = -EINVAL;
|
|
|
|
if (pgoff & ~PAGE_MASK) {
|
|
printk(KERN_INFO "no pagemask in mmap\r\n");
|
|
goto out;
|
|
}
|
|
|
|
err = sys_mmap2(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
|
|
out:
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
* Do a system call from kernel instead of calling sys_execve so we
|
|
* end up with proper pt_regs.
|
|
*/
|
|
int kernel_execve(const char *filename, char *const argv[], char *const envp[])
|
|
{
|
|
register const char *__a __asm__("r5") = filename;
|
|
register const void *__b __asm__("r6") = argv;
|
|
register const void *__c __asm__("r7") = envp;
|
|
register unsigned long __syscall __asm__("r12") = __NR_execve;
|
|
register unsigned long __ret __asm__("r3");
|
|
__asm__ __volatile__ ("brki r14, 0x8"
|
|
: "=r" (__ret), "=r" (__syscall)
|
|
: "1" (__syscall), "r" (__a), "r" (__b), "r" (__c)
|
|
: "r4", "r8", "r9",
|
|
"r10", "r11", "r14", "cc", "memory");
|
|
return __ret;
|
|
}
|