summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-01-05 10:01:09 +0200
committerDan McDonald <danmcd@joyent.com>2019-01-07 10:05:12 -0500
commit916bf6b9509e36cfde18ed64b9fa13c942d2d9bd (patch)
tree3c2472a021ef5ded3bb5250772efa1b8c2196ee2
parent467e811cd2cb3b7e96cdf5621c4ed383e2b3efc8 (diff)
downloadillumos-joyent-916bf6b9509e36cfde18ed64b9fa13c942d2d9bd.tar.gz
10177 etdump: additional cstyle cleanup and remove unused functions
Reviewed by: John Levon <john.levon@joyent.com> Reviewed by: Gergő Mihály Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/etdump/Makefile4
-rw-r--r--usr/src/cmd/etdump/THIRDPARTYLICENSE.descrip2
-rw-r--r--usr/src/cmd/etdump/cd9660_conversion.c191
-rw-r--r--usr/src/cmd/etdump/etdump.c11
-rw-r--r--usr/src/cmd/etdump/output_shell.c5
-rw-r--r--usr/src/cmd/etdump/output_text.c4
6 files changed, 20 insertions, 197 deletions
diff --git a/usr/src/cmd/etdump/Makefile b/usr/src/cmd/etdump/Makefile
index 8776a2d698..1ff307b3cd 100644
--- a/usr/src/cmd/etdump/Makefile
+++ b/usr/src/cmd/etdump/Makefile
@@ -10,11 +10,11 @@
#
#
-# Copyright 2018 Toomas Soome <tsoome@me.com>
+# Copyright 2019 Toomas Soome <tsoome@me.com>
#
PROG= etdump
-OBJS= etdump.o output_shell.o output_text.o cd9660_conversion.o
+OBJS= etdump.o output_shell.o output_text.o
SRCS= $(OBJS:%.o=%.c)
include ../Makefile.cmd
diff --git a/usr/src/cmd/etdump/THIRDPARTYLICENSE.descrip b/usr/src/cmd/etdump/THIRDPARTYLICENSE.descrip
index 18f61b4a66..e7afc0fa1d 100644
--- a/usr/src/cmd/etdump/THIRDPARTYLICENSE.descrip
+++ b/usr/src/cmd/etdump/THIRDPARTYLICENSE.descrip
@@ -1 +1 @@
-etdump utility cpommand
+etdump utility command
diff --git a/usr/src/cmd/etdump/cd9660_conversion.c b/usr/src/cmd/etdump/cd9660_conversion.c
deleted file mode 100644
index a980af35fb..0000000000
--- a/usr/src/cmd/etdump/cd9660_conversion.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * $NetBSD: cd9660_conversion.c,v 1.4 2007/03/14 14:11:17 christos Exp $
- */
-
-/*
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
- *
- * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
- * Perez-Rathke and Ram Vedam. All rights reserved.
- *
- * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
- * Alan Perez-Rathke and Ram Vedam.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
- * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
- * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <endian.h>
-
-static char cd9660_compute_gm_offset(time_t);
-
-/*
- * These can probably be implemented using a macro
- */
-
-/* Little endian */
-void
-cd9660_721(uint16_t w, unsigned char *twochar)
-{
-#if BYTE_ORDER == BIG_ENDIAN
- w = htole16(w);
-#endif
- memcpy(twochar, &w, 2);
-}
-
-void
-cd9660_731(uint32_t w, unsigned char *fourchar)
-{
-#if BYTE_ORDER == BIG_ENDIAN
- w = htole32(w);
-#endif
- memcpy(fourchar, &w, 4);
-}
-
-/* Big endian */
-void
-cd9660_722(uint16_t w, unsigned char *twochar)
-{
-#if BYTE_ORDER == LITTLE_ENDIAN
- w = htobe16(w);
-#endif
- memcpy(twochar, &w, 2);
-}
-
-void
-cd9660_732(uint32_t w, unsigned char *fourchar)
-{
-#if BYTE_ORDER == LITTLE_ENDIAN
- w = htobe32(w);
-#endif
- memcpy(fourchar, &w, 4);
-}
-
-/*
- * Convert a dword into a double endian string of eight characters
- * @param int The double word to convert
- * @param char* The string to write the both endian double word to - It is
- * assumed this is allocated and at least eight characters long.
- */
-void
-cd9660_bothendian_dword(uint32_t dw, unsigned char *eightchar)
-{
- uint32_t le, be;
-#if BYTE_ORDER == LITTLE_ENDIAN
- le = dw;
- be = htobe32(dw);
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- be = dw;
- le = htole32(dw);
-#endif
- memcpy(eightchar, &le, 4);
- memcpy((eightchar+4), &be, 4);
-}
-
-/*
- * Convert a word into a double endian string of four characters
- * @param int The word to convert
- * @param char* The string to write the both endian word to - It is assumed
- * this is allocated and at least four characters long.
- */
-void
-cd9660_bothendian_word(uint16_t dw, unsigned char *fourchar)
-{
- uint16_t le, be;
-#if BYTE_ORDER == LITTLE_ENDIAN
- le = dw;
- be = htobe16(dw);
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- be = dw;
- le = htole16(dw);
-#endif
- memcpy(fourchar, &le, 2);
- memcpy((fourchar+2), &be, 2);
-}
-
-void
-cd9660_pad_string_spaces(char *str, int len)
-{
- int i;
-
- for (i = 0; i < len; i ++) {
- if (str[i] == '\0')
- str[i] = 0x20;
- }
-}
-
-static char
-cd9660_compute_gm_offset(time_t tim)
-{
- struct tm t, gm;
-
- (void) localtime_r(&tim, &t);
- (void) gmtime_r(&tim, &gm);
- gm.tm_year -= t.tm_year;
- gm.tm_yday -= t.tm_yday;
- gm.tm_hour -= t.tm_hour;
- gm.tm_min -= t.tm_min;
- if (gm.tm_year < 0)
- gm.tm_yday = -1;
- else if (gm.tm_year > 0)
- gm.tm_yday = 1;
-
- return (char)(-(gm.tm_min + 60* (24 * gm.tm_yday + gm.tm_hour)) / 15);
-}
-
-/* Long dates: 17 characters */
-void
-cd9660_time_8426(unsigned char *buf, time_t tim)
-{
- struct tm t;
- char temp[18];
-
- (void) localtime_r(&tim, &t);
- (void) snprintf(temp, sizeof (temp), "%04i%02i%02i%02i%02i%02i%02i",
- 1900 + (int)t.tm_year, (int)t.tm_mon + 1, (int)t.tm_mday,
- (int)t.tm_hour, (int)t.tm_min, (int)t.tm_sec, 0);
- (void) memcpy(buf, temp, 16);
- buf[16] = cd9660_compute_gm_offset(tim);
-}
-
-/* Short dates: 7 characters */
-void
-cd9660_time_915(unsigned char *buf, time_t tim)
-{
- struct tm t;
-
- (void) localtime_r(&tim, &t);
- buf[0] = t.tm_year;
- buf[1] = t.tm_mon+1;
- buf[2] = t.tm_mday;
- buf[3] = t.tm_hour;
- buf[4] = t.tm_min;
- buf[5] = t.tm_sec;
- buf[6] = cd9660_compute_gm_offset(tim);
-}
diff --git a/usr/src/cmd/etdump/etdump.c b/usr/src/cmd/etdump/etdump.c
index 5469597151..60b2c332b1 100644
--- a/usr/src/cmd/etdump/etdump.c
+++ b/usr/src/cmd/etdump/etdump.c
@@ -33,6 +33,7 @@
#include <string.h>
#include <errno.h>
#include <sys/queue.h>
+#include <endian.h>
#include <sys/fs/hsfs_isospec.h>
#include "cd9660_eltorito.h"
@@ -42,6 +43,16 @@
#define ISO_DEFAULT_BLOCK_SHIFT 11
#define ISO_DEFAULT_BLOCK_SIZE (1 << ISO_DEFAULT_BLOCK_SHIFT)
+/* Little endian */
+void
+cd9660_721(uint16_t w, unsigned char *twochar)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ w = htole16(w);
+#endif
+ memcpy(twochar, &w, 2);
+}
+
const char *
system_id_string(uchar_t system_id)
{
diff --git a/usr/src/cmd/etdump/output_shell.c b/usr/src/cmd/etdump/output_shell.c
index 291983ff64..c9ba4bf311 100644
--- a/usr/src/cmd/etdump/output_shell.c
+++ b/usr/src/cmd/etdump/output_shell.c
@@ -26,6 +26,7 @@
#include <stdbool.h>
#include <stdio.h>
+#include <inttypes.h>
#include "cd9660_eltorito.h"
@@ -51,8 +52,8 @@ output_entry(FILE *outfile, const char *filename __unused,
platform = system_id_string(platform_id);
fprintf(outfile,
- "et_platform=%s;et_system=%s;et_lba=%d;et_sectors=%d\n",
- platform, system_id_string(bcse->system_type[0]),
+ "et_platform=%s;et_system=%s;et_lba=%" PRIu32 ";et_sectors=%"
+ PRIu16 "\n", platform, system_id_string(bcse->system_type[0]),
isonum_731(bcse->load_rba), isonum_721(bcse->sector_count));
}
diff --git a/usr/src/cmd/etdump/output_text.c b/usr/src/cmd/etdump/output_text.c
index eb0681c63f..d1b40e65f6 100644
--- a/usr/src/cmd/etdump/output_text.c
+++ b/usr/src/cmd/etdump/output_text.c
@@ -26,6 +26,7 @@
#include <stdbool.h>
#include <stdio.h>
+#include <inttypes.h>
#include "cd9660_eltorito.h"
#include "etdump.h"
@@ -77,7 +78,8 @@ output_entry(FILE *outfile, const char *filename __unused,
fprintf(outfile, "%sSystem %s\n", indent,
system_id_string(bcse->system_type[0]));
- fprintf(outfile, "%sStart LBA %d (0x%x), sector count %d (0x%x)\n",
+ fprintf(outfile, "%sStart LBA %" PRIu32 " (0x%" PRIx32
+ "), sector count %" PRIu16 " (0x%" PRIx16 ")\n",
indent, isonum_731(bcse->load_rba), isonum_731(bcse->load_rba),
isonum_721(bcse->sector_count), isonum_721(bcse->sector_count));
fprintf(outfile, "%sMedia type: %s\n", indent,