xref: /f-stack/lib/ff_vfs_ops.c (revision a9643ea8)
1 /*
2  * Copyright (c) 2011 Kip Macy. All rights reserved.
3  * Copyright (C) 2017 THL A29 Limited, a Tencent company.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice, this
10  *   list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  *   this list of conditions and the following disclaimer in the documentation
13  *   and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * Derived in part from libplebnet's pn_vfs_ops.c.
27  */
28 
29 #include <sys/cdefs.h>
30 #include <sys/param.h>
31 #include <sys/types.h>
32 #include <sys/limits.h>
33 #include <sys/malloc.h>
34 #include <sys/namei.h>
35 #include <sys/refcount.h>
36 #include <sys/resourcevar.h>
37 #include <sys/systm.h>
38 #include <sys/proc.h>
39 #include <sys/priv.h>
40 #include <sys/time.h>
41 #include <sys/ucred.h>
42 #include <sys/vnode.h>
43 #include <sys/uio.h>
44 #include <sys/file.h>
45 #include <sys/capsicum.h>
46 
47 void
48 NDFREE(struct nameidata *ndp, const u_int flags)
49 {
50 
51 }
52 
53 int
54 vn_open(struct nameidata *ndp, int *flagp, int cmode, struct file *fp)
55 {
56     panic("vn_open not implemented");
57 
58     return (0);
59 }
60 
61 
62 int
63 vn_close(struct vnode *vp,
64         int flags, struct ucred *file_cred, struct thread *td)
65 {
66     panic("vn_close not implemented");
67 
68     return (0);
69 }
70 
71 
72 int
73 vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base,
74         int len, off_t offset, enum uio_seg segflg, int ioflg,
75         struct ucred *active_cred, struct ucred *file_cred, ssize_t *aresid,
76         struct thread *td)
77 {
78     panic("vn_rdwr not implemented");
79 
80     return (0);
81 }
82 
83 int
84 vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif)
85 {
86     panic("vn_fill_kinfo_vnode not implemented");
87 
88     return (0);
89 }
90 
91 void
92 NDINIT_ALL(struct nameidata *ndp, u_long op, u_long flags, enum uio_seg segflg,
93     const char *namep, int dirfd, struct vnode *startdir, cap_rights_t *rightsp,
94     struct thread *td)
95 {
96 
97     ndp->ni_cnd.cn_nameiop = op;
98     ndp->ni_cnd.cn_flags = flags;
99     ndp->ni_segflg = segflg;
100     ndp->ni_dirp = namep;
101     ndp->ni_dirfd = dirfd;
102     ndp->ni_startdir = startdir;
103     ndp->ni_strictrelative = 0;
104     if (rightsp != NULL)
105         ndp->ni_rightsneeded = *rightsp;
106     else
107         cap_rights_init(&ndp->ni_rightsneeded);
108     filecaps_init(&ndp->ni_filecaps);
109     ndp->ni_cnd.cn_thread = td;
110 }
111 
112