summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2021-07-12 14:06:20 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2021-07-12 14:06:20 +0000
commit317652d7642cfae08f8064ab198360267a4b5e9c (patch)
tree05177db36aff6adde81b4a67565f52650383e849 /sbin
parent214291e760434e1b038322228f08e164ce99c063 (diff)
Add 'dk_' prefix to struct disk field names.
No functional change.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/cmd.c34
-rw-r--r--sbin/fdisk/disk.c54
-rw-r--r--sbin/fdisk/disk.h14
-rw-r--r--sbin/fdisk/fdisk.c34
-rw-r--r--sbin/fdisk/gpt.c18
-rw-r--r--sbin/fdisk/mbr.c14
-rw-r--r--sbin/fdisk/misc.c4
-rw-r--r--sbin/fdisk/part.c10
-rw-r--r--sbin/fdisk/user.c4
9 files changed, 93 insertions, 93 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 1ab8065913c..695d0948491 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.123 2021/07/11 20:51:50 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.124 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -101,14 +101,14 @@ Xdisk(char *args, struct mbr *mbr)
/* Ask for new info */
if (ask_yn("Change disk geometry?")) {
- disk.cylinders = ask_num("BIOS Cylinders",
- disk.cylinders, 1, maxcyl);
- disk.heads = ask_num("BIOS Heads",
- disk.heads, 1, maxhead);
- disk.sectors = ask_num("BIOS Sectors",
- disk.sectors, 1, maxsec);
-
- disk.size = disk.cylinders * disk.heads * disk.sectors;
+ disk.dk_cylinders = ask_num("BIOS Cylinders",
+ disk.dk_cylinders, 1, maxcyl);
+ disk.dk_heads = ask_num("BIOS Heads",
+ disk.dk_heads, 1, maxhead);
+ disk.dk_sectors = ask_num("BIOS Sectors",
+ disk.dk_sectors, 1, maxsec);
+
+ disk.dk_size = disk.dk_cylinders * disk.dk_heads * disk.dk_sectors;
}
return CMD_CONT;
@@ -251,28 +251,28 @@ edit(int pn, struct mbr *mbr)
if (ask_yn("Do you wish to edit in CHS mode?")) {
pp->prt_scyl = ask_num("BIOS Starting cylinder", pp->prt_scyl, 0,
- disk.cylinders - 1);
+ disk.dk_cylinders - 1);
pp->prt_shead = ask_num("BIOS Starting head", pp->prt_shead, 0,
- disk.heads - 1);
+ disk.dk_heads - 1);
pp->prt_ssect = ask_num("BIOS Starting sector", pp->prt_ssect, 1,
- disk.sectors);
+ disk.dk_sectors);
pp->prt_ecyl = ask_num("BIOS Ending cylinder", pp->prt_ecyl,
- pp->prt_scyl, disk.cylinders - 1);
+ pp->prt_scyl, disk.dk_cylinders - 1);
pp->prt_ehead = ask_num("BIOS Ending head", pp->prt_ehead,
- (pp->prt_scyl == pp->prt_ecyl) ? pp->prt_shead : 0, disk.heads - 1);
+ (pp->prt_scyl == pp->prt_ecyl) ? pp->prt_shead : 0, disk.dk_heads - 1);
pp->prt_esect = ask_num("BIOS Ending sector", pp->prt_esect,
(pp->prt_scyl == pp->prt_ecyl && pp->prt_shead == pp->prt_ehead) ? pp->prt_ssect
- : 1, disk.sectors);
+ : 1, disk.dk_sectors);
/* Fix up off/size values */
PRT_fix_BN(pp, pn);
/* Fix up CHS values for LBA */
PRT_fix_CHS(pp);
} else {
- pp->prt_bs = getuint64("Partition offset", pp->prt_bs, 0, disk.size - 1);
+ pp->prt_bs = getuint64("Partition offset", pp->prt_bs, 0, disk.dk_size - 1);
pp->prt_ns = getuint64("Partition size", pp->prt_ns, 1,
- disk.size - pp->prt_bs);
+ disk.dk_size - pp->prt_bs);
/* Fix up CHS values */
PRT_fix_CHS(pp);
diff --git a/sbin/fdisk/disk.c b/sbin/fdisk/disk.c
index d06810e8eef..77206aa6ae5 100644
--- a/sbin/fdisk/disk.c
+++ b/sbin/fdisk/disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.c,v 1.59 2021/07/11 13:38:27 krw Exp $ */
+/* $OpenBSD: disk.c,v 1.60 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -43,38 +43,38 @@ DISK_open(int rw)
struct stat st;
uint64_t sz, spc;
- disk.fd = opendev(disk.name, rw ? O_RDWR : O_RDONLY, OPENDEV_PART,
+ disk.dk_fd = opendev(disk.dk_name, rw ? O_RDWR : O_RDONLY, OPENDEV_PART,
NULL);
- if (disk.fd == -1)
- err(1, "%s", disk.name);
- if (fstat(disk.fd, &st) == -1)
- err(1, "%s", disk.name);
+ if (disk.dk_fd == -1)
+ err(1, "%s", disk.dk_name);
+ if (fstat(disk.dk_fd, &st) == -1)
+ err(1, "%s", disk.dk_name);
if (!S_ISCHR(st.st_mode))
- errx(1, "%s is not a character device", disk.name);
+ errx(1, "%s is not a character device", disk.dk_name);
/* Get label geometry. */
- if (ioctl(disk.fd, DIOCGPDINFO, &dl) == -1) {
+ if (ioctl(disk.dk_fd, DIOCGPDINFO, &dl) == -1) {
warn("DIOCGPDINFO");
} else {
unit_types[SECTORS].conversion = dl.d_secsize;
- if (disk.size == 0) {
+ if (disk.dk_size == 0) {
/* -l or -c/-h/-s not used. Use disklabel info. */
- disk.cylinders = dl.d_ncylinders;
- disk.heads = dl.d_ntracks;
- disk.sectors = dl.d_nsectors;
+ disk.dk_cylinders = dl.d_ncylinders;
+ disk.dk_heads = dl.d_ntracks;
+ disk.dk_sectors = dl.d_nsectors;
/* MBR handles only first UINT32_MAX sectors. */
- spc = (uint64_t)disk.heads * disk.sectors;
+ spc = (uint64_t)disk.dk_heads * disk.dk_sectors;
sz = DL_GETDSIZE(&dl);
if (sz > UINT32_MAX) {
- disk.cylinders = UINT32_MAX / spc;
- disk.size = disk.cylinders * spc;
+ disk.dk_cylinders = UINT32_MAX / spc;
+ disk.dk_size = disk.dk_cylinders * spc;
} else
- disk.size = sz;
+ disk.dk_size = sz;
}
}
- if (disk.size == 0 || disk.cylinders == 0 || disk.heads == 0 ||
- disk.sectors == 0 || unit_types[SECTORS].conversion == 0)
+ if (disk.dk_size == 0 || disk.dk_cylinders == 0 || disk.dk_heads == 0 ||
+ disk.dk_sectors == 0 || unit_types[SECTORS].conversion == 0)
errx(1, "Can't get disk geometry, please use [-chs] or [-l]"
"to specify.");
}
@@ -91,11 +91,11 @@ DISK_printgeometry(char *units)
int i;
i = unit_lookup(units);
- size = ((double)disk.size * secsize) / unit_types[i].conversion;
- printf("Disk: %s\t", disk.name);
- if (disk.size) {
- printf("geometry: %d/%d/%d [%.0f ", disk.cylinders,
- disk.heads, disk.sectors, size);
+ size = ((double)disk.dk_size * secsize) / unit_types[i].conversion;
+ printf("Disk: %s\t", disk.dk_name);
+ if (disk.dk_size) {
+ printf("geometry: %d/%d/%d [%.0f ", disk.dk_cylinders,
+ disk.dk_heads, disk.dk_sectors, size);
if (i == SECTORS && secsize != sizeof(struct dos_mbr))
printf("%d-byte ", secsize);
printf("%s]\n", unit_types[i].lname);
@@ -123,7 +123,7 @@ DISK_readsector(off_t where)
secsize = dl.d_secsize;
where *= secsize;
- off = lseek(disk.fd, where, SEEK_SET);
+ off = lseek(disk.dk_fd, where, SEEK_SET);
if (off != where)
return NULL;
@@ -131,7 +131,7 @@ DISK_readsector(off_t where)
if (secbuf == NULL)
return NULL;
- len = read(disk.fd, secbuf, secsize);
+ len = read(disk.dk_fd, secbuf, secsize);
if (len == -1 || len != secsize) {
free(secbuf);
return NULL;
@@ -156,9 +156,9 @@ DISK_writesector(char *secbuf, off_t where)
secsize = dl.d_secsize;
where *= secsize;
- off = lseek(disk.fd, where, SEEK_SET);
+ off = lseek(disk.dk_fd, where, SEEK_SET);
if (off == where)
- len = write(disk.fd, secbuf, secsize);
+ len = write(disk.dk_fd, secbuf, secsize);
if (len == -1 || len != secsize) {
/* short read or write */
diff --git a/sbin/fdisk/disk.h b/sbin/fdisk/disk.h
index 77442987d21..cb5267fd594 100644
--- a/sbin/fdisk/disk.h
+++ b/sbin/fdisk/disk.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.h,v 1.24 2021/07/11 13:23:18 krw Exp $ */
+/* $OpenBSD: disk.h,v 1.25 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -20,12 +20,12 @@
#define _DISK_H
struct disk {
- char *name;
- int fd;
- uint32_t cylinders;
- uint32_t heads;
- uint32_t sectors;
- uint32_t size;
+ char *dk_name;
+ int dk_fd;
+ uint32_t dk_cylinders;
+ uint32_t dk_heads;
+ uint32_t dk_sectors;
+ uint32_t dk_size;
};
/* Align partition starts/sizes on 32K-byte boundaries. */
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 66631802887..21670d08aaa 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdisk.c,v 1.118 2021/07/11 19:43:19 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.119 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -103,22 +103,22 @@ main(int argc, char *argv[])
if (errstr)
errx(1, "Cylinder argument %s [1..262144].",
errstr);
- disk.cylinders = c_arg;
- disk.size = c_arg * h_arg * s_arg;
+ disk.dk_cylinders = c_arg;
+ disk.dk_size = c_arg * h_arg * s_arg;
break;
case 'h':
h_arg = strtonum(optarg, 1, 256, &errstr);
if (errstr)
errx(1, "Head argument %s [1..256].", errstr);
- disk.heads = h_arg;
- disk.size = c_arg * h_arg * s_arg;
+ disk.dk_heads = h_arg;
+ disk.dk_size = c_arg * h_arg * s_arg;
break;
case 's':
s_arg = strtonum(optarg, 1, 63, &errstr);
if (errstr)
errx(1, "Sector argument %s [1..63].", errstr);
- disk.sectors = s_arg;
- disk.size = c_arg * h_arg * s_arg;
+ disk.dk_sectors = s_arg;
+ disk.dk_size = c_arg * h_arg * s_arg;
break;
case 'g':
g_flag = 1;
@@ -131,10 +131,10 @@ main(int argc, char *argv[])
if (errstr)
errx(1, "Block argument %s [%u..%u].", errstr,
BLOCKALIGNMENT, UINT32_MAX);
- disk.cylinders = l_arg / BLOCKALIGNMENT;
- disk.heads = 1;
- disk.sectors = BLOCKALIGNMENT;
- disk.size = l_arg;
+ disk.dk_cylinders = l_arg / BLOCKALIGNMENT;
+ disk.dk_heads = 1;
+ disk.dk_sectors = BLOCKALIGNMENT;
+ disk.dk_size = l_arg;
break;
case 'y':
y_flag = 1;
@@ -157,7 +157,7 @@ main(int argc, char *argv[])
((c_arg | h_arg | s_arg) && l_arg))
usage();
- disk.name = argv[0];
+ disk.dk_name = argv[0];
DISK_open(A_flag || i_flag || u_flag || e_flag);
bps = DL_BLKSPERSEC(&dl);
if (b_sectors > 0) {
@@ -172,10 +172,10 @@ main(int argc, char *argv[])
if (l_arg % bps != 0)
l_arg += bps - l_arg % bps;
l_arg = DL_BLKTOSEC(&dl, l_arg);
- disk.cylinders = l_arg / BLOCKALIGNMENT;
- disk.heads = 1;
- disk.sectors = BLOCKALIGNMENT;
- disk.size = l_arg;
+ disk.dk_cylinders = l_arg / BLOCKALIGNMENT;
+ disk.dk_heads = 1;
+ disk.dk_sectors = BLOCKALIGNMENT;
+ disk.dk_size = l_arg;
}
/* "proc exec" for man page display */
@@ -252,7 +252,7 @@ main(int argc, char *argv[])
USER_edit(0, 0);
done:
- close(disk.fd);
+ close(disk.dk_fd);
return 0;
}
diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c
index cd36d06ea35..44aa6cac1b2 100644
--- a/sbin/fdisk/gpt.c
+++ b/sbin/fdisk/gpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gpt.c,v 1.37 2021/07/11 13:51:42 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.38 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
@@ -179,13 +179,13 @@ get_partition_table(void)
memset(&gp, 0, sizeof(gp));
where = letoh64(gh.gh_part_lba) * dl.d_secsize;
- off = lseek(disk.fd, where, SEEK_SET);
+ off = lseek(disk.dk_fd, where, SEEK_SET);
if (off == -1) {
DPRINTF("seek to gpt partition table @ sector %llu failed\n",
(unsigned long long)where / dl.d_secsize);
return 1;
}
- len = read(disk.fd, &gp, secs * dl.d_secsize);
+ len = read(disk.dk_fd, &gp, secs * dl.d_secsize);
if (len == -1 || len != secs * dl.d_secsize) {
DPRINTF("gpt partition table read failed.\n");
return 1;
@@ -245,7 +245,7 @@ GPT_print(char *units, int verbosity)
u = unit_lookup(units);
size = ((double)DL_GETDSIZE(&dl) * secsize) / unit_types[u].conversion;
printf("Disk: %s Usable LBA: %llu to %llu [%.0f ",
- disk.name, letoh64(gh.gh_lba_start), letoh64(gh.gh_lba_end), size);
+ disk.dk_name, letoh64(gh.gh_lba_start), letoh64(gh.gh_lba_end), size);
if (u == SECTORS && secsize != DEV_BSIZE)
printf("%d-byte ", secsize);
@@ -536,9 +536,9 @@ GPT_write(void)
DISK_writesector(secbuf, altgh);
free(secbuf);
- off = lseek(disk.fd, secsize * prigp, SEEK_SET);
+ off = lseek(disk.dk_fd, secsize * prigp, SEEK_SET);
if (off == secsize * prigp)
- len = write(disk.fd, &gp, gpbytes);
+ len = write(disk.dk_fd, &gp, gpbytes);
else
len = -1;
if (len == -1 || len != gpbytes) {
@@ -546,9 +546,9 @@ GPT_write(void)
return -1;
}
- off = lseek(disk.fd, secsize * altgp, SEEK_SET);
+ off = lseek(disk.dk_fd, secsize * altgp, SEEK_SET);
if (off == secsize * altgp)
- len = write(disk.fd, &gp, gpbytes);
+ len = write(disk.dk_fd, &gp, gpbytes);
else
len = -1;
@@ -558,7 +558,7 @@ GPT_write(void)
}
/* Refresh in-kernel disklabel from the updated disk information. */
- ioctl(disk.fd, DIOCRLDINFO, 0);
+ ioctl(disk.dk_fd, DIOCRLDINFO, 0);
return 0;
}
diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c
index 956d272bca7..e4ada994bb3 100644
--- a/sbin/fdisk/mbr.c
+++ b/sbin/fdisk/mbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbr.c,v 1.82 2021/07/11 20:51:50 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.83 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -99,20 +99,20 @@ MBR_init(struct mbr *mbr)
/* Use whole disk. Reserve first track, or first cyl, if possible. */
mbr->mbr_prt[3].prt_id = DOSPTYP_OPENBSD;
- if (disk.heads > 1)
+ if (disk.dk_heads > 1)
mbr->mbr_prt[3].prt_shead = 1;
else
mbr->mbr_prt[3].prt_shead = 0;
- if (disk.heads < 2 && disk.cylinders > 1)
+ if (disk.dk_heads < 2 && disk.dk_cylinders > 1)
mbr->mbr_prt[3].prt_scyl = 1;
else
mbr->mbr_prt[3].prt_scyl = 0;
mbr->mbr_prt[3].prt_ssect = 1;
/* Go right to the end */
- mbr->mbr_prt[3].prt_ecyl = disk.cylinders - 1;
- mbr->mbr_prt[3].prt_ehead = disk.heads - 1;
- mbr->mbr_prt[3].prt_esect = disk.sectors;
+ mbr->mbr_prt[3].prt_ecyl = disk.dk_cylinders - 1;
+ mbr->mbr_prt[3].prt_ehead = disk.dk_heads - 1;
+ mbr->mbr_prt[3].prt_esect = disk.dk_sectors;
/* Fix up start/length fields */
PRT_fix_BN(&mbr->mbr_prt[3], 3);
@@ -241,7 +241,7 @@ MBR_write(off_t where, struct dos_mbr *dos_mbr)
DISK_writesector(secbuf, where);
/* Refresh in-kernel disklabel from the updated disk information. */
- ioctl(disk.fd, DIOCRLDINFO, 0);
+ ioctl(disk.dk_fd, DIOCRLDINFO, 0);
free(secbuf);
diff --git a/sbin/fdisk/misc.c b/sbin/fdisk/misc.c
index 26fe3e1ad17..22d9dfdcc64 100644
--- a/sbin/fdisk/misc.c
+++ b/sbin/fdisk/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.72 2021/07/11 13:51:42 krw Exp $ */
+/* $OpenBSD: misc.c,v 1.73 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -122,7 +122,7 @@ getuint64(char *prompt, uint64_t oval, uint64_t minval, uint64_t maxval)
if (oval < minval)
oval = minval;
- secpercyl = disk.sectors * disk.heads;
+ secpercyl = disk.dk_sectors * disk.dk_heads;
do {
printf("%s [%llu - %llu]: [%llu] ", prompt, minval, maxval,
diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c
index 3beeba27396..e909e94c12d 100644
--- a/sbin/fdisk/part.c
+++ b/sbin/fdisk/part.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: part.c,v 1.91 2021/07/11 20:51:50 krw Exp $ */
+/* $OpenBSD: part.c,v 1.92 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -370,8 +370,8 @@ PRT_fix_BN(struct prt *prt, int pn)
}
/* Disk geometry. */
- spt = disk.sectors;
- tpc = disk.heads;
+ spt = disk.dk_sectors;
+ tpc = disk.dk_heads;
spc = spt * tpc;
start += prt->prt_scyl * spc;
@@ -404,8 +404,8 @@ PRT_fix_CHS(struct prt *prt)
}
/* Disk geometry. */
- spt = disk.sectors;
- tpc = disk.heads;
+ spt = disk.dk_sectors;
+ tpc = disk.dk_heads;
spc = spt * tpc;
start = prt->prt_bs;
diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c
index e078281fc6e..1e323ed0d71 100644
--- a/sbin/fdisk/user.c
+++ b/sbin/fdisk/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.59 2021/07/11 20:51:50 krw Exp $ */
+/* $OpenBSD: user.c,v 1.60 2021/07/12 14:06:19 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -91,7 +91,7 @@ USER_edit(off_t offset, off_t reloff)
/* Edit cycle */
again:
do {
- printf("%s%s: %d> ", disk.name, modified ? "*" : "", editlevel);
+ printf("%s%s: %d> ", disk.dk_name, modified ? "*" : "", editlevel);
fflush(stdout);
ask_cmd(&cmd, &args);