Lines Matching +full:entry +full:- +full:name

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2002, 2005-2009 Marcel Moolenaar
67 { "apple-apfs", G_PART_ALIAS_APPLE_APFS },
68 { "apple-boot", G_PART_ALIAS_APPLE_BOOT },
69 { "apple-core-storage", G_PART_ALIAS_APPLE_CORE_STORAGE },
70 { "apple-hfs", G_PART_ALIAS_APPLE_HFS },
71 { "apple-label", G_PART_ALIAS_APPLE_LABEL },
72 { "apple-raid", G_PART_ALIAS_APPLE_RAID },
73 { "apple-raid-offline", G_PART_ALIAS_APPLE_RAID_OFFLINE },
74 { "apple-tv-recovery", G_PART_ALIAS_APPLE_TV_RECOVERY },
75 { "apple-ufs", G_PART_ALIAS_APPLE_UFS },
76 { "apple-zfs", G_PART_ALIAS_APPLE_ZFS },
77 { "bios-boot", G_PART_ALIAS_BIOS_BOOT },
78 { "chromeos-firmware", G_PART_ALIAS_CHROMEOS_FIRMWARE },
79 { "chromeos-kernel", G_PART_ALIAS_CHROMEOS_KERNEL },
80 { "chromeos-reserved", G_PART_ALIAS_CHROMEOS_RESERVED },
81 { "chromeos-root", G_PART_ALIAS_CHROMEOS_ROOT },
82 { "dragonfly-ccd", G_PART_ALIAS_DFBSD_CCD },
83 { "dragonfly-hammer", G_PART_ALIAS_DFBSD_HAMMER },
84 { "dragonfly-hammer2", G_PART_ALIAS_DFBSD_HAMMER2 },
85 { "dragonfly-label32", G_PART_ALIAS_DFBSD },
86 { "dragonfly-label64", G_PART_ALIAS_DFBSD64 },
87 { "dragonfly-legacy", G_PART_ALIAS_DFBSD_LEGACY },
88 { "dragonfly-swap", G_PART_ALIAS_DFBSD_SWAP },
89 { "dragonfly-ufs", G_PART_ALIAS_DFBSD_UFS },
90 { "dragonfly-vinum", G_PART_ALIAS_DFBSD_VINUM },
97 { "freebsd-boot", G_PART_ALIAS_FREEBSD_BOOT },
98 { "freebsd-nandfs", G_PART_ALIAS_FREEBSD_NANDFS },
99 { "freebsd-swap", G_PART_ALIAS_FREEBSD_SWAP },
100 { "freebsd-ufs", G_PART_ALIAS_FREEBSD_UFS },
101 { "freebsd-vinum", G_PART_ALIAS_FREEBSD_VINUM },
102 { "freebsd-zfs", G_PART_ALIAS_FREEBSD_ZFS },
103 { "hifive-fsbl", G_PART_ALIAS_HIFIVE_FSBL },
104 { "hifive-bbl", G_PART_ALIAS_HIFIVE_BBL },
105 { "linux-data", G_PART_ALIAS_LINUX_DATA },
106 { "linux-lvm", G_PART_ALIAS_LINUX_LVM },
107 { "linux-raid", G_PART_ALIAS_LINUX_RAID },
108 { "linux-swap", G_PART_ALIAS_LINUX_SWAP },
110 { "ms-basic-data", G_PART_ALIAS_MS_BASIC_DATA },
111 { "ms-ldm-data", G_PART_ALIAS_MS_LDM_DATA },
112 { "ms-ldm-metadata", G_PART_ALIAS_MS_LDM_METADATA },
113 { "ms-recovery", G_PART_ALIAS_MS_RECOVERY },
114 { "ms-reserved", G_PART_ALIAS_MS_RESERVED },
115 { "ms-spaces", G_PART_ALIAS_MS_SPACES },
116 { "netbsd-ccd", G_PART_ALIAS_NETBSD_CCD },
117 { "netbsd-cgd", G_PART_ALIAS_NETBSD_CGD },
118 { "netbsd-ffs", G_PART_ALIAS_NETBSD_FFS },
119 { "netbsd-lfs", G_PART_ALIAS_NETBSD_LFS },
120 { "netbsd-raid", G_PART_ALIAS_NETBSD_RAID },
121 { "netbsd-swap", G_PART_ALIAS_NETBSD_SWAP },
123 { "openbsd-data", G_PART_ALIAS_OPENBSD_DATA },
124 { "prep-boot", G_PART_ALIAS_PREP_BOOT },
125 { "solaris-boot", G_PART_ALIAS_SOLARIS_BOOT },
126 { "solaris-root", G_PART_ALIAS_SOLARIS_ROOT },
127 { "solaris-swap", G_PART_ALIAS_SOLARIS_SWAP },
128 { "solaris-backup", G_PART_ALIAS_SOLARIS_BACKUP },
129 { "solaris-var", G_PART_ALIAS_SOLARIS_VAR },
130 { "solaris-home", G_PART_ALIAS_SOLARIS_HOME },
131 { "solaris-altsec", G_PART_ALIAS_SOLARIS_ALTSEC },
132 { "solaris-reserved", G_PART_ALIAS_SOLARIS_RESERVED },
133 { "u-boot-env", G_PART_ALIAS_U_BOOT_ENV },
134 { "vmware-reserved", G_PART_ALIAS_VMRESERVED },
135 { "vmware-vmfs", G_PART_ALIAS_VMFS },
136 { "vmware-vmkdiag", G_PART_ALIAS_VMKDIAG },
137 { "vmware-vsanhdr", G_PART_ALIAS_VMVSANHDR },
158 "Partition name separator");
178 .name = "PART",
256 table->gpt_fixgeom = 0; in g_part_geometry()
257 table->gpt_heads = 0; in g_part_geometry()
258 table->gpt_sectors = 0; in g_part_geometry()
270 table->gpt_sectors == 1)) { in g_part_geometry()
272 table->gpt_heads = heads; in g_part_geometry()
273 table->gpt_sectors = sectors; in g_part_geometry()
282 table->gpt_heads = 255; in g_part_geometry()
283 table->gpt_sectors = 63; in g_part_geometry()
286 table->gpt_fixgeom = 1; in g_part_geometry()
287 table->gpt_heads = heads; in g_part_geometry()
288 table->gpt_sectors = sectors; in g_part_geometry()
296 struct g_part_entry *entry; in g_part_get_physpath_done() local
301 pbp = bp->bio_parent; in g_part_get_physpath_done()
302 pp = pbp->bio_to; in g_part_get_physpath_done()
303 gp = pp->geom; in g_part_get_physpath_done()
304 table = gp->softc; in g_part_get_physpath_done()
305 entry = pp->private; in g_part_get_physpath_done()
307 if (bp->bio_error == 0) { in g_part_get_physpath_done()
310 len = strlcat(bp->bio_data, "/", bp->bio_length); in g_part_get_physpath_done()
311 if (len < bp->bio_length) { in g_part_get_physpath_done()
312 end = bp->bio_data + len; in g_part_get_physpath_done()
313 remainder = bp->bio_length - len; in g_part_get_physpath_done()
314 G_PART_NAME(table, entry, end, remainder); in g_part_get_physpath_done()
333 pp = cp->provider; in g_part_check_integrity()
334 if (table->gpt_last < table->gpt_first) { in g_part_check_integrity()
336 (intmax_t)table->gpt_last, (intmax_t)table->gpt_first); in g_part_check_integrity()
339 if (table->gpt_last > pp->mediasize / pp->sectorsize - 1) { in g_part_check_integrity()
341 "%jd > %jd\n", (intmax_t)table->gpt_last, in g_part_check_integrity()
342 (intmax_t)pp->mediasize / pp->sectorsize - 1); in g_part_check_integrity()
345 LIST_FOREACH(e1, &table->gpt_entry, gpe_entry) { in g_part_check_integrity()
346 if (e1->gpe_deleted || e1->gpe_internal) in g_part_check_integrity()
348 if (e1->gpe_start < table->gpt_first) { in g_part_check_integrity()
350 "LBA: %jd < %jd\n", e1->gpe_index, in g_part_check_integrity()
351 (intmax_t)e1->gpe_start, in g_part_check_integrity()
352 (intmax_t)table->gpt_first); in g_part_check_integrity()
355 if (e1->gpe_start > table->gpt_last) { in g_part_check_integrity()
357 "LBA: %jd > %jd\n", e1->gpe_index, in g_part_check_integrity()
358 (intmax_t)e1->gpe_start, in g_part_check_integrity()
359 (intmax_t)table->gpt_last); in g_part_check_integrity()
362 if (e1->gpe_end < e1->gpe_start) { in g_part_check_integrity()
364 "offset: %jd < %jd\n", e1->gpe_index, in g_part_check_integrity()
365 (intmax_t)e1->gpe_end, in g_part_check_integrity()
366 (intmax_t)e1->gpe_start); in g_part_check_integrity()
369 if (e1->gpe_end > table->gpt_last) { in g_part_check_integrity()
371 "LBA: %jd > %jd\n", e1->gpe_index, in g_part_check_integrity()
372 (intmax_t)e1->gpe_end, in g_part_check_integrity()
373 (intmax_t)table->gpt_last); in g_part_check_integrity()
376 if (pp->stripesize > 0) { in g_part_check_integrity()
377 offset = e1->gpe_start * pp->sectorsize; in g_part_check_integrity()
378 if (e1->gpe_offset > offset) in g_part_check_integrity()
379 offset = e1->gpe_offset; in g_part_check_integrity()
380 if ((offset + pp->stripeoffset) % pp->stripesize) { in g_part_check_integrity()
382 "aligned on %ju bytes\n", e1->gpe_index, in g_part_check_integrity()
383 pp->name, table->gpt_scheme->name, in g_part_check_integrity()
384 (uintmax_t)pp->stripesize); in g_part_check_integrity()
390 if (e2->gpe_deleted || e2->gpe_internal) in g_part_check_integrity()
392 if (e1->gpe_start >= e2->gpe_start && in g_part_check_integrity()
393 e1->gpe_start <= e2->gpe_end) { in g_part_check_integrity()
397 e1->gpe_index, e2->gpe_index, in g_part_check_integrity()
398 e2->gpe_index, (intmax_t)e2->gpe_start, in g_part_check_integrity()
399 e1->gpe_index, (intmax_t)e1->gpe_start, in g_part_check_integrity()
400 e2->gpe_index, (intmax_t)e2->gpe_end); in g_part_check_integrity()
403 if (e1->gpe_end >= e2->gpe_start && in g_part_check_integrity()
404 e1->gpe_end <= e2->gpe_end) { in g_part_check_integrity()
408 e1->gpe_index, e2->gpe_index, in g_part_check_integrity()
409 e2->gpe_index, (intmax_t)e2->gpe_start, in g_part_check_integrity()
410 e1->gpe_index, (intmax_t)e1->gpe_end, in g_part_check_integrity()
411 e2->gpe_index, (intmax_t)e2->gpe_end); in g_part_check_integrity()
414 if (e1->gpe_start < e2->gpe_start && in g_part_check_integrity()
415 e1->gpe_end > e2->gpe_end) { in g_part_check_integrity()
419 e1->gpe_index, e2->gpe_index, in g_part_check_integrity()
420 e1->gpe_index, (intmax_t)e1->gpe_start, in g_part_check_integrity()
421 e2->gpe_index, (intmax_t)e2->gpe_start, in g_part_check_integrity()
422 e2->gpe_index, (intmax_t)e2->gpe_end, in g_part_check_integrity()
423 e1->gpe_index, (intmax_t)e1->gpe_end); in g_part_check_integrity()
430 pp->name, table->gpt_scheme->name); in g_part_check_integrity()
433 table->gpt_corrupt = 1; in g_part_check_integrity()
443 struct g_part_entry *entry, *last; in g_part_new_entry() local
446 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_new_entry()
447 if (entry->gpe_index == index) in g_part_new_entry()
449 if (entry->gpe_index > index) { in g_part_new_entry()
450 entry = NULL; in g_part_new_entry()
453 last = entry; in g_part_new_entry()
455 if (entry == NULL) { in g_part_new_entry()
456 entry = g_malloc(table->gpt_scheme->gps_entrysz, in g_part_new_entry()
458 entry->gpe_index = index; in g_part_new_entry()
460 LIST_INSERT_HEAD(&table->gpt_entry, entry, gpe_entry); in g_part_new_entry()
462 LIST_INSERT_AFTER(last, entry, gpe_entry); in g_part_new_entry()
464 entry->gpe_offset = 0; in g_part_new_entry()
465 entry->gpe_start = start; in g_part_new_entry()
466 entry->gpe_end = end; in g_part_new_entry()
467 return (entry); in g_part_new_entry()
472 struct g_part_entry *entry) in g_part_new_provider() argument
479 cp = LIST_FIRST(&gp->consumer); in g_part_new_provider()
480 pp = cp->provider; in g_part_new_provider()
482 offset = entry->gpe_start * pp->sectorsize; in g_part_new_provider()
483 if (entry->gpe_offset < offset) in g_part_new_provider()
484 entry->gpe_offset = offset; in g_part_new_provider()
486 if (entry->gpe_pp == NULL) { in g_part_new_provider()
487 entry->gpe_pp = G_PART_NEW_PROVIDER(table, gp, entry, gp->name); in g_part_new_provider()
491 * there for it to create the aliases with those name used in in g_part_new_provider()
492 * place of the geom's name we use to create the provider. The in g_part_new_provider()
495 LIST_FOREACH(gap, &pp->aliases, ga_next) in g_part_new_provider()
496 G_PART_ADD_ALIAS(table, entry->gpe_pp, entry, gap->ga_alias); in g_part_new_provider()
497 entry->gpe_pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; in g_part_new_provider()
498 entry->gpe_pp->private = entry; /* Close the circle. */ in g_part_new_provider()
500 entry->gpe_pp->index = entry->gpe_index - 1; /* index is 1-based. */ in g_part_new_provider()
501 entry->gpe_pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) * in g_part_new_provider()
502 pp->sectorsize; in g_part_new_provider()
503 entry->gpe_pp->mediasize -= entry->gpe_offset - offset; in g_part_new_provider()
504 entry->gpe_pp->sectorsize = pp->sectorsize; in g_part_new_provider()
505 entry->gpe_pp->stripesize = pp->stripesize; in g_part_new_provider()
506 entry->gpe_pp->stripeoffset = pp->stripeoffset + entry->gpe_offset; in g_part_new_provider()
507 if (pp->stripesize > 0) in g_part_new_provider()
508 entry->gpe_pp->stripeoffset %= pp->stripesize; in g_part_new_provider()
509 entry->gpe_pp->flags |= pp->flags & G_PF_ACCEPT_UNMAPPED; in g_part_new_provider()
510 g_error_provider(entry->gpe_pp, 0); in g_part_new_provider()
514 g_part_find_geom(const char *name) in g_part_find_geom() argument
518 if ((gp->flags & G_GEOM_WITHER) == 0 && in g_part_find_geom()
519 strcmp(name, gp->name) == 0) in g_part_find_geom()
526 g_part_parm_geom(struct gctl_req *req, const char *name, struct g_geom **v) in g_part_parm_geom() argument
531 gname = gctl_get_asciiparam(req, name); in g_part_parm_geom()
534 if (strncmp(gname, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) in g_part_parm_geom()
535 gname += sizeof(_PATH_DEV) - 1; in g_part_parm_geom()
538 gctl_error(req, "%d %s '%s'", EINVAL, name, gname); in g_part_parm_geom()
546 g_part_parm_provider(struct gctl_req *req, const char *name, in g_part_parm_provider() argument
552 pname = gctl_get_asciiparam(req, name); in g_part_parm_provider()
555 if (strncmp(pname, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) in g_part_parm_provider()
556 pname += sizeof(_PATH_DEV) - 1; in g_part_parm_provider()
559 gctl_error(req, "%d %s '%s'", EINVAL, name, pname); in g_part_parm_provider()
567 g_part_parm_quad(struct gctl_req *req, const char *name, quad_t *v) in g_part_parm_quad() argument
573 p = gctl_get_asciiparam(req, name); in g_part_parm_quad()
578 gctl_error(req, "%d %s '%s'", EINVAL, name, p); in g_part_parm_quad()
586 g_part_parm_scheme(struct gctl_req *req, const char *name, in g_part_parm_scheme() argument
592 p = gctl_get_asciiparam(req, name); in g_part_parm_scheme()
598 if (!strcasecmp(s->name, p)) in g_part_parm_scheme()
602 gctl_error(req, "%d %s '%s'", EINVAL, name, p); in g_part_parm_scheme()
610 g_part_parm_str(struct gctl_req *req, const char *name, const char **v) in g_part_parm_str() argument
614 p = gctl_get_asciiparam(req, name); in g_part_parm_str()
618 if (strcmp(name, "label") != 0 && p[0] == '\0') { in g_part_parm_str()
619 gctl_error(req, "%d %s '%s'", EINVAL, name, p); in g_part_parm_str()
627 g_part_parm_intmax(struct gctl_req *req, const char *name, u_int *v) in g_part_parm_intmax() argument
632 p = gctl_get_param(req, name, &size); in g_part_parm_intmax()
636 gctl_error(req, "%d %s '%jd'", EINVAL, name, *p); in g_part_parm_intmax()
644 g_part_parm_uint32(struct gctl_req *req, const char *name, u_int *v) in g_part_parm_uint32() argument
649 p = gctl_get_param(req, name, &size); in g_part_parm_uint32()
653 gctl_error(req, "%d %s '%u'", EINVAL, name, (unsigned int)*p); in g_part_parm_uint32()
661 g_part_parm_bootcode(struct gctl_req *req, const char *name, const void **v, in g_part_parm_bootcode() argument
667 p = gctl_get_param(req, name, &size); in g_part_parm_bootcode()
682 table = gp->softc; in g_part_probe()
683 scheme = (table != NULL) ? table->gpt_scheme : NULL; in g_part_probe()
697 table->gpt_gp = gp; in g_part_probe()
698 table->gpt_scheme = iter; in g_part_probe()
699 table->gpt_depth = depth; in g_part_probe()
704 if (gp->softc != NULL) in g_part_probe()
705 kobj_delete((kobj_t)gp->softc, M_GEOM); in g_part_probe()
706 gp->softc = table; in g_part_probe()
726 struct g_part_entry *delent, *last, *entry; in g_part_ctl_add() local
733 gp = gpp->gpp_geom; in g_part_ctl_add()
734 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_add()
737 pp = LIST_FIRST(&gp->consumer)->provider; in g_part_ctl_add()
738 table = gp->softc; in g_part_ctl_add()
739 end = gpp->gpp_start + gpp->gpp_size - 1; in g_part_ctl_add()
741 if (gpp->gpp_start < table->gpt_first || in g_part_ctl_add()
742 gpp->gpp_start > table->gpt_last) { in g_part_ctl_add()
744 (intmax_t)gpp->gpp_start); in g_part_ctl_add()
747 if (end < gpp->gpp_start || end > table->gpt_last) { in g_part_ctl_add()
749 (intmax_t)gpp->gpp_size); in g_part_ctl_add()
752 if (gpp->gpp_index > table->gpt_entries) { in g_part_ctl_add()
753 gctl_error(req, "%d index '%d'", EINVAL, gpp->gpp_index); in g_part_ctl_add()
758 index = (gpp->gpp_index > 0) ? gpp->gpp_index : 1; in g_part_ctl_add()
759 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_add()
760 if (entry->gpe_deleted) { in g_part_ctl_add()
761 if (entry->gpe_index == index) in g_part_ctl_add()
762 delent = entry; in g_part_ctl_add()
765 if (entry->gpe_index == index) in g_part_ctl_add()
766 index = entry->gpe_index + 1; in g_part_ctl_add()
767 if (entry->gpe_index < index) in g_part_ctl_add()
768 last = entry; in g_part_ctl_add()
769 if (entry->gpe_internal) in g_part_ctl_add()
771 if (gpp->gpp_start >= entry->gpe_start && in g_part_ctl_add()
772 gpp->gpp_start <= entry->gpe_end) { in g_part_ctl_add()
774 (intmax_t)gpp->gpp_start); in g_part_ctl_add()
777 if (end >= entry->gpe_start && end <= entry->gpe_end) { in g_part_ctl_add()
781 if (gpp->gpp_start < entry->gpe_start && end > entry->gpe_end) { in g_part_ctl_add()
783 (intmax_t)gpp->gpp_size); in g_part_ctl_add()
787 if (gpp->gpp_index > 0 && index != gpp->gpp_index) { in g_part_ctl_add()
788 gctl_error(req, "%d index '%d'", EEXIST, gpp->gpp_index); in g_part_ctl_add()
791 if (index > table->gpt_entries) { in g_part_ctl_add()
796 entry = (delent == NULL) ? g_malloc(table->gpt_scheme->gps_entrysz, in g_part_ctl_add()
798 entry->gpe_index = index; in g_part_ctl_add()
799 entry->gpe_start = gpp->gpp_start; in g_part_ctl_add()
800 entry->gpe_end = end; in g_part_ctl_add()
801 error = G_PART_ADD(table, entry, gpp); in g_part_ctl_add()
805 g_free(entry); in g_part_ctl_add()
810 LIST_INSERT_HEAD(&table->gpt_entry, entry, gpe_entry); in g_part_ctl_add()
812 LIST_INSERT_AFTER(last, entry, gpe_entry); in g_part_ctl_add()
813 entry->gpe_created = 1; in g_part_ctl_add()
815 entry->gpe_deleted = 0; in g_part_ctl_add()
816 entry->gpe_modified = 1; in g_part_ctl_add()
818 g_part_new_provider(gp, table, entry); in g_part_ctl_add()
821 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_add()
823 G_PART_FULLNAME(table, entry, sb, gp->name); in g_part_ctl_add()
824 if (pp->stripesize > 0 && entry->gpe_pp->stripeoffset != 0) in g_part_ctl_add()
826 "aligned on %ju bytes\n", (uintmax_t)pp->stripesize); in g_part_ctl_add()
844 gp = gpp->gpp_geom; in g_part_ctl_bootcode()
845 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_bootcode()
848 table = gp->softc; in g_part_ctl_bootcode()
849 sz = table->gpt_scheme->gps_bootcodesz; in g_part_ctl_bootcode()
854 if (gpp->gpp_codesize > sz) { in g_part_ctl_bootcode()
864 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_bootcode()
866 sbuf_printf(sb, "bootcode written to %s\n", gp->name); in g_part_ctl_bootcode()
884 struct g_part_entry *entry, *tmp; in g_part_ctl_commit() local
889 gp = gpp->gpp_geom; in g_part_ctl_commit()
890 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_commit()
893 table = gp->softc; in g_part_ctl_commit()
894 if (!table->gpt_opened) { in g_part_ctl_commit()
901 cp = LIST_FIRST(&gp->consumer); in g_part_ctl_commit()
902 if ((table->gpt_smhead | table->gpt_smtail) != 0) { in g_part_ctl_commit()
903 pp = cp->provider; in g_part_ctl_commit()
904 buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO); in g_part_ctl_commit()
905 while (table->gpt_smhead != 0) { in g_part_ctl_commit()
906 i = ffs(table->gpt_smhead) - 1; in g_part_ctl_commit()
907 error = g_write_data(cp, i * pp->sectorsize, buf, in g_part_ctl_commit()
908 pp->sectorsize); in g_part_ctl_commit()
913 table->gpt_smhead &= ~(1 << i); in g_part_ctl_commit()
915 while (table->gpt_smtail != 0) { in g_part_ctl_commit()
916 i = ffs(table->gpt_smtail) - 1; in g_part_ctl_commit()
917 error = g_write_data(cp, pp->mediasize - (i + 1) * in g_part_ctl_commit()
918 pp->sectorsize, buf, pp->sectorsize); in g_part_ctl_commit()
923 table->gpt_smtail &= ~(1 << i); in g_part_ctl_commit()
928 if (table->gpt_scheme == &g_part_null_scheme) { in g_part_ctl_commit()
930 g_access(cp, -1, -1, -1); in g_part_ctl_commit()
939 LIST_FOREACH_SAFE(entry, &table->gpt_entry, gpe_entry, tmp) { in g_part_ctl_commit()
940 if (!entry->gpe_deleted) { in g_part_ctl_commit()
942 if (entry->gpe_modified && ( in g_part_ctl_commit()
943 entry->gpe_pp->acw + entry->gpe_pp->ace + in g_part_ctl_commit()
944 entry->gpe_pp->acr) == 0) in g_part_ctl_commit()
945 g_media_changed(entry->gpe_pp, M_NOWAIT); in g_part_ctl_commit()
946 entry->gpe_created = 0; in g_part_ctl_commit()
947 entry->gpe_modified = 0; in g_part_ctl_commit()
950 LIST_REMOVE(entry, gpe_entry); in g_part_ctl_commit()
951 g_free(entry); in g_part_ctl_commit()
953 table->gpt_created = 0; in g_part_ctl_commit()
954 table->gpt_opened = 0; in g_part_ctl_commit()
957 g_access(cp, -1, -1, -1); in g_part_ctl_commit()
977 pp = gpp->gpp_provider; in g_part_ctl_create()
978 scheme = gpp->gpp_scheme; in g_part_ctl_create()
979 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, pp->name)); in g_part_ctl_create()
983 gp = g_part_find_geom(pp->name); in g_part_ctl_create()
985 null = gp->softc; in g_part_ctl_create()
986 if (null->gpt_scheme != &g_part_null_scheme) { in g_part_ctl_create()
987 gctl_error(req, "%d geom '%s'", EEXIST, pp->name); in g_part_ctl_create()
993 if ((gpp->gpp_parms & G_PART_PARM_ENTRIES) && in g_part_ctl_create()
994 (gpp->gpp_entries < scheme->gps_minent || in g_part_ctl_create()
995 gpp->gpp_entries > scheme->gps_maxent)) { in g_part_ctl_create()
996 gctl_error(req, "%d entries '%d'", EINVAL, gpp->gpp_entries); in g_part_ctl_create()
1001 gp = g_new_geomf(&g_part_class, "%s", pp->name); in g_part_ctl_create()
1002 gp->softc = kobj_create((kobj_class_t)gpp->gpp_scheme, M_GEOM, in g_part_ctl_create()
1004 table = gp->softc; in g_part_ctl_create()
1005 table->gpt_gp = gp; in g_part_ctl_create()
1006 table->gpt_scheme = gpp->gpp_scheme; in g_part_ctl_create()
1007 table->gpt_entries = (gpp->gpp_parms & G_PART_PARM_ENTRIES) ? in g_part_ctl_create()
1008 gpp->gpp_entries : scheme->gps_defent; in g_part_ctl_create()
1009 LIST_INIT(&table->gpt_entry); in g_part_ctl_create()
1012 cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; in g_part_ctl_create()
1018 gctl_error(req, "%d geom '%s'", error, pp->name); in g_part_ctl_create()
1021 table->gpt_opened = 1; in g_part_ctl_create()
1023 cp = LIST_FIRST(&gp->consumer); in g_part_ctl_create()
1024 table->gpt_opened = null->gpt_opened; in g_part_ctl_create()
1025 table->gpt_smhead = null->gpt_smhead; in g_part_ctl_create()
1026 table->gpt_smtail = null->gpt_smtail; in g_part_ctl_create()
1032 if (pp->mediasize == 0 || pp->sectorsize == 0) { in g_part_ctl_create()
1044 table->gpt_depth = (!error) ? attr + 1 : 0; in g_part_ctl_create()
1050 * scheme-independent code. in g_part_ctl_create()
1052 g_part_geometry(table, cp, pp->mediasize / pp->sectorsize); in g_part_ctl_create()
1060 table->gpt_created = 1; in g_part_ctl_create()
1068 gpp->gpp_parms |= G_PART_PARM_GEOM; in g_part_ctl_create()
1069 gpp->gpp_geom = gp; in g_part_ctl_create()
1072 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_create()
1074 sbuf_printf(sb, "%s created\n", gp->name); in g_part_ctl_create()
1084 g_access(cp, -1, -1, -1); in g_part_ctl_create()
1087 kobj_delete((kobj_t)gp->softc, M_GEOM); in g_part_ctl_create()
1088 gp->softc = null; in g_part_ctl_create()
1099 struct g_part_entry *entry; in g_part_ctl_delete() local
1103 gp = gpp->gpp_geom; in g_part_ctl_delete()
1104 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_delete()
1107 table = gp->softc; in g_part_ctl_delete()
1109 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_delete()
1110 if (entry->gpe_deleted || entry->gpe_internal) in g_part_ctl_delete()
1112 if (entry->gpe_index == gpp->gpp_index) in g_part_ctl_delete()
1115 if (entry == NULL) { in g_part_ctl_delete()
1116 gctl_error(req, "%d index '%d'", ENOENT, gpp->gpp_index); in g_part_ctl_delete()
1120 pp = entry->gpe_pp; in g_part_ctl_delete()
1122 if (pp->acr > 0 || pp->acw > 0 || pp->ace > 0) { in g_part_ctl_delete()
1127 pp->private = NULL; in g_part_ctl_delete()
1128 entry->gpe_pp = NULL; in g_part_ctl_delete()
1135 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_delete()
1137 G_PART_FULLNAME(table, entry, sb, gp->name); in g_part_ctl_delete()
1144 if (entry->gpe_created) { in g_part_ctl_delete()
1145 LIST_REMOVE(entry, gpe_entry); in g_part_ctl_delete()
1146 g_free(entry); in g_part_ctl_delete()
1148 entry->gpe_modified = 0; in g_part_ctl_delete()
1149 entry->gpe_deleted = 1; in g_part_ctl_delete()
1160 struct g_part_entry *entry, *tmp; in g_part_ctl_destroy() local
1165 gp = gpp->gpp_geom; in g_part_ctl_destroy()
1166 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_destroy()
1169 table = gp->softc; in g_part_ctl_destroy()
1171 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_destroy()
1172 if (entry->gpe_deleted || entry->gpe_internal) in g_part_ctl_destroy()
1174 if (gpp->gpp_force) { in g_part_ctl_destroy()
1175 pp = entry->gpe_pp; in g_part_ctl_destroy()
1178 if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) in g_part_ctl_destroy()
1185 if (gpp->gpp_force) { in g_part_ctl_destroy()
1187 LIST_FOREACH_SAFE(entry, &table->gpt_entry, gpe_entry, tmp) { in g_part_ctl_destroy()
1188 pp = entry->gpe_pp; in g_part_ctl_destroy()
1190 pp->private = NULL; in g_part_ctl_destroy()
1193 LIST_REMOVE(entry, gpe_entry); in g_part_ctl_destroy()
1194 g_free(entry); in g_part_ctl_destroy()
1204 gp->softc = kobj_create((kobj_class_t)&g_part_null_scheme, M_GEOM, in g_part_ctl_destroy()
1206 null = gp->softc; in g_part_ctl_destroy()
1207 null->gpt_gp = gp; in g_part_ctl_destroy()
1208 null->gpt_scheme = &g_part_null_scheme; in g_part_ctl_destroy()
1209 LIST_INIT(&null->gpt_entry); in g_part_ctl_destroy()
1211 cp = LIST_FIRST(&gp->consumer); in g_part_ctl_destroy()
1212 pp = cp->provider; in g_part_ctl_destroy()
1213 null->gpt_last = pp->mediasize / pp->sectorsize - 1; in g_part_ctl_destroy()
1215 null->gpt_depth = table->gpt_depth; in g_part_ctl_destroy()
1216 null->gpt_opened = table->gpt_opened; in g_part_ctl_destroy()
1217 null->gpt_smhead = table->gpt_smhead; in g_part_ctl_destroy()
1218 null->gpt_smtail = table->gpt_smtail; in g_part_ctl_destroy()
1220 while ((entry = LIST_FIRST(&table->gpt_entry)) != NULL) { in g_part_ctl_destroy()
1221 LIST_REMOVE(entry, gpe_entry); in g_part_ctl_destroy()
1222 g_free(entry); in g_part_ctl_destroy()
1227 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_destroy()
1229 sbuf_printf(sb, "%s destroyed\n", gp->name); in g_part_ctl_destroy()
1241 struct g_part_entry *entry; in g_part_ctl_modify() local
1246 gp = gpp->gpp_geom; in g_part_ctl_modify()
1247 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_modify()
1250 table = gp->softc; in g_part_ctl_modify()
1252 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_modify()
1253 if (entry->gpe_deleted || entry->gpe_internal) in g_part_ctl_modify()
1255 if (entry->gpe_index == gpp->gpp_index) in g_part_ctl_modify()
1258 if (entry == NULL) { in g_part_ctl_modify()
1259 gctl_error(req, "%d index '%d'", ENOENT, gpp->gpp_index); in g_part_ctl_modify()
1263 error = G_PART_MODIFY(table, entry, gpp); in g_part_ctl_modify()
1269 if (!entry->gpe_created) in g_part_ctl_modify()
1270 entry->gpe_modified = 1; in g_part_ctl_modify()
1273 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_modify()
1275 G_PART_FULLNAME(table, entry, sb, gp->name); in g_part_ctl_modify()
1299 gp = gpp->gpp_geom; in g_part_ctl_recover()
1300 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_recover()
1302 table = gp->softc; in g_part_ctl_recover()
1305 if (table->gpt_corrupt) { in g_part_ctl_recover()
1309 LIST_FIRST(&gp->consumer)); in g_part_ctl_recover()
1312 error, gp->name); in g_part_ctl_recover()
1318 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_recover()
1321 sbuf_printf(sb, "%s recovered\n", gp->name); in g_part_ctl_recover()
1324 gp->name); in g_part_ctl_recover()
1337 struct g_part_entry *pe, *entry; in g_part_ctl_resize() local
1344 gp = gpp->gpp_geom; in g_part_ctl_resize()
1345 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_resize()
1347 table = gp->softc; in g_part_ctl_resize()
1350 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_resize()
1351 if (entry->gpe_deleted || entry->gpe_internal) in g_part_ctl_resize()
1353 if (entry->gpe_index == gpp->gpp_index) in g_part_ctl_resize()
1356 if (entry == NULL) { in g_part_ctl_resize()
1357 gctl_error(req, "%d index '%d'", ENOENT, gpp->gpp_index); in g_part_ctl_resize()
1362 end = entry->gpe_start + gpp->gpp_size - 1; in g_part_ctl_resize()
1363 if (gpp->gpp_size < 1 || end > table->gpt_last) { in g_part_ctl_resize()
1365 (intmax_t)gpp->gpp_size); in g_part_ctl_resize()
1369 LIST_FOREACH(pe, &table->gpt_entry, gpe_entry) { in g_part_ctl_resize()
1370 if (pe->gpe_deleted || pe->gpe_internal || pe == entry) in g_part_ctl_resize()
1372 if (end >= pe->gpe_start && end <= pe->gpe_end) { in g_part_ctl_resize()
1377 if (entry->gpe_start < pe->gpe_start && end > pe->gpe_end) { in g_part_ctl_resize()
1379 (intmax_t)gpp->gpp_size); in g_part_ctl_resize()
1384 pp = entry->gpe_pp; in g_part_ctl_resize()
1386 (pp->acr > 0 || pp->acw > 0 || pp->ace > 0)) { in g_part_ctl_resize()
1387 if (entry->gpe_end - entry->gpe_start + 1 > gpp->gpp_size) { in g_part_ctl_resize()
1394 error = G_PART_RESIZE(table, entry, gpp); in g_part_ctl_resize()
1402 if (!entry->gpe_created) in g_part_ctl_resize()
1403 entry->gpe_modified = 1; in g_part_ctl_resize()
1406 mediasize = (entry->gpe_end - entry->gpe_start + 1) * in g_part_ctl_resize()
1407 pp->sectorsize; in g_part_ctl_resize()
1411 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_resize()
1413 G_PART_FULLNAME(table, entry, sb, gp->name); in g_part_ctl_resize()
1427 struct g_part_entry *entry; in g_part_ctl_setunset() local
1432 gp = gpp->gpp_geom; in g_part_ctl_setunset()
1433 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_setunset()
1436 table = gp->softc; in g_part_ctl_setunset()
1438 if (gpp->gpp_parms & G_PART_PARM_INDEX) { in g_part_ctl_setunset()
1439 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_setunset()
1440 if (entry->gpe_deleted || entry->gpe_internal) in g_part_ctl_setunset()
1442 if (entry->gpe_index == gpp->gpp_index) in g_part_ctl_setunset()
1445 if (entry == NULL) { in g_part_ctl_setunset()
1447 gpp->gpp_index); in g_part_ctl_setunset()
1451 entry = NULL; in g_part_ctl_setunset()
1453 error = G_PART_SETUNSET(table, entry, gpp->gpp_attrib, set); in g_part_ctl_setunset()
1455 gctl_error(req, "%d attrib '%s'", error, gpp->gpp_attrib); in g_part_ctl_setunset()
1460 if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { in g_part_ctl_setunset()
1462 sbuf_printf(sb, "%s %sset on ", gpp->gpp_attrib, in g_part_ctl_setunset()
1464 if (entry) in g_part_ctl_setunset()
1465 G_PART_FULLNAME(table, entry, sb, gp->name); in g_part_ctl_setunset()
1467 sbuf_cat(sb, gp->name); in g_part_ctl_setunset()
1482 struct g_part_entry *entry, *tmp; in g_part_ctl_undo() local
1486 gp = gpp->gpp_geom; in g_part_ctl_undo()
1487 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); in g_part_ctl_undo()
1490 table = gp->softc; in g_part_ctl_undo()
1491 if (!table->gpt_opened) { in g_part_ctl_undo()
1496 cp = LIST_FIRST(&gp->consumer); in g_part_ctl_undo()
1497 LIST_FOREACH_SAFE(entry, &table->gpt_entry, gpe_entry, tmp) { in g_part_ctl_undo()
1498 entry->gpe_modified = 0; in g_part_ctl_undo()
1499 if (entry->gpe_created) { in g_part_ctl_undo()
1500 pp = entry->gpe_pp; in g_part_ctl_undo()
1502 pp->private = NULL; in g_part_ctl_undo()
1503 entry->gpe_pp = NULL; in g_part_ctl_undo()
1506 entry->gpe_deleted = 1; in g_part_ctl_undo()
1508 if (entry->gpe_deleted) { in g_part_ctl_undo()
1509 LIST_REMOVE(entry, gpe_entry); in g_part_ctl_undo()
1510 g_free(entry); in g_part_ctl_undo()
1516 reprobe = (table->gpt_scheme == &g_part_null_scheme || in g_part_ctl_undo()
1517 table->gpt_created) ? 1 : 0; in g_part_ctl_undo()
1520 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_undo()
1521 if (entry->gpe_internal) in g_part_ctl_undo()
1526 while ((entry = LIST_FIRST(&table->gpt_entry)) != NULL) { in g_part_ctl_undo()
1527 LIST_REMOVE(entry, gpe_entry); in g_part_ctl_undo()
1528 g_free(entry); in g_part_ctl_undo()
1530 error = g_part_probe(gp, cp, table->gpt_depth); in g_part_ctl_undo()
1533 g_access(cp, -1, -1, -1); in g_part_ctl_undo()
1537 table = gp->softc; in g_part_ctl_undo()
1543 * scheme-independent code. in g_part_ctl_undo()
1545 pp = cp->provider; in g_part_ctl_undo()
1546 g_part_geometry(table, cp, pp->mediasize / pp->sectorsize); in g_part_ctl_undo()
1557 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_ctl_undo()
1558 if (!entry->gpe_internal) in g_part_ctl_undo()
1559 g_part_new_provider(gp, table, entry); in g_part_ctl_undo()
1562 table->gpt_opened = 0; in g_part_ctl_undo()
1563 g_access(cp, -1, -1, -1); in g_part_ctl_undo()
1575 struct g_part_entry *entry; in g_part_wither() local
1579 table = gp->softc; in g_part_wither()
1581 gp->softc = NULL; in g_part_wither()
1582 while ((entry = LIST_FIRST(&table->gpt_entry)) != NULL) { in g_part_wither()
1583 LIST_REMOVE(entry, gpe_entry); in g_part_wither()
1584 pp = entry->gpe_pp; in g_part_wither()
1585 entry->gpe_pp = NULL; in g_part_wither()
1587 pp->private = NULL; in g_part_wither()
1590 g_free(entry); in g_part_wither()
1613 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s,%s)", __func__, mp->name, verb)); in g_part_ctlreq()
1702 for (i = 0; i < req->narg; i++) { in g_part_ctlreq()
1703 ap = &req->arg[i]; in g_part_ctlreq()
1705 switch (ap->name[0]) { in g_part_ctlreq()
1707 if (!strcmp(ap->name, "arg0")) { in g_part_ctlreq()
1711 if (!strcmp(ap->name, "attrib")) in g_part_ctlreq()
1715 if (!strcmp(ap->name, "bootcode")) in g_part_ctlreq()
1719 if (!strcmp(ap->name, "class")) in g_part_ctlreq()
1723 if (!strcmp(ap->name, "entries")) in g_part_ctlreq()
1727 if (!strcmp(ap->name, "flags")) in g_part_ctlreq()
1729 else if (!strcmp(ap->name, "force")) in g_part_ctlreq()
1733 if (!strcmp(ap->name, "index")) in g_part_ctlreq()
1737 if (!strcmp(ap->name, "label")) in g_part_ctlreq()
1741 if (!strcmp(ap->name, "output")) in g_part_ctlreq()
1745 if (!strcmp(ap->name, "scheme")) in g_part_ctlreq()
1747 else if (!strcmp(ap->name, "size")) in g_part_ctlreq()
1749 else if (!strcmp(ap->name, "start")) in g_part_ctlreq()
1751 else if (!strcmp(ap->name, "skip_dsn")) in g_part_ctlreq()
1755 if (!strcmp(ap->name, "type")) in g_part_ctlreq()
1759 if (!strcmp(ap->name, "verb")) in g_part_ctlreq()
1761 else if (!strcmp(ap->name, "version")) in g_part_ctlreq()
1766 gctl_error(req, "%d param '%s'", EINVAL, ap->name); in g_part_ctlreq()
1771 error = g_part_parm_str(req, ap->name, in g_part_ctlreq()
1775 error = g_part_parm_bootcode(req, ap->name, in g_part_ctlreq()
1779 error = g_part_parm_intmax(req, ap->name, in g_part_ctlreq()
1783 error = g_part_parm_str(req, ap->name, &gpp.gpp_flags); in g_part_ctlreq()
1786 error = g_part_parm_uint32(req, ap->name, in g_part_ctlreq()
1790 error = g_part_parm_geom(req, ap->name, &gpp.gpp_geom); in g_part_ctlreq()
1793 error = g_part_parm_intmax(req, ap->name, in g_part_ctlreq()
1797 error = g_part_parm_str(req, ap->name, &gpp.gpp_label); in g_part_ctlreq()
1800 error = 0; /* Write-only parameter */ in g_part_ctlreq()
1803 error = g_part_parm_provider(req, ap->name, in g_part_ctlreq()
1807 error = g_part_parm_scheme(req, ap->name, in g_part_ctlreq()
1811 error = g_part_parm_quad(req, ap->name, &gpp.gpp_size); in g_part_ctlreq()
1814 error = g_part_parm_uint32(req, ap->name, in g_part_ctlreq()
1818 error = g_part_parm_quad(req, ap->name, in g_part_ctlreq()
1822 error = g_part_parm_str(req, ap->name, &gpp.gpp_type); in g_part_ctlreq()
1825 error = g_part_parm_uint32(req, ap->name, in g_part_ctlreq()
1830 gctl_error(req, "%d %s", error, ap->name); in g_part_ctlreq()
1836 ap->name); in g_part_ctlreq()
1843 parm = mparms - (gpp.gpp_parms & mparms); in g_part_ctlreq()
1852 table = gpp.gpp_geom->softc; in g_part_ctlreq()
1853 if (table != NULL && table->gpt_corrupt && in g_part_ctlreq()
1858 EPERM, gpp.gpp_geom->name); in g_part_ctlreq()
1861 if (table != NULL && !table->gpt_opened) { in g_part_ctlreq()
1862 error = g_access(LIST_FIRST(&gpp.gpp_geom->consumer), in g_part_ctlreq()
1866 gpp.gpp_geom->name); in g_part_ctlreq()
1869 table->gpt_opened = 1; in g_part_ctlreq()
1878 gctl_error(req, "%d pre-check failed", error); in g_part_ctlreq()
1942 g_access(LIST_FIRST(&gpp.gpp_geom->consumer), -1, -1, -1); in g_part_ctlreq()
1943 table->gpt_opened = 0; in g_part_ctlreq()
1952 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s,%s)", __func__, mp->name, gp->name)); in g_part_destroy_geom()
1964 struct g_part_entry *entry; in g_part_taste() local
1970 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s,%s)", __func__, mp->name, pp->name)); in g_part_taste()
1974 if (pp->acw > 0) in g_part_taste()
1982 gp = g_new_geomf(mp, "%s", pp->name); in g_part_taste()
1984 cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; in g_part_taste()
1989 if (cp->provider) in g_part_taste()
1996 rht = root_mount_hold(mp->name); in g_part_taste()
2000 * Short-circuit the whole probing galore when there's no in g_part_taste()
2003 if (pp->mediasize == 0 || pp->sectorsize == 0) { in g_part_taste()
2021 table = gp->softc; in g_part_taste()
2027 * scheme-independent code. in g_part_taste()
2029 g_part_geometry(table, cp, pp->mediasize / pp->sectorsize); in g_part_taste()
2039 LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { in g_part_taste()
2040 if (!entry->gpe_internal) in g_part_taste()
2041 g_part_new_provider(gp, table, entry); in g_part_taste()
2045 g_access(cp, -1, 0, 0); in g_part_taste()
2051 g_access(cp, -1, 0, 0); in g_part_taste()
2067 G_PART_TRACE((G_T_ACCESS, "%s(%s,%d,%d,%d)", __func__, pp->name, dr, in g_part_access()
2070 cp = LIST_FIRST(&pp->geom->consumer); in g_part_access()
2072 /* We always gain write-exclusive access. */ in g_part_access()
2081 struct g_part_entry *entry; in g_part_dumpconf() local
2085 table = gp->softc; in g_part_dumpconf()
2089 entry = pp->private; in g_part_dumpconf()
2090 if (entry == NULL) in g_part_dumpconf()
2092 sbuf_printf(sb, " i %u o %ju ty %s", entry->gpe_index, in g_part_dumpconf()
2093 (uintmax_t)entry->gpe_offset, in g_part_dumpconf()
2094 G_PART_TYPE(table, entry, buf, sizeof(buf))); in g_part_dumpconf()
2096 * libdisk compatibility quirk - the scheme dumps the in g_part_dumpconf()
2097 * slicer name and partition type in a way that is in g_part_dumpconf()
2101 G_PART_DUMPCONF(table, entry, sb, indent); in g_part_dumpconf()
2106 entry = pp->private; in g_part_dumpconf()
2107 if (entry == NULL) in g_part_dumpconf()
2110 (uintmax_t)entry->gpe_start); in g_part_dumpconf()
2112 (uintmax_t)entry->gpe_end); in g_part_dumpconf()
2114 entry->gpe_index); in g_part_dumpconf()
2116 G_PART_TYPE(table, entry, buf, sizeof(buf))); in g_part_dumpconf()
2118 (uintmax_t)entry->gpe_offset); in g_part_dumpconf()
2120 (uintmax_t)pp->mediasize); in g_part_dumpconf()
2121 G_PART_DUMPCONF(table, entry, sb, indent); in g_part_dumpconf()
2124 table->gpt_scheme->name); in g_part_dumpconf()
2126 table->gpt_entries); in g_part_dumpconf()
2128 (uintmax_t)table->gpt_first); in g_part_dumpconf()
2130 (uintmax_t)table->gpt_last); in g_part_dumpconf()
2132 table->gpt_sectors); in g_part_dumpconf()
2134 table->gpt_heads); in g_part_dumpconf()
2136 table->gpt_corrupt ? "CORRUPT": "OK"); in g_part_dumpconf()
2138 table->gpt_opened ? "true": "false"); in g_part_dumpconf()
2143 /*-
2144 * This start routine is only called for non-trivial requests, all the
2147 * bio, and return non-zero to indicate to the slice code that we did so.
2158 table = pp->geom->softc; in g_part_ioctl()
2167 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, cp->provider->name)); in g_part_resize()
2173 table = cp->geom->softc; in g_part_resize()
2174 if (table->gpt_opened == 0) { in g_part_resize()
2177 table->gpt_opened = 1; in g_part_resize()
2182 "`gpart undo %s` to revert them.\n", cp->geom->name, in g_part_resize()
2183 cp->geom->name, cp->geom->name); in g_part_resize()
2185 g_access(cp, -1, -1, -1); in g_part_resize()
2186 table->gpt_opened = 0; in g_part_resize()
2187 g_part_wither(table->gpt_gp, ENXIO); in g_part_resize()
2197 pp = cp->provider; in g_part_orphan()
2199 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, pp->name)); in g_part_orphan()
2202 KASSERT(pp->error != 0, ("%s", __func__)); in g_part_orphan()
2203 table = cp->geom->softc; in g_part_orphan()
2204 if (table != NULL && table->gpt_opened) in g_part_orphan()
2205 g_access(cp, -1, -1, -1); in g_part_orphan()
2206 g_part_wither(cp->geom, pp->error); in g_part_orphan()
2213 G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, cp->provider->name)); in g_part_spoiled()
2216 cp->flags |= G_CF_ORPHAN; in g_part_spoiled()
2217 g_part_wither(cp->geom, ENXIO); in g_part_spoiled()
2226 struct g_part_entry *entry; in g_part_start() local
2235 pp = bp->bio_to; in g_part_start()
2236 gp = pp->geom; in g_part_start()
2237 table = gp->softc; in g_part_start()
2238 cp = LIST_FIRST(&gp->consumer); in g_part_start()
2240 G_PART_TRACE((G_T_BIO, "%s: cmd=%d, provider=%s", __func__, bp->bio_cmd, in g_part_start()
2241 pp->name)); in g_part_start()
2243 entry = pp->private; in g_part_start()
2244 if (entry == NULL) { in g_part_start()
2249 switch(bp->bio_cmd) { in g_part_start()
2253 if (bp->bio_offset >= pp->mediasize) { in g_part_start()
2262 if (bp2->bio_offset + bp2->bio_length > pp->mediasize) in g_part_start()
2263 bp2->bio_length = pp->mediasize - bp2->bio_offset; in g_part_start()
2264 bp2->bio_done = g_std_done; in g_part_start()
2265 bp2->bio_offset += entry->gpe_offset; in g_part_start()
2272 if (g_handleattr_int(bp, "GEOM::fwheads", table->gpt_heads)) in g_part_start()
2274 if (g_handleattr_int(bp, "GEOM::fwsectors", table->gpt_sectors)) in g_part_start()
2281 table->gpt_isleaf && in g_part_start()
2282 (allow_nesting == 0 || entry->gpe_offset == 0))) in g_part_start()
2284 if (g_handleattr_int(bp, "PART::depth", table->gpt_depth)) in g_part_start()
2287 table->gpt_scheme->name)) in g_part_start()
2290 G_PART_TYPE(table, entry, buf, sizeof(buf)))) in g_part_start()
2292 if (!strcmp("GEOM::physpath", bp->bio_attribute)) { in g_part_start()
2296 if (!strcmp("GEOM::kerneldump", bp->bio_attribute)) { in g_part_start()
2303 if ((bp->bio_from == NULL || in g_part_start()
2304 bp->bio_from->geom->class != &g_part_class) && in g_part_start()
2305 G_PART_DUMPTO(table, entry) == 0) { in g_part_start()
2309 pp->name); in g_part_start()
2312 gkd = (struct g_kerneldump *)bp->bio_data; in g_part_start()
2313 if (gkd->offset >= pp->mediasize) { in g_part_start()
2317 if (gkd->offset + gkd->length > pp->mediasize) in g_part_start()
2318 gkd->length = pp->mediasize - gkd->offset; in g_part_start()
2319 gkd->offset += entry->gpe_offset; in g_part_start()
2332 bp2->bio_done = done_func; in g_part_start()
2371 table = gp->softc; in g_part_unload_event()
2372 if (table->gpt_scheme != scheme) in g_part_unload_event()
2376 LIST_FOREACH(pp, &gp->provider, provider) in g_part_unload_event()
2377 acc += pp->acr + pp->acw + pp->ace; in g_part_unload_event()
2378 LIST_FOREACH(cp, &gp->consumer, consumer) in g_part_unload_event()
2379 acc += cp->acr + cp->acw + cp->ace; in g_part_unload_event()
2406 "registered!\n", scheme->name); in g_part_modevent()