svn commit: r238091 - user/ae/bootcode/sys/boot/common

Andrey V. Elsukov ae at FreeBSD.org
Wed Jul 4 06:29:57 UTC 2012


Author: ae
Date: Wed Jul  4 06:29:56 2012
New Revision: 238091
URL: http://svn.freebsd.org/changeset/base/238091

Log:
  Revert r238067, instead use the proper format specifier for sprintf.
  Also change the display_size's output format.
  
  Suggested by:	marcel

Modified:
  user/ae/bootcode/sys/boot/common/disk.c
  user/ae/bootcode/sys/boot/common/part.c

Modified: user/ae/bootcode/sys/boot/common/disk.c
==============================================================================
--- user/ae/bootcode/sys/boot/common/disk.c	Wed Jul  4 00:54:16 2012	(r238090)
+++ user/ae/bootcode/sys/boot/common/disk.c	Wed Jul  4 06:29:56 2012	(r238091)
@@ -73,7 +73,7 @@ display_size(uint64_t size, u_int sector
 		size /= 1024;
 		unit = 'M';
 	}
-	sprintf(buf, "%.6ld%cB", (long)size, unit);
+	sprintf(buf, "%ld%cB", (long)size, unit);
 	return (buf);
 }
 
@@ -89,6 +89,7 @@ ptblread(void *d, void *buf, size_t bloc
 	    blocks * od->sectorsize, (char *)buf, NULL));
 }
 
+#define	PWIDTH	35
 static void
 ptable_print(void *arg, const char *pname, const struct ptable_entry *part)
 {
@@ -99,9 +100,13 @@ ptable_print(void *arg, const char *pnam
 
 	pa = (struct print_args *)arg;
 	od = (struct open_disk *)pa->dev->d_opendata;
-	sprintf(line, "  %s%s: %s %s\n", pa->prefix, pname,
-	    parttype2str(part->type), pa->verbose == 0 ? "":
-	    display_size(part->end - part->start + 1, od->sectorsize));
+	sprintf(line, "  %s%s: %s", pa->prefix, pname,
+	    parttype2str(part->type));
+	if (pa->verbose)
+		sprintf(line, "%-*s%s", PWIDTH, line,
+		    display_size(part->end - part->start + 1,
+		    od->sectorsize));
+	strcat(line, "\n");
 	pager_output(line);
 	if (part->type == PART_FREEBSD) {
 		/* Open slice with BSD label */
@@ -118,6 +123,7 @@ ptable_print(void *arg, const char *pnam
 		ptable_close(table);
 	}
 }
+#undef PWIDTH
 
 void
 disk_print(struct disk_devdesc *dev, char *prefix, int verbose)

Modified: user/ae/bootcode/sys/boot/common/part.c
==============================================================================
--- user/ae/bootcode/sys/boot/common/part.c	Wed Jul  4 00:54:16 2012	(r238090)
+++ user/ae/bootcode/sys/boot/common/part.c	Wed Jul  4 06:29:56 2012	(r238091)
@@ -88,17 +88,17 @@ static struct parttypes {
 	enum partition_type	type;
 	const char		*desc;
 } ptypes[] = {
-	{ PART_UNKNOWN,		"Unknown      " },
-	{ PART_EFI,		"EFI          " },
-	{ PART_FREEBSD,		"FreeBSD      " },
-	{ PART_FREEBSD_BOOT,	"FreeBSD boot " },
-	{ PART_FREEBSD_UFS,	"FreeBSD UFS  " },
-	{ PART_FREEBSD_ZFS,	"FreeBSD ZFS  " },
-	{ PART_FREEBSD_SWAP,	"FreeBSD swap " },
+	{ PART_UNKNOWN,		"Unknown" },
+	{ PART_EFI,		"EFI" },
+	{ PART_FREEBSD,		"FreeBSD" },
+	{ PART_FREEBSD_BOOT,	"FreeBSD boot" },
+	{ PART_FREEBSD_UFS,	"FreeBSD UFS" },
+	{ PART_FREEBSD_ZFS,	"FreeBSD ZFS" },
+	{ PART_FREEBSD_SWAP,	"FreeBSD swap" },
 	{ PART_FREEBSD_VINUM,	"FreeBSD vinum" },
-	{ PART_LINUX,		"Linux        " },
-	{ PART_LINUX_SWAP,	"Linux swap   " },
-	{ PART_DOS,		"DOS/Windows  " },
+	{ PART_LINUX,		"Linux" },
+	{ PART_LINUX_SWAP,	"Linux swap" },
+	{ PART_DOS,		"DOS/Windows" },
 };
 
 const char *


More information about the svn-src-user mailing list