summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-11-18 16:40:12 +0200
committerToomas Soome <tsoome@me.com>2019-12-06 17:53:56 +0200
commitedbad4fe075c5178507eaf0bfb85aa903b66bf91 (patch)
tree336fa82165cf3024e5d1d94358b600b952cfe7e7 /usr/src
parent5ac07b12fb4c39cb2415c0997f7c5b4dd5209f96 (diff)
downloadillumos-gate-edbad4fe075c5178507eaf0bfb85aa903b66bf91.tar.gz
11997 format: cstyle cleanup
Reviewed by: Robert Mustacchi <rm@fingolfin.org> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/format/io.c205
-rw-r--r--usr/src/cmd/format/menu_partition.c126
-rw-r--r--usr/src/cmd/format/modify_partition.c306
-rw-r--r--usr/src/cmd/format/partition.c219
4 files changed, 373 insertions, 483 deletions
diff --git a/usr/src/cmd/format/io.c b/usr/src/cmd/format/io.c
index dd0cbc2397..e9171a7fdc 100644
--- a/usr/src/cmd/format/io.c
+++ b/usr/src/cmd/format/io.c
@@ -49,7 +49,6 @@
extern int data_lineno;
extern char *space2str();
-extern long strtol();
/*
* This variable is used to determine whether a token is present in the pipe
@@ -62,10 +61,6 @@ static char token_present = 0;
*/
int last_token_type = 0;
-#ifdef __STDC__
-/*
- * Prototypes for ANSI C compilers
- */
static int sup_get_token(char *);
static void pushchar(int c);
static int checkeof(void);
@@ -79,33 +74,11 @@ static int sup_inputchar(void);
static void sup_pushchar(int c);
static int geti64(char *str, uint64_t *iptr, uint64_t *wild);
-#else /* __STDC__ */
-/*
- * Prototypes for non-ANSI C compilers
- */
-
-static int sup_get_token();
-static void pushchar(int c);
-static int checkeof(void);
-static void flushline(void);
-static int strcnt(char *s1, char *s2);
-static int getbn(char *str, diskaddr_t *iptr);
-static void print_input_choices(int type, u_ioparam_t *param);
-static int slist_widest_str(slist_t *slist);
-static void ljust_print(char *str, int width);
-static int sup_inputchar(void);
-static void sup_pushchar(int c);
-static int geti64(char *str, uint64_t *iptr, uint64_t *wild);
-
-#endif /* __STDC__ */
-
-
/*
* This routine pushes the given character back onto the input stream.
*/
static void
-pushchar(c)
- int c;
+pushchar(int c)
{
(void) ungetc(c, stdin);
}
@@ -114,7 +87,7 @@ pushchar(c)
* This routine checks the input stream for an eof condition.
*/
static int
-checkeof()
+checkeof(void)
{
return (feof(stdin));
}
@@ -124,8 +97,7 @@ checkeof()
* basically any consecutive non-white characters.
*/
char *
-gettoken(inbuf)
- char *inbuf;
+gettoken(char *inbuf)
{
char *ptr = inbuf;
int c, quoted = 0;
@@ -196,8 +168,7 @@ retoke:
* This routine removes the leading and trailing spaces from a token.
*/
void
-clean_token(cleantoken, token)
- char *cleantoken, *token;
+clean_token(char *cleantoken, char *token)
{
char *ptr;
@@ -214,7 +185,7 @@ clean_token(cleantoken, token)
* Strip off trailing white-space.
*/
for (ptr = cleantoken + strlen(cleantoken) - 1;
- isspace(*ptr) && (ptr >= cleantoken); ptr--) {
+ isspace(*ptr) && (ptr >= cleantoken); ptr--) {
*ptr = '\0';
}
}
@@ -254,8 +225,7 @@ flushline()
* between s1 and s2, stopping as soon as a mismatch is found.
*/
static int
-strcnt(s1, s2)
- char *s1, *s2;
+strcnt(char *s1, char *s2)
{
int i = 0;
@@ -271,9 +241,7 @@ strcnt(s1, s2)
* is present, the wildcard value will be returned.
*/
int
-geti(str, iptr, wild)
- char *str;
- int *iptr, *wild;
+geti(char *str, int *iptr, int *wild)
{
char *str2;
@@ -306,9 +274,7 @@ geti(str, iptr, wild)
* is present, the wildcard value will be returned.
*/
static int
-geti64(str, iptr, wild)
- char *str;
- uint64_t *iptr, *wild;
+geti64(char *str, uint64_t *iptr, uint64_t *wild)
{
char *str2;
@@ -345,9 +311,7 @@ geti64(str, iptr, wild)
* to the highest possible legal value.
*/
static int
-getbn(str, iptr)
- char *str;
- diskaddr_t *iptr;
+getbn(char *str, diskaddr_t *iptr)
{
char *cptr, *hptr, *sptr;
int cyl, head, sect;
@@ -442,13 +406,8 @@ getbn(str, iptr)
* values and prompt strings.
*/
uint64_t
-input(type, promptstr, delim, param, deflt, cmdflag)
- int type;
- char *promptstr;
- int delim;
- u_ioparam_t *param;
- int *deflt;
- int cmdflag;
+input(int type, char *promptstr, int delim, u_ioparam_t *param, int *deflt,
+ int cmdflag)
{
int interactive, help, i, length, index, tied;
blkaddr_t bn;
@@ -586,7 +545,7 @@ reprompt:
cylno = bn2c(part_deflt->deflt_size) - 1;
} else {
cylno = (bn2c(part_deflt->deflt_size) +
- part_deflt->start_cyl) - 1;
+ part_deflt->start_cyl) - 1;
}
fmt_print("[%ub, %uc, %de, %1.2fmb, %1.2fgb]",
@@ -609,11 +568,11 @@ reprompt:
efi_deflt->end_sector,
efi_deflt->start_sector + efi_deflt->end_sector - 1,
(efi_deflt->end_sector * cur_blksz) /
- (1024 * 1024),
+ (1024 * 1024),
(efi_deflt->end_sector * cur_blksz) /
- (1024 * 1024 * 1024),
+ (1024 * 1024 * 1024),
(efi_deflt->end_sector * cur_blksz) /
- ((uint64_t)1024 * 1024 * 1024 * 1024));
+ ((uint64_t)1024 * 1024 * 1024 * 1024));
break;
case FIO_OPINT:
/* no default value for optional input type */
@@ -659,9 +618,9 @@ reprompt:
* exit gracefully.
*/
if ((strlcat(shell_argv, arg, sizeof (shell_argv)) >=
- sizeof (shell_argv)) ||
+ sizeof (shell_argv)) ||
(strlcat(shell_argv, " ", sizeof (shell_argv)) >=
- sizeof (shell_argv))) {
+ sizeof (shell_argv))) {
err_print("Error: Command line too long.\n");
fullabort();
}
@@ -781,8 +740,8 @@ reprompt:
* If token is a '?' or a 'h', it is a request for help.
*/
if ((strcmp(cleantoken, "?") == 0) ||
- (strcmp(cleantoken, "h") == 0) ||
- (strcmp(cleantoken, "help") == 0)) {
+ (strcmp(cleantoken, "h") == 0) ||
+ (strcmp(cleantoken, "help") == 0)) {
help = 1;
}
/*
@@ -813,12 +772,12 @@ reprompt:
* Convert token to a disk block number.
*/
if (cur_label == L_TYPE_EFI) {
- if (geti64(cleantoken, (uint64_t *)&bn64,
- (uint64_t *)NULL))
- break;
+ if (geti64(cleantoken, (uint64_t *)&bn64,
+ (uint64_t *)NULL))
+ break;
} else {
- if (getbn(cleantoken, &bn64))
- break;
+ if (getbn(cleantoken, &bn64))
+ break;
}
/*
* Check to be sure it is within the legal bounds.
@@ -1066,8 +1025,7 @@ reprompt:
* Return the value associated with the matched string.
*/
case FIO_SLIST:
- i = find_value((slist_t *)param->io_slist,
- cleantoken, &value);
+ i = find_value((slist_t *)param->io_slist, cleantoken, &value);
if (i == 1) {
return (value);
} else {
@@ -1520,14 +1478,14 @@ or g(gigabytes)\n");
fmt_print("Expecting up to %llu sectors,",
cur_parts->etoc->efi_last_u_lba);
fmt_print("or %llu megabytes,",
- (cur_parts->etoc->efi_last_u_lba * cur_blksz)/
- (1024 * 1024));
+ (cur_parts->etoc->efi_last_u_lba * cur_blksz) /
+ (1024 * 1024));
fmt_print("or %llu gigabytes\n",
- (cur_parts->etoc->efi_last_u_lba * cur_blksz)/
- (1024 * 1024 * 1024));
+ (cur_parts->etoc->efi_last_u_lba * cur_blksz) /
+ (1024 * 1024 * 1024));
fmt_print("or %llu terabytes\n",
- (cur_parts->etoc->efi_last_u_lba * cur_blksz)/
- ((uint64_t)1024 * 1024 * 1024 * 1024));
+ (cur_parts->etoc->efi_last_u_lba * cur_blksz) /
+ ((uint64_t)1024 * 1024 * 1024 * 1024));
break;
}
@@ -1591,12 +1549,12 @@ or g(gigabytes)\n");
* Token is number of blocks
*/
if (geti64(cleantoken, &blokno, (uint64_t *)NULL)) {
- break;
+ break;
}
if (blokno > bounds->upper) {
- err_print(
-"Number of blocks must be less that the total available blocks.\n");
- break;
+ err_print("Number of blocks must be less that "
+ "the total available blocks.\n");
+ break;
}
return (blokno);
@@ -1614,8 +1572,8 @@ or g(gigabytes)\n");
* Some sanity check
*/
if (blokno < efi_deflt->start_sector) {
- err_print(
-"End Sector must fall on or after start sector %llu\n",
+ err_print("End Sector must fall on or after "
+ "start sector %llu\n",
efi_deflt->start_sector);
break;
}
@@ -1624,8 +1582,8 @@ or g(gigabytes)\n");
* verify that our input is within range
*/
if (blokno > cur_parts->etoc->efi_last_u_lba) {
- err_print(
-"End Sector %llu is beyond max Sector %llu\n",
+ err_print("End Sector %llu is beyond max "
+ "Sector %llu\n",
blokno, cur_parts->etoc->efi_last_u_lba);
break;
}
@@ -1681,11 +1639,11 @@ or g(gigabytes)\n");
break;
}
return (uint64_t)((float)nmegs * 1024.0 *
- 1024.0 * 1024.0 * 1024.0 / cur_blksz);
+ 1024.0 * 1024.0 * 1024.0 / cur_blksz);
default:
- err_print(
-"Please specify units in either b(number of blocks), e(end sector),\n");
+ err_print("Please specify units in either "
+ "b(number of blocks), e(end sector),\n");
err_print(" g(gigabytes), m(megabytes)");
err_print(" or t(terabytes)\n");
break;
@@ -1721,9 +1679,7 @@ or g(gigabytes)\n");
* Print input choices
*/
static void
-print_input_choices(type, param)
- int type;
- u_ioparam_t *param;
+print_input_choices(int type, u_ioparam_t *param)
{
char **sp;
slist_t *lp;
@@ -1803,10 +1759,7 @@ common:
* associated with the matched string in match_value.
*/
int
-find_value(slist, match_str, match_value)
- slist_t *slist;
- char *match_str;
- int *match_value;
+find_value(slist_t *slist, char *match_str, int *match_value)
{
int i;
int nmatches;
@@ -1851,9 +1804,7 @@ find_value(slist, match_str, match_value)
* Return the string associated with that value.
*/
char *
-find_string(slist, match_value)
- slist_t *slist;
- int match_value;
+find_string(slist_t *slist, int match_value)
{
for (; slist->str != NULL; slist++) {
if (slist->value == match_value) {
@@ -1861,15 +1812,14 @@ find_string(slist, match_value)
}
}
- return ((char *)NULL);
+ return (NULL);
}
/*
* Return the width of the widest string in an slist
*/
static int
-slist_widest_str(slist)
- slist_t *slist;
+slist_widest_str(slist_t *slist)
{
int i;
int width;
@@ -1887,9 +1837,7 @@ slist_widest_str(slist)
* Print a string left-justified to a fixed width.
*/
static void
-ljust_print(str, width)
- char *str;
- int width;
+ljust_print(char *str, int width)
{
int i;
@@ -2050,9 +1998,7 @@ err_print(char *format, ...)
* data is not crud, so be rather defensive.
*/
void
-print_buf(buf, nbytes)
- char *buf;
- int nbytes;
+print_buf(char *buf, int nbytes)
{
int c;
@@ -2072,13 +2018,12 @@ print_buf(buf, nbytes)
* booting.
*/
void
-pr_ctlrline(ctlr)
- register struct ctlr_info *ctlr;
+pr_ctlrline(struct ctlr_info *ctlr)
{
fmt_print(" %s%d at %s 0x%x ",
- ctlr->ctlr_cname, ctlr->ctlr_num,
- space2str(ctlr->ctlr_space), ctlr->ctlr_addr);
+ ctlr->ctlr_cname, ctlr->ctlr_num,
+ space2str(ctlr->ctlr_space), ctlr->ctlr_addr);
if (ctlr->ctlr_vec != 0)
fmt_print("vec 0x%x ", ctlr->ctlr_vec);
else
@@ -2093,9 +2038,7 @@ pr_ctlrline(ctlr)
* booting.
*/
void
-pr_diskline(disk, num)
- register struct disk_info *disk;
- int num;
+pr_diskline(struct disk_info *disk, int num)
{
struct ctlr_info *ctlr = disk->disk_ctlr;
struct disk_type *type = disk->disk_type;
@@ -2103,13 +2046,13 @@ pr_diskline(disk, num)
fmt_print(" %4d. %s ", num, disk->disk_name);
if ((type != NULL) && (disk->label_type == L_TYPE_SOLARIS)) {
fmt_print("<%s cyl %u alt %u hd %u sec %u>",
- type->dtype_asciilabel, type->dtype_ncyl,
- type->dtype_acyl, type->dtype_nhead,
- type->dtype_nsect);
+ type->dtype_asciilabel, type->dtype_ncyl,
+ type->dtype_acyl, type->dtype_nhead,
+ type->dtype_nsect);
} else if ((type != NULL) && (disk->label_type == L_TYPE_EFI)) {
cur_blksz = disk->disk_lbasize;
print_efi_string(type->vendor, type->product,
- type->revision, type->capacity);
+ type->revision, type->capacity);
} else if (disk->disk_flags & DSK_RESERVED) {
fmt_print("<drive not available: reserved>");
} else if (disk->disk_flags & DSK_UNAVAILABLE) {
@@ -2127,9 +2070,9 @@ pr_diskline(disk, num)
fmt_print(" %s\n", disk->devfs_name);
} else {
fmt_print(" %s%d at %s%d slave %d\n",
- ctlr->ctlr_dname, disk->disk_dkinfo.dki_unit,
- ctlr->ctlr_cname, ctlr->ctlr_num,
- disk->disk_dkinfo.dki_slave);
+ ctlr->ctlr_dname, disk->disk_dkinfo.dki_unit,
+ ctlr->ctlr_cname, ctlr->ctlr_num,
+ disk->disk_dkinfo.dki_slave);
}
#ifdef OLD
@@ -2141,8 +2084,7 @@ pr_diskline(disk, num)
}
fmt_print("\n");
if (type != NULL) {
- fmt_print(
-" %s%d: <%s cyl %u alt %u hd %u sec %u>\n",
+ fmt_print(" %s%d: <%s cyl %u alt %u hd %u sec %u>\n",
ctlr->ctlr_dname, disk->disk_dkinfo.dki_unit,
type->dtype_asciilabel, type->dtype_ncyl,
type->dtype_acyl, type->dtype_nhead,
@@ -2175,7 +2117,7 @@ pr_dblock(void (*func)(char *, ...), diskaddr_t bn)
* track of the current line in the data file via a global variable.
*/
static int
-sup_inputchar()
+sup_inputchar(void)
{
int c;
@@ -2210,8 +2152,7 @@ sup_inputchar()
* This routine pushes a character back onto the input pipe for the data file.
*/
static void
-sup_pushchar(c)
- int c;
+sup_pushchar(int c)
{
(void) ungetc(c, data_file);
}
@@ -2230,16 +2171,14 @@ static int pushed_token;
* last token around, which is useful for error recovery.
*/
int
-sup_gettoken(buf)
- char *buf;
+sup_gettoken(char *buf)
{
last_token_type = sup_get_token(buf);
return (last_token_type);
}
static int
-sup_get_token(buf)
- char *buf;
+sup_get_token(char *buf)
{
char *ptr = buf;
int c, quoted = 0;
@@ -2288,7 +2227,7 @@ sup_get_token(buf)
* a token.
*/
if (!quoted && (c == '=' || c == ',' || c == ':' ||
- c == '#' || c == '|' || c == '&' || c == '~'))
+ c == '#' || c == '|' || c == '&' || c == '~'))
break;
/*
* Store the character if there's room left.
@@ -2350,9 +2289,7 @@ sup_get_token(buf)
* Push back a token
*/
void
-sup_pushtoken(token_buf, token_type)
- char *token_buf;
- int token_type;
+sup_pushtoken(char *token_buf, int token_type)
{
/*
* We can only push one token back at a time
@@ -2369,9 +2306,7 @@ sup_pushtoken(token_buf, token_type)
* and EOF.
*/
void
-get_inputline(line, nbytes)
- char *line;
- int nbytes;
+get_inputline(char *line, int nbytes)
{
char *p = line;
int c;
@@ -2481,9 +2416,9 @@ execute_shell(char *s, size_t buff_size)
/* reopen file descriptor if one was open before */
if (cur_disk != NULL) {
if ((cur_file = open_disk(cur_disk->disk_path,
- O_RDWR | O_NDELAY)) < 0) {
+ O_RDWR | O_NDELAY)) < 0) {
err_print("Error: can't reopen selected disk '%s'. \n",
- cur_disk->disk_name);
+ cur_disk->disk_name);
fullabort();
}
}
diff --git a/usr/src/cmd/format/menu_partition.c b/usr/src/cmd/format/menu_partition.c
index 444d4f585d..26e0867018 100644
--- a/usr/src/cmd/format/menu_partition.c
+++ b/usr/src/cmd/format/menu_partition.c
@@ -35,25 +35,15 @@
#include "misc.h"
#include "param.h"
-#ifdef __STDC__
-
/* Function prototypes for ANSI C Compilers */
static void nspaces(int);
static int ndigits(uint64_t);
-#else /* __STDC__ */
-
-/* Function prototypes for non-ANSI C Compilers */
-static void nspaces();
-static int ndigits();
-
-#endif /* __STDC__ */
-
/*
* This routine implements the 'a' command. It changes the 'a' partition.
*/
int
-p_apart()
+p_apart(void)
{
change_partition(0);
@@ -64,7 +54,7 @@ p_apart()
* This routine implements the 'b' command. It changes the 'b' partition.
*/
int
-p_bpart()
+p_bpart(void)
{
change_partition(1);
@@ -75,7 +65,7 @@ p_bpart()
* This routine implements the 'c' command. It changes the 'c' partition.
*/
int
-p_cpart()
+p_cpart(void)
{
change_partition(2);
@@ -86,7 +76,7 @@ p_cpart()
* This routine implements the 'd' command. It changes the 'd' partition.
*/
int
-p_dpart()
+p_dpart(void)
{
change_partition(3);
@@ -97,7 +87,7 @@ p_dpart()
* This routine implements the 'e' command. It changes the 'e' partition.
*/
int
-p_epart()
+p_epart(void)
{
change_partition(4);
@@ -108,7 +98,7 @@ p_epart()
* This routine implements the 'f' command. It changes the 'f' partition.
*/
int
-p_fpart()
+p_fpart(void)
{
change_partition(5);
@@ -119,7 +109,7 @@ p_fpart()
* This routine implements the 'g' command. It changes the 'g' partition.
*/
int
-p_gpart()
+p_gpart(void)
{
change_partition(6);
@@ -130,7 +120,7 @@ p_gpart()
* This routine implements the 'h' command. It changes the 'h' partition.
*/
int
-p_hpart()
+p_hpart(void)
{
change_partition(7);
@@ -142,7 +132,7 @@ p_hpart()
* labeled disks. This can be used only in expert mode.
*/
int
-p_ipart()
+p_ipart(void)
{
change_partition(8);
return (0);
@@ -153,7 +143,7 @@ p_ipart()
* This routine implements the 'j' command. It changes the 'j' partition.
*/
int
-p_jpart()
+p_jpart(void)
{
change_partition(9);
@@ -162,7 +152,7 @@ p_jpart()
#endif /* defined(i386) */
int
-p_expand()
+p_expand(void)
{
uint64_t delta;
uint_t nparts;
@@ -193,7 +183,7 @@ p_expand()
* to make a pre-defined partition map the current map.
*/
int
-p_select()
+p_select(void)
{
struct partition_info *pptr, *parts;
u_ioparam_t ioparam;
@@ -254,8 +244,8 @@ p_select()
cyl_offset = pptr->pinfo_map[I_PARTITION].dkl_cylno + 1;
if (pptr->pinfo_map[J_PARTITION].dkl_nblk != 0) {
cyl_offset = pptr->pinfo_map[J_PARTITION].dkl_cylno +
- ((pptr->pinfo_map[J_PARTITION].dkl_nblk +
- (spc() - 1)) / spc());
+ ((pptr->pinfo_map[J_PARTITION].dkl_nblk +
+ (spc() - 1)) / spc());
}
#else /* !defined(i386) */
@@ -281,11 +271,10 @@ p_select()
}
#endif /* defined(i386) */
if (pptr->pinfo_map[i].dkl_cylno < b_cylno ||
- pptr->pinfo_map[i].dkl_cylno > (ncyl-1)) {
- err_print(
-"partition %c: starting cylinder %d is out of range\n",
- (PARTITION_BASE+i),
- pptr->pinfo_map[i].dkl_cylno);
+ pptr->pinfo_map[i].dkl_cylno > (ncyl-1)) {
+ err_print("partition %c: starting cylinder %d is out "
+ "of range\n", (PARTITION_BASE + i),
+ pptr->pinfo_map[i].dkl_cylno);
return (0);
}
if (pptr->pinfo_map[i].dkl_nblk > ((ncyl -
@@ -336,7 +325,7 @@ p_select()
* to be created.
*/
int
-p_name()
+p_name(void)
{
char *name;
@@ -493,25 +482,23 @@ print_efi_partition(struct dk_gpt *map, int partnum, int want_header)
ncyl2_digits = ndigits(map->efi_last_u_lba);
if (want_header) {
- fmt_print("Part ");
- fmt_print("Tag Flag ");
- fmt_print("First Sector");
- nspaces(ncyl2_digits);
- fmt_print("Size");
- nspaces(ncyl2_digits);
- fmt_print("Last Sector\n");
+ fmt_print("Part ");
+ fmt_print("Tag Flag ");
+ fmt_print("First Sector");
+ nspaces(ncyl2_digits);
+ fmt_print("Size");
+ nspaces(ncyl2_digits);
+ fmt_print("Last Sector\n");
}
fmt_print(" %d ", partnum);
- s = find_string(ptag_choices,
- (int)map->efi_parts[partnum].p_tag);
+ s = find_string(ptag_choices, (int)map->efi_parts[partnum].p_tag);
if (s == (char *)NULL)
s = "-";
nspaces(10 - (int)strlen(s));
fmt_print("%s", s);
- s = find_string(pflag_choices,
- (int)map->efi_parts[partnum].p_flag);
+ s = find_string(pflag_choices, (int)map->efi_parts[partnum].p_flag);
if (s == (char *)NULL)
s = "-";
nspaces(6 - (int)strlen(s));
@@ -521,28 +508,27 @@ print_efi_partition(struct dk_gpt *map, int partnum, int want_header)
secsize = map->efi_parts[partnum].p_size;
if (secsize == 0) {
- fmt_print("%16llu", map->efi_parts[partnum].p_start);
- nspaces(ncyl2_digits);
- fmt_print(" 0 ");
+ fmt_print("%16llu", map->efi_parts[partnum].p_start);
+ nspaces(ncyl2_digits);
+ fmt_print(" 0 ");
} else {
- fmt_print("%16llu", map->efi_parts[partnum].p_start);
- scaled = bn2mb(secsize);
- nspaces(ncyl2_digits - 5);
- if (scaled >= (float)1024.0 * 1024) {
- fmt_print("%8.2fTB", scaled/((float)1024.0 * 1024));
- } else if (scaled >= (float)1024.0) {
- fmt_print("%8.2fGB", scaled/(float)1024.0);
- } else {
- fmt_print("%8.2fMB", scaled);
- }
+ fmt_print("%16llu", map->efi_parts[partnum].p_start);
+ scaled = bn2mb(secsize);
+ nspaces(ncyl2_digits - 5);
+ if (scaled >= (float)1024.0 * 1024) {
+ fmt_print("%8.2fTB", scaled/((float)1024.0 * 1024));
+ } else if (scaled >= (float)1024.0) {
+ fmt_print("%8.2fGB", scaled/(float)1024.0);
+ } else {
+ fmt_print("%8.2fMB", scaled);
+ }
}
nspaces(ncyl2_digits);
- if ((map->efi_parts[partnum].p_start+secsize - 1) ==
- UINT_MAX64) {
- fmt_print(" 0 \n");
+ if ((map->efi_parts[partnum].p_start + secsize - 1) == UINT_MAX64) {
+ fmt_print(" 0 \n");
} else {
- fmt_print(" %llu \n",
- map->efi_parts[partnum].p_start+secsize - 1);
+ fmt_print(" %llu \n",
+ map->efi_parts[partnum].p_start + secsize - 1);
}
}
@@ -607,8 +593,7 @@ print_partition(struct partition_info *pinfo, int partnum, int want_header)
/*
* Print the partition tag. If invalid, print -
*/
- s = find_string(ptag_choices,
- (int)pinfo->vtoc.v_part[partnum].p_tag);
+ s = find_string(ptag_choices, (int)pinfo->vtoc.v_part[partnum].p_tag);
if (s == (char *)NULL)
s = "-";
nspaces(10 - (int)strlen(s));
@@ -617,9 +602,8 @@ print_partition(struct partition_info *pinfo, int partnum, int want_header)
/*
* Print the partition flag. If invalid print -
*/
- s = find_string(pflag_choices,
- (int)pinfo->vtoc.v_part[partnum].p_flag);
- if (s == (char *)NULL)
+ s = find_string(pflag_choices, (int)pinfo->vtoc.v_part[partnum].p_flag);
+ if (s == NULL)
s = "-";
nspaces(6 - (int)strlen(s));
fmt_print("%s", s);
@@ -637,7 +621,7 @@ print_partition(struct partition_info *pinfo, int partnum, int want_header)
scaled = bn2mb(nblks);
if (scaled > (float)1024.0 * 1024.0) {
fmt_print("%8.2fTB ",
- scaled/((float)1024.0 * 1024.0));
+ scaled/((float)1024.0 * 1024.0));
} else if (scaled > (float)1024.0) {
fmt_print("%8.2fGB ", scaled/(float)1024.0);
} else {
@@ -666,8 +650,7 @@ print_partition(struct partition_info *pinfo, int partnum, int want_header)
* Return true if a disk has a volume name
*/
int
-chk_volname(disk)
- struct disk_info *disk;
+chk_volname(struct disk_info *disk)
{
return (disk->v_volume[0] != 0);
}
@@ -677,8 +660,7 @@ chk_volname(disk)
* Print the volume name, if it appears to be set
*/
void
-print_volname(disk)
- struct disk_info *disk;
+print_volname(struct disk_info *disk)
{
int i;
char *p;
@@ -696,8 +678,7 @@ print_volname(disk)
* Print a number of spaces
*/
static void
-nspaces(n)
- int n;
+nspaces(int n)
{
while (n-- > 0)
fmt_print(" ");
@@ -707,8 +688,7 @@ nspaces(n)
* Return the number of digits required to print a number
*/
static int
-ndigits(n)
- uint64_t n;
+ndigits(uint64_t n)
{
int i;
diff --git a/usr/src/cmd/format/modify_partition.c b/usr/src/cmd/format/modify_partition.c
index 8f4905b594..ba168bb79e 100644
--- a/usr/src/cmd/format/modify_partition.c
+++ b/usr/src/cmd/format/modify_partition.c
@@ -38,26 +38,11 @@
#include "label.h"
#include "auto_sense.h"
-#ifdef __STDC__
-
-/* Function prototypes for ANSI C Compilers */
-
static void adj_cyl_offset(struct dk_map32 *map);
static int check_map(struct dk_map32 *map);
static void get_user_map(struct dk_map32 *map, int float_part);
static void get_user_map_efi(struct dk_gpt *map, int float_part);
-#else /* __STDC__ */
-
-/* Function prototypes for non-ANSI C Compilers */
-
-static void adj_cyl_offset();
-static int check_map();
-static void get_user_map();
-static void get_user_map_efi();
-
-#endif /* __STDC__ */
-
static char *partn_list[] = { "0", "1", "2", "3", "4", "5", "6", "7", NULL };
static char *sel_list[] = { "0", "1", "2", "3", NULL };
@@ -69,7 +54,7 @@ static char *sel_list[] = { "0", "1", "2", "3", NULL };
* Modify/Create a predefined partition table.
*/
int
-p_modify()
+p_modify(void)
{
struct partition_info tmp_pinfo[1];
struct dk_map32 *map = tmp_pinfo->pinfo_map;
@@ -134,89 +119,92 @@ currently being used for swapping.\n");
*/
if (cur_parts->pinfo_name != NULL) {
(void) snprintf(tmpstr, sizeof (tmpstr),
- "\t0. Current partition table (%s)",
- cur_parts->pinfo_name);
+ "\t0. Current partition table (%s)",
+ cur_parts->pinfo_name);
} else {
(void) sprintf(tmpstr,
- "\t0. Current partition table (unnamed)");
+ "\t0. Current partition table (unnamed)");
}
(void) snprintf(tmpstr2, sizeof (tmpstr2),
-"Select partitioning base:\n%s\n"
-"\t1. All Free Hog\n"
-"Choose base (enter number) ",
- tmpstr);
+ "Select partitioning base:\n%s\n"
+ "\t1. All Free Hog\n"
+ "Choose base (enter number) ",
+ tmpstr);
ioparam.io_charlist = sel_list;
sel_type = input(FIO_MSTR, tmpstr2, '?', &ioparam,
- &sel_type, DATA_INPUT);
+ &sel_type, DATA_INPUT);
switch (cur_label) {
case L_TYPE_SOLARIS:
- if (sel_type == 0) {
- /*
- * Check for invalid parameters but do
- * not modify the table.
- */
- if (check_map(cur_parts->pinfo_map)) {
- err_print("\
-Warning: Fix, or select a different partition table.\n");
- return (0);
- }
- /*
- * Create partition map from existing map
- */
- tmp_pinfo->vtoc = cur_parts->vtoc;
- for (i = 0; i < NDKMAP; i++) {
- map[i].dkl_nblk = cur_parts->pinfo_map[i].dkl_nblk;
- map[i].dkl_cylno = cur_parts->pinfo_map[i].dkl_cylno;
- }
- } else {
- /*
- * Make an empty partition map, with all the space
- * in the c partition.
- */
- set_vtoc_defaults(tmp_pinfo);
- for (i = 0; i < NDKMAP; i++) {
- map[i].dkl_nblk = 0;
- map[i].dkl_cylno = 0;
- }
- map[C_PARTITION].dkl_nblk = ncyl * spc();
+ if (sel_type == 0) {
+ /*
+ * Check for invalid parameters but do
+ * not modify the table.
+ */
+ if (check_map(cur_parts->pinfo_map)) {
+ err_print("Warning: Fix, or select a "
+ "different partition table.\n");
+ return (0);
+ }
+ /*
+ * Create partition map from existing map
+ */
+ tmp_pinfo->vtoc = cur_parts->vtoc;
+ for (i = 0; i < NDKMAP; i++) {
+ map[i].dkl_nblk =
+ cur_parts->pinfo_map[i].dkl_nblk;
+ map[i].dkl_cylno =
+ cur_parts->pinfo_map[i].dkl_cylno;
+ }
+ } else {
+ /*
+ * Make an empty partition map, with all the space
+ * in the c partition.
+ */
+ set_vtoc_defaults(tmp_pinfo);
+ for (i = 0; i < NDKMAP; i++) {
+ map[i].dkl_nblk = 0;
+ map[i].dkl_cylno = 0;
+ }
+ map[C_PARTITION].dkl_nblk = ncyl * spc();
#if defined(i386)
- /*
- * Adjust for the boot and possibly alternates partitions
- */
- map[I_PARTITION].dkl_nblk = spc();
- map[I_PARTITION].dkl_cylno = 0;
- if (cur_ctype->ctype_ctype != DKC_SCSI_CCS) {
- map[J_PARTITION].dkl_nblk = 2 * spc();
- map[J_PARTITION].dkl_cylno = spc() / spc();
- }
+ /*
+ * Adjust for the boot and possibly alternates
+ * partitions.
+ */
+ map[I_PARTITION].dkl_nblk = spc();
+ map[I_PARTITION].dkl_cylno = 0;
+ if (cur_ctype->ctype_ctype != DKC_SCSI_CCS) {
+ map[J_PARTITION].dkl_nblk = 2 * spc();
+ map[J_PARTITION].dkl_cylno = spc() / spc();
+ }
#endif /* defined(i386) */
- }
- break;
+ }
+ break;
case L_TYPE_EFI:
- if (sel_type == 1) {
- for (i = 0; i < cur_parts->etoc->efi_nparts; i++) {
- cur_parts->etoc->efi_parts[i].p_start = 0;
- cur_parts->etoc->efi_parts[i].p_size = 0;
+ if (sel_type == 1) {
+ for (i = 0; i < cur_parts->etoc->efi_nparts; i++) {
+ cur_parts->etoc->efi_parts[i].p_start = 0;
+ cur_parts->etoc->efi_parts[i].p_size = 0;
+ }
}
- }
- break;
+ break;
}
fmt_print("\n");
if (cur_label == L_TYPE_SOLARIS) {
- print_map(tmp_pinfo);
+ print_map(tmp_pinfo);
} else {
- print_map(cur_parts);
+ print_map(cur_parts);
}
ioparam.io_charlist = confirm_list;
- if (input(FIO_MSTR,
-"Do you wish to continue creating a new partition\ntable based on above table",
- '?', &ioparam, &inpt_dflt, DATA_INPUT)) {
+ if (input(FIO_MSTR, "Do you wish to continue creating a new "
+ "partition\ntable based on above table",
+ '?', &ioparam, &inpt_dflt, DATA_INPUT)) {
return (0);
}
@@ -228,11 +216,11 @@ Warning: Fix, or select a different partition table.\n");
free_hog = G_PARTITION; /* default to g partition */
ioparam.io_charlist = partn_list;
free_hog = input(FIO_MSTR, "Free Hog partition", '?',
- &ioparam, &free_hog, DATA_INPUT);
+ &ioparam, &free_hog, DATA_INPUT);
/* disallow c partition */
if (free_hog == C_PARTITION) {
fmt_print("'%c' cannot be the 'Free Hog' partition.\n",
- C_PARTITION + PARTITION_BASE);
+ C_PARTITION + PARTITION_BASE);
free_hog = -1;
continue;
}
@@ -246,7 +234,7 @@ Warning: Fix, or select a different partition table.\n");
map[free_hog].dkl_nblk -= map[I_PARTITION].dkl_nblk;
if (cur_ctype->ctype_ctype != DKC_SCSI_CCS) {
map[free_hog].dkl_nblk -=
- map[J_PARTITION].dkl_nblk;
+ map[J_PARTITION].dkl_nblk;
}
#endif /* defined(i386) */
break;
@@ -256,11 +244,11 @@ Warning: Fix, or select a different partition table.\n");
* the float partition.
*/
if (map[free_hog].dkl_nblk == 0) {
- err_print("\
-Warning: No space available from Free Hog partition.\n");
+ err_print("Warning: No space available from Free Hog "
+ "partition.\n");
ioparam.io_charlist = confirm_list;
if (input(FIO_MSTR, "Continue", '?',
- &ioparam, &inpt_dflt, DATA_INPUT)) {
+ &ioparam, &inpt_dflt, DATA_INPUT)) {
free_hog = -1;
}
}
@@ -268,27 +256,27 @@ Warning: No space available from Free Hog partition.\n");
inpt_dflt = 0;
if (cur_label == L_TYPE_EFI) {
- free_hog = G_PARTITION; /* default to g partition */
- ioparam.io_charlist = partn_list;
- free_hog = input(FIO_MSTR, "Free Hog partition", '?',
- &ioparam, &free_hog, DATA_INPUT);
- /* disallow c partition */
- if (free_hog == C_PARTITION) {
- fmt_print("'%c' cannot be the 'Free Hog' partition.\n",
- C_PARTITION + PARTITION_BASE);
- return (-1);
- }
- get_user_map_efi(cur_parts->etoc, free_hog);
- print_map(cur_parts);
- if (check("Ready to label disk, continue")) {
- return (-1);
- }
- fmt_print("\n");
- if (write_label()) {
- err_print("Writing label failed\n");
- return (-1);
- }
- return (0);
+ free_hog = G_PARTITION; /* default to g partition */
+ ioparam.io_charlist = partn_list;
+ free_hog = input(FIO_MSTR, "Free Hog partition", '?',
+ &ioparam, &free_hog, DATA_INPUT);
+ /* disallow c partition */
+ if (free_hog == C_PARTITION) {
+ fmt_print("'%c' cannot be the 'Free Hog' partition.\n",
+ C_PARTITION + PARTITION_BASE);
+ return (-1);
+ }
+ get_user_map_efi(cur_parts->etoc, free_hog);
+ print_map(cur_parts);
+ if (check("Ready to label disk, continue")) {
+ return (-1);
+ }
+ fmt_print("\n");
+ if (write_label()) {
+ err_print("Writing label failed\n");
+ return (-1);
+ }
+ return (0);
}
/*
* get user modified partition table
@@ -304,9 +292,8 @@ Warning: No space available from Free Hog partition.\n");
print_map(tmp_pinfo);
ioparam.io_charlist = confirm_list;
- if (input(FIO_MSTR, "\
-Okay to make this the current partition table", '?',
- &ioparam, &inpt_dflt, DATA_INPUT)) {
+ if (input(FIO_MSTR, "Okay to make this the current partition table",
+ '?', &ioparam, &inpt_dflt, DATA_INPUT)) {
return (0);
} else {
make_partition();
@@ -318,9 +305,9 @@ Okay to make this the current partition table", '?',
cur_parts->pinfo_map[i].dkl_cylno = map[i].dkl_cylno;
#ifdef i386
cur_parts->vtoc.v_part[i].p_start =
- map[i].dkl_cylno * nhead * nsect;
+ map[i].dkl_cylno * nhead * nsect;
cur_parts->vtoc.v_part[i].p_size =
- map[i].dkl_nblk;
+ map[i].dkl_nblk;
#endif
}
(void) p_name();
@@ -340,14 +327,11 @@ Okay to make this the current partition table", '?',
}
}
-
-
/*
* Adjust cylinder offsets
*/
static void
-adj_cyl_offset(map)
- struct dk_map32 *map;
+adj_cyl_offset(struct dk_map32 *map)
{
int i;
int cyloffset = 0;
@@ -390,8 +374,7 @@ adj_cyl_offset(map)
* Check partition table
*/
static int
-check_map(map)
- struct dk_map32 *map;
+check_map(struct dk_map32 *map)
{
int i;
int cyloffset = 0;
@@ -411,16 +394,16 @@ check_map(map)
*/
for (i = 0; i < NDKMAP; i++) {
if (map[i].dkl_cylno > (blkaddr32_t)ncyl-1) {
- err_print("\
-Warning: Partition %c starting cylinder %d is out of range.\n",
- (PARTITION_BASE+i), map[i].dkl_cylno);
+ err_print("Warning: Partition %c starting cylinder "
+ "%d is out of range.\n",
+ (PARTITION_BASE+i), map[i].dkl_cylno);
return (-1);
}
if (map[i].dkl_nblk >
- (blkaddr32_t)(ncyl - map[i].dkl_cylno) * spc()) {
- err_print("\
-Warning: Partition %c, specified # of blocks, %u, is out of range.\n",
- (PARTITION_BASE+i), map[i].dkl_nblk);
+ (blkaddr32_t)(ncyl - map[i].dkl_cylno) * spc()) {
+ err_print("Warning: Partition %c, specified # of "
+ "blocks, %u, is out of range.\n",
+ (PARTITION_BASE+i), map[i].dkl_nblk);
return (-1);
}
if (i != C_PARTITION && map[i].dkl_nblk) {
@@ -429,21 +412,21 @@ Warning: Partition %c, specified # of blocks, %u, is out of range.\n",
continue;
#endif
if (map[i].dkl_cylno < cyloffset) {
- err_print(
-"Warning: Overlapping partition (%c) in table.\n", PARTITION_BASE+i);
+ err_print("Warning: Overlapping partition "
+ "(%c) in table.\n", PARTITION_BASE+i);
return (-1);
} else if (map[i].dkl_cylno > cyloffset) {
- err_print(
-"Warning: Non-contiguous partition (%c) in table.\n", PARTITION_BASE+i);
+ err_print("Warning: Non-contiguous partition "
+ "(%c) in table.\n", PARTITION_BASE+i);
}
cyloffset += (map[i].dkl_nblk + (spc()-1))/spc();
tot_blks = map[i].dkl_nblk;
}
}
if (tot_blks > map[C_PARTITION].dkl_nblk) {
- err_print("\
-Warning: Total blocks used is greater than number of blocks in '%c'\n\
-\tpartition.\n", C_PARTITION + PARTITION_BASE);
+ err_print("Warning: Total blocks used is greater than number "
+ "of blocks in '%c'\n\tpartition.\n",
+ C_PARTITION + PARTITION_BASE);
return (-1);
}
return (0);
@@ -455,9 +438,7 @@ Warning: Total blocks used is greater than number of blocks in '%c'\n\
* get user defined partitions
*/
static void
-get_user_map(map, float_part)
- struct dk_map32 *map;
- int float_part;
+get_user_map(struct dk_map32 *map, int float_part)
{
int i;
blkaddr32_t newsize;
@@ -471,24 +452,24 @@ get_user_map(map, float_part)
for (i = 0; i < NDKMAP; i++) {
if (partn_list[i] == NULL)
break;
- if ((i == C_PARTITION) || (i == float_part))
+ if ((i == C_PARTITION) || (i == float_part)) {
continue;
- else {
+ } else {
ioparam.io_bounds.lower = 0;
ioparam.io_bounds.upper = map[i].dkl_nblk +
- map[float_part].dkl_nblk;
+ map[float_part].dkl_nblk;
deflt = map[i].dkl_nblk;
if (ioparam.io_bounds.upper == 0) {
- err_print("\
-Warning: no space available for '%s' from Free Hog partition\n",
- partn_list[i]);
+ err_print("Warning: no space available for "
+ "'%s' from Free Hog partition\n",
+ partn_list[i]);
continue;
}
(void) snprintf(tmpstr, sizeof (tmpstr),
- "Enter size of partition '%s' ",
- partn_list[i]);
+ "Enter size of partition '%s' ",
+ partn_list[i]);
newsize = (blkaddr32_t)input(FIO_CYL, tmpstr, ':',
- &ioparam, (int *)&deflt, DATA_INPUT);
+ &ioparam, (int *)&deflt, DATA_INPUT);
map[float_part].dkl_nblk -= (newsize - map[i].dkl_nblk);
map[i].dkl_nblk = newsize;
}
@@ -496,8 +477,7 @@ Warning: no space available for '%s' from Free Hog partition\n",
}
static struct partition_info *
-build_partition(tptr)
-struct disk_type *tptr;
+build_partition(struct disk_type *tptr)
{
struct partition_info *part;
struct dk_label *label;
@@ -524,21 +504,20 @@ struct disk_type *tptr;
if (!build_default_partition(label, cur_ctype->ctype_ctype))
return (NULL);
- part = (struct partition_info *)
- zalloc(sizeof (struct partition_info));
+ part = zalloc(sizeof (struct partition_info));
part->pinfo_name = alloc_string(tptr->dtype_asciilabel);
/*
* Fill in the partition info from the label
*/
for (i = 0; i < NDKMAP; i++) {
#if defined(_SUNOS_VTOC_8)
- part->pinfo_map[i] = label->dkl_map[i];
+ part->pinfo_map[i] = label->dkl_map[i];
#else
- part->pinfo_map[i].dkl_cylno =
- label->dkl_vtoc.v_part[i].p_start /
- (blkaddr32_t)(tptr->dtype_nhead * tptr->dtype_nsect - apc);
- part->pinfo_map[i].dkl_nblk =
- label->dkl_vtoc.v_part[i].p_size;
+ part->pinfo_map[i].dkl_cylno =
+ label->dkl_vtoc.v_part[i].p_start /
+ (blkaddr32_t)(tptr->dtype_nhead * tptr->dtype_nsect - apc);
+ part->pinfo_map[i].dkl_nblk =
+ label->dkl_vtoc.v_part[i].p_size;
#endif /* ifdefined(_SUNOS_VTOC_8) */
}
part->vtoc = label->dkl_vtoc;
@@ -549,11 +528,8 @@ struct disk_type *tptr;
* build new partition table for given disk type
*/
static void
-get_user_map_efi(map, float_part)
- struct dk_gpt *map;
- int float_part;
+get_user_map_efi(struct dk_gpt *map, int float_part)
{
-
int i;
efi_deflt_t efi_deflt;
u_ioparam_t ioparam;
@@ -591,7 +567,7 @@ get_user_map_efi(map, float_part)
}
map->efi_parts[float_part].p_start = start_lba;
map->efi_parts[float_part].p_size = map->efi_last_u_lba + 1 -
- start_lba - reserved;
+ start_lba - reserved;
map->efi_parts[float_part].p_tag = V_USR;
if (map->efi_parts[float_part].p_size == 0) {
map->efi_parts[float_part].p_size = 0;
@@ -612,8 +588,7 @@ get_user_map_efi(map, float_part)
void
-new_partitiontable(tptr, oldtptr)
-struct disk_type *tptr, *oldtptr;
+new_partitiontable(struct disk_type *tptr, struct disk_type *oldtptr)
{
struct partition_info *part;
@@ -622,16 +597,15 @@ struct disk_type *tptr, *oldtptr;
* partition table else copy the old partition table.(best guess).
*/
if ((oldtptr != NULL) &&
- (tptr->dtype_ncyl == oldtptr->dtype_ncyl) &&
- (tptr->dtype_nhead == oldtptr->dtype_nhead) &&
- (tptr->dtype_nsect == oldtptr->dtype_nsect)) {
-
- part = (struct partition_info *)
- zalloc(sizeof (struct partition_info));
- bcopy((char *)cur_parts, (char *)part,
- sizeof (struct partition_info));
- part->pinfo_next = tptr->dtype_plist;
- tptr->dtype_plist = part;
+ (tptr->dtype_ncyl == oldtptr->dtype_ncyl) &&
+ (tptr->dtype_nhead == oldtptr->dtype_nhead) &&
+ (tptr->dtype_nsect == oldtptr->dtype_nsect)) {
+ part = (struct partition_info *)
+ zalloc(sizeof (struct partition_info));
+ bcopy((char *)cur_parts, (char *)part,
+ sizeof (struct partition_info));
+ part->pinfo_next = tptr->dtype_plist;
+ tptr->dtype_plist = part;
} else {
#ifdef DEBUG
diff --git a/usr/src/cmd/format/partition.c b/usr/src/cmd/format/partition.c
index 7da2901ce5..1a376bd333 100644
--- a/usr/src/cmd/format/partition.c
+++ b/usr/src/cmd/format/partition.c
@@ -80,31 +80,31 @@ maxofN(struct dk_gpt *map)
int i;
for (i = 0; i < map->efi_nparts - 1; i++) {
- start[0] = map->efi_parts[i].p_start;
- size[0] = map->efi_parts[i].p_size;
- sec_no[0] = start[0] + size[0];
-
- start[1] = map->efi_parts[i+1].p_start;
- size[1] = map->efi_parts[i+1].p_size;
- sec_no[1] = start[1] + size[1];
-
- if (map->efi_parts[i].p_tag == V_BACKUP) {
- sec_no[0] = 0;
- }
- if (map->efi_parts[i+1].p_tag == V_BACKUP) {
- sec_no[1] = 0;
- }
- if (i == 0) {
- max = sec_no[1];
- }
- if (sec_no[0] > max) {
- max = sec_no[0];
- } else {
- max = max;
- }
+ start[0] = map->efi_parts[i].p_start;
+ size[0] = map->efi_parts[i].p_size;
+ sec_no[0] = start[0] + size[0];
+
+ start[1] = map->efi_parts[i + 1].p_start;
+ size[1] = map->efi_parts[i + 1].p_size;
+ sec_no[1] = start[1] + size[1];
+
+ if (map->efi_parts[i].p_tag == V_BACKUP) {
+ sec_no[0] = 0;
+ }
+ if (map->efi_parts[i+1].p_tag == V_BACKUP) {
+ sec_no[1] = 0;
+ }
+ if (i == 0) {
+ max = sec_no[1];
+ }
+ if (sec_no[0] > max) {
+ max = sec_no[0];
+ } else {
+ max = max;
+ }
}
if (max == 0)
- max = map->efi_first_u_lba;
+ max = map->efi_first_u_lba;
return (max);
}
@@ -136,66 +136,66 @@ change_partition(int num)
}
if (cur_label == L_TYPE_EFI) {
- if (num > cur_parts->etoc->efi_nparts - 1) {
- err_print("Invalid partition for EFI label\n");
- return;
- }
- print_efi_partition(cur_parts->etoc, num, 1);
- fmt_print("\n");
+ if (num > cur_parts->etoc->efi_nparts - 1) {
+ err_print("Invalid partition for EFI label\n");
+ return;
+ }
+ print_efi_partition(cur_parts->etoc, num, 1);
+ fmt_print("\n");
/*
* Prompt for p_tag and p_flag values for this partition
*/
- deflt = cur_parts->etoc->efi_parts[num].p_tag;
- if (deflt == V_UNASSIGNED) {
- deflt = V_USR;
- }
- (void) sprintf(msg, "Enter partition id tag");
- ioparam.io_slist = ptag_choices;
- tag = input(FIO_SLIST, msg, ':', &ioparam, &deflt, DATA_INPUT);
-
- deflt = cur_parts->etoc->efi_parts[num].p_flag;
- (void) sprintf(msg, "Enter partition permission flags");
- ioparam.io_slist = pflag_choices;
- flag = input(FIO_SLIST, msg, ':', &ioparam, &deflt, DATA_INPUT);
-
- ioparam.io_bounds.lower = cur_parts->etoc->efi_first_u_lba;
- ioparam.io_bounds.upper = cur_parts->etoc->efi_last_u_lba;
-
- efi_deflt.start_sector = maxofN(cur_parts->etoc);
- if ((cur_parts->etoc->efi_parts[num].p_start != 0) &&
- (cur_parts->etoc->efi_parts[num].p_size != 0)) {
- efi_deflt.start_sector =
- cur_parts->etoc->efi_parts[num].p_start;
- }
- efi_deflt.end_sector = ioparam.io_bounds.upper -
- efi_deflt.start_sector;
- i64 = input(FIO_INT64, "Enter new starting Sector", ':', &ioparam,
- (int *)&efi_deflt, DATA_INPUT);
-
- ioparam.io_bounds.lower = 0;
- ioparam.io_bounds.upper = cur_parts->etoc->efi_last_u_lba;
- efi_deflt.end_sector = cur_parts->etoc->efi_parts[num].p_size;
- efi_deflt.start_sector = i64;
- j64 = input(FIO_EFI, "Enter partition size", ':', &ioparam,
- (int *)&efi_deflt, DATA_INPUT);
- if (j64 == 0) {
- tag = V_UNASSIGNED;
- i64 = 0;
- } else if ((j64 != 0) && (tag == V_UNASSIGNED)) {
- tag = V_USR;
- }
+ deflt = cur_parts->etoc->efi_parts[num].p_tag;
+ if (deflt == V_UNASSIGNED) {
+ deflt = V_USR;
+ }
+ (void) sprintf(msg, "Enter partition id tag");
+ ioparam.io_slist = ptag_choices;
+ tag = input(FIO_SLIST, msg, ':', &ioparam, &deflt, DATA_INPUT);
+
+ deflt = cur_parts->etoc->efi_parts[num].p_flag;
+ (void) sprintf(msg, "Enter partition permission flags");
+ ioparam.io_slist = pflag_choices;
+ flag = input(FIO_SLIST, msg, ':', &ioparam, &deflt, DATA_INPUT);
+
+ ioparam.io_bounds.lower = cur_parts->etoc->efi_first_u_lba;
+ ioparam.io_bounds.upper = cur_parts->etoc->efi_last_u_lba;
+
+ efi_deflt.start_sector = maxofN(cur_parts->etoc);
+ if ((cur_parts->etoc->efi_parts[num].p_start != 0) &&
+ (cur_parts->etoc->efi_parts[num].p_size != 0)) {
+ efi_deflt.start_sector =
+ cur_parts->etoc->efi_parts[num].p_start;
+ }
+ efi_deflt.end_sector = ioparam.io_bounds.upper -
+ efi_deflt.start_sector;
+ i64 = input(FIO_INT64, "Enter new starting Sector", ':',
+ &ioparam, (int *)&efi_deflt, DATA_INPUT);
+
+ ioparam.io_bounds.lower = 0;
+ ioparam.io_bounds.upper = cur_parts->etoc->efi_last_u_lba;
+ efi_deflt.end_sector = cur_parts->etoc->efi_parts[num].p_size;
+ efi_deflt.start_sector = i64;
+ j64 = input(FIO_EFI, "Enter partition size", ':', &ioparam,
+ (int *)&efi_deflt, DATA_INPUT);
+ if (j64 == 0) {
+ tag = V_UNASSIGNED;
+ i64 = 0;
+ } else if ((j64 != 0) && (tag == V_UNASSIGNED)) {
+ tag = V_USR;
+ }
- if (cur_parts->pinfo_name != NULL)
- make_partition();
+ if (cur_parts->pinfo_name != NULL)
+ make_partition();
- cur_parts->etoc->efi_parts[num].p_tag = tag;
- cur_parts->etoc->efi_parts[num].p_flag = flag;
- cur_parts->etoc->efi_parts[num].p_start = i64;
- cur_parts->etoc->efi_parts[num].p_size = j64;
- /*
- * We are now done with EFI part, so return now
- */
- return;
+ cur_parts->etoc->efi_parts[num].p_tag = tag;
+ cur_parts->etoc->efi_parts[num].p_flag = flag;
+ cur_parts->etoc->efi_parts[num].p_start = i64;
+ cur_parts->etoc->efi_parts[num].p_size = j64;
+ /*
+ * We are now done with EFI part, so return now
+ */
+ return;
}
/*
* Print out the given partition so the user knows what they're
@@ -237,9 +237,11 @@ change_partition(int num)
if (tag != V_ALTSCTR) {
if (cur_parts->pinfo_map[J_PARTITION].dkl_nblk != 0) {
cyl_offset =
- cur_parts->pinfo_map[J_PARTITION].dkl_cylno +
- ((cur_parts->pinfo_map[J_PARTITION].dkl_nblk +
- (spc()-1)) / spc());
+ cur_parts->
+ pinfo_map[J_PARTITION].dkl_cylno +
+ ((cur_parts->
+ pinfo_map[J_PARTITION].dkl_nblk +
+ (spc() - 1)) / spc());
}
}
}
@@ -247,8 +249,7 @@ change_partition(int num)
ioparam.io_bounds.lower = 0;
ioparam.io_bounds.upper = ncyl - 1;
- deflt = max(cur_parts->pinfo_map[num].dkl_cylno,
- cyl_offset);
+ deflt = max(cur_parts->pinfo_map[num].dkl_cylno, cyl_offset);
i = (uint_t)input(FIO_INT, "Enter new starting cyl", ':', &ioparam,
&deflt, DATA_INPUT);
@@ -257,9 +258,8 @@ change_partition(int num)
/* fill in defaults for the current partition */
p_deflt.start_cyl = i;
- p_deflt.deflt_size =
- min(cur_parts->pinfo_map[num].dkl_nblk,
- ioparam.io_bounds.upper);
+ p_deflt.deflt_size = min(cur_parts->pinfo_map[num].dkl_nblk,
+ ioparam.io_bounds.upper);
/* call input, passing p_deflt's address, typecast to (int *) */
j = (uint_t)input(FIO_ECYL, "Enter partition size", ':', &ioparam,
@@ -378,18 +378,18 @@ get_partition()
*/
enter_critical();
for (pptr = parts; pptr != NULL; pptr = pptr->pinfo_next) {
- if (cur_dtype->dtype_asciilabel) {
- if (pptr->pinfo_name != NULL && strcmp(pptr->pinfo_name,
- cur_dtype->dtype_asciilabel) == 0) {
- /*
- * Set current partition and name it.
- */
- cur_disk->disk_parts = cur_parts = pptr;
- cur_parts->pinfo_name = pptr->pinfo_name;
- exit_critical();
- return (0);
+ if (cur_dtype->dtype_asciilabel) {
+ if (pptr->pinfo_name != NULL && strcmp(pptr->pinfo_name,
+ cur_dtype->dtype_asciilabel) == 0) {
+ /*
+ * Set current partition and name it.
+ */
+ cur_disk->disk_parts = cur_parts = pptr;
+ cur_parts->pinfo_name = pptr->pinfo_name;
+ exit_critical();
+ return (0);
+ }
}
- }
}
/*
* If we couldn't find a match, take the first one.
@@ -436,18 +436,19 @@ make_partition()
* If there was a current map, copy its values.
*/
if (cur_label == L_TYPE_EFI) {
- struct dk_gpt *map;
- int nparts;
- int size;
-
- nparts = cur_parts->etoc->efi_nparts;
- size = sizeof (struct dk_part) * nparts + sizeof (struct dk_gpt);
- map = zalloc(size);
- (void) memcpy(map, cur_parts->etoc, size);
- pptr->etoc = map;
- cur_disk->disk_parts = cur_parts = pptr;
- exit_critical();
- return;
+ struct dk_gpt *map;
+ int nparts;
+ int size;
+
+ nparts = cur_parts->etoc->efi_nparts;
+ size = sizeof (struct dk_part) * nparts +
+ sizeof (struct dk_gpt);
+ map = zalloc(size);
+ (void) memcpy(map, cur_parts->etoc, size);
+ pptr->etoc = map;
+ cur_disk->disk_parts = cur_parts = pptr;
+ exit_critical();
+ return;
}
if (cur_parts != NULL) {
for (i = 0; i < NDKMAP; i++) {