| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vnd.c,v 1.203 2009/07/07 19:51:22 dyoung Exp $ */ | | 1 | /* $NetBSD: vnd.c,v 1.204 2009/08/07 00:08:07 dyoung Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996, 1997, 1998, 2008 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 Jason R. Thorpe. | | 8 | * by Jason R. Thorpe. |
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. |
| @@ -120,27 +120,27 @@ | | | @@ -120,27 +120,27 @@ |
120 | * systems where the block-level operations are not implemented for | | 120 | * systems where the block-level operations are not implemented for |
121 | * whatever reason. | | 121 | * whatever reason. |
122 | * | | 122 | * |
123 | * NOTE 2: There is a security issue involved with this driver. | | 123 | * NOTE 2: There is a security issue involved with this driver. |
124 | * Once mounted all access to the contents of the "mapped" file via | | 124 | * Once mounted all access to the contents of the "mapped" file via |
125 | * the special file is controlled by the permissions on the special | | 125 | * the special file is controlled by the permissions on the special |
126 | * file, the protection of the mapped file is ignored (effectively, | | 126 | * file, the protection of the mapped file is ignored (effectively, |
127 | * by using root credentials in all transactions). | | 127 | * by using root credentials in all transactions). |
128 | * | | 128 | * |
129 | * NOTE 3: Doesn't interact with leases, should it? | | 129 | * NOTE 3: Doesn't interact with leases, should it? |
130 | */ | | 130 | */ |
131 | | | 131 | |
132 | #include <sys/cdefs.h> | | 132 | #include <sys/cdefs.h> |
133 | __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.203 2009/07/07 19:51:22 dyoung Exp $"); | | 133 | __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.204 2009/08/07 00:08:07 dyoung Exp $"); |
134 | | | 134 | |
135 | #if defined(_KERNEL_OPT) | | 135 | #if defined(_KERNEL_OPT) |
136 | #include "fs_nfs.h" | | 136 | #include "fs_nfs.h" |
137 | #include "opt_vnd.h" | | 137 | #include "opt_vnd.h" |
138 | #endif | | 138 | #endif |
139 | | | 139 | |
140 | #include <sys/param.h> | | 140 | #include <sys/param.h> |
141 | #include <sys/systm.h> | | 141 | #include <sys/systm.h> |
142 | #include <sys/namei.h> | | 142 | #include <sys/namei.h> |
143 | #include <sys/proc.h> | | 143 | #include <sys/proc.h> |
144 | #include <sys/kthread.h> | | 144 | #include <sys/kthread.h> |
145 | #include <sys/errno.h> | | 145 | #include <sys/errno.h> |
146 | #include <sys/buf.h> | | 146 | #include <sys/buf.h> |
| @@ -153,26 +153,27 @@ __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.20 | | | @@ -153,26 +153,27 @@ __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.20 |
153 | #include <sys/stat.h> | | 153 | #include <sys/stat.h> |
154 | #include <sys/mount.h> | | 154 | #include <sys/mount.h> |
155 | #include <sys/vnode.h> | | 155 | #include <sys/vnode.h> |
156 | #include <sys/file.h> | | 156 | #include <sys/file.h> |
157 | #include <sys/uio.h> | | 157 | #include <sys/uio.h> |
158 | #include <sys/conf.h> | | 158 | #include <sys/conf.h> |
159 | #include <sys/kauth.h> | | 159 | #include <sys/kauth.h> |
160 | | | 160 | |
161 | #include <net/zlib.h> | | 161 | #include <net/zlib.h> |
162 | | | 162 | |
163 | #include <miscfs/genfs/genfs.h> | | 163 | #include <miscfs/genfs/genfs.h> |
164 | #include <miscfs/specfs/specdev.h> | | 164 | #include <miscfs/specfs/specdev.h> |
165 | | | 165 | |
| | | 166 | #include <dev/dkvar.h> |
166 | #include <dev/vndvar.h> | | 167 | #include <dev/vndvar.h> |
167 | | | 168 | |
168 | #include <prop/proplib.h> | | 169 | #include <prop/proplib.h> |
169 | | | 170 | |
170 | #if defined(VNDDEBUG) && !defined(DEBUG) | | 171 | #if defined(VNDDEBUG) && !defined(DEBUG) |
171 | #define DEBUG | | 172 | #define DEBUG |
172 | #endif | | 173 | #endif |
173 | | | 174 | |
174 | #ifdef DEBUG | | 175 | #ifdef DEBUG |
175 | int dovndcluster = 1; | | 176 | int dovndcluster = 1; |
176 | #define VDB_FOLLOW 0x01 | | 177 | #define VDB_FOLLOW 0x01 |
177 | #define VDB_INIT 0x02 | | 178 | #define VDB_INIT 0x02 |
178 | #define VDB_IO 0x04 | | 179 | #define VDB_IO 0x04 |
| @@ -962,29 +963,27 @@ vnd_cget(struct lwp *l, int unit, int *u | | | @@ -962,29 +963,27 @@ vnd_cget(struct lwp *l, int unit, int *u |
962 | static int | | 963 | static int |
963 | vnddoclear(struct vnd_softc *vnd, int pmask, int minor, bool force) | | 964 | vnddoclear(struct vnd_softc *vnd, int pmask, int minor, bool force) |
964 | { | | 965 | { |
965 | int error; | | 966 | int error; |
966 | | | 967 | |
967 | if ((error = vndlock(vnd)) != 0) | | 968 | if ((error = vndlock(vnd)) != 0) |
968 | return error; | | 969 | return error; |
969 | | | 970 | |
970 | /* | | 971 | /* |
971 | * Don't unconfigure if any other partitions are open | | 972 | * Don't unconfigure if any other partitions are open |
972 | * or if both the character and block flavors of this | | 973 | * or if both the character and block flavors of this |
973 | * partition are open. | | 974 | * partition are open. |
974 | */ | | 975 | */ |
975 | if (((vnd->sc_dkdev.dk_openmask & ~pmask) || | | 976 | if (DK_BUSY(vnd, pmask) && !force) { |
976 | ((vnd->sc_dkdev.dk_bopenmask & pmask) && | | | |
977 | (vnd->sc_dkdev.dk_copenmask & pmask))) && !force) { | | | |
978 | vndunlock(vnd); | | 977 | vndunlock(vnd); |
979 | return EBUSY; | | 978 | return EBUSY; |
980 | } | | 979 | } |
981 | | | 980 | |
982 | /* | | 981 | /* |
983 | * XXX vndclear() might call vndclose() implicitly; | | 982 | * XXX vndclear() might call vndclose() implicitly; |
984 | * release lock to avoid recursion | | 983 | * release lock to avoid recursion |
985 | * | | 984 | * |
986 | * Set VNF_CLEARING to prevent vndopen() from | | 985 | * Set VNF_CLEARING to prevent vndopen() from |
987 | * sneaking in after we vndunlock(). | | 986 | * sneaking in after we vndunlock(). |
988 | */ | | 987 | */ |
989 | vnd->sc_flags |= VNF_CLEARING; | | 988 | vnd->sc_flags |= VNF_CLEARING; |
990 | vndunlock(vnd); | | 989 | vndunlock(vnd); |