1f0bf889imp/*-
24736ccfpfg * SPDX-License-Identifier: BSD-3-Clause
34736ccfpfg *
48fb65cergrimes * Copyright (c) 1982, 1986, 1989, 1993
58fb65cergrimes *	The Regents of the University of California.  All rights reserved.
68fb65cergrimes *
78fb65cergrimes * Redistribution and use in source and binary forms, with or without
88fb65cergrimes * modification, are permitted provided that the following conditions
98fb65cergrimes * are met:
108fb65cergrimes * 1. Redistributions of source code must retain the above copyright
118fb65cergrimes *    notice, this list of conditions and the following disclaimer.
128fb65cergrimes * 2. Redistributions in binary form must reproduce the above copyright
138fb65cergrimes *    notice, this list of conditions and the following disclaimer in the
148fb65cergrimes *    documentation and/or other materials provided with the distribution.
157e6cabdimp * 3. Neither the name of the University nor the names of its contributors
168fb65cergrimes *    may be used to endorse or promote products derived from this software
178fb65cergrimes *    without specific prior written permission.
188fb65cergrimes *
198fb65cergrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
208fb65cergrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218fb65cergrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228fb65cergrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
238fb65cergrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248fb65cergrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
258fb65cergrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
268fb65cergrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
278fb65cergrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288fb65cergrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
298fb65cergrimes * SUCH DAMAGE.
308fb65cergrimes *
314ce83d9hsu *	@(#)file.h	8.3 (Berkeley) 1/9/95
323b842d3peter * $FreeBSD$
338fb65cergrimes */
348fb65cergrimes
351f5dfa1paul#ifndef _SYS_FILE_H_
3651ff523bde#define	_SYS_FILE_H_
371f5dfa1paul
3815b9bcbpeter#ifndef _KERNEL
39024665dmike#include <sys/types.h> /* XXX */
400d3591bbde#include <sys/fcntl.h>
418fb65cergrimes#include <sys/unistd.h>
4243aa4c7des#else
4303877ffalfred#include <sys/queue.h>
444d240aaattilio#include <sys/refcount.h>
455e2f4cfalfred#include <sys/_lock.h>
465e2f4cfalfred#include <sys/_mutex.h>
47bba1e1ejhb#include <vm/vm.h>
484ce83d9hsu
498f08266jhbstruct filedesc;
50f004a3apeterstruct stat;
515596676julianstruct thread;
528fb65cergrimesstruct uio;
5311781a7jlemonstruct knote;
54e3b965fdillonstruct vnode;
558fb65cergrimes
5643aa4c7des#endif /* _KERNEL */
5743aa4c7des
5892b4fcfkib#define	DTYPE_NONE	0	/* not yet initialized */
5943aa4c7des#define	DTYPE_VNODE	1	/* file */
6043aa4c7des#define	DTYPE_SOCKET	2	/* communications endpoint */
6143aa4c7des#define	DTYPE_PIPE	3	/* pipe */
6243aa4c7des#define	DTYPE_FIFO	4	/* fifo (named pipe) */
6343aa4c7des#define	DTYPE_KQUEUE	5	/* event queue */
640196f79sam#define	DTYPE_CRYPTO	6	/* crypto */
65dac7c81davidxu#define	DTYPE_MQUEUE	7	/* posix message queue */
668cd9437jhb#define	DTYPE_SHM	8	/* swap-backed shared memory */
67411d068jhb#define	DTYPE_SEM	9	/* posix semaphore */
68cc3116aed#define	DTYPE_PTS	10	/* pseudo teletype master device */
692d7d8c0jeff#define	DTYPE_DEV	11	/* Device specific fd type */
70f07ebb8pjd#define	DTYPE_PROCDESC	12	/* process descriptor */
71d7e47c5dchagin#define	DTYPE_LINUXEFD	13	/* emulation eventfd type */
72396e175dchagin#define	DTYPE_LINUXTFD	14	/* emulation timerfd type */
7343aa4c7des
7443aa4c7des#ifdef _KERNEL
7543aa4c7des
76b9e7819phkstruct file;
77f07ebb8pjdstruct filecaps;
78be47bc6jhbstruct kaiocb;
798f08266jhbstruct kinfo_file;
80b9e7819phkstruct ucred;
81b9e7819phk
8253224f0kib#define	FOF_OFFSET	0x01	/* Use the offset in uio argument */
8353224f0kib#define	FOF_NOLOCK	0x02	/* Do not take FOFFSET_LOCK */
8453224f0kib#define	FOF_NEXTOFF	0x04	/* Also update f_nextoff */
8553224f0kib#define	FOF_NOUPDATE	0x10	/* Do not update f_offset */
8653224f0kiboff_t foffset_lock(struct file *fp, int flags);
8753224f0kibvoid foffset_lock_uio(struct file *fp, struct uio *uio, int flags);
8853224f0kibvoid foffset_unlock(struct file *fp, off_t val, int flags);
8953224f0kibvoid foffset_unlock_uio(struct file *fp, struct uio *uio, int flags);
9053224f0kib
9153224f0kibstatic inline off_t
9253224f0kibfoffset_get(struct file *fp)
9353224f0kib{
9453224f0kib
9553224f0kib	return (foffset_lock(fp, FOF_NOLOCK));
9653224f0kib}
9753224f0kib
98b9e7819phktypedef int fo_rdwr_t(struct file *fp, struct uio *uio,
99b9e7819phk		    struct ucred *active_cred, int flags,
100b9e7819phk		    struct thread *td);
101f8a246bjhbtypedef	int fo_truncate_t(struct file *fp, off_t length,
102f8a246bjhb		    struct ucred *active_cred, struct thread *td);
103b9e7819phktypedef	int fo_ioctl_t(struct file *fp, u_long com, void *data,
104b9e7819phk		    struct ucred *active_cred, struct thread *td);
105b9e7819phktypedef	int fo_poll_t(struct file *fp, int events,
106b9e7819phk		    struct ucred *active_cred, struct thread *td);
107b9e7819phktypedef	int fo_kqfilter_t(struct file *fp, struct knote *kn);
108b9e7819phktypedef	int fo_stat_t(struct file *fp, struct stat *sb,
109b9e7819phk		    struct ucred *active_cred, struct thread *td);
110b9e7819phktypedef	int fo_close_t(struct file *fp, struct thread *td);
111011f420kibtypedef	int fo_chmod_t(struct file *fp, mode_t mode,
112011f420kib		    struct ucred *active_cred, struct thread *td);
113011f420kibtypedef	int fo_chown_t(struct file *fp, uid_t uid, gid_t gid,
114011f420kib		    struct ucred *active_cred, struct thread *td);
115722a1a5glebiustypedef int fo_sendfile_t(struct file *fp, int sockfd, struct uio *hdr_uio,
116722a1a5glebius		    struct uio *trl_uio, off_t offset, size_t nbytes,
117e05176aglebius		    off_t *sent, int flags, struct thread *td);
1186a459ebkibtypedef int fo_seek_t(struct file *fp, off_t offset, int whence,
1196a459ebkib		    struct thread *td);
1208f08266jhbtypedef int fo_fill_kinfo_t(struct file *fp, struct kinfo_file *kif,
1218f08266jhb		    struct filedesc *fdp);
122bba1e1ejhbtypedef int fo_mmap_t(struct file *fp, vm_map_t map, vm_offset_t *addr,
123bba1e1ejhb		    vm_size_t size, vm_prot_t prot, vm_prot_t cap_maxprot,
124bba1e1ejhb		    int flags, vm_ooffset_t foff, struct thread *td);
125be47bc6jhbtypedef int fo_aio_queue_t(struct file *fp, struct kaiocb *job);
12613d4dfekevanstypedef int fo_add_seals_t(struct file *fp, int flags);
12713d4dfekevanstypedef int fo_get_seals_t(struct file *fp, int *flags);
12889798a7kevanstypedef int fo_fallocate_t(struct file *fp, off_t offset, off_t len,
12989798a7kevans		    struct thread *td);
13029fb7c2alfredtypedef	int fo_flags_t;
131b9e7819phk
132b9e7819phkstruct fileops {
133b9e7819phk	fo_rdwr_t	*fo_read;
134b9e7819phk	fo_rdwr_t	*fo_write;
135f8a246bjhb	fo_truncate_t	*fo_truncate;
136b9e7819phk	fo_ioctl_t	*fo_ioctl;
137b9e7819phk	fo_poll_t	*fo_poll;
138b9e7819phk	fo_kqfilter_t	*fo_kqfilter;
139b9e7819phk	fo_stat_t	*fo_stat;
140b9e7819phk	fo_close_t	*fo_close;
141011f420kib	fo_chmod_t	*fo_chmod;
142011f420kib	fo_chown_t	*fo_chown;
143722a1a5glebius	fo_sendfile_t	*fo_sendfile;
1446a459ebkib	fo_seek_t	*fo_seek;
1458f08266jhb	fo_fill_kinfo_t	*fo_fill_kinfo;
146bba1e1ejhb	fo_mmap_t	*fo_mmap;
147be47bc6jhb	fo_aio_queue_t	*fo_aio_queue;
14813d4dfekevans	fo_add_seals_t	*fo_add_seals;
14913d4dfekevans	fo_get_seals_t	*fo_get_seals;
15089798a7kevans	fo_fallocate_t	*fo_fallocate;
15129fb7c2alfred	fo_flags_t	fo_flags;	/* DFLAG_* below */
152b9e7819phk};
153b9e7819phk
15429fb7c2alfred#define DFLAG_PASSABLE	0x01	/* may be passed via unix sockets. */
155a81d7fdphk#define DFLAG_SEEKABLE	0x02	/* seekable / nonsequential */
156268a4c4pjd#endif /* _KERNEL */
15729fb7c2alfred
158268a4c4pjd#if defined(_KERNEL) || defined(_WANT_FILE)
1598fb65cergrimes/*
1608fb65cergrimes * Kernel descriptor table.
1618fb65cergrimes * One entry for each open kernel vnode and socket.
162844237balfred *
163844237balfred * Below is the list of locks that protects members in struct file.
164844237balfred *
165c5c0a26mjg * (a) f_vnode lock required (shared allows both reads and writes)
166ce18638jeff * (f) protected with mtx_lock(mtx_pool_find(fp))
1675971791kib * (d) cdevpriv_mtx
168844237balfred * none	not locked
1698fb65cergrimes */
170ddf9ef1dillon
17178c0751jhbstruct fadvise_info {
17278c0751jhb	int		fa_advice;	/* (f) FADV_* type. */
17378c0751jhb	off_t		fa_start;	/* (f) Region start. */
17478c0751jhb	off_t		fa_end;		/* (f) Region end. */
17578c0751jhb};
17678c0751jhb
1778fb65cergrimesstruct file {
178ce18638jeff	void		*f_data;	/* file descriptor specific data */
179ce18638jeff	struct fileops	*f_ops;		/* File operations */
180ce18638jeff	struct ucred	*f_cred;	/* associated credentials. */
181ce18638jeff	struct vnode 	*f_vnode;	/* NULL or applicable vnode */
182ce18638jeff	short		f_type;		/* descriptor type */
183b3e5e62obrien	short		f_vnread_flags; /* (f) Sleep lock for f_offset */
184ce18638jeff	volatile u_int	f_flag;		/* see fcntl.h */
1854d240aaattilio	volatile u_int 	f_count;	/* reference count */
186ce18638jeff	/*
187ce18638jeff	 *  DTYPE_VNODE specific fields.
188ce18638jeff	 */
189927d2d4asomers	union {
190927d2d4asomers		int16_t	f_seqcount;	/* (a) Count of sequential accesses. */
191927d2d4asomers		int	f_pipegen;
192927d2d4asomers	};
193ce18638jeff	off_t		f_nextoff;	/* next expected read/write offset. */
19478c0751jhb	union {
19578c0751jhb		struct cdev_privdata *fvn_cdevpriv;
19678c0751jhb					/* (d) Private data for the cdev. */
19778c0751jhb		struct fadvise_info *fvn_advice;
19878c0751jhb	} f_vnun;
199ce18638jeff	/*
200ce18638jeff	 *  DFLAG_SEEKABLE specific fields
201ce18638jeff	 */
202ce18638jeff	off_t		f_offset;
203ce18638jeff	/*
204ce18638jeff	 * Mandatory Access control information.
205ce18638jeff	 */
206ce18638jeff	void		*f_label;	/* Place-holder for MAC label. */
2078fb65cergrimes};
2088fb65cergrimes
20978c0751jhb#define	f_cdevpriv	f_vnun.fvn_cdevpriv
21078c0751jhb#define	f_advice	f_vnun.fvn_advice
21178c0751jhb
212ce18638jeff#define	FOFFSET_LOCKED       0x1
213c6bad3bkib#define	FOFFSET_LOCK_WAITING 0x2
214ce18638jeff
215268a4c4pjd#endif /* _KERNEL || _WANT_FILE */
21643aa4c7des
21743aa4c7des/*
21843aa4c7des * Userland version of struct file, for sysctl
21943aa4c7des */
22043aa4c7desstruct xfile {
2216615ed4brooks	ksize_t	xf_size;	/* size of struct xfile */
22243aa4c7des	pid_t	xf_pid;		/* owning process */
22343aa4c7des	uid_t	xf_uid;		/* effective uid of owning process */
22443aa4c7des	int	xf_fd;		/* descriptor number */
2256615ed4brooks	int	_xf_int_pad1;
2266615ed4brooks	kvaddr_t xf_file;	/* address of struct file */
22743aa4c7des	short	xf_type;	/* descriptor type */
2286615ed4brooks	short	_xf_short_pad1;
22943aa4c7des	int	xf_count;	/* reference count */
23043aa4c7des	int	xf_msgcount;	/* references from message queue */
2316615ed4brooks	int	_xf_int_pad2;
23243aa4c7des	off_t	xf_offset;	/* file offset */
2336615ed4brooks	kvaddr_t xf_data;	/* file descriptor specific data */
2346615ed4brooks	kvaddr_t xf_vnode;	/* vnode pointer */
23543aa4c7des	u_int	xf_flag;	/* flags (see fcntl.h) */
2366615ed4brooks	int	_xf_int_pad3;
2376615ed4brooks	int64_t	_xf_int64_pad[6];
23843aa4c7des};
23943aa4c7des
24043aa4c7des#ifdef _KERNEL
24143aa4c7des
242289f11abdeextern struct fileops vnops;
243c03366agreenextern struct fileops badfileops;
24422ca3b5phkextern struct fileops socketops;
2458fb65cergrimesextern int maxfiles;		/* kernel limit on number of open files */
246a5eaebeguidoextern int maxfilesperproc;	/* per process limit on number of open files */
2478fb65cergrimes
248029a6f5pjdint fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp);
249029a6f5pjdint fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp,
25073ba42akevans    vm_prot_t *maxprotp, struct file **fpp);
251029a6f5pjdint fget_read(struct thread *td, int fd, cap_rights_t *rightsp,
2524af919brwatson    struct file **fpp);
253029a6f5pjdint fget_write(struct thread *td, int fd, cap_rights_t *rightsp,
2544af919brwatson    struct file **fpp);
2550a219bamjgint fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp,
2560a219bamjg    int needfcntl, struct file **fpp);
257ce18638jeffint _fdrop(struct file *fp, struct thread *td);
258844237balfred
2594cd91e9jhbfo_rdwr_t	invfo_rdwr;
2604cd91e9jhbfo_truncate_t	invfo_truncate;
2614cd91e9jhbfo_ioctl_t	invfo_ioctl;
2624cd91e9jhbfo_poll_t	invfo_poll;
2634cd91e9jhbfo_kqfilter_t	invfo_kqfilter;
264011f420kibfo_chmod_t	invfo_chmod;
265011f420kibfo_chown_t	invfo_chown;
266722a1a5glebiusfo_sendfile_t	invfo_sendfile;
267011f420kib
268408a640kibfo_sendfile_t	vn_sendfile;
2696a459ebkibfo_seek_t	vn_seek;
2708f08266jhbfo_fill_kinfo_t	vn_fill_kinfo;
2718f08266jhbint vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif);
272408a640kib
273ce18638jeffvoid finit(struct file *, u_int, short, void *, struct fileops *);
274029a6f5pjdint fgetvp(struct thread *td, int fd, cap_rights_t *rightsp,
2751e0d3famjg    struct vnode **vpp);
276029a6f5pjdint fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp,
277029a6f5pjd    struct vnode **vpp);
278029a6f5pjdint fgetvp_rights(struct thread *td, int fd, cap_rights_t *needrightsp,
279f07ebb8pjd    struct filecaps *havecaps, struct vnode **vpp);
280029a6f5pjdint fgetvp_read(struct thread *td, int fd, cap_rights_t *rightsp,
2814af919brwatson    struct vnode **vpp);
282029a6f5pjdint fgetvp_write(struct thread *td, int fd, cap_rights_t *rightsp,
2834af919brwatson    struct vnode **vpp);
2844af919brwatson
2854c502dajkimstatic __inline int
2864c502dajkim_fnoop(void)
2874c502dajkim{
2884c502dajkim
2894c502dajkim	return (0);
2904c502dajkim}
2914c502dajkim
2927d29da5kibstatic __inline __result_use_check bool
2937d29da5kibfhold(struct file *fp)
2947d29da5kib{
2957d29da5kib	return (refcount_acquire_checked(&fp->f_count));
2967d29da5kib}
2977d29da5kib
298ce18638jeff#define	fdrop(fp, td)							\
2994c502dajkim	(refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : _fnoop())
300140cb4fgreen
30122ca3b5phkstatic __inline fo_rdwr_t	fo_read;
30222ca3b5phkstatic __inline fo_rdwr_t	fo_write;
303f8a246bjhbstatic __inline fo_truncate_t	fo_truncate;
30422ca3b5phkstatic __inline fo_ioctl_t	fo_ioctl;
30522ca3b5phkstatic __inline fo_poll_t	fo_poll;
30622ca3b5phkstatic __inline fo_kqfilter_t	fo_kqfilter;
30722ca3b5phkstatic __inline fo_stat_t	fo_stat;
30822ca3b5phkstatic __inline fo_close_t	fo_close;
309011f420kibstatic __inline fo_chmod_t	fo_chmod;
310011f420kibstatic __inline fo_chown_t	fo_chown;
311722a1a5glebiusstatic __inline fo_sendfile_t	fo_sendfile;
312140cb4fgreen
313140cb4fgreenstatic __inline int
314ce94206edfo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
315ce94206ed    int flags, struct thread *td)
316140cb4fgreen{
317140cb4fgreen
31844404e4rwatson	return ((*fp->f_ops->fo_read)(fp, uio, active_cred, flags, td));
319140cb4fgreen}
320140cb4fgreen
321140cb4fgreenstatic __inline int
322ce94206edfo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
323ce94206ed    int flags, struct thread *td)
324140cb4fgreen{
32522846f6alfred
32644404e4rwatson	return ((*fp->f_ops->fo_write)(fp, uio, active_cred, flags, td));
327140cb4fgreen}
328140cb4fgreen
329140cb4fgreenstatic __inline int
330ce94206edfo_truncate(struct file *fp, off_t length, struct ucred *active_cred,
331ce94206ed    struct thread *td)
332f8a246bjhb{
333f8a246bjhb
334f8a246bjhb	return ((*fp->f_ops->fo_truncate)(fp, length, active_cred, td));
335f8a246bjhb}
336f8a246bjhb
337f8a246bjhbstatic __inline int
338ce94206edfo_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
339ce94206ed    struct thread *td)
340140cb4fgreen{
34122846f6alfred
3423246fbfrwatson	return ((*fp->f_ops->fo_ioctl)(fp, com, data, active_cred, td));
343140cb4fgreen}
344140cb4fgreen
345140cb4fgreenstatic __inline int
346ce94206edfo_poll(struct file *fp, int events, struct ucred *active_cred,
347ce94206ed    struct thread *td)
348140cb4fgreen{
34922846f6alfred
3502b82cd2rwatson	return ((*fp->f_ops->fo_poll)(fp, events, active_cred, td));
351140cb4fgreen}
352140cb4fgreen
353140cb4fgreenstatic __inline int
354ce94206edfo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
355ce94206ed    struct thread *td)
356f004a3apeter{
35722846f6alfred
3582b82cd2rwatson	return ((*fp->f_ops->fo_stat)(fp, sb, active_cred, td));
359f004a3apeter}
360f004a3apeter
361f004a3apeterstatic __inline int
362ce94206edfo_close(struct file *fp, struct thread *td)
363140cb4fgreen{
364140cb4fgreen
3655596676julian	return ((*fp->f_ops->fo_close)(fp, td));
366140cb4fgreen}
367140cb4fgreen
36811781a7jlemonstatic __inline int
369ce94206edfo_kqfilter(struct file *fp, struct knote *kn)
37011781a7jlemon{
37111781a7jlemon
37211781a7jlemon	return ((*fp->f_ops->fo_kqfilter)(fp, kn));
37311781a7jlemon}
37411781a7jlemon
375011f420kibstatic __inline int
376011f420kibfo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred,
377011f420kib    struct thread *td)
378011f420kib{
379011f420kib
380011f420kib	return ((*fp->f_ops->fo_chmod)(fp, mode, active_cred, td));
381011f420kib}
382011f420kib
383011f420kibstatic __inline int
384011f420kibfo_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,
385011f420kib    struct thread *td)
386011f420kib{
387011f420kib
388011f420kib	return ((*fp->f_ops->fo_chown)(fp, uid, gid, active_cred, td));
389011f420kib}
390011f420kib
391722a1a5glebiusstatic __inline int
392722a1a5glebiusfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
393722a1a5glebius    struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
394e05176aglebius    struct thread *td)
395722a1a5glebius{
396722a1a5glebius
397722a1a5glebius	return ((*fp->f_ops->fo_sendfile)(fp, sockfd, hdr_uio, trl_uio, offset,
398e05176aglebius	    nbytes, sent, flags, td));
399722a1a5glebius}
400722a1a5glebius
4016a459ebkibstatic __inline int
4026a459ebkibfo_seek(struct file *fp, off_t offset, int whence, struct thread *td)
4036a459ebkib{
4046a459ebkib
4056a459ebkib	return ((*fp->f_ops->fo_seek)(fp, offset, whence, td));
4066a459ebkib}
4076a459ebkib
4088f08266jhbstatic __inline int
4098f08266jhbfo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
4108f08266jhb{
4118f08266jhb
4128f08266jhb	return ((*fp->f_ops->fo_fill_kinfo)(fp, kif, fdp));
4138f08266jhb}
4148f08266jhb
415bba1e1ejhbstatic __inline int
416bba1e1ejhbfo_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size,
417bba1e1ejhb    vm_prot_t prot, vm_prot_t cap_maxprot, int flags, vm_ooffset_t foff,
418bba1e1ejhb    struct thread *td)
419bba1e1ejhb{
420bba1e1ejhb
421bba1e1ejhb	if (fp->f_ops->fo_mmap == NULL)
422bba1e1ejhb		return (ENODEV);
423bba1e1ejhb	return ((*fp->f_ops->fo_mmap)(fp, map, addr, size, prot, cap_maxprot,
424bba1e1ejhb	    flags, foff, td));
425bba1e1ejhb}
426bba1e1ejhb
427be47bc6jhbstatic __inline int
428be47bc6jhbfo_aio_queue(struct file *fp, struct kaiocb *job)
429be47bc6jhb{
430be47bc6jhb
431be47bc6jhb	return ((*fp->f_ops->fo_aio_queue)(fp, job));
432be47bc6jhb}
433be47bc6jhb
43413d4dfekevansstatic __inline int
43513d4dfekevansfo_add_seals(struct file *fp, int seals)
43613d4dfekevans{
43713d4dfekevans
43813d4dfekevans	if (fp->f_ops->fo_add_seals == NULL)
43913d4dfekevans		return (EINVAL);
44013d4dfekevans	return ((*fp->f_ops->fo_add_seals)(fp, seals));
44113d4dfekevans}
44213d4dfekevans
44313d4dfekevansstatic __inline int
44413d4dfekevansfo_get_seals(struct file *fp, int *seals)
44513d4dfekevans{
44613d4dfekevans
44713d4dfekevans	if (fp->f_ops->fo_get_seals == NULL)
44813d4dfekevans		return (EINVAL);
44913d4dfekevans	return ((*fp->f_ops->fo_get_seals)(fp, seals));
45013d4dfekevans}
45113d4dfekevans
45289798a7kevansstatic __inline int
45389798a7kevansfo_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td)
45489798a7kevans{
45589798a7kevans
45689798a7kevans	if (fp->f_ops->fo_fallocate == NULL)
45789798a7kevans		return (ENODEV);
45889798a7kevans	return ((*fp->f_ops->fo_fallocate)(fp, offset, len, td));
45989798a7kevans}
46089798a7kevans
46115b9bcbpeter#endif /* _KERNEL */
4621f5dfa1paul
46351ff523bde#endif /* !SYS_FILE_H */
464