summaryrefslogtreecommitdiffstats
path: root/sys/sys/file.h
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2013-08-15 07:54:31 +0000
committerglebius <glebius@FreeBSD.org>2013-08-15 07:54:31 +0000
commit722a1a5e5d54a4935a4136368f443f6c88ca0d71 (patch)
tree72f140bc20e3f03e8744a0112282734ba89f474b /sys/sys/file.h
parent8c7687b41c874820110a7106c1167f5b0e3fc7d0 (diff)
downloadFreeBSD-src-722a1a5e5d54a4935a4136368f443f6c88ca0d71.zip
FreeBSD-src-722a1a5e5d54a4935a4136368f443f6c88ca0d71.tar.gz
Make sendfile() a method in the struct fileops. Currently only
vnode backed file descriptors have this method implemented. Reviewed by: kib Sponsored by: Nginx, Inc. Sponsored by: Netflix
Diffstat (limited to 'sys/sys/file.h')
-rw-r--r--sys/sys/file.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/sys/file.h b/sys/sys/file.h
index cfdc1d8..63a7e8f 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -105,6 +105,9 @@ typedef int fo_chmod_t(struct file *fp, mode_t mode,
struct ucred *active_cred, struct thread *td);
typedef int fo_chown_t(struct file *fp, uid_t uid, gid_t gid,
struct ucred *active_cred, struct thread *td);
+typedef int fo_sendfile_t(struct file *fp, int sockfd, struct uio *hdr_uio,
+ struct uio *trl_uio, off_t offset, size_t nbytes,
+ off_t *sent, int flags, int kflags, struct thread *td);
typedef int fo_flags_t;
struct fileops {
@@ -118,6 +121,7 @@ struct fileops {
fo_close_t *fo_close;
fo_chmod_t *fo_chmod;
fo_chown_t *fo_chown;
+ fo_sendfile_t *fo_sendfile;
fo_flags_t fo_flags; /* DFLAG_* below */
};
@@ -235,6 +239,7 @@ fo_close_t soo_close;
fo_chmod_t invfo_chmod;
fo_chown_t invfo_chown;
+fo_sendfile_t invfo_sendfile;
void finit(struct file *, u_int, short, void *, struct fileops *);
int fgetvp(struct thread *td, int fd, cap_rights_t rights, struct vnode **vpp);
@@ -273,6 +278,7 @@ static __inline fo_stat_t fo_stat;
static __inline fo_close_t fo_close;
static __inline fo_chmod_t fo_chmod;
static __inline fo_chown_t fo_chown;
+static __inline fo_sendfile_t fo_sendfile;
static __inline int
fo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
@@ -352,6 +358,16 @@ fo_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,
return ((*fp->f_ops->fo_chown)(fp, uid, gid, active_cred, td));
}
+static __inline int
+fo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
+ struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
+ int kflags, struct thread *td)
+{
+
+ return ((*fp->f_ops->fo_sendfile)(fp, sockfd, hdr_uio, trl_uio, offset,
+ nbytes, sent, flags, kflags, td));
+}
+
#endif /* _KERNEL */
#endif /* !SYS_FILE_H */
OpenPOWER on IntegriCloud