Final batch of struct field name tweaks. 'cmd_' for cmd, ut_' for
authorkrw <krw@openbsd.org>
Mon, 12 Jul 2021 18:31:53 +0000 (18:31 +0000)
committerkrw <krw@openbsd.org>
Mon, 12 Jul 2021 18:31:53 +0000 (18:31 +0000)
unit_types, 'pt_' for part_type, 'pg_' for protected_guid.

No functional change.

sbin/fdisk/cmd.c
sbin/fdisk/cmd.h
sbin/fdisk/disk.c
sbin/fdisk/gpt.c
sbin/fdisk/misc.c
sbin/fdisk/part.c
sbin/fdisk/user.c

index 695d094..473eb9d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cmd.c,v 1.124 2021/07/12 14:06:19 krw Exp $   */
+/*     $OpenBSD: cmd.c,v 1.125 2021/07/12 18:31:53 krw Exp $   */
 
 /*
  * Copyright (c) 1997 Tobias Weingartner
@@ -506,16 +506,16 @@ Xhelp(char *args, struct mbr *mbr)
        char                    *mbrstr;
        int                      i;
 
-       for (i = 0; cmd_table[i].cmd != NULL; i++) {
-               strlcpy(help, cmd_table[i].help, sizeof(help));
+       for (i = 0; cmd_table[i].cmd_name != NULL; i++) {
+               strlcpy(help, cmd_table[i].cmd_help, sizeof(help));
                if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
-                       if (cmd_table[i].gpt == 0)
+                       if (cmd_table[i].cmd_gpt == 0)
                                continue;
                        mbrstr = strstr(help, "MBR");
                        if (mbrstr)
                                memcpy(mbrstr, "GPT", 3);
                }
-               printf("\t%s\t\t%s\n", cmd_table[i].cmd, help);
+               printf("\t%s\t\t%s\n", cmd_table[i].cmd_name, help);
        }
 
        return CMD_CONT;
index 3151f9e..1954b55 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cmd.h,v 1.21 2021/07/11 13:23:18 krw Exp $    */
+/*     $OpenBSD: cmd.h,v 1.22 2021/07/12 18:31:53 krw Exp $    */
 
 /*
  * Copyright (c) 1997 Tobias Weingartner
 #define CMD_DIRTY      0x0004
 
 struct cmd {
-       char    *cmd;
-       int      gpt;
-       int     (*fcn)(char *, struct mbr *);
-       char    *help;
+       char    *cmd_name;
+       int      cmd_gpt;
+       int     (*cmd_fcn)(char *, struct mbr *);
+       char    *cmd_help;
 };
 extern struct cmd      cmd_table[];
 
index 77206aa..4349aa9 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: disk.c,v 1.60 2021/07/12 14:06:19 krw Exp $   */
+/*     $OpenBSD: disk.c,v 1.61 2021/07/12 18:31:53 krw Exp $   */
 
 /*
  * Copyright (c) 1997 Tobias Weingartner
@@ -56,7 +56,7 @@ DISK_open(int rw)
        if (ioctl(disk.dk_fd, DIOCGPDINFO, &dl) == -1) {
                warn("DIOCGPDINFO");
        } else {
-               unit_types[SECTORS].conversion = dl.d_secsize;
+               unit_types[SECTORS].ut_conversion = dl.d_secsize;
                if (disk.dk_size == 0) {
                        /* -l or -c/-h/-s not used. Use disklabel info. */
                        disk.dk_cylinders = dl.d_ncylinders;
@@ -74,7 +74,7 @@ DISK_open(int rw)
        }
 
        if (disk.dk_size == 0 || disk.dk_cylinders == 0 || disk.dk_heads == 0 ||
-           disk.dk_sectors == 0 || unit_types[SECTORS].conversion == 0)
+           disk.dk_sectors == 0 || unit_types[SECTORS].ut_conversion == 0)
                errx(1, "Can't get disk geometry, please use [-chs] or [-l]"
                    "to specify.");
 }
@@ -86,19 +86,19 @@ DISK_open(int rw)
 int
 DISK_printgeometry(char *units)
 {
-       const int               secsize = unit_types[SECTORS].conversion;
+       const int               secsize = unit_types[SECTORS].ut_conversion;
        double                  size;
        int                     i;
 
        i = unit_lookup(units);
-       size = ((double)disk.dk_size * secsize) / unit_types[i].conversion;
+       size = ((double)disk.dk_size * secsize) / unit_types[i].ut_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);
+               printf("%s]\n", unit_types[i].ut_lname);
        } else
                printf("geometry: <none>\n");
 
index 44aa6ca..bb867bd 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: gpt.c,v 1.38 2021/07/12 14:06:19 krw Exp $    */
+/*     $OpenBSD: gpt.c,v 1.39 2021/07/12 18:31:53 krw Exp $    */
 /*
  * Copyright (c) 2015 Markus Muller <mmu@grummel.net>
  * Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
@@ -236,20 +236,20 @@ GPT_read(int which)
 void
 GPT_print(char *units, int verbosity)
 {
-       const int                secsize = unit_types[SECTORS].conversion;
+       const int                secsize = unit_types[SECTORS].ut_conversion;
        struct uuid              guid;
        char                    *guidstr = NULL;
        double                   size;
        int                      i, u, status;
 
        u = unit_lookup(units);
-       size = ((double)DL_GETDSIZE(&dl) * secsize) / unit_types[u].conversion;
+       size = ((double)DL_GETDSIZE(&dl) * secsize) / unit_types[u].ut_conversion;
        printf("Disk: %s       Usable LBA: %llu to %llu [%.0f ",
            disk.dk_name, letoh64(gh.gh_lba_start), letoh64(gh.gh_lba_end), size);
 
        if (u == SECTORS && secsize != DEV_BSIZE)
                printf("%d-byte ", secsize);
-       printf("%s]\n", unit_types[u].lname);
+       printf("%s]\n", unit_types[u].ut_lname);
 
        if (verbosity == VERBOSE) {
                printf("GUID: ");
@@ -287,18 +287,18 @@ GPT_print_part(int n, char *units, int verbosity)
        struct uuid              guid;
        struct gpt_partition    *partn = &gp[n];
        char                    *guidstr = NULL;
-       const int                secsize = unit_types[SECTORS].conversion;
+       const int                secsize = unit_types[SECTORS].ut_conversion;
        double                   size;
        int                      u, status;
 
        uuid_dec_le(&partn->gp_type, &guid);
        u = unit_lookup(units);
        size = letoh64(partn->gp_lba_end) - letoh64(partn->gp_lba_start) + 1;
-       size = (size * secsize) / unit_types[u].conversion;
+       size = (size * secsize) / unit_types[u].ut_conversion;
        printf("%c%3d: %-36s [%12lld: %12.0f%s]\n",
            (letoh64(partn->gp_attrs) & GPTDOSACTIVE)?'*':' ', n,
            PRT_uuid_to_typename(&guid), letoh64(partn->gp_lba_start),
-           size, unit_types[u].abbr);
+           size, unit_types[u].ut_abbr);
 
        if (verbosity == VERBOSE) {
                uuid_dec_le(&partn->gp_guid, &guid);
@@ -378,7 +378,7 @@ init_gh(void)
 {
        struct gpt_header       oldgh;
        struct uuid             guid;
-       const int               secsize = unit_types[SECTORS].conversion;
+       const int               secsize = unit_types[SECTORS].ut_conversion;
        int                     needed;
        uint32_t                status;
 
@@ -494,7 +494,7 @@ GPT_write(void)
        char                    *secbuf;
        ssize_t                  len;
        off_t                    off;
-       const int                secsize = unit_types[SECTORS].conversion;
+       const int                secsize = unit_types[SECTORS].ut_conversion;
        uint64_t                 altgh, altgp, prigh, prigp, gpbytes;
 
        /*
index 22d9dfd..a57c6cc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: misc.c,v 1.73 2021/07/12 14:06:19 krw Exp $   */
+/*     $OpenBSD: misc.c,v 1.74 2021/07/12 18:31:53 krw Exp $   */
 
 /*
  * Copyright (c) 1997 Tobias Weingartner
@@ -50,13 +50,13 @@ unit_lookup(char *units)
        if (units == NULL)
                return SECTORS;
 
-       while (unit_types[i].abbr != NULL) {
-               if (strncasecmp(unit_types[i].abbr, units, 1) == 0)
+       while (unit_types[i].ut_abbr != NULL) {
+               if (strncasecmp(unit_types[i].ut_abbr, units, 1) == 0)
                        break;
                i++;
        }
        /* default */
-       if (unit_types[i].abbr == NULL)
+       if (unit_types[i].ut_abbr == NULL)
                return SECTORS;
 
        return i;
@@ -110,7 +110,7 @@ uint64_t
 getuint64(char *prompt, uint64_t oval, uint64_t minval, uint64_t maxval)
 {
        char                    buf[BUFSIZ], *endptr, *p, operator = '\0';
-       const int               secsize = unit_types[SECTORS].conversion;
+       const int               secsize = unit_types[SECTORS].ut_conversion;
        size_t                  n;
        int64_t                 mult = 1;
        double                  d, d2;
index e909e94..ab974e2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: part.c,v 1.92 2021/07/12 14:06:19 krw Exp $   */
+/*     $OpenBSD: part.c,v 1.93 2021/07/12 18:31:53 krw Exp $   */
 
 /*
  * Copyright (c) 1997 Tobias Weingartner
@@ -34,9 +34,9 @@ int                    check_chs(struct prt *);
 const char             *ascii_id(int);
 
 static const struct part_type {
-       int     type;
-       char    sname[14];
-       char    guid[UUID_STR_LEN + 1];
+       int     pt_type;
+       char    pt_sname[14];
+       char    pt_guid[UUID_STR_LEN + 1];
 } part_types[] = {
        { 0x00, "unused      ", "00000000-0000-0000-0000-000000000000" },
        { 0x01, "FAT12       ", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7" },
@@ -143,7 +143,7 @@ static const struct part_type {
 };
 
 static const struct protected_guid {
-       char    guid[UUID_STR_LEN + 1];
+       char    pg_guid[UUID_STR_LEN + 1];
 } protected_guid[] = {
        { "7c3457ef-0000-11aa-aa11-00306543ecac" },     /* APFS         */
        { "69646961-6700-11aa-aa11-00306543ecac" },     /* APFS ISC     */
@@ -174,7 +174,7 @@ PRT_protected_guid(struct uuid *leuuid)
 
        rslt = 0;
        for(i = 0; i < nitems(protected_guid); i++) {
-               if (strncmp(str, protected_guid[i].guid, UUID_STR_LEN) == 0) {
+               if (strncmp(str, protected_guid[i].pg_guid, UUID_STR_LEN) == 0) {
                        rslt = 1;
                        break;
                }
@@ -195,13 +195,13 @@ PRT_printall(void)
        printf("Choose from the following Partition id values:\n");
        for (i = 0; i < idrows; i++) {
                printf("%02X %s   %02X %s   %02X %s",
-                   part_types[i].type, part_types[i].sname,
-                   part_types[i+idrows].type, part_types[i+idrows].sname,
-                   part_types[i+idrows*2].type, part_types[i+idrows*2].sname);
+                   part_types[i].pt_type, part_types[i].pt_sname,
+                   part_types[i+idrows].pt_type, part_types[i+idrows].pt_sname,
+                   part_types[i+idrows*2].pt_type, part_types[i+idrows*2].pt_sname);
                if ((i+idrows*3) < (sizeof(part_types)/sizeof(struct part_type))) {
                        printf("   %02X %s\n",
-                           part_types[i+idrows*3].type,
-                           part_types[i+idrows*3].sname);
+                           part_types[i+idrows*3].pt_type,
+                           part_types[i+idrows*3].pt_sname);
                } else
                        printf( "\n" );
        }
@@ -214,8 +214,8 @@ ascii_id(int id)
        int                     i;
 
        for (i = 0; i < sizeof(part_types)/sizeof(struct part_type); i++) {
-               if (part_types[i].type == id)
-                       return part_types[i].sname;
+               if (part_types[i].pt_type == id)
+                       return part_types[i].pt_sname;
        }
 
        return unknown;
@@ -329,7 +329,7 @@ PRT_make(struct prt *prt, off_t lba_self, off_t lba_firstembr,
 void
 PRT_print(int num, struct prt *prt, char *units)
 {
-       const int               secsize = unit_types[SECTORS].conversion;
+       const int               secsize = unit_types[SECTORS].ut_conversion;
        double                  size;
        int                     i;
 
@@ -343,7 +343,7 @@ PRT_print(int num, struct prt *prt, char *units)
                printf("---------------------------------------"
                    "----------------------------------------\n");
        } else {
-               size = ((double)prt->prt_ns * secsize) / unit_types[i].conversion;
+               size = ((double)prt->prt_ns * secsize) / unit_types[i].ut_conversion;
                printf("%c%1d: %.2X %6u %3u %3u - %6u %3u %3u "
                    "[%12llu:%12.0f%s] %s\n",
                    (prt->prt_flag == DOSACTIVE)?'*':' ',
@@ -351,7 +351,7 @@ PRT_print(int num, struct prt *prt, char *units)
                    prt->prt_scyl, prt->prt_shead, prt->prt_ssect,
                    prt->prt_ecyl, prt->prt_ehead, prt->prt_esect,
                    prt->prt_bs, size,
-                   unit_types[i].abbr,
+                   unit_types[i].ut_abbr,
                    ascii_id(prt->prt_id));
        }
 }
@@ -447,13 +447,13 @@ PRT_uuid_to_typename(struct uuid *uuid)
        entries = sizeof(part_types) / sizeof(struct part_type);
 
        for (i = 0; i < entries; i++) {
-               if (memcmp(part_types[i].guid, uuidstr,
-                   sizeof(part_types[i].guid)) == 0)
+               if (memcmp(part_types[i].pt_guid, uuidstr,
+                   sizeof(part_types[i].pt_guid)) == 0)
                        break;
        }
 
        if (i < entries)
-               strlcpy(partition_type, part_types[i].sname,
+               strlcpy(partition_type, part_types[i].pt_sname,
                    sizeof(partition_type));
        else
                strlcpy(partition_type, uuidstr, sizeof(partition_type));
@@ -478,9 +478,9 @@ PRT_uuid_to_type(struct uuid *uuid)
 
        entries = sizeof(part_types) / sizeof(struct part_type);
        for (i = 0; i < entries; i++) {
-               if (memcmp(part_types[i].guid, uuidstr,
-                   sizeof(part_types[i].guid)) == 0) {
-                       type = part_types[i].type;
+               if (memcmp(part_types[i].pt_guid, uuidstr,
+                   sizeof(part_types[i].pt_guid)) == 0) {
+                       type = part_types[i].pt_type;
                        break;
                }
        }
@@ -501,13 +501,13 @@ PRT_type_to_uuid(int type)
        entries = sizeof(part_types) / sizeof(struct part_type);
 
        for (i = 0; i < entries; i++) {
-               if (part_types[i].type == type)
+               if (part_types[i].pt_type == type)
                        break;
        }
        if (i < entries)
-               uuid_from_string(part_types[i].guid, &guid, &status);
+               uuid_from_string(part_types[i].pt_guid, &guid, &status);
        if (i == entries || status != uuid_s_ok)
-               uuid_from_string(part_types[0].guid, &guid, &status);
+               uuid_from_string(part_types[0].pt_guid, &guid, &status);
 
        return &guid;
 }
index 1e323ed..ed37588 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: user.c,v 1.60 2021/07/12 14:06:19 krw Exp $   */
+/*     $OpenBSD: user.c,v 1.61 2021/07/12 18:31:53 krw Exp $   */
 
 /*
  * Copyright (c) 1997 Tobias Weingartner
@@ -97,8 +97,8 @@ again:
 
                if (cmd[0] == '\0')
                        continue;
-               for (i = 0; cmd_table[i].cmd != NULL; i++)
-                       if (strstr(cmd_table[i].cmd, cmd) == cmd_table[i].cmd)
+               for (i = 0; cmd_table[i].cmd_name != NULL; i++)
+                       if (strstr(cmd_table[i].cmd_name, cmd) == cmd_table[i].cmd_name)
                                break;
 
                /* Quick hack to put in '?' == 'help' */
@@ -106,14 +106,14 @@ again:
                        i = 0;
 
                /* Check for valid command */
-               if ((cmd_table[i].cmd == NULL) || (letoh64(gh.gh_sig) ==
-                   GPTSIGNATURE && cmd_table[i].gpt == 0)) {
+               if ((cmd_table[i].cmd_name == NULL) || (letoh64(gh.gh_sig) ==
+                   GPTSIGNATURE && cmd_table[i].cmd_gpt == 0)) {
                        printf("Invalid command '%s'.  Try 'help'.\n", cmd);
                        continue;
                }
 
                /* Call function */
-               st = cmd_table[i].fcn(args, &mbr);
+               st = cmd_table[i].cmd_fcn(args, &mbr);
 
                /* Update status */
                if (st == CMD_EXIT)