summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--isomd5sum/checkisomd5.c37
-rw-r--r--isomd5sum/libcheckisomd5.c8
-rw-r--r--isomd5sum/libimplantisomd5.c8
3 files changed, 40 insertions, 13 deletions
diff --git a/isomd5sum/checkisomd5.c b/isomd5sum/checkisomd5.c
index 6ddd37fdf..75ad87279 100644
--- a/isomd5sum/checkisomd5.c
+++ b/isomd5sum/checkisomd5.c
@@ -8,20 +8,43 @@
#include "libcheckisomd5.h"
int main(int argc, char **argv) {
+ int i;
int rc;
+ int verbose;
+ int md5only;
+ int filearg;
if (argc < 2) {
- printf("Usage: checkisomd5 [--md5sumonly] <isofilename>|<blockdevice>\n\n");
+ printf("Usage: checkisomd5 [--md5sumonly] [--verbose] <isofilename>|<blockdevice>\n\n");
exit(1);
}
- /* see if they just want md5sum */
- if (strcmp(argv[1], "--md5sumonly") == 0) {
- printMD5SUM(argv[2]);
- exit(0);
+ md5only = 0;
+ verbose = 0;
+ filearg = 1;
+ for (i=1; i < argc; i++) {
+ if (strcmp(argv[i], "--md5sumonly") == 0) {
+ md5only = 1;
+ filearg++;
+ } else if (strcmp(argv[i], "--verbose") == 0) {
+ filearg++;
+ verbose = 1;
+ } else
+ break;
}
- rc = mediaCheckFile(argv[1], 1);
+ if (md5only|verbose)
+ printMD5SUM(argv[filearg]);
+
+ if (md5only)
+ exit(0);
+
+ rc = mediaCheckFile(argv[filearg], !verbose);
- exit(rc ? 0 : 1);
+ /* 1 means it passed, 0 means it failed, -1 means we couldnt find chksum */
+ if (rc == 1)
+ exit(0);
+ else
+ exit(1);
}
+
diff --git a/isomd5sum/libcheckisomd5.c b/isomd5sum/libcheckisomd5.c
index 621bd92c0..847b41055 100644
--- a/isomd5sum/libcheckisomd5.c
+++ b/isomd5sum/libcheckisomd5.c
@@ -237,7 +237,7 @@ static int doMediaCheck(int isofd, char *mediasum, char *computedsum, long long
if (parsepvd(isofd, mediasum, &skipsectors, isosize, supported) < 0) {
fprintf(stderr, "Unable to read the disc checksum from the "
- "primary volume descriptor. This probably "
+ "primary volume descriptor.\nThis probably "
"means the disc was created without adding the "
"checksum.");
return -1;
@@ -274,7 +274,7 @@ int mediaCheckFile(char *file, int quiet) {
if (!quiet)
fprintf(stderr, "The supported flag value is %d\n", supported);
- if ( rc == 0)
+ if (rc == 0)
result = "FAIL.\n\nIt is not recommended to use this media.";
else if (rc > 0)
result = "PASS.\n\nIt is OK to install from this media.";
@@ -307,6 +307,10 @@ int printMD5SUM(char *file) {
if (parsepvd(isofd, mediasum, &skipsectors, &isosize, &supported) < 0) {
fprintf(stderr, "%s: Could not get pvd data", file);
+ fprintf(stderr, "\nUnable to read the disc checksum from the "
+ "primary volume descriptor.\nThis probably "
+ "means the disc was created without adding the "
+ "checksum.");
exit(1);
}
diff --git a/isomd5sum/libimplantisomd5.c b/isomd5sum/libimplantisomd5.c
index 33c223b09..4d7d4c5d0 100644
--- a/isomd5sum/libimplantisomd5.c
+++ b/isomd5sum/libimplantisomd5.c
@@ -27,12 +27,12 @@ static int parsepvd(int isofd, char *mediasum, long long *isosize) {
long long offset;
unsigned char *p;
- if (lseek(isofd, (off_t)(16L * 2048L), SEEK_SET) == -1)
+ if (lseek(isofd, 16*2048, SEEK_SET) == -1)
return ((long long)-1);
-
- offset = (16L * 2048L);
+
+ offset = (16 * 2048);
for (;1;) {
- if (read(isofd, buf, 2048) <= 0)
+ if (read(isofd, buf, 2048L) == -1)
return ((long long)-1);
if (buf[0] == 1)