| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kobj.c,v 1.1 2009/08/07 20:57:57 haad Exp $ */ | | 1 | /* $NetBSD: kobj.c,v 1.2 2011/01/21 12:24:24 pooka Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2009 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 Andrew Doran. | | 8 | * by Andrew Doran. |
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. |
| @@ -47,27 +47,27 @@ | | | @@ -47,27 +47,27 @@ |
47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE | | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
55 | * SUCH DAMAGE. | | 55 | * SUCH DAMAGE. |
56 | */ | | 56 | */ |
57 | | | 57 | |
58 | #include <sys/cdefs.h> | | 58 | #include <sys/cdefs.h> |
59 | /* __FBSDID("$FreeBSD: src/sys/compat/opensolaris/kern/opensolaris_kobj.c,v 1.4 2007/05/31 11:51:49 kib Exp $"); */ | | 59 | /* __FBSDID("$FreeBSD: src/sys/compat/opensolaris/kern/opensolaris_kobj.c,v 1.4 2007/05/31 11:51:49 kib Exp $"); */ |
60 | __KERNEL_RCSID(0, "$NetBSD: kobj.c,v 1.1 2009/08/07 20:57:57 haad Exp $"); | | 60 | __KERNEL_RCSID(0, "$NetBSD: kobj.c,v 1.2 2011/01/21 12:24:24 pooka Exp $"); |
61 | | | 61 | |
62 | #include <sys/types.h> | | 62 | #include <sys/types.h> |
63 | #include <sys/systm.h> | | 63 | #include <sys/systm.h> |
64 | #include <sys/kernel.h> | | 64 | #include <sys/kernel.h> |
65 | #include <sys/systm.h> | | 65 | #include <sys/systm.h> |
66 | #include <sys/kthread.h> | | 66 | #include <sys/kthread.h> |
67 | #include <sys/namei.h> | | 67 | #include <sys/namei.h> |
68 | #include <sys/proc.h> | | 68 | #include <sys/proc.h> |
69 | #include <sys/filedesc.h> | | 69 | #include <sys/filedesc.h> |
70 | #include <sys/fcntl.h> | | 70 | #include <sys/fcntl.h> |
71 | #include <sys/kobj.h> | | 71 | #include <sys/kobj.h> |
72 | #include <sys/namei.h> | | 72 | #include <sys/namei.h> |
73 | | | 73 | |
| @@ -87,27 +87,27 @@ kobj_alloc(size_t size, int flag) | | | @@ -87,27 +87,27 @@ kobj_alloc(size_t size, int flag) |
87 | | | 87 | |
88 | void * | | 88 | void * |
89 | kobj_zalloc(size_t size, int flag) | | 89 | kobj_zalloc(size_t size, int flag) |
90 | { | | 90 | { |
91 | | | 91 | |
92 | return (kmem_zalloc(size, (flag & KM_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)); | | 92 | return (kmem_zalloc(size, (flag & KM_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)); |
93 | } | | 93 | } |
94 | | | 94 | |
95 | static void * | | 95 | static void * |
96 | kobj_open_file_vnode(const char *file) | | 96 | kobj_open_file_vnode(const char *file) |
97 | { | | 97 | { |
98 | vnode_t *vp; | | 98 | vnode_t *vp; |
99 | | | 99 | |
100 | if (vn_open(file, UIO_SYSSPACE, 0, 0, &vp, CRCREAT, 0) != 0) { | | 100 | if (vn_open(file, UIO_SYSSPACE, FCREAT, 0, &vp, CRCREAT, 0) != 0) { |
101 | return NULL; | | 101 | return NULL; |
102 | } | | 102 | } |
103 | return vp; | | 103 | return vp; |
104 | } | | 104 | } |
105 | | | 105 | |
106 | struct _buf * | | 106 | struct _buf * |
107 | kobj_open_file(const char *file) | | 107 | kobj_open_file(const char *file) |
108 | { | | 108 | { |
109 | struct _buf *out; | | 109 | struct _buf *out; |
110 | | | 110 | |
111 | out = kmem_alloc(sizeof(*out), KM_SLEEP); | | 111 | out = kmem_alloc(sizeof(*out), KM_SLEEP); |
112 | out->mounted = 1; | | 112 | out->mounted = 1; |
113 | out->ptr = kobj_open_file_vnode(file); | | 113 | out->ptr = kobj_open_file_vnode(file); |