Deleted Added
sdiff udiff text old ( 93778 ) new ( 94287 )
full compact
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_slice.c 93778 2002-04-04 09:58:20Z phk $
36 */
37
38
39#include <sys/param.h>
40#ifndef _KERNEL
41#include <stdio.h>
42#include <unistd.h>
43#include <stdlib.h>

--- 80 unchanged lines hidden (view full) ---

124{
125 struct bio *bp2;
126 struct g_provider *pp;
127 struct g_geom *gp;
128 struct g_consumer *cp;
129 struct g_slicer *gsp;
130 struct g_slice *gsl;
131 int index;
132
133 pp = bp->bio_to;
134 gp = pp->geom;
135 gsp = gp->softc;
136 cp = LIST_FIRST(&gp->consumer);
137 index = pp->index;
138 switch(bp->bio_cmd) {
139 case BIO_READ:
140 case BIO_WRITE:
141 case BIO_DELETE:
142 gsl = &gsp->slices[index];
143 if (bp->bio_offset > gsl->length) {
144 bp->bio_error = EINVAL; /* XXX: EWHAT ? */
145 g_io_deliver(bp);
146 return;
147 }
148 bp2 = g_clone_bio(bp);
149 if (bp2->bio_offset + bp2->bio_length > gsl->length)
150 bp2->bio_length = gsl->length - bp2->bio_offset;
151 bp2->bio_done = g_std_done;
152 bp2->bio_offset += gsl->offset;
153 g_io_request(bp2, cp);
154 return;
155 case BIO_GETATTR:
156 case BIO_SETATTR:
157 if (g_haveattr_off_t(bp, "GEOM::mediasize",
158 gsp->slices[index].length))
159 return;
160 if (gsp->start(bp))
161 return;
162 bp2 = g_clone_bio(bp);
163 bp2->bio_done = g_std_done;
164 g_io_request(bp2, cp);
165 break;
166 default:
167 bp->bio_error = EOPNOTSUPP;
168 g_io_deliver(bp);
169 return;
170 }
171}
172
173void
174g_slice_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp)
175{
176 struct g_mbr_softc *mp;
177 struct g_slicer *gsp;
178
179 gsp = gp->softc;
180 mp = gsp->softc;
181 if (pp != NULL) {
182 sbuf_printf(sb, "%s<index>%u</index>\n", indent, pp->index);
183 sbuf_printf(sb, "%s<length>%llu</length>\n",
184 indent, (unsigned long long)gsp->slices[pp->index].length);
185 sbuf_printf(sb, "%s<seclength>%llu</seclength>\n", indent,
186 (unsigned long long)gsp->slices[pp->index].length / 512);
187 sbuf_printf(sb, "%s<offset>%llu</offset>\n", indent,
188 (unsigned long long)gsp->slices[pp->index].offset);

--- 30 unchanged lines hidden (view full) ---

219
220struct g_geom *
221g_slice_new(struct g_class *mp, int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start)
222{
223 struct g_geom *gp;
224 struct g_slicer *gsp;
225 struct g_consumer *cp;
226 void **vp;
227 int error;
228
229 g_topology_assert();
230 vp = (void **)extrap;
231 gp = g_new_geomf(mp, "%s", pp->name);
232 gsp = g_slice_init(slices, extra);
233 gsp->start = start;
234 gp->access = g_slice_access;
235 gp->orphan = g_slice_orphan;

--- 7 unchanged lines hidden (view full) ---

243 if (error) {
244 g_dettach(cp);
245 g_destroy_consumer(cp);
246 g_free(gsp->slices);
247 g_free(gp->softc);
248 g_destroy_geom(gp);
249 return (NULL);
250 }
251 *vp = gsp->softc;
252 *cpp = cp;
253 return (gp);
254}
255
256static void
257g_slice_orphan(struct g_consumer *cp)
258{

--- 18 unchanged lines hidden ---