Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux_file.c
Show First 20 Lines • Show All 492 Lines • ▼ Show 20 Lines | while (len > 0) { | ||||
*/ | */ | ||||
if (resid < linuxreclen) { | if (resid < linuxreclen) { | ||||
error = EINVAL; | error = EINVAL; | ||||
goto out; | goto out; | ||||
} | } | ||||
linux_dirent = (struct l_dirent*)lbuf; | linux_dirent = (struct l_dirent*)lbuf; | ||||
linux_dirent->d_ino = bdp->d_fileno; | linux_dirent->d_ino = bdp->d_fileno; | ||||
linux_dirent->d_off = base + reclen; | linux_dirent->d_off = bdp->d_off; | ||||
linux_dirent->d_reclen = linuxreclen; | linux_dirent->d_reclen = linuxreclen; | ||||
/* | /* | ||||
* Copy d_type to last byte of l_dirent buffer | * Copy d_type to last byte of l_dirent buffer | ||||
*/ | */ | ||||
lbuf[linuxreclen - 1] = bdp->d_type; | lbuf[linuxreclen - 1] = bdp->d_type; | ||||
strlcpy(linux_dirent->d_name, bdp->d_name, | strlcpy(linux_dirent->d_name, bdp->d_name, | ||||
linuxreclen - offsetof(struct l_dirent, d_name)-1); | linuxreclen - offsetof(struct l_dirent, d_name)-1); | ||||
error = copyout(linux_dirent, outp, linuxreclen); | error = copyout(linux_dirent, outp, linuxreclen); | ||||
Show All 36 Lines | linux_getdents64(struct thread *td, struct linux_getdents64_args *args) | ||||
buf = malloc(buflen, M_TEMP, M_WAITOK); | buf = malloc(buflen, M_TEMP, M_WAITOK); | ||||
error = kern_getdirentries(td, args->fd, buf, buflen, | error = kern_getdirentries(td, args->fd, buf, buflen, | ||||
&base, NULL, UIO_SYSSPACE); | &base, NULL, UIO_SYSSPACE); | ||||
if (error != 0) { | if (error != 0) { | ||||
error = linux_getdents_error(td, args->fd, error); | error = linux_getdents_error(td, args->fd, error); | ||||
goto out1; | goto out1; | ||||
} | } | ||||
lbuf = malloc(LINUX_RECLEN64(LINUX_NAME_MAX), M_TEMP, M_WAITOK | M_ZERO); | lbuf = malloc(LINUX_RECLEN64(LINUX_NAME_MAX), M_TEMP, M_WAITOK | M_ZERO); | ||||
len = td->td_retval[0]; | len = td->td_retval[0]; | ||||
inp = buf; | inp = buf; | ||||
outp = (caddr_t)args->dirent; | outp = (caddr_t)args->dirent; | ||||
resid = args->count; | resid = args->count; | ||||
retval = 0; | retval = 0; | ||||
while (len > 0) { | while (len > 0) { | ||||
bdp = (struct dirent *) inp; | bdp = (struct dirent *) inp; | ||||
reclen = bdp->d_reclen; | reclen = bdp->d_reclen; | ||||
linuxreclen = LINUX_RECLEN64(bdp->d_namlen); | linuxreclen = LINUX_RECLEN64(bdp->d_namlen); | ||||
/* | /* | ||||
* No more space in the user supplied dirent buffer. | * No more space in the user supplied dirent buffer. | ||||
* Return EINVAL. | * Return EINVAL. | ||||
*/ | */ | ||||
if (resid < linuxreclen) { | if (resid < linuxreclen) { | ||||
error = EINVAL; | error = EINVAL; | ||||
goto out; | goto out; | ||||
} | } | ||||
linux_dirent64 = (struct l_dirent64*)lbuf; | linux_dirent64 = (struct l_dirent64*)lbuf; | ||||
linux_dirent64->d_ino = bdp->d_fileno; | linux_dirent64->d_ino = bdp->d_fileno; | ||||
linux_dirent64->d_off = base + reclen; | linux_dirent64->d_off = bdp->d_off; | ||||
linux_dirent64->d_reclen = linuxreclen; | linux_dirent64->d_reclen = linuxreclen; | ||||
linux_dirent64->d_type = bdp->d_type; | linux_dirent64->d_type = bdp->d_type; | ||||
strlcpy(linux_dirent64->d_name, bdp->d_name, | strlcpy(linux_dirent64->d_name, bdp->d_name, | ||||
linuxreclen - offsetof(struct l_dirent64, d_name)); | linuxreclen - offsetof(struct l_dirent64, d_name)); | ||||
error = copyout(linux_dirent64, outp, linuxreclen); | error = copyout(linux_dirent64, outp, linuxreclen); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
Show All 40 Lines | linux_readdir(struct thread *td, struct linux_readdir_args *args) | ||||
lbuf = malloc(LINUX_RECLEN(LINUX_NAME_MAX), M_TEMP, M_WAITOK | M_ZERO); | lbuf = malloc(LINUX_RECLEN(LINUX_NAME_MAX), M_TEMP, M_WAITOK | M_ZERO); | ||||
bdp = (struct dirent *) buf; | bdp = (struct dirent *) buf; | ||||
linuxreclen = LINUX_RECLEN(bdp->d_namlen); | linuxreclen = LINUX_RECLEN(bdp->d_namlen); | ||||
linux_dirent = (struct l_dirent*)lbuf; | linux_dirent = (struct l_dirent*)lbuf; | ||||
linux_dirent->d_ino = bdp->d_fileno; | linux_dirent->d_ino = bdp->d_fileno; | ||||
linux_dirent->d_off = linuxreclen; | linux_dirent->d_off = bdp->d_off; | ||||
linux_dirent->d_reclen = bdp->d_namlen; | linux_dirent->d_reclen = bdp->d_namlen; | ||||
strlcpy(linux_dirent->d_name, bdp->d_name, | strlcpy(linux_dirent->d_name, bdp->d_name, | ||||
linuxreclen - offsetof(struct l_dirent, d_name)); | linuxreclen - offsetof(struct l_dirent, d_name)); | ||||
error = copyout(linux_dirent, args->dent, linuxreclen); | error = copyout(linux_dirent, args->dent, linuxreclen); | ||||
if (error == 0) | if (error == 0) | ||||
td->td_retval[0] = linuxreclen; | td->td_retval[0] = linuxreclen; | ||||
free(lbuf, M_TEMP); | free(lbuf, M_TEMP); | ||||
▲ Show 20 Lines • Show All 1,439 Lines • Show Last 20 Lines |