Lines Matching refs:lp

171 void	psize(u_int64_t sz, char unit, const struct disklabel *lp);
556 allocate_diskchunk(const struct disklabel *lp, in allocate_diskchunk() argument
565 chunk = free_chunks(lp, -1); in allocate_diskchunk()
570 maxstop = largest.start + DL_BLKTOSEC(lp, sa->maxsz); in allocate_diskchunk()
574 if (lp->d_flags & D_VENDOR) { in allocate_diskchunk()
575 largest.start = ROUNDUP(largest.start, lp->d_secpercyl); in allocate_diskchunk()
576 maxstop = ROUNDUP(maxstop, lp->d_secpercyl); in allocate_diskchunk()
578 maxstop -= lp->d_secpercyl; in allocate_diskchunk()
585 if (CHUNKSZ(&largest) < DL_BLKTOSEC(lp, sa->minsz)) in allocate_diskchunk()
592 allocate_partition(struct disklabel *lp, struct space_allocation *sa) in allocate_partition() argument
598 for (partno = 0; partno < nitems(lp->d_partitions); partno++) { in allocate_partition()
601 pp = &lp->d_partitions[partno]; in allocate_partition()
605 if (partno >= nitems(lp->d_partitions)) in allocate_partition()
609 chunk = allocate_diskchunk(lp, sa); in allocate_partition()
629 if (set_fragblock(lp, partno)) in allocate_partition()
657 allocate_space(struct disklabel *lp, const struct alloc_table *alloc_table) in allocate_space() argument
663 xtrablks = DL_SECTOBLK(lp, editor_countfree(lp)); in allocate_space()
675 for (i = lp->d_npartitions; i < MAXPARTITIONS; i++) { in allocate_space()
678 memset(&lp->d_partitions[i], 0, sizeof(lp->d_partitions[i])); in allocate_space()
680 lp->d_npartitions = MAXPARTITIONS; in allocate_space()
690 if (allocate_partition(lp, &sa[i])) { in allocate_space()
703 editor_resize(struct disklabel *lp, const char *p) in editor_resize() argument
710 label = *lp; in editor_resize()
722 ui = getuint64(lp, "[+|-]new size (with unit)", in editor_resize()
724 "unit", sz, sz + editor_countfree(lp), &flags); in editor_resize()
736 if (lp->d_flags & D_VENDOR) in editor_resize()
737 ui = ROUNDUP(ui, lp->d_secpercyl); in editor_resize()
787 *lp = label; in editor_resize()
794 editor_add(struct disklabel *lp, const char *p) in editor_add() argument
801 chunk = free_chunks(lp, -1); in editor_add()
811 if ((lp->d_flags & D_VENDOR) && new_size < lp->d_secpercyl) { in editor_add()
824 if ((partno = getpartno(lp, p, "add")) == -1) in editor_add()
826 pp = &lp->d_partitions[partno]; in editor_add()
833 for(; lp->d_npartitions <= partno; lp->d_npartitions++) in editor_add()
834 memset(&lp->d_partitions[lp->d_npartitions], 0, sizeof(*pp)); in editor_add()
840 if (get_offset(lp, partno) == 0 && in editor_add()
841 get_size(lp, partno) == 0 && in editor_add()
842 get_fstype(lp, partno) == 0 && in editor_add()
843 get_mp(lp, partno) == 0 && in editor_add()
844 set_fragblock(lp, partno) == 0) in editor_add()
855 editor_name(const struct disklabel *lp, const char *p) in editor_name() argument
859 if ((partno = getpartno(lp, p, "name")) == -1) in editor_name()
862 get_mp(lp, partno); in editor_name()
869 editor_modify(struct disklabel *lp, const char *p) in editor_modify() argument
874 if ((partno = getpartno(lp, p, "modify")) == -1) in editor_modify()
877 pp = &lp->d_partitions[partno]; in editor_modify()
880 if (get_offset(lp, partno) == 0 && in editor_modify()
881 get_size(lp, partno) == 0 && in editor_modify()
882 get_fstype(lp, partno) == 0 && in editor_modify()
883 get_mp(lp, partno) == 0 && in editor_modify()
884 set_fragblock(lp, partno) == 0) in editor_modify()
895 editor_delete(struct disklabel *lp, const char *p) in editor_delete() argument
900 if ((partno = getpartno(lp, p, "delete")) == -1) in editor_delete()
902 if (partno == lp->d_npartitions) { in editor_delete()
903 zero_partitions(lp); in editor_delete()
906 pp = &lp->d_partitions[partno]; in editor_delete()
918 editor_change(struct disklabel *lp, const char *p) in editor_change() argument
923 if ((partno = getpartno(lp, p, "change size")) == -1) in editor_change()
926 pp = &lp->d_partitions[partno]; in editor_change()
929 'a' + partno, DL_GETPSIZE(pp), max_partition_size(lp, partno)); in editor_change()
932 get_size(lp, partno); in editor_change()
986 getpartno(const struct disklabel *lp, const char *p, const char *action) in getpartno() argument
1000 maxpart = 'a' - 1 + (add ? MAXPARTITIONS : lp->d_npartitions); in getpartno()
1014 pp = &lp->d_partitions[partno]; in getpartno()
1015 if (partno >= lp->d_npartitions || in getpartno()
1032 return lp->d_npartitions; in getpartno()
1040 pp = &lp->d_partitions[partno]; in getpartno()
1041 inuse = partno < lp->d_npartitions && DL_GETPSIZE(pp) > 0 && in getpartno()
1095 getuint64(const struct disklabel *lp, char *prompt, char *helpstring, in getuint64() argument
1127 rval = d / lp->d_secsize; in getuint64()
1130 rval = d * lp->d_secpercyl; in getuint64()
1133 rval = DL_GETDSIZE(lp) * (d / 100.0); in getuint64()
1141 rval = DL_BLKTOSEC(lp, rval); in getuint64()
1166 if (lp->d_flags & D_VENDOR) in getuint64()
1182 has_overlap(struct disklabel *lp) in has_overlap() argument
1191 spp = sort_partitions(lp, -1); in has_overlap()
1202 p1 = 'a' + (spp[i] - lp->d_partitions); in has_overlap()
1203 p2 = 'a' + (spp[i+1] - lp->d_partitions); in has_overlap()
1207 display_partition(stdout, lp, p1 - 'a', 0); in has_overlap()
1208 display_partition(stdout, lp, p2 - 'a', 0); in has_overlap()
1218 lp->d_partitions[line[0] - 'a'].p_fstype = FS_UNUSED; in has_overlap()
1228 edit_packname(struct disklabel *lp) in edit_packname() argument
1231 struct disklabel oldlabel = *lp; in edit_packname()
1238 lp->d_packname); in edit_packname()
1240 *lp = oldlabel; /* undo damage */ in edit_packname()
1243 strncpy(lp->d_packname, p, sizeof(lp->d_packname)); /* checked */ in edit_packname()
1247 sort_partitions(const struct disklabel *lp, int ignore) in sort_partitions() argument
1254 for (npartitions = 0, i = 0; i < lp->d_npartitions; i++) { in sort_partitions()
1255 if (i != ignore && lp->d_partitions[i].p_fstype != FS_UNUSED && in sort_partitions()
1256 DL_GETPSIZE(&lp->d_partitions[i]) != 0) in sort_partitions()
1257 spp[npartitions++] = &lp->d_partitions[i]; in sort_partitions()
1277 set_bounds(struct disklabel *lp) in set_bounds() argument
1283 ui = getuint64(lp, "Starting sector", in set_bounds()
1285 starting_sector, DL_GETDSIZE(lp), NULL); in set_bounds()
1290 else if (ui >= DL_GETDSIZE(lp)) in set_bounds()
1292 DL_GETDSIZE(lp)); in set_bounds()
1300 ui = getuint64(lp, "Size ('*' for entire disk)", in set_bounds()
1303 DL_GETDSIZE(lp) - start_temp, NULL); in set_bounds()
1308 else if (ui > DL_GETDSIZE(lp) - start_temp) in set_bounds()
1310 DL_GETDSIZE(lp) - start_temp); in set_bounds()
1315 DL_SETBEND(lp, ending_sector); in set_bounds()
1317 DL_SETBSTART(lp, starting_sector); in set_bounds()
1324 set_duid(struct disklabel *lp) in set_duid() argument
1331 lp->d_uid[0], lp->d_uid[1], lp->d_uid[2], lp->d_uid[3], in set_duid()
1332 lp->d_uid[4], lp->d_uid[5], lp->d_uid[6], lp->d_uid[7]); in set_duid()
1341 i = duid_parse(lp, s); in set_duid()
1351 free_chunks(const struct disklabel *lp, int partno) in free_chunks() argument
1359 spp = sort_partitions(lp, partno); in free_chunks()
1403 find_bounds(const struct disklabel *lp) in find_bounds() argument
1405 starting_sector = DL_GETBSTART(lp); in find_bounds()
1406 ending_sector = DL_GETBEND(lp); in find_bounds()
1421 editor_countfree(const struct disklabel *lp) in editor_countfree() argument
1426 chunk = free_chunks(lp, -1); in editor_countfree()
1493 mpsave(const struct disklabel *lp) in mpsave() argument
1507 fstype = lp->d_partitions[i].p_fstype; in mpsave()
1540 fstype = lp->d_partitions[j].p_fstype; in mpsave()
1575 get_offset(struct disklabel *lp, int partno) in get_offset() argument
1577 struct partition opp, *pp = &lp->d_partitions[partno]; in get_offset()
1582 ui = getuint64(lp, "offset", in get_offset()
1600 offsetalign = lp->d_secpercyl; in get_offset()
1602 if (alignpartition(lp, partno, offsetalign, 1, ROUND_OFFSET_UP) == 1) { in get_offset()
1611 get_size(struct disklabel *lp, int partno) in get_size() argument
1613 struct partition opp, *pp = &lp->d_partitions[partno]; in get_size()
1617 maxsize = max_partition_size(lp, partno); in get_size()
1619 ui = getuint64(lp, "size", "Size of the partition. " in get_size()
1631 sizealign = lp->d_secpercyl; in get_size()
1633 if (alignpartition(lp, partno, 1, sizealign, ROUND_SIZE_UP) == 1) { in get_size()
1642 set_fragblock(struct disklabel *lp, int partno) in set_fragblock() argument
1644 struct partition opp, *pp = &lp->d_partitions[partno]; in set_fragblock()
1659 bytes = DL_GETPSIZE(pp) * lp->d_secsize; in set_fragblock()
1664 if (fsize < lp->d_secsize) in set_fragblock()
1665 fsize = lp->d_secsize; in set_fragblock()
1675 DISKLABELV1_FFS_FSIZE(pp->p_fragblock)) / lp->d_secsize; in set_fragblock()
1680 if (alignpartition(lp, partno, offsetalign, sizealign, ROUND_OFFSET_UP | in set_fragblock()
1690 get_fstype(struct disklabel *lp, int partno) in get_fstype() argument
1694 struct partition *pp = &lp->d_partitions[partno]; in get_fstype()
1733 get_mp(const struct disklabel *lp, int partno) in get_mp() argument
1735 const struct partition *pp = &lp->d_partitions[partno]; in get_mp()
1800 zero_partitions(struct disklabel *lp) in zero_partitions() argument
1802 memset(lp->d_partitions, 0, sizeof(lp->d_partitions)); in zero_partitions()
1803 DL_SETPSIZE(&lp->d_partitions[RAW_PART], DL_GETDSIZE(lp)); in zero_partitions()
1809 max_partition_size(const struct disklabel *lp, int partno) in max_partition_size() argument
1814 chunk = free_chunks(lp, partno); in max_partition_size()
1816 offset = DL_GETPOFFSET(&lp->d_partitions[partno]); in max_partition_size()
1827 psize(u_int64_t sz, char unit, const struct disklabel *lp) in psize() argument
1829 double d = scale(sz, unit, lp); in psize()
1837 display_edit(const struct disklabel *lp, char unit) in display_edit() argument
1842 fr = editor_countfree(lp); in display_edit()
1843 unit = canonical_unit(lp, unit); in display_edit()
1846 psize(starting_sector, 0, lp); in display_edit()
1848 psize(ending_sector, 0, lp); in display_edit()
1850 psize(ending_sector - starting_sector, unit, lp); in display_edit()
1852 psize(fr, unit, lp); in display_edit()
1856 for (i = 0; i < lp->d_npartitions; i++) in display_edit()
1857 display_partition(stdout, lp, i, unit); in display_edit()
2032 alignpartition(struct disklabel *lp, int partno, u_int64_t startalign, in alignpartition() argument
2035 struct partition *pp = &lp->d_partitions[partno]; in alignpartition()
2046 chunk = free_chunks(lp, partno); in alignpartition()