| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sysvbfs_vnops.c,v 1.48 2013/05/15 16:44:03 pooka Exp $ */ | | 1 | /* $NetBSD: sysvbfs_vnops.c,v 1.49 2013/12/24 09:56:18 hannken Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2004 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2004 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by UCHIYAMA Yasushi. | | 8 | * by UCHIYAMA Yasushi. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.48 2013/05/15 16:44:03 pooka Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.49 2013/12/24 09:56:18 hannken Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/kernel.h> | | 36 | #include <sys/kernel.h> |
37 | #include <sys/resource.h> | | 37 | #include <sys/resource.h> |
38 | #include <sys/vnode.h> | | 38 | #include <sys/vnode.h> |
39 | #include <sys/namei.h> | | 39 | #include <sys/namei.h> |
40 | #include <sys/dirent.h> | | 40 | #include <sys/dirent.h> |
41 | #include <sys/malloc.h> | | 41 | #include <sys/malloc.h> |
42 | #include <sys/lockf.h> | | 42 | #include <sys/lockf.h> |
43 | #include <sys/unistd.h> | | 43 | #include <sys/unistd.h> |
44 | #include <sys/fcntl.h> | | 44 | #include <sys/fcntl.h> |
45 | #include <sys/kauth.h> | | 45 | #include <sys/kauth.h> |
46 | #include <sys/buf.h> | | 46 | #include <sys/buf.h> |
| @@ -175,34 +175,30 @@ sysvbfs_create(void *arg) | | | @@ -175,34 +175,30 @@ sysvbfs_create(void *arg) |
175 | } | | 175 | } |
176 | | | 176 | |
177 | int | | 177 | int |
178 | sysvbfs_open(void *arg) | | 178 | sysvbfs_open(void *arg) |
179 | { | | 179 | { |
180 | struct vop_open_args /* { | | 180 | struct vop_open_args /* { |
181 | struct vnode *a_vp; | | 181 | struct vnode *a_vp; |
182 | int a_mode; | | 182 | int a_mode; |
183 | kauth_cred_t a_cred; | | 183 | kauth_cred_t a_cred; |
184 | } */ *a = arg; | | 184 | } */ *a = arg; |
185 | struct vnode *v = a->a_vp; | | 185 | struct vnode *v = a->a_vp; |
186 | struct sysvbfs_node *bnode = v->v_data; | | 186 | struct sysvbfs_node *bnode = v->v_data; |
187 | struct bfs_inode *inode = bnode->inode; | | 187 | struct bfs_inode *inode = bnode->inode; |
188 | struct bfs *bfs = bnode->bmp->bfs; | | | |
189 | struct bfs_dirent *dirent; | | | |
190 | | | 188 | |
191 | DPRINTF("%s:\n", __func__); | | 189 | DPRINTF("%s:\n", __func__); |
192 | KDASSERT(v->v_type == VREG || v->v_type == VDIR); | | 190 | KDASSERT(v->v_type == VREG || v->v_type == VDIR); |
193 | | | 191 | |
194 | if (!bfs_dirent_lookup_by_inode(bfs, inode->number, &dirent)) | | | |
195 | return ENOENT; | | | |
196 | bnode->update_atime = true; | | 192 | bnode->update_atime = true; |
197 | if ((a->a_mode & FWRITE) && !(a->a_mode & O_APPEND)) { | | 193 | if ((a->a_mode & FWRITE) && !(a->a_mode & O_APPEND)) { |
198 | bnode->size = 0; | | 194 | bnode->size = 0; |
199 | } else { | | 195 | } else { |
200 | bnode->size = bfs_file_size(inode); | | 196 | bnode->size = bfs_file_size(inode); |
201 | } | | 197 | } |
202 | bnode->data_block = inode->start_sector; | | 198 | bnode->data_block = inode->start_sector; |
203 | | | 199 | |
204 | return 0; | | 200 | return 0; |
205 | } | | 201 | } |
206 | | | 202 | |
207 | int | | 203 | int |
208 | sysvbfs_close(void *arg) | | 204 | sysvbfs_close(void *arg) |