geom_sunlabel.c (94285) | geom_sunlabel.c (94287) |
---|---|
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 --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 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 --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD: head/sys/geom/geom_sunlabel.c 94285 2002-04-09 15:17:59Z phk $ | 35 * $FreeBSD: head/sys/geom/geom_sunlabel.c 94287 2002-04-09 15:43:32Z phk $ |
36 */ 37 38 39#include <sys/param.h> 40#ifndef _KERNEL 41#include <stdio.h> 42#include <string.h> 43#include <stdlib.h> --- 40 unchanged lines hidden (view full) --- 84} 85 86static struct g_geom * 87g_sunlabel_taste(struct g_class *mp, struct g_provider *pp, int flags) 88{ 89 struct g_geom *gp; 90 struct g_consumer *cp; 91 struct g_provider *pp2; | 36 */ 37 38 39#include <sys/param.h> 40#ifndef _KERNEL 41#include <stdio.h> 42#include <string.h> 43#include <stdlib.h> --- 40 unchanged lines hidden (view full) --- 84} 85 86static struct g_geom * 87g_sunlabel_taste(struct g_class *mp, struct g_provider *pp, int flags) 88{ 89 struct g_geom *gp; 90 struct g_consumer *cp; 91 struct g_provider *pp2; |
92 int error, i, j, npart; | 92 int error, i, npart; |
93 u_char *buf; 94 struct g_sunlabel_softc *ms; 95 u_int sectorsize, u, v, csize; 96 off_t mediasize; | 93 u_char *buf; 94 struct g_sunlabel_softc *ms; 95 u_int sectorsize, u, v, csize; 96 off_t mediasize; |
97 struct g_slicer *gsp; |
|
97 98 g_trace(G_T_TOPOLOGY, "g_sunlabel_taste(%s,%s)", mp->name, pp->name); 99 g_topology_assert(); 100 if (flags == G_TF_NORMAL && 101 !strcmp(pp->geom->class->name, SUNLABEL_CLASS_NAME)) 102 return (NULL); 103 gp = g_slice_new(mp, 8, pp, &cp, &ms, sizeof *ms, g_sunlabel_start); 104 if (gp == NULL) 105 return (NULL); | 98 99 g_trace(G_T_TOPOLOGY, "g_sunlabel_taste(%s,%s)", mp->name, pp->name); 100 g_topology_assert(); 101 if (flags == G_TF_NORMAL && 102 !strcmp(pp->geom->class->name, SUNLABEL_CLASS_NAME)) 103 return (NULL); 104 gp = g_slice_new(mp, 8, pp, &cp, &ms, sizeof *ms, g_sunlabel_start); 105 if (gp == NULL) 106 return (NULL); |
107 gsp = gp->softc; |
|
106 g_topology_unlock(); 107 gp->dumpconf = g_sunlabel_dumpconf; 108 npart = 0; 109 while (1) { /* a trick to allow us to use break */ 110 if (gp->rank != 2 && flags == G_TF_NORMAL) 111 break; | 108 g_topology_unlock(); 109 gp->dumpconf = g_sunlabel_dumpconf; 110 npart = 0; 111 while (1) { /* a trick to allow us to use break */ 112 if (gp->rank != 2 && flags == G_TF_NORMAL) 113 break; |
112 j = sizeof sectorsize; 113 error = g_io_getattr("GEOM::sectorsize", cp, &j, §orsize); | 114 error = g_getattr("GEOM::sectorsize", cp, §orsize); |
114 if (error) { 115 sectorsize = 512; 116 printf("g_sunlabel_taste: error %d Sectors are %d bytes\n", 117 error, sectorsize); 118 } | 115 if (error) { 116 sectorsize = 512; 117 printf("g_sunlabel_taste: error %d Sectors are %d bytes\n", 118 error, sectorsize); 119 } |
119 j = sizeof mediasize; 120 error = g_io_getattr("GEOM::mediasize", cp, &j, &mediasize); | 120 gsp->frontstuff = 16 * sectorsize; 121 error = g_getattr("GEOM::mediasize", cp, &mediasize); |
121 if (error) { 122 mediasize = 0; 123 printf("g_error %d Mediasize is %lld bytes\n", 124 error, (long long)mediasize); 125 } 126 buf = g_read_data(cp, 0, sectorsize, &error); 127 if (buf == NULL || error != 0) 128 break; --- 66 unchanged lines hidden --- | 122 if (error) { 123 mediasize = 0; 124 printf("g_error %d Mediasize is %lld bytes\n", 125 error, (long long)mediasize); 126 } 127 buf = g_read_data(cp, 0, sectorsize, &error); 128 if (buf == NULL || error != 0) 129 break; --- 66 unchanged lines hidden --- |