Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sysinst Avoid using the global "pm" variable in uti...
details: https://anonhg.NetBSD.org/src/rev/be1b0ead859d
branches: trunk
changeset: 848051:be1b0ead859d
user: martin <martin%NetBSD.org@localhost>
date: Wed Jan 15 19:37:41 2020 +0000
description:
Avoid using the global "pm" variable in utility functions - during
extended partitioning they may point to a different device.
diffstat:
usr.sbin/sysinst/label.c | 34 +++++++++++++++++++---------------
1 files changed, 19 insertions(+), 15 deletions(-)
diffs (108 lines):
diff -r fd5e3639b785 -r be1b0ead859d usr.sbin/sysinst/label.c
--- a/usr.sbin/sysinst/label.c Wed Jan 15 19:36:30 2020 +0000
+++ b/usr.sbin/sysinst/label.c Wed Jan 15 19:37:41 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.18 2020/01/09 13:22:30 martin Exp $ */
+/* $NetBSD: label.c,v 1.19 2020/01/15 19:37:41 martin Exp $ */
/*
* Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.18 2020/01/09 13:22:30 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.19 2020/01/15 19:37:41 martin Exp $");
#endif
#include <sys/types.h>
@@ -1983,14 +1983,16 @@
i = min;
localsizemult = 1;
} else {
- i = parse_disk_pos(isize, &localsizemult, pm->dlcylsize, NULL);
+ i = parse_disk_pos(isize, &localsizemult,
+ parts->pscheme->get_cylinder_size(parts), NULL);
if (i < 0) {
errmsg = msg_string(MSG_invalid_sector_number);
continue;
}
}
/* round to cylinder size if localsizemult != 1 */
- i = NUMSEC(i, localsizemult, pm->dlcylsize);
+ int cylsize = parts->pscheme->get_cylinder_size(parts);
+ i = NUMSEC(i, localsizemult, cylsize);
/* Adjust to start of slice if needed */
if ((i < min && (min - i) < localsizemult) ||
(i > min && (i - min) < localsizemult)) {
@@ -2014,10 +2016,11 @@
char dsize[24], isize[24], max_size[24], maxpartc, valid_parts[4],
*label_msg, *prompt, *head, *hint, *tail;
const char *errmsg = NULL;
- daddr_t i, partend, localsizemult, max, max_r, dflt_r;
+ daddr_t i, partend, diskend, localsizemult, max, max_r, dflt_r;
struct disk_part_info info;
part_id partn;
+ diskend = parts->disk_start + parts->disk_size;
max = parts->pscheme->max_free_space_at(parts, partstart);
/* We need to keep both the unrounded and rounded (_r) max and dflt */
@@ -2092,7 +2095,7 @@
max_r = max;
} else {
i = parse_disk_pos(isize, &localsizemult,
- pm->dlcylsize, NULL);
+ parts->pscheme->get_cylinder_size(parts), NULL);
if (localsizemult != sizemult)
max_r = max;
}
@@ -2107,18 +2110,19 @@
* partend is aligned to a cylinder if localsizemult
* is not 1 sector
*/
+ int cylsize = parts->pscheme->get_cylinder_size(parts);
partend = NUMSEC((partstart + i*localsizemult) / localsizemult,
- localsizemult, pm->dlcylsize);
+ localsizemult, cylsize);
/* Align to end-of-disk or end-of-slice if close enough */
- if (partend > (pm->dlsize - sizemult)
- && partend < (pm->dlsize + sizemult))
- partend = pm->dlsize;
+ if (partend > (diskend - sizemult)
+ && partend < (diskend + sizemult))
+ partend = diskend;
if (partend > (partstart + max - sizemult)
&& partend < (partstart + max + sizemult))
partend = partstart + max;
/* sanity checks */
- if (partend > (partstart + pm->dlsize)) {
- partend = pm->dlsize;
+ if (partend > diskend) {
+ partend = diskend;
errmsg = msg_string(MSG_endoutsidedisk);
continue;
}
@@ -2161,19 +2165,19 @@
if (*cp == 'G' || *cp == 'g') {
if (mult_found)
return -1;
- *localsizemult = GIG / pm->sectorsize;
+ *localsizemult = GIG / 512;
goto next;
}
if (*cp == 'M' || *cp == 'm') {
if (mult_found)
return -1;
- *localsizemult = MEG / pm->sectorsize;
+ *localsizemult = MEG / 512;
goto next;
}
if (*cp == 'c' || *cp == 'C') {
if (mult_found)
return -1;
- *localsizemult = pm->dlcylsize;
+ *localsizemult = cyl_size;
goto next;
}
if (*cp == 's' || *cp == 'S') {
Home |
Main Index |
Thread Index |
Old Index