FreeBSD/Linux Kernel Cross Reference
sys/geom/geom_bsd.c
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
9 * DARPA CHATS research program.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The names of the authors may not be used to endorse or promote
20 * products derived from this software without specific prior written
21 * permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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
36 /*
37 * This is the method for dealing with BSD disklabels. It has been
38 * extensively (by my standards at least) commented, in the vain hope that
39 * it will serve as the source in future copy&paste operations.
40 */
41
42 #include <sys/cdefs.h>
43 __FBSDID("$FreeBSD: releng/8.4/sys/geom/geom_bsd.c 235502 2012-05-16 09:03:29Z avg $");
44
45 #include <sys/param.h>
46 #include <sys/endian.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
49 #include <sys/fcntl.h>
50 #include <sys/conf.h>
51 #include <sys/bio.h>
52 #include <sys/malloc.h>
53 #include <sys/lock.h>
54 #include <sys/mutex.h>
55 #include <sys/md5.h>
56 #include <sys/errno.h>
57 #include <sys/disklabel.h>
58 #include <sys/gpt.h>
59 #include <sys/proc.h>
60 #include <sys/uuid.h>
61 #include <geom/geom.h>
62 #include <geom/geom_slice.h>
63
64 #define BSD_CLASS_NAME "BSD"
65
66 #define ALPHA_LABEL_OFFSET 64
67 #define HISTORIC_LABEL_OFFSET 512
68
69 #define LABELSIZE (148 + 16 * MAXPARTITIONS)
70
71 static void g_bsd_hotwrite(void *arg, int flag);
72 /*
73 * Our private data about one instance. All the rest is handled by the
74 * slice code and stored in its softc, so this is just the stuff
75 * specific to BSD disklabels.
76 */
77 struct g_bsd_softc {
78 off_t labeloffset;
79 off_t mbroffset;
80 off_t rawoffset;
81 struct disklabel ondisk;
82 u_char label[LABELSIZE];
83 u_char labelsum[16];
84 };
85
86 /*
87 * Modify our slicer to match proposed disklabel, if possible.
88 * This is where we make sure we don't do something stupid.
89 */
90 static int
91 g_bsd_modify(struct g_geom *gp, u_char *label)
92 {
93 int i, error;
94 struct partition *ppp;
95 struct g_slicer *gsp;
96 struct g_consumer *cp;
97 struct g_bsd_softc *ms;
98 u_int secsize, u;
99 off_t rawoffset, o;
100 struct disklabel dl;
101 MD5_CTX md5sum;
102
103 g_topology_assert();
104 gsp = gp->softc;
105 ms = gsp->softc;
106
107 error = bsd_disklabel_le_dec(label, &dl, MAXPARTITIONS);
108 if (error) {
109 return (error);
110 }
111
112 /* Get dimensions of our device. */
113 cp = LIST_FIRST(&gp->consumer);
114 secsize = cp->provider->sectorsize;
115
116 /* ... or a smaller sector size. */
117 if (dl.d_secsize < secsize) {
118 return (EINVAL);
119 }
120
121 /* ... or a non-multiple sector size. */
122 if (dl.d_secsize % secsize != 0) {
123 return (EINVAL);
124 }
125
126 /* Historical braindamage... */
127 rawoffset = (off_t)dl.d_partitions[RAW_PART].p_offset * dl.d_secsize;
128
129 for (i = 0; i < dl.d_npartitions; i++) {
130 ppp = &dl.d_partitions[i];
131 if (ppp->p_size == 0)
132 continue;
133 o = (off_t)ppp->p_offset * dl.d_secsize;
134
135 if (o < rawoffset)
136 rawoffset = 0;
137 }
138
139 if (rawoffset != 0 && (off_t)rawoffset != ms->mbroffset)
140 printf("WARNING: %s expected rawoffset %jd, found %jd\n",
141 gp->name,
142 (intmax_t)ms->mbroffset/dl.d_secsize,
143 (intmax_t)rawoffset/dl.d_secsize);
144
145 /* Don't munge open partitions. */
146 for (i = 0; i < dl.d_npartitions; i++) {
147 ppp = &dl.d_partitions[i];
148
149 o = (off_t)ppp->p_offset * dl.d_secsize;
150 if (o == 0)
151 o = rawoffset;
152 error = g_slice_config(gp, i, G_SLICE_CONFIG_CHECK,
153 o - rawoffset,
154 (off_t)ppp->p_size * dl.d_secsize,
155 dl.d_secsize,
156 "%s%c", gp->name, 'a' + i);
157 if (error)
158 return (error);
159 }
160
161 /* Look good, go for it... */
162 for (u = 0; u < gsp->nslice; u++) {
163 ppp = &dl.d_partitions[u];
164 o = (off_t)ppp->p_offset * dl.d_secsize;
165 if (o == 0)
166 o = rawoffset;
167 g_slice_config(gp, u, G_SLICE_CONFIG_SET,
168 o - rawoffset,
169 (off_t)ppp->p_size * dl.d_secsize,
170 dl.d_secsize,
171 "%s%c", gp->name, 'a' + u);
172 }
173
174 /* Update our softc */
175 ms->ondisk = dl;
176 if (label != ms->label)
177 bcopy(label, ms->label, LABELSIZE);
178 ms->rawoffset = rawoffset;
179
180 /*
181 * In order to avoid recursively attaching to the same
182 * on-disk label (it's usually visible through the 'c'
183 * partition) we calculate an MD5 and ask if other BSD's
184 * below us love that label. If they do, we don't.
185 */
186 MD5Init(&md5sum);
187 MD5Update(&md5sum, ms->label, sizeof(ms->label));
188 MD5Final(ms->labelsum, &md5sum);
189
190 return (0);
191 }
192
193 /*
194 * This is an internal helper function, called multiple times from the taste
195 * function to try to locate a disklabel on the disk. More civilized formats
196 * will not need this, as there is only one possible place on disk to look
197 * for the magic spot.
198 */
199
200 static int
201 g_bsd_try(struct g_geom *gp, struct g_slicer *gsp, struct g_consumer *cp, int secsize, struct g_bsd_softc *ms, off_t offset)
202 {
203 int error;
204 u_char *buf;
205 struct disklabel *dl;
206 off_t secoff;
207
208 /*
209 * We need to read entire aligned sectors, and we assume that the
210 * disklabel does not span sectors, so one sector is enough.
211 */
212 secoff = offset % secsize;
213 buf = g_read_data(cp, offset - secoff, secsize, NULL);
214 if (buf == NULL)
215 return (ENOENT);
216
217 /* Decode into our native format. */
218 dl = &ms->ondisk;
219 error = bsd_disklabel_le_dec(buf + secoff, dl, MAXPARTITIONS);
220 if (!error)
221 bcopy(buf + secoff, ms->label, LABELSIZE);
222
223 /* Remember to free the buffer g_read_data() gave us. */
224 g_free(buf);
225
226 ms->labeloffset = offset;
227 return (error);
228 }
229
230 /*
231 * This function writes the current label to disk, possibly updating
232 * the alpha SRM checksum.
233 */
234
235 static int
236 g_bsd_writelabel(struct g_geom *gp, u_char *bootcode)
237 {
238 off_t secoff;
239 u_int secsize;
240 struct g_consumer *cp;
241 struct g_slicer *gsp;
242 struct g_bsd_softc *ms;
243 u_char *buf;
244 uint64_t sum;
245 int error, i;
246
247 gsp = gp->softc;
248 ms = gsp->softc;
249 cp = LIST_FIRST(&gp->consumer);
250 /* Get sector size, we need it to read data. */
251 secsize = cp->provider->sectorsize;
252 secoff = ms->labeloffset % secsize;
253 if (bootcode == NULL) {
254 buf = g_read_data(cp, ms->labeloffset - secoff, secsize, &error);
255 if (buf == NULL)
256 return (error);
257 bcopy(ms->label, buf + secoff, sizeof(ms->label));
258 } else {
259 buf = bootcode;
260 bcopy(ms->label, buf + ms->labeloffset, sizeof(ms->label));
261 }
262 if (ms->labeloffset == ALPHA_LABEL_OFFSET) {
263 sum = 0;
264 for (i = 0; i < 63; i++)
265 sum += le64dec(buf + i * 8);
266 le64enc(buf + 504, sum);
267 }
268 if (bootcode == NULL) {
269 error = g_write_data(cp, ms->labeloffset - secoff, buf, secsize);
270 g_free(buf);
271 } else {
272 error = g_write_data(cp, 0, bootcode, BBSIZE);
273 }
274 return(error);
275 }
276
277 /*
278 * If the user tries to overwrite our disklabel through an open partition
279 * or via a magicwrite config call, we end up here and try to prevent
280 * footshooting as best we can.
281 */
282 static void
283 g_bsd_hotwrite(void *arg, int flag)
284 {
285 struct bio *bp;
286 struct g_geom *gp;
287 struct g_slicer *gsp;
288 struct g_slice *gsl;
289 struct g_bsd_softc *ms;
290 u_char *p;
291 int error;
292
293 g_topology_assert();
294 /*
295 * We should never get canceled, because that would amount to a removal
296 * of the geom while there was outstanding I/O requests.
297 */
298 KASSERT(flag != EV_CANCEL, ("g_bsd_hotwrite cancelled"));
299 bp = arg;
300 gp = bp->bio_to->geom;
301 gsp = gp->softc;
302 ms = gsp->softc;
303 gsl = &gsp->slices[bp->bio_to->index];
304 p = (u_char*)bp->bio_data + ms->labeloffset
305 - (bp->bio_offset + gsl->offset);
306 error = g_bsd_modify(gp, p);
307 if (error) {
308 g_io_deliver(bp, EPERM);
309 return;
310 }
311 g_slice_finish_hot(bp);
312 }
313
314 /*-
315 * This start routine is only called for non-trivial requests, all the
316 * trivial ones are handled autonomously by the slice code.
317 * For requests we handle here, we must call the g_io_deliver() on the
318 * bio, and return non-zero to indicate to the slice code that we did so.
319 * This code executes in the "DOWN" I/O path, this means:
320 * * No sleeping.
321 * * Don't grab the topology lock.
322 * * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
323 */
324 static int
325 g_bsd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
326 {
327 struct g_geom *gp;
328 struct g_bsd_softc *ms;
329 struct g_slicer *gsp;
330 u_char *label;
331 int error;
332
333 gp = pp->geom;
334 gsp = gp->softc;
335 ms = gsp->softc;
336
337 switch(cmd) {
338 case DIOCGDINFO:
339 /* Return a copy of the disklabel to userland. */
340 bsd_disklabel_le_dec(ms->label, data, MAXPARTITIONS);
341 return(0);
342 case DIOCBSDBB: {
343 struct g_consumer *cp;
344 u_char *buf;
345 void *p;
346 int error, i;
347 uint64_t sum;
348
349 if (!(fflag & FWRITE))
350 return (EPERM);
351 /* The disklabel to set is the ioctl argument. */
352 buf = g_malloc(BBSIZE, M_WAITOK);
353 p = *(void **)data;
354 error = copyin(p, buf, BBSIZE);
355 if (!error) {
356 /* XXX: Rude, but supposedly safe */
357 DROP_GIANT();
358 g_topology_lock();
359 /* Validate and modify our slice instance to match. */
360 error = g_bsd_modify(gp, buf + ms->labeloffset);
361 if (!error) {
362 cp = LIST_FIRST(&gp->consumer);
363 if (ms->labeloffset == ALPHA_LABEL_OFFSET) {
364 sum = 0;
365 for (i = 0; i < 63; i++)
366 sum += le64dec(buf + i * 8);
367 le64enc(buf + 504, sum);
368 }
369 error = g_write_data(cp, 0, buf, BBSIZE);
370 }
371 g_topology_unlock();
372 PICKUP_GIANT();
373 }
374 g_free(buf);
375 return (error);
376 }
377 case DIOCSDINFO:
378 case DIOCWDINFO: {
379 if (!(fflag & FWRITE))
380 return (EPERM);
381 label = g_malloc(LABELSIZE, M_WAITOK);
382 /* The disklabel to set is the ioctl argument. */
383 bsd_disklabel_le_enc(label, data);
384
385 DROP_GIANT();
386 g_topology_lock();
387 /* Validate and modify our slice instance to match. */
388 error = g_bsd_modify(gp, label);
389 if (error == 0 && cmd == DIOCWDINFO)
390 error = g_bsd_writelabel(gp, NULL);
391 g_topology_unlock();
392 PICKUP_GIANT();
393 g_free(label);
394 return(error);
395 }
396 default:
397 return (ENOIOCTL);
398 }
399 }
400
401 static int
402 g_bsd_start(struct bio *bp)
403 {
404 struct g_geom *gp;
405 struct g_bsd_softc *ms;
406 struct g_slicer *gsp;
407
408 gp = bp->bio_to->geom;
409 gsp = gp->softc;
410 ms = gsp->softc;
411 if (bp->bio_cmd == BIO_GETATTR) {
412 if (g_handleattr(bp, "BSD::labelsum", ms->labelsum,
413 sizeof(ms->labelsum)))
414 return (1);
415 }
416 return (0);
417 }
418
419 /*
420 * Dump configuration information in XML format.
421 * Notice that the function is called once for the geom and once for each
422 * consumer and provider. We let g_slice_dumpconf() do most of the work.
423 */
424 static void
425 g_bsd_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp)
426 {
427 struct g_bsd_softc *ms;
428 struct g_slicer *gsp;
429
430 gsp = gp->softc;
431 ms = gsp->softc;
432 g_slice_dumpconf(sb, indent, gp, cp, pp);
433 if (indent != NULL && pp == NULL && cp == NULL) {
434 sbuf_printf(sb, "%s<labeloffset>%jd</labeloffset>\n",
435 indent, (intmax_t)ms->labeloffset);
436 sbuf_printf(sb, "%s<rawoffset>%jd</rawoffset>\n",
437 indent, (intmax_t)ms->rawoffset);
438 sbuf_printf(sb, "%s<mbroffset>%jd</mbroffset>\n",
439 indent, (intmax_t)ms->mbroffset);
440 } else if (pp != NULL) {
441 if (indent == NULL)
442 sbuf_printf(sb, " ty %d",
443 ms->ondisk.d_partitions[pp->index].p_fstype);
444 else
445 sbuf_printf(sb, "%s<type>%d</type>\n", indent,
446 ms->ondisk.d_partitions[pp->index].p_fstype);
447 }
448 }
449
450 /*
451 * The taste function is called from the event-handler, with the topology
452 * lock already held and a provider to examine. The flags are unused.
453 *
454 * If flags == G_TF_NORMAL, the idea is to take a bite of the provider and
455 * if we find valid, consistent magic on it, build a geom on it.
456 *
457 * There may be cases where the operator would like to put a BSD-geom on
458 * providers which do not meet all of the requirements. This can be done
459 * by instead passing the G_TF_INSIST flag, which will override these
460 * checks.
461 *
462 * The final flags value is G_TF_TRANSPARENT, which instructs the method
463 * to put a geom on top of the provider and configure it to be as transparent
464 * as possible. This is not really relevant to the BSD method and therefore
465 * not implemented here.
466 */
467
468 static struct uuid freebsd_slice = GPT_ENT_TYPE_FREEBSD;
469
470 static struct g_geom *
471 g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
472 {
473 struct g_geom *gp;
474 struct g_consumer *cp;
475 int error, i;
476 struct g_bsd_softc *ms;
477 u_int secsize;
478 struct g_slicer *gsp;
479 u_char hash[16];
480 MD5_CTX md5sum;
481 struct uuid uuid;
482
483 g_trace(G_T_TOPOLOGY, "bsd_taste(%s,%s)", mp->name, pp->name);
484 g_topology_assert();
485
486 /* We don't implement transparent inserts. */
487 if (flags == G_TF_TRANSPARENT)
488 return (NULL);
489
490 /*
491 * BSD labels are a subclass of the general "slicing" topology so
492 * a lot of the work can be done by the common "slice" code.
493 * Create a geom with space for MAXPARTITIONS providers, one consumer
494 * and a softc structure for us. Specify the provider to attach
495 * the consumer to and our "start" routine for special requests.
496 * The provider is opened with mode (1,0,0) so we can do reads
497 * from it.
498 */
499 gp = g_slice_new(mp, MAXPARTITIONS, pp, &cp, &ms,
500 sizeof(*ms), g_bsd_start);
501 if (gp == NULL)
502 return (NULL);
503
504 /* Get the geom_slicer softc from the geom. */
505 gsp = gp->softc;
506
507 /*
508 * The do...while loop here allows us to have multiple escapes
509 * using a simple "break". This improves code clarity without
510 * ending up in deep nesting and without using goto or come from.
511 */
512 do {
513 /*
514 * If the provider is an MBR we will only auto attach
515 * to type 165 slices in the G_TF_NORMAL case. We will
516 * attach to any other type.
517 */
518 error = g_getattr("MBR::type", cp, &i);
519 if (!error) {
520 if (i != 165 && flags == G_TF_NORMAL)
521 break;
522 error = g_getattr("MBR::offset", cp, &ms->mbroffset);
523 if (error)
524 break;
525 }
526
527 /* Same thing if we are inside a PC98 */
528 error = g_getattr("PC98::type", cp, &i);
529 if (!error) {
530 if (i != 0xc494 && flags == G_TF_NORMAL)
531 break;
532 error = g_getattr("PC98::offset", cp, &ms->mbroffset);
533 if (error)
534 break;
535 }
536
537 /* Same thing if we are inside a GPT */
538 error = g_getattr("GPT::type", cp, &uuid);
539 if (!error) {
540 if (memcmp(&uuid, &freebsd_slice, sizeof(uuid)) != 0 &&
541 flags == G_TF_NORMAL)
542 break;
543 }
544
545 /* Get sector size, we need it to read data. */
546 secsize = cp->provider->sectorsize;
547 if (secsize < 512)
548 break;
549
550 /* First look for a label at the start of the second sector. */
551 error = g_bsd_try(gp, gsp, cp, secsize, ms, secsize);
552
553 /*
554 * If sector size is not 512 the label still can be at
555 * offset 512, not at the start of the second sector. At least
556 * it's true for labels created by the FreeBSD's bsdlabel(8).
557 */
558 if (error && secsize != HISTORIC_LABEL_OFFSET)
559 error = g_bsd_try(gp, gsp, cp, secsize, ms,
560 HISTORIC_LABEL_OFFSET);
561
562 /* Next, look for alpha labels */
563 if (error)
564 error = g_bsd_try(gp, gsp, cp, secsize, ms,
565 ALPHA_LABEL_OFFSET);
566
567 /* If we didn't find a label, punt. */
568 if (error)
569 break;
570
571 /*
572 * In order to avoid recursively attaching to the same
573 * on-disk label (it's usually visible through the 'c'
574 * partition) we calculate an MD5 and ask if other BSD's
575 * below us love that label. If they do, we don't.
576 */
577 MD5Init(&md5sum);
578 MD5Update(&md5sum, ms->label, sizeof(ms->label));
579 MD5Final(ms->labelsum, &md5sum);
580
581 error = g_getattr("BSD::labelsum", cp, &hash);
582 if (!error && !bcmp(ms->labelsum, hash, sizeof(hash)))
583 break;
584
585 /*
586 * Process the found disklabel, and modify our "slice"
587 * instance to match it, if possible.
588 */
589 error = g_bsd_modify(gp, ms->label);
590 } while (0);
591
592 /* Success or failure, we can close our provider now. */
593 g_access(cp, -1, 0, 0);
594
595 /* If we have configured any providers, return the new geom. */
596 if (gsp->nprovider > 0) {
597 g_slice_conf_hot(gp, 0, ms->labeloffset, LABELSIZE,
598 G_SLICE_HOT_ALLOW, G_SLICE_HOT_DENY, G_SLICE_HOT_CALL);
599 gsp->hot = g_bsd_hotwrite;
600 return (gp);
601 }
602 /*
603 * ...else push the "self-destruct" button, by spoiling our own
604 * consumer. This triggers a call to g_slice_spoiled which will
605 * dismantle what was setup.
606 */
607 g_slice_spoiled(cp);
608 return (NULL);
609 }
610
611 struct h0h0 {
612 struct g_geom *gp;
613 struct g_bsd_softc *ms;
614 u_char *label;
615 int error;
616 };
617
618 static void
619 g_bsd_callconfig(void *arg, int flag)
620 {
621 struct h0h0 *hp;
622
623 hp = arg;
624 hp->error = g_bsd_modify(hp->gp, hp->label);
625 if (!hp->error)
626 hp->error = g_bsd_writelabel(hp->gp, NULL);
627 }
628
629 /*
630 * NB! curthread is user process which GCTL'ed.
631 */
632 static void
633 g_bsd_config(struct gctl_req *req, struct g_class *mp, char const *verb)
634 {
635 u_char *label;
636 int error;
637 struct h0h0 h0h0;
638 struct g_geom *gp;
639 struct g_slicer *gsp;
640 struct g_consumer *cp;
641 struct g_bsd_softc *ms;
642
643 g_topology_assert();
644 gp = gctl_get_geom(req, mp, "geom");
645 if (gp == NULL)
646 return;
647 cp = LIST_FIRST(&gp->consumer);
648 gsp = gp->softc;
649 ms = gsp->softc;
650 if (!strcmp(verb, "read mbroffset")) {
651 gctl_set_param_err(req, "mbroffset", &ms->mbroffset,
652 sizeof(ms->mbroffset));
653 return;
654 } else if (!strcmp(verb, "write label")) {
655 label = gctl_get_paraml(req, "label", LABELSIZE);
656 if (label == NULL)
657 return;
658 h0h0.gp = gp;
659 h0h0.ms = gsp->softc;
660 h0h0.label = label;
661 h0h0.error = -1;
662 /* XXX: Does this reference register with our selfdestruct code ? */
663 error = g_access(cp, 1, 1, 1);
664 if (error) {
665 gctl_error(req, "could not access consumer");
666 return;
667 }
668 g_bsd_callconfig(&h0h0, 0);
669 error = h0h0.error;
670 g_access(cp, -1, -1, -1);
671 } else if (!strcmp(verb, "write bootcode")) {
672 label = gctl_get_paraml(req, "bootcode", BBSIZE);
673 if (label == NULL)
674 return;
675 /* XXX: Does this reference register with our selfdestruct code ? */
676 error = g_access(cp, 1, 1, 1);
677 if (error) {
678 gctl_error(req, "could not access consumer");
679 return;
680 }
681 error = g_bsd_writelabel(gp, label);
682 g_access(cp, -1, -1, -1);
683 } else {
684 gctl_error(req, "Unknown verb parameter");
685 }
686
687 return;
688 }
689
690 /* Finally, register with GEOM infrastructure. */
691 static struct g_class g_bsd_class = {
692 .name = BSD_CLASS_NAME,
693 .version = G_VERSION,
694 .taste = g_bsd_taste,
695 .ctlreq = g_bsd_config,
696 .dumpconf = g_bsd_dumpconf,
697 .ioctl = g_bsd_ioctl,
698 };
699
700 DECLARE_GEOM_CLASS(g_bsd_class, g_bsd);
Cache object: aea99dd30991daa903d172651b964529
|