Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_descrip.c
Show First 20 Lines • Show All 1,298 Lines • ▼ Show 20 Lines | ofstat(struct thread *td, struct ofstat_args *uap) | ||||
if (error == 0) { | if (error == 0) { | ||||
cvtstat(&ub, &oub); | cvtstat(&ub, &oub); | ||||
error = copyout(&oub, uap->sb, sizeof(oub)); | error = copyout(&oub, uap->sb, sizeof(oub)); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif /* COMPAT_43 */ | #endif /* COMPAT_43 */ | ||||
#if defined(COMPAT_FREEBSD11) | |||||
int | |||||
freebsd11_fstat(struct thread *td, struct freebsd11_fstat_args *uap) | |||||
{ | |||||
struct stat sb; | |||||
struct freebsd11_stat osb; | |||||
int error; | |||||
error = kern_fstat(td, uap->fd, &sb); | |||||
if (error != 0) | |||||
return (error); | |||||
freebsd11_cvtstat(&sb, &osb); | |||||
error = copyout(&osb, uap->sb, sizeof(osb)); | |||||
return (error); | |||||
} | |||||
#endif /* COMPAT_FREEBSD11 */ | |||||
/* | /* | ||||
* Return status information about a file descriptor. | * Return status information about a file descriptor. | ||||
*/ | */ | ||||
#ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
struct fstat_args { | struct fstat_args { | ||||
int fd; | int fd; | ||||
struct stat *sb; | struct stat *sb; | ||||
}; | }; | ||||
Show All 23 Lines | kern_fstat(struct thread *td, int fd, struct stat *sbp) | ||||
error = fget(td, fd, cap_rights_init(&rights, CAP_FSTAT), &fp); | error = fget(td, fd, cap_rights_init(&rights, CAP_FSTAT), &fp); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
AUDIT_ARG_FILE(td->td_proc, fp); | AUDIT_ARG_FILE(td->td_proc, fp); | ||||
error = fo_stat(fp, sbp, td->td_ucred, td); | error = fo_stat(fp, sbp, td->td_ucred, td); | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
#ifdef __STAT_TIME_T_EXT | |||||
if (error == 0) { | |||||
sbp->st_atim_ext = 0; | |||||
sbp->st_mtim_ext = 0; | |||||
sbp->st_ctim_ext = 0; | |||||
sbp->st_btim_ext = 0; | |||||
} | |||||
#endif | |||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (error == 0 && KTRPOINT(td, KTR_STRUCT)) | if (error == 0 && KTRPOINT(td, KTR_STRUCT)) | ||||
ktrstat(sbp); | ktrstat(sbp); | ||||
#endif | #endif | ||||
return (error); | return (error); | ||||
} | } | ||||
#if defined(COMPAT_FREEBSD11) | |||||
/* | /* | ||||
* Return status information about a file descriptor. | * Return status information about a file descriptor. | ||||
*/ | */ | ||||
#ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
struct nfstat_args { | struct freebsd11_nfstat_args { | ||||
int fd; | int fd; | ||||
struct nstat *sb; | struct nstat *sb; | ||||
}; | }; | ||||
#endif | #endif | ||||
/* ARGSUSED */ | /* ARGSUSED */ | ||||
int | int | ||||
sys_nfstat(struct thread *td, struct nfstat_args *uap) | freebsd11_nfstat(struct thread *td, struct freebsd11_nfstat_args *uap) | ||||
{ | { | ||||
struct nstat nub; | struct nstat nub; | ||||
struct stat ub; | struct stat ub; | ||||
int error; | int error; | ||||
error = kern_fstat(td, uap->fd, &ub); | error = kern_fstat(td, uap->fd, &ub); | ||||
if (error == 0) { | if (error == 0) { | ||||
cvtnstat(&ub, &nub); | freebsd11_cvtnstat(&ub, &nub); | ||||
error = copyout(&nub, uap->sb, sizeof(nub)); | error = copyout(&nub, uap->sb, sizeof(nub)); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif /* COMPAT_FREEBSD11 */ | |||||
/* | /* | ||||
* Return pathconf information about a file descriptor. | * Return pathconf information about a file descriptor. | ||||
*/ | */ | ||||
#ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
struct fpathconf_args { | struct fpathconf_args { | ||||
int fd; | int fd; | ||||
int name; | int name; | ||||
▲ Show 20 Lines • Show All 2,200 Lines • ▼ Show 20 Lines | kinfo_to_okinfo(struct kinfo_file *kif, struct kinfo_ofile *okif) | ||||
okif->kf_structsize = sizeof(*okif); | okif->kf_structsize = sizeof(*okif); | ||||
okif->kf_type = kif->kf_type; | okif->kf_type = kif->kf_type; | ||||
okif->kf_fd = kif->kf_fd; | okif->kf_fd = kif->kf_fd; | ||||
okif->kf_ref_count = kif->kf_ref_count; | okif->kf_ref_count = kif->kf_ref_count; | ||||
okif->kf_flags = kif->kf_flags & (KF_FLAG_READ | KF_FLAG_WRITE | | okif->kf_flags = kif->kf_flags & (KF_FLAG_READ | KF_FLAG_WRITE | | ||||
KF_FLAG_APPEND | KF_FLAG_ASYNC | KF_FLAG_FSYNC | KF_FLAG_NONBLOCK | | KF_FLAG_APPEND | KF_FLAG_ASYNC | KF_FLAG_FSYNC | KF_FLAG_NONBLOCK | | ||||
KF_FLAG_DIRECT | KF_FLAG_HASLOCK); | KF_FLAG_DIRECT | KF_FLAG_HASLOCK); | ||||
okif->kf_offset = kif->kf_offset; | okif->kf_offset = kif->kf_offset; | ||||
okif->kf_vnode_type = kif->kf_vnode_type; | if (kif->kf_type == KF_TYPE_VNODE) | ||||
okif->kf_sock_domain = kif->kf_sock_domain; | okif->kf_vnode_type = kif->kf_un.kf_file.kf_file_type; | ||||
okif->kf_sock_type = kif->kf_sock_type; | else | ||||
okif->kf_sock_protocol = kif->kf_sock_protocol; | okif->kf_vnode_type = KF_VTYPE_VNON; | ||||
strlcpy(okif->kf_path, kif->kf_path, sizeof(okif->kf_path)); | strlcpy(okif->kf_path, kif->kf_path, sizeof(okif->kf_path)); | ||||
okif->kf_sa_local = kif->kf_sa_local; | if (kif->kf_type == KF_TYPE_SOCKET) { | ||||
okif->kf_sa_peer = kif->kf_sa_peer; | okif->kf_sock_domain = kif->kf_un.kf_sock.kf_sock_domain0; | ||||
okif->kf_sock_type = kif->kf_un.kf_sock.kf_sock_type0; | |||||
okif->kf_sock_protocol = kif->kf_un.kf_sock.kf_sock_protocol0; | |||||
okif->kf_sa_local = kif->kf_un.kf_sock.kf_sa_local; | |||||
okif->kf_sa_peer = kif->kf_un.kf_sock.kf_sa_peer; | |||||
} else { | |||||
okif->kf_sa_local.ss_family = AF_UNSPEC; | |||||
okif->kf_sa_peer.ss_family = AF_UNSPEC; | |||||
} | |||||
} | } | ||||
static int | static int | ||||
export_vnode_for_osysctl(struct vnode *vp, int type, struct kinfo_file *kif, | export_vnode_for_osysctl(struct vnode *vp, int type, struct kinfo_file *kif, | ||||
struct kinfo_ofile *okif, struct filedesc *fdp, struct sysctl_req *req) | struct kinfo_ofile *okif, struct filedesc *fdp, struct sysctl_req *req) | ||||
{ | { | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 522 Lines • Show Last 20 Lines |