geom_slice.c (131408) | geom_slice.c (131568) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 20 unchanged lines hidden (view full) --- 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 20 unchanged lines hidden (view full) --- 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/geom/geom_slice.c 131408 2004-07-01 12:42:13Z pjd $"); | 37__FBSDID("$FreeBSD: head/sys/geom/geom_slice.c 131568 2004-07-04 13:44:48Z phk $"); |
38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> 42#include <sys/malloc.h> 43#include <sys/bio.h> 44#include <sys/sysctl.h> 45#include <sys/proc.h> --- 48 unchanged lines hidden (view full) --- 94 struct g_provider *pp2; 95 struct g_slicer *gsp; 96 struct g_slice *gsl, *gsl2; 97 98 gp = pp->geom; 99 cp = LIST_FIRST(&gp->consumer); 100 KASSERT (cp != NULL, ("g_slice_access but no consumer")); 101 gsp = gp->softc; | 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> 42#include <sys/malloc.h> 43#include <sys/bio.h> 44#include <sys/sysctl.h> 45#include <sys/proc.h> --- 48 unchanged lines hidden (view full) --- 94 struct g_provider *pp2; 95 struct g_slicer *gsp; 96 struct g_slice *gsl, *gsl2; 97 98 gp = pp->geom; 99 cp = LIST_FIRST(&gp->consumer); 100 KASSERT (cp != NULL, ("g_slice_access but no consumer")); 101 gsp = gp->softc; |
102 gsl = &gsp->slices[pp->index]; 103 for (u = 0; u < gsp->nslice; u++) { 104 gsl2 = &gsp->slices[u]; 105 if (gsl2->length == 0) 106 continue; 107 if (u == pp->index) 108 continue; 109 if (gsl->offset + gsl->length <= gsl2->offset) 110 continue; 111 if (gsl2->offset + gsl2->length <= gsl->offset) 112 continue; 113 /* overlap */ 114 pp2 = gsl2->provider; 115 if ((pp->acw + dw) > 0 && pp2->ace > 0) 116 return (EPERM); 117 if ((pp->ace + de) > 0 && pp2->acw > 0) 118 return (EPERM); | 102 if (dr > 0 || dw > 0 || de > 0) { 103 gsl = &gsp->slices[pp->index]; 104 for (u = 0; u < gsp->nslice; u++) { 105 gsl2 = &gsp->slices[u]; 106 if (gsl2->length == 0) 107 continue; 108 if (u == pp->index) 109 continue; 110 if (gsl->offset + gsl->length <= gsl2->offset) 111 continue; 112 if (gsl2->offset + gsl2->length <= gsl->offset) 113 continue; 114 /* overlap */ 115 pp2 = gsl2->provider; 116 if ((pp->acw + dw) > 0 && pp2->ace > 0) 117 return (EPERM); 118 if ((pp->ace + de) > 0 && pp2->acw > 0) 119 return (EPERM); 120 } |
119 } 120 /* On first open, grab an extra "exclusive" bit */ 121 if (cp->acr == 0 && cp->acw == 0 && cp->ace == 0) 122 de++; 123 /* ... and let go of it on last close */ 124 if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1) 125 de--; 126 error = g_access(cp, dr, dw, de); --- 367 unchanged lines hidden --- | 121 } 122 /* On first open, grab an extra "exclusive" bit */ 123 if (cp->acr == 0 && cp->acw == 0 && cp->ace == 0) 124 de++; 125 /* ... and let go of it on last close */ 126 if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1) 127 de--; 128 error = g_access(cp, dr, dw, de); --- 367 unchanged lines hidden --- |