Project

General

Profile

Bug #1471 ยป linux_file.c.diff

ftigeot, 09/02/2009 09:22 AM

View differences:

linux_file.c 2009-09-02 10:32:42 +0200
error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW);
if (error == 0) {
error = kern_open(&nd, O_WRONLY | O_CREAT | O_TRUNC,
args->mode, &args->sysmsg_iresult);
args->mode, &args->sysmsg_result);
}
linux_free_path(&path);
return(error);
......
error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW);
if (error == 0) {
error = kern_open(&nd, flags,
args->mode, &args->sysmsg_iresult);
args->mode, &args->sysmsg_result);
}
if (error == 0 && !(flags & O_NOCTTY) &&
SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
struct file *fp;
fp = holdfp(p->p_fd, args->sysmsg_iresult, -1);
fp = holdfp(p->p_fd, args->sysmsg_result, -1);
if (fp) {
if (fp->f_type == DTYPE_VNODE)
fo_ioctl(fp, TIOCSCTTY, NULL, p->p_ucred, NULL);
......
lda.fd = args->fd;
lda.dent = args->dent;
lda.count = -1;
lda.sysmsg_iresult = 0;
lda.sysmsg_result = 0;
error = sys_linux_getdents(&lda);
args->sysmsg_iresult = lda.sysmsg_iresult;
args->sysmsg_result = lda.sysmsg_result;
return(error);
}
......
struct dirent *bdp;
struct vnode *vp;
caddr_t inp, buf; /* BSD-format */
int reclen; /* BSD-format */
size_t len;
int len, reclen; /* BSD-format */
caddr_t outp; /* Linux-format */
int linuxreclen = 0; /* Linux-format */
size_t resid;
int resid, linuxreclen=0; /* Linux-format */
struct file *fp;
struct uio auio;
struct iovec aiov;
......
off_t off;
struct l_dirent linux_dirent;
struct l_dirent64 linux_dirent64;
int error, eofflag, justone;
size_t buflen, nbytes;
int buflen, error, eofflag, nbytes, justone;
off_t *cookies = NULL, *cookiep;
int ncookies;
......
goto done;
nbytes = args->count;
if (nbytes == (size_t)-1) {
if (nbytes == -1) {
/* readdir(2) case. Always struct dirent. */
if (is64bit) {
error = EINVAL;
......
} else {
justone = 0;
}
if ((size_t)nbytes < 0)
if (nbytes < 0)
nbytes = 0;
off = fp->f_offset;
......
inp = buf;
outp = (caddr_t)args->dirent;
resid = nbytes;
if (auio.uio_resid >= buflen);
if ((len = buflen - auio.uio_resid) <= 0)
goto eof;
len = buflen - auio.uio_resid;
cookiep = cookies;
if (cookies) {
......
nbytes = resid + linuxreclen;
eof:
args->sysmsg_iresult = (int)(nbytes - resid);
args->sysmsg_result = nbytes - resid;
out:
if (cookies)
......
error = nlookup_init(&nd, path, UIO_SYSSPACE, 0);
if (error == 0) {
error = kern_readlink(&nd, args->buf, args->count,
&args->sysmsg_iresult);
&args->sysmsg_result);
}
nlookup_done(&nd);
linux_free_path(&path);
......
int error;
bsd.fd = uap->fd;
bsd.sysmsg_iresult = 0;
bsd.sysmsg_result = 0;
error = sys_fsync(&bsd);
uap->sysmsg_iresult = bsd.sysmsg_iresult;
uap->sysmsg_result = bsd.sysmsg_result;
return(error);
}
......
auio.uio_segflg = UIO_USERSPACE;
auio.uio_td = td;
if ((ssize_t)auio.uio_resid < 0) {
if (auio.uio_resid < 0)
error = EINVAL;
} else {
error = kern_preadv(uap->fd, &auio, O_FOFFSET,
&uap->sysmsg_szresult);
}
else
error = kern_preadv(uap->fd, &auio, O_FOFFSET, &uap->sysmsg_result);
return(error);
}
......
auio.uio_segflg = UIO_USERSPACE;
auio.uio_td = td;
if ((ssize_t)auio.uio_resid < 0) {
if (auio.uio_resid < 0)
error = EINVAL;
} else {
error = kern_pwritev(uap->fd, &auio, O_FOFFSET,
&uap->sysmsg_szresult);
}
else
error = kern_pwritev(uap->fd, &auio, O_FOFFSET, &uap->sysmsg_result);
return(error);
}
......
args2.path = args->path;
args2.flags = 0;
args2.sysmsg_iresult = 0;
args2.sysmsg_result = 0;
error = sys_linux_umount(&args2);
args->sysmsg_iresult = args2.sysmsg_iresult;
args->sysmsg_result = args2.sysmsg_result;
return(error);
}
......
bsd.path = args->path;
bsd.flags = args->flags; /* XXX correct? */
bsd.sysmsg_iresult = 0;
bsd.sysmsg_result = 0;
error = sys_unmount(&bsd);
args->sysmsg_iresult = bsd.sysmsg_iresult;
args->sysmsg_result = bsd.sysmsg_result;
return(error);
}
......
if (error == 0) {
switch (args->cmd) {
case LINUX_F_DUPFD:
args->sysmsg_iresult = dat.fc_fd;
args->sysmsg_result = dat.fc_fd;
break;
case LINUX_F_GETFD:
args->sysmsg_iresult = dat.fc_cloexec;
args->sysmsg_result = dat.fc_cloexec;
break;
case LINUX_F_SETFD:
break;
case LINUX_F_GETFL:
args->sysmsg_iresult = 0;
args->sysmsg_result = 0;
if (dat.fc_flags & O_RDONLY)
args->sysmsg_iresult |= LINUX_O_RDONLY;
args->sysmsg_result |= LINUX_O_RDONLY;
if (dat.fc_flags & O_WRONLY)
args->sysmsg_iresult |= LINUX_O_WRONLY;
args->sysmsg_result |= LINUX_O_WRONLY;
if (dat.fc_flags & O_RDWR)
args->sysmsg_iresult |= LINUX_O_RDWR;
args->sysmsg_result |= LINUX_O_RDWR;
if (dat.fc_flags & O_NDELAY)
args->sysmsg_iresult |= LINUX_O_NONBLOCK;
args->sysmsg_result |= LINUX_O_NONBLOCK;
if (dat.fc_flags & O_APPEND)
args->sysmsg_iresult |= LINUX_O_APPEND;
args->sysmsg_result |= LINUX_O_APPEND;
if (dat.fc_flags & O_FSYNC)
args->sysmsg_iresult |= LINUX_O_SYNC;
args->sysmsg_result |= LINUX_O_SYNC;
if (dat.fc_flags & O_ASYNC)
args->sysmsg_iresult |= LINUX_FASYNC;
args->sysmsg_result |= LINUX_FASYNC;
break;
case LINUX_F_GETLK:
bsd_to_linux_flock(&dat.fc_flock, &linux_flock);
......
case LINUX_F_SETLKW:
break;
case LINUX_F_GETOWN:
args->sysmsg_iresult = dat.fc_owner;
args->sysmsg_result = dat.fc_owner;
break;
case LINUX_F_SETOWN:
break;
......
args64.fd = args->fd;
args64.cmd = args->cmd;
args64.arg = args->arg;
args64.sysmsg_iresult = 0;
args64.sysmsg_result = 0;
error = linux_fcntl_common(&args64);
args->sysmsg_iresult = args64.sysmsg_iresult;
args->sysmsg_result = args64.sysmsg_result;
return(error);
}
    (1-1/1)