Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux_stats.c
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | |||||
linux_newstat(struct thread *td, struct linux_newstat_args *args) | linux_newstat(struct thread *td, struct linux_newstat_args *args) | ||||
{ | { | ||||
struct stat buf; | struct stat buf; | ||||
char *path; | char *path; | ||||
int error; | int error; | ||||
LCONVPATHEXIST(td, args->path, &path); | LCONVPATHEXIST(td, args->path, &path); | ||||
#ifdef DEBUG | |||||
if (ldebug(newstat)) | |||||
printf(ARGS(newstat, "%s, *"), path); | |||||
#endif | |||||
error = linux_kern_stat(td, path, UIO_SYSSPACE, &buf); | error = linux_kern_stat(td, path, UIO_SYSSPACE, &buf); | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
return (newstat_copyout(&buf, args->buf)); | return (newstat_copyout(&buf, args->buf)); | ||||
} | } | ||||
int | int | ||||
linux_newlstat(struct thread *td, struct linux_newlstat_args *args) | linux_newlstat(struct thread *td, struct linux_newlstat_args *args) | ||||
{ | { | ||||
struct stat sb; | struct stat sb; | ||||
char *path; | char *path; | ||||
int error; | int error; | ||||
LCONVPATHEXIST(td, args->path, &path); | 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); | error = linux_kern_lstat(td, path, UIO_SYSSPACE, &sb); | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
return (newstat_copyout(&sb, args->buf)); | return (newstat_copyout(&sb, args->buf)); | ||||
} | } | ||||
#endif | #endif | ||||
int | int | ||||
linux_newfstat(struct thread *td, struct linux_newfstat_args *args) | linux_newfstat(struct thread *td, struct linux_newfstat_args *args) | ||||
{ | { | ||||
struct stat buf; | struct stat buf; | ||||
int error; | int error; | ||||
#ifdef DEBUG | |||||
if (ldebug(newfstat)) | |||||
printf(ARGS(newfstat, "%d, *"), args->fd); | |||||
#endif | |||||
error = kern_fstat(td, args->fd, &buf); | error = kern_fstat(td, args->fd, &buf); | ||||
translate_fd_major_minor(td, args->fd, &buf); | translate_fd_major_minor(td, args->fd, &buf); | ||||
if (!error) | if (!error) | ||||
error = newstat_copyout(&buf, args->buf); | error = newstat_copyout(&buf, args->buf); | ||||
return (error); | return (error); | ||||
} | } | ||||
Show All 30 Lines | |||||
linux_stat(struct thread *td, struct linux_stat_args *args) | linux_stat(struct thread *td, struct linux_stat_args *args) | ||||
{ | { | ||||
struct stat buf; | struct stat buf; | ||||
char *path; | char *path; | ||||
int error; | int error; | ||||
LCONVPATHEXIST(td, args->path, &path); | LCONVPATHEXIST(td, args->path, &path); | ||||
#ifdef DEBUG | |||||
if (ldebug(stat)) | |||||
printf(ARGS(stat, "%s, *"), path); | |||||
#endif | |||||
error = linux_kern_stat(td, path, UIO_SYSSPACE, &buf); | error = linux_kern_stat(td, path, UIO_SYSSPACE, &buf); | ||||
if (error) { | if (error) { | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
return (error); | return (error); | ||||
} | } | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
return (stat_copyout(&buf, args->up)); | return (stat_copyout(&buf, args->up)); | ||||
} | } | ||||
int | int | ||||
linux_lstat(struct thread *td, struct linux_lstat_args *args) | linux_lstat(struct thread *td, struct linux_lstat_args *args) | ||||
{ | { | ||||
struct stat buf; | struct stat buf; | ||||
char *path; | char *path; | ||||
int error; | int error; | ||||
LCONVPATHEXIST(td, args->path, &path); | 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); | error = linux_kern_lstat(td, path, UIO_SYSSPACE, &buf); | ||||
if (error) { | if (error) { | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
return (error); | return (error); | ||||
} | } | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
return (stat_copyout(&buf, args->up)); | return (stat_copyout(&buf, args->up)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct l_statfs linux_statfs; | struct l_statfs linux_statfs; | ||||
struct statfs *bsd_statfs; | struct statfs *bsd_statfs; | ||||
char *path; | char *path; | ||||
int error; | int error; | ||||
LCONVPATHEXIST(td, args->path, &path); | LCONVPATHEXIST(td, args->path, &path); | ||||
#ifdef DEBUG | |||||
if (ldebug(statfs)) | |||||
printf(ARGS(statfs, "%s, *"), path); | |||||
#endif | |||||
bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | ||||
error = kern_statfs(td, path, UIO_SYSSPACE, bsd_statfs); | error = kern_statfs(td, path, UIO_SYSSPACE, bsd_statfs); | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
if (error == 0) | if (error == 0) | ||||
error = bsd_to_linux_statfs(bsd_statfs, &linux_statfs); | error = bsd_to_linux_statfs(bsd_statfs, &linux_statfs); | ||||
free(bsd_statfs, M_STATFS); | free(bsd_statfs, M_STATFS); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
Show All 28 Lines | linux_statfs64(struct thread *td, struct linux_statfs64_args *args) | ||||
char *path; | char *path; | ||||
int error; | int error; | ||||
if (args->bufsize != sizeof(struct l_statfs64)) | if (args->bufsize != sizeof(struct l_statfs64)) | ||||
return (EINVAL); | return (EINVAL); | ||||
LCONVPATHEXIST(td, args->path, &path); | LCONVPATHEXIST(td, args->path, &path); | ||||
#ifdef DEBUG | |||||
if (ldebug(statfs64)) | |||||
printf(ARGS(statfs64, "%s, *"), path); | |||||
#endif | |||||
bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | ||||
error = kern_statfs(td, path, UIO_SYSSPACE, bsd_statfs); | error = kern_statfs(td, path, UIO_SYSSPACE, bsd_statfs); | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
if (error == 0) | if (error == 0) | ||||
bsd_to_linux_statfs64(bsd_statfs, &linux_statfs); | bsd_to_linux_statfs64(bsd_statfs, &linux_statfs); | ||||
free(bsd_statfs, M_STATFS); | free(bsd_statfs, M_STATFS); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); | return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); | ||||
} | } | ||||
int | int | ||||
linux_fstatfs64(struct thread *td, struct linux_fstatfs64_args *args) | linux_fstatfs64(struct thread *td, struct linux_fstatfs64_args *args) | ||||
{ | { | ||||
struct l_statfs64 linux_statfs; | struct l_statfs64 linux_statfs; | ||||
struct statfs *bsd_statfs; | struct statfs *bsd_statfs; | ||||
int error; | int error; | ||||
#ifdef DEBUG | |||||
if (ldebug(fstatfs64)) | |||||
printf(ARGS(fstatfs64, "%d, *"), args->fd); | |||||
#endif | |||||
if (args->bufsize != sizeof(struct l_statfs64)) | if (args->bufsize != sizeof(struct l_statfs64)) | ||||
return (EINVAL); | return (EINVAL); | ||||
bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | ||||
error = kern_fstatfs(td, args->fd, bsd_statfs); | error = kern_fstatfs(td, args->fd, bsd_statfs); | ||||
if (error == 0) | if (error == 0) | ||||
bsd_to_linux_statfs64(bsd_statfs, &linux_statfs); | bsd_to_linux_statfs64(bsd_statfs, &linux_statfs); | ||||
free(bsd_statfs, M_STATFS); | free(bsd_statfs, M_STATFS); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); | return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); | ||||
} | } | ||||
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ | #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ | ||||
int | int | ||||
linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args) | linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args) | ||||
{ | { | ||||
struct l_statfs linux_statfs; | struct l_statfs linux_statfs; | ||||
struct statfs *bsd_statfs; | struct statfs *bsd_statfs; | ||||
int error; | int error; | ||||
#ifdef DEBUG | |||||
if (ldebug(fstatfs)) | |||||
printf(ARGS(fstatfs, "%d, *"), args->fd); | |||||
#endif | |||||
bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | bsd_statfs = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); | ||||
error = kern_fstatfs(td, args->fd, bsd_statfs); | error = kern_fstatfs(td, args->fd, bsd_statfs); | ||||
if (error == 0) | if (error == 0) | ||||
error = bsd_to_linux_statfs(bsd_statfs, &linux_statfs); | error = bsd_to_linux_statfs(bsd_statfs, &linux_statfs); | ||||
free(bsd_statfs, M_STATFS); | free(bsd_statfs, M_STATFS); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); | return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); | ||||
} | } | ||||
struct l_ustat | struct l_ustat | ||||
{ | { | ||||
l_daddr_t f_tfree; | l_daddr_t f_tfree; | ||||
l_ino_t f_tinode; | l_ino_t f_tinode; | ||||
char f_fname[6]; | char f_fname[6]; | ||||
char f_fpack[6]; | char f_fpack[6]; | ||||
}; | }; | ||||
#ifdef LINUX_LEGACY_SYSCALLS | #ifdef LINUX_LEGACY_SYSCALLS | ||||
int | int | ||||
linux_ustat(struct thread *td, struct linux_ustat_args *args) | linux_ustat(struct thread *td, struct linux_ustat_args *args) | ||||
{ | { | ||||
#ifdef DEBUG | |||||
if (ldebug(ustat)) | |||||
printf(ARGS(ustat, "%ju, *"), (uintmax_t)args->dev); | |||||
#endif | |||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
#endif | #endif | ||||
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) | #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) | ||||
static int | static int | ||||
Show All 34 Lines | |||||
linux_stat64(struct thread *td, struct linux_stat64_args *args) | linux_stat64(struct thread *td, struct linux_stat64_args *args) | ||||
{ | { | ||||
struct stat buf; | struct stat buf; | ||||
char *filename; | char *filename; | ||||
int error; | int error; | ||||
LCONVPATHEXIST(td, args->filename, &filename); | LCONVPATHEXIST(td, args->filename, &filename); | ||||
#ifdef DEBUG | |||||
if (ldebug(stat64)) | |||||
printf(ARGS(stat64, "%s, *"), filename); | |||||
#endif | |||||
error = linux_kern_stat(td, filename, UIO_SYSSPACE, &buf); | error = linux_kern_stat(td, filename, UIO_SYSSPACE, &buf); | ||||
LFREEPATH(filename); | LFREEPATH(filename); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
return (stat64_copyout(&buf, args->statbuf)); | return (stat64_copyout(&buf, args->statbuf)); | ||||
} | } | ||||
int | int | ||||
linux_lstat64(struct thread *td, struct linux_lstat64_args *args) | linux_lstat64(struct thread *td, struct linux_lstat64_args *args) | ||||
{ | { | ||||
struct stat sb; | struct stat sb; | ||||
char *filename; | char *filename; | ||||
int error; | int error; | ||||
LCONVPATHEXIST(td, args->filename, &filename); | 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); | error = linux_kern_lstat(td, filename, UIO_SYSSPACE, &sb); | ||||
LFREEPATH(filename); | LFREEPATH(filename); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
return (stat64_copyout(&sb, args->statbuf)); | return (stat64_copyout(&sb, args->statbuf)); | ||||
} | } | ||||
int | int | ||||
linux_fstat64(struct thread *td, struct linux_fstat64_args *args) | linux_fstat64(struct thread *td, struct linux_fstat64_args *args) | ||||
{ | { | ||||
struct stat buf; | struct stat buf; | ||||
int error; | int error; | ||||
#ifdef DEBUG | |||||
if (ldebug(fstat64)) | |||||
printf(ARGS(fstat64, "%d, *"), args->fd); | |||||
#endif | |||||
error = kern_fstat(td, args->fd, &buf); | error = kern_fstat(td, args->fd, &buf); | ||||
translate_fd_major_minor(td, args->fd, &buf); | translate_fd_major_minor(td, args->fd, &buf); | ||||
if (!error) | if (!error) | ||||
error = stat64_copyout(&buf, args->statbuf); | error = stat64_copyout(&buf, args->statbuf); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args) | linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args) | ||||
{ | { | ||||
char *path; | char *path; | ||||
int error, dfd, flag; | int error, dfd, flag; | ||||
struct stat buf; | struct stat buf; | ||||
if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) | if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) | ||||
return (EINVAL); | return (EINVAL); | ||||
flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? | flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? | ||||
AT_SYMLINK_NOFOLLOW : 0; | AT_SYMLINK_NOFOLLOW : 0; | ||||
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; | dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; | ||||
LCONVPATHEXIST_AT(td, args->pathname, &path, dfd); | LCONVPATHEXIST_AT(td, args->pathname, &path, dfd); | ||||
#ifdef DEBUG | |||||
if (ldebug(fstatat64)) | |||||
printf(ARGS(fstatat64, "%i, %s, %i"), args->dfd, path, args->flag); | |||||
#endif | |||||
error = linux_kern_statat(td, flag, dfd, path, UIO_SYSSPACE, &buf); | error = linux_kern_statat(td, flag, dfd, path, UIO_SYSSPACE, &buf); | ||||
if (!error) | if (!error) | ||||
error = stat64_copyout(&buf, args->statbuf); | error = stat64_copyout(&buf, args->statbuf); | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
return (error); | return (error); | ||||
} | } | ||||
#else /* __amd64__ && !COMPAT_LINUX32 */ | #else /* __amd64__ && !COMPAT_LINUX32 */ | ||||
int | int | ||||
linux_newfstatat(struct thread *td, struct linux_newfstatat_args *args) | linux_newfstatat(struct thread *td, struct linux_newfstatat_args *args) | ||||
{ | { | ||||
char *path; | char *path; | ||||
int error, dfd, flag; | int error, dfd, flag; | ||||
struct stat buf; | struct stat buf; | ||||
if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) | if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) | ||||
return (EINVAL); | return (EINVAL); | ||||
flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? | flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? | ||||
AT_SYMLINK_NOFOLLOW : 0; | AT_SYMLINK_NOFOLLOW : 0; | ||||
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; | dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; | ||||
LCONVPATHEXIST_AT(td, args->pathname, &path, dfd); | LCONVPATHEXIST_AT(td, args->pathname, &path, dfd); | ||||
#ifdef DEBUG | |||||
if (ldebug(newfstatat)) | |||||
printf(ARGS(newfstatat, "%i, %s, %i"), args->dfd, path, args->flag); | |||||
#endif | |||||
error = linux_kern_statat(td, flag, dfd, path, UIO_SYSSPACE, &buf); | error = linux_kern_statat(td, flag, dfd, path, UIO_SYSSPACE, &buf); | ||||
if (error == 0) | if (error == 0) | ||||
error = newstat_copyout(&buf, args->statbuf); | error = newstat_copyout(&buf, args->statbuf); | ||||
LFREEPATH(path); | LFREEPATH(path); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |