Пример #1
0
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
	int error;
	char *newpath;
	struct image_args eargs;

	LCONVPATHEXIST(td, args->path, &newpath);

#ifdef DEBUG
	if (ldebug(execve))
		printf(ARGS(execve, "%s"), newpath);
#endif

	error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
	    args->argp, args->envp);
	free(newpath, M_TEMP);
	if (error == 0)
		error = kern_execve(td, &eargs, NULL);
	if (error == 0)
	   	/* linux process can exec fbsd one, dont attempt
		 * to create emuldata for such process using
		 * linux_proc_init, this leads to a panic on KASSERT
		 * because such process has p->p_emuldata == NULL
		 */
		if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX)
   			error = linux_proc_init(td, 0, 0);
	return (error);
}
Пример #2
0
int
linux_statfs(struct thread *td, struct linux_statfs_args *args)
{
	struct l_statfs linux_statfs;
	struct statfs bsd_statfs;
	char *path;
	int error, dev_shm;

	LCONVPATHEXIST(td, args->path, &path);

#ifdef DEBUG
	if (ldebug(statfs))
		printf(ARGS(statfs, "%s, *"), path);
#endif
	dev_shm = 0;
	error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs);
	if (strncmp(path, "/dev/shm", sizeof("/dev/shm") - 1) == 0)
		dev_shm = (path[8] == '\0'
		    || (path[8] == '/' && path[9] == '\0'));
	LFREEPATH(path);
	if (error)
		return (error);
	bsd_to_linux_statfs(&bsd_statfs, &linux_statfs);
	if (dev_shm)
		linux_statfs.f_type = LINUX_SHMFS_MAGIC;
	return copyout(&linux_statfs, args->buf, sizeof(linux_statfs));
}
Пример #3
0
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
	struct image_args eargs;
	char *path;
	int error;

	LCONVPATHEXIST(td, args->path, &path);

#ifdef DEBUG
	if (ldebug(execve))
		printf(ARGS(execve, "%s"), path);
#endif

	error = freebsd32_exec_copyin_args(&eargs, path, UIO_SYSSPACE,
	    args->argp, args->envp);
	free(path, M_TEMP);
	if (error == 0)
		error = kern_execve(td, &eargs, NULL);
	if (error == 0)
		/* Linux process can execute FreeBSD one, do not attempt
		 * to create emuldata for such process using
		 * linux_proc_init, this leads to a panic on KASSERT
		 * because such process has p->p_emuldata == NULL.
		 */
	   	if (td->td_proc->p_sysent == &elf_linux_sysvec)
			error = linux_proc_init(td, 0, 0);
	return (error);
}
Пример #4
0
int
linux_creat(struct thread *td, struct linux_creat_args *args)
{
	char *path;
	int error;

	LCONVPATHEXIST(td, args->path, &path);
#ifdef DEBUG
	if (ldebug(creat))
		printf(ARGS(creat, "%s, %d"), path, args->mode);
#endif
	error = kern_openat(td, AT_FDCWD, path, UIO_SYSSPACE,
	    O_WRONLY | O_CREAT | O_TRUNC, args->mode);
	LFREEPATH(path);
	return (error);
}
Пример #5
0
int
linux_open(struct thread *td, struct linux_open_args *args)
{
	char *path;

	if (args->flags & LINUX_O_CREAT)
		LCONVPATHCREAT(td, args->path, &path);
	else
		LCONVPATHEXIST(td, args->path, &path);
#ifdef DEBUG
	if (ldebug(open))
		printf(ARGS(open, "%s, 0x%x, 0x%x"),
		    path, args->flags, args->mode);
#endif
	return (linux_common_open(td, AT_FDCWD, path, args->flags, args->mode));
}
Пример #6
0
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
    struct image_args eargs;
    char *path;
    int error;

    LCONVPATHEXIST(td, args->path, &path);

    LINUX_CTR(execve);

    error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp,
                             args->envp);
    free(path, M_TEMP);
    if (error == 0)
        error = linux_common_execve(td, &eargs);
    return (error);
}
Пример #7
0
int
linux_lstat64(struct thread *td, struct linux_lstat64_args *args)
{
	struct stat sb;
	char *filename;
	int error;

	LCONVPATHEXIST(td, args->filename, &filename);

#ifdef DEBUG
	if (ldebug(lstat64))
		printf(ARGS(lstat64, "%s, *"), args->filename);
#endif

	error = linux_kern_lstat(td, filename, UIO_SYSSPACE, &sb);
	LFREEPATH(filename);
	if (error)
		return (error);
	return (stat64_copyout(&sb, args->statbuf));
}
Пример #8
0
int
linux_newlstat(struct thread *td, struct linux_newlstat_args *args)
{
	struct stat sb;
	char *path;
	int error;

	LCONVPATHEXIST(td, args->path, &path);

#ifdef DEBUG
	if (ldebug(newlstat))
		printf(ARGS(newlstat, "%s, *"), path);
#endif

	error = linux_kern_lstat(td, path, UIO_SYSSPACE, &sb);
	LFREEPATH(path);
	if (error)
		return (error);
	return (newstat_copyout(&sb, args->buf));
}
Пример #9
0
int
linux_lstat(struct thread *td, struct linux_lstat_args *args)
{
	struct stat buf;
	char *path;
	int error;

	LCONVPATHEXIST(td, args->path, &path);

#ifdef DEBUG
	if (ldebug(lstat))
		printf(ARGS(lstat, "%s, *"), path);
#endif
	error = linux_kern_lstat(td, path, UIO_SYSSPACE, &buf);
	if (error) {
		LFREEPATH(path);
		return (error);
	}
	LFREEPATH(path);
	return(stat_copyout(&buf, args->up));
}
Пример #10
0
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
	struct image_args eargs;
	char *newpath;
	int error;

	LCONVPATHEXIST(td, args->path, &newpath);

#ifdef DEBUG
	if (ldebug(execve))
		printf(ARGS(execve, "%s"), newpath);
#endif

	error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
	    args->argp, args->envp);
	free(newpath, M_TEMP);
	if (error == 0)
		error = linux_common_execve(td, &eargs);
	return (error);
}
Пример #11
0
int
linux_statfs(struct thread *td, struct linux_statfs_args *args)
{
	struct l_statfs linux_statfs;
	struct statfs bsd_statfs;
	char *path;
	int error;

	LCONVPATHEXIST(td, args->path, &path);

#ifdef DEBUG
	if (ldebug(statfs))
		printf(ARGS(statfs, "%s, *"), path);
#endif
	error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs);
	LFREEPATH(path);
	if (error)
		return (error);
	bsd_to_linux_statfs(&bsd_statfs, &linux_statfs);
	return copyout(&linux_statfs, args->buf, sizeof(linux_statfs));
}
Пример #12
0
int
linux_lchown16(struct thread *td, struct linux_lchown16_args *args)
{
	char *path;
	int error;

	LCONVPATHEXIST(td, args->path, &path);

	/*
	 * The DTrace probes have to be after the LCONVPATHEXIST, as
	 * LCONVPATHEXIST may return on its own and we do not want to
	 * have a stray entry without the corresponding return.
	 */
	LIN_SDT_PROBE3(uid16, linux_lchown16, entry, args->path, args->uid,
	    args->gid);
	LIN_SDT_PROBE1(uid16, linux_lchown16, conv_path, path);

	error = kern_lchown(td, path, UIO_SYSSPACE, CAST_NOCHG(args->uid),
	    CAST_NOCHG(args->gid));
	LFREEPATH(path);

	LIN_SDT_PROBE1(uid16, linux_lchown16, return, error);
	return (error);
}