Fri Jan 21 12:24:25 2011 UTC ()
fix kobj_open_file_vnode()

patch from haad


(pooka)
diff -r1.1 -r1.2 src/external/cddl/osnet/sys/kern/kobj.c
diff -r1.7 -r1.8 src/external/cddl/osnet/sys/sys/vnode.h

cvs diff -r1.1 -r1.2 src/external/cddl/osnet/sys/kern/kobj.c (expand / switch to unified diff)

--- src/external/cddl/osnet/sys/kern/kobj.c 2009/08/07 20:57:57 1.1
+++ src/external/cddl/osnet/sys/kern/kobj.c 2011/01/21 12:24:24 1.2
@@ -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
88void * 88void *
89kobj_zalloc(size_t size, int flag) 89kobj_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
95static void * 95static void *
96kobj_open_file_vnode(const char *file) 96kobj_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
106struct _buf * 106struct _buf *
107kobj_open_file(const char *file) 107kobj_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);

cvs diff -r1.7 -r1.8 src/external/cddl/osnet/sys/sys/vnode.h (expand / switch to unified diff)

--- src/external/cddl/osnet/sys/sys/vnode.h 2010/12/14 01:21:02 1.7
+++ src/external/cddl/osnet/sys/sys/vnode.h 2011/01/21 12:24:24 1.8
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1 1
2/* $NetBSD: vnode.h,v 1.7 2010/12/14 01:21:02 haad Exp $ */ 2/* $NetBSD: vnode.h,v 1.8 2011/01/21 12:24:24 pooka Exp $ */
3 3
4/* 4/*
5 * CDDL HEADER START 5 * CDDL HEADER START
6 * 6 *
7 * The contents of this file are subject to the terms of the 7 * The contents of this file are subject to the terms of the
8 * Common Development and Distribution License (the "License"). 8 * Common Development and Distribution License (the "License").
9 * You may not use this file except in compliance with the License. 9 * You may not use this file except in compliance with the License.
10 * 10 *
11 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
12 * or http://www.opensolaris.org/os/licensing. 12 * or http://www.opensolaris.org/os/licensing.
13 * See the License for the specific language governing permissions 13 * See the License for the specific language governing permissions
14 * and limitations under the License. 14 * and limitations under the License.
15 * 15 *
@@ -526,27 +526,27 @@ vattr_init_mask(vattr_t *vap) @@ -526,27 +526,27 @@ vattr_init_mask(vattr_t *vap)
526#define FOFFMAX 0x00 526#define FOFFMAX 0x00
527 527
528enum create { CRCREAT }; 528enum create { CRCREAT };
529 529
530static __inline int 530static __inline int
531zfs_vn_open(const char *pnamep, enum uio_seg seg, int filemode, int createmode, 531zfs_vn_open(const char *pnamep, enum uio_seg seg, int filemode, int createmode,
532 vnode_t **vpp, enum create crwhy, mode_t umask) 532 vnode_t **vpp, enum create crwhy, mode_t umask)
533{ 533{
534 struct pathbuf *pb; 534 struct pathbuf *pb;
535 struct nameidata nd; 535 struct nameidata nd;
536 int error; 536 int error;
537 537
538 ASSERT(seg == UIO_SYSSPACE); 538 ASSERT(seg == UIO_SYSSPACE);
539 ASSERT(filemode == (FWRITE | FCREAT | FTRUNC | FOFFMAX)); 539 ASSERT((filemode & (FWRITE | FCREAT | FTRUNC | FOFFMAX)) != 0);
540 ASSERT(crwhy == CRCREAT); 540 ASSERT(crwhy == CRCREAT);
541 ASSERT(umask == 0); 541 ASSERT(umask == 0);
542 542
543 pb = pathbuf_create(pnamep); 543 pb = pathbuf_create(pnamep);
544 if (pb == NULL) { 544 if (pb == NULL) {
545 return ENOMEM; 545 return ENOMEM;
546 } 546 }
547 NDINIT(&nd, LOOKUP, NOFOLLOW, pb); 547 NDINIT(&nd, LOOKUP, NOFOLLOW, pb);
548 error = vn_open(&nd, filemode, createmode); 548 error = vn_open(&nd, filemode, createmode);
549 if (error == 0) { 549 if (error == 0) {
550 VOP_UNLOCK(nd.ni_vp); 550 VOP_UNLOCK(nd.ni_vp);
551 *vpp = nd.ni_vp; 551 *vpp = nd.ni_vp;
552 } 552 }