Exemplo n.º 1
0
int
linux_newstat(struct proc *p, struct linux_newstat_args *args)
{
    struct stat buf;
    struct nameidata nd;
    int error;
    caddr_t sg;

    sg = stackgap_init();
    CHECKALTEXIST(p, &sg, args->path);

#ifdef DEBUG
    printf("Linux-emul(%ld): newstat(%s, *)\n", (long)p->p_pid,
           args->path);
#endif

    NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
           args->path, p);
    error = namei(&nd);
    if (error)
        return (error);
    NDFREE(&nd, NDF_ONLY_PNBUF);

    error = vn_stat(nd.ni_vp, &buf, p);
    vput(nd.ni_vp);
    if (error)
        return (error);

    return (newstat_copyout(&buf, args->buf));
}
Exemplo n.º 2
0
int
linux_lchown16(struct proc *p, struct linux_lchown16_args *args)
{
	struct lchown_args bsd;
	caddr_t sg;

	sg = stackgap_init();
	CHECKALTEXIST(p, &sg, args->path);

#ifdef DEBUG
	if (ldebug(lchown16))
		printf(ARGS(lchown16, "%s, %d, %d"), args->path, args->uid,
		    args->gid);
#endif

	bsd.path = args->path;
	bsd.uid = CAST_NOCHG(args->uid);
	bsd.gid = CAST_NOCHG(args->gid);
	return (lchown(p, &bsd));
}
Exemplo n.º 3
0
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
	struct execve_args ap;
	caddr_t sg;
	int error;
	u_int32_t *p32, arg;
	char **p, *p64;
	int count;

	sg = stackgap_init();
	CHECKALTEXIST(td, &sg, args->path);

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

	ap.fname = args->path;

	if (args->argp != NULL) {
		count = 0;
		p32 = (u_int32_t *)args->argp;
		do {
			error = copyin(p32++, &arg, sizeof(arg));
			if (error)
				return error;
			count++;
		} while (arg != 0);
		p = stackgap_alloc(&sg, count * sizeof(char *));
		ap.argv = p;
		p32 = (u_int32_t *)args->argp;
		do {
			error = copyin(p32++, &arg, sizeof(arg));
			if (error)
				return error;
			p64 = PTRIN(arg);
			error = copyout(&p64, p++, sizeof(p64));
			if (error)
				return error;
		} while (arg != 0);
	}
	if (args->envp != NULL) {
		count = 0;
		p32 = (u_int32_t *)args->envp;
		do {
			error = copyin(p32++, &arg, sizeof(arg));
			if (error)
				return error;
			count++;
		} while (arg != 0);
		p = stackgap_alloc(&sg, count * sizeof(char *));
		ap.envv = p;
		p32 = (u_int32_t *)args->envp;
		do {
			error = copyin(p32++, &arg, sizeof(arg));
			if (error)
				return error;
			p64 = PTRIN(arg);
			error = copyout(&p64, p++, sizeof(p64));
			if (error)
				return error;
		} while (arg != 0);
	}

	return (execve(td, &ap));
}