Re: [PATCH] Adds the ability to abort an MD5 sum check.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This patch introduces an ABI change, so you also
need to change the soname version (and then all deps will need to
be rebuild):

[hans@localhost ~]$ repoquery -q --whatrequires --alldeps isomd5sum
isomd5sum-devel-1:1.0.5-3.fc12.x86_64
mkinitrd-0:6.0.93-1.fc12.x86_64
isomd5sum-devel-1:1.0.5-3.fc12.i686
livecd-tools-0:031-1.fc12.1.x86_64
liveusb-creator-0:3.9.1-1.fc12.noarch
liveusb-creator-0:3.9-1.fc12.noarch
anaconda-0:12.46-2.fc12.x86_64
liveusb-creator-0:3.7.3-1.fc12.noarch

Also there is one small unneeded hunk in the second file being patched,
see below.

Also it would be good to hear from some other people what they think about
this, so people what do you think ?


On 01/04/2010 05:20 PM, Darryl L. Pierce wrote:
If the user presses [ENTER] then the check will exit. The return code
will be 2 and a message stating the check was aborted displayed to the
user.

Signed-off-by: Darryl L. Pierce<dpierce@xxxxxxxxxx>
---
  checkisomd5.c    |   25 ++++++++++++++++++++++++-
  libcheckisomd5.c |    3 ++-
  libcheckisomd5.h |    2 +-
  3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/checkisomd5.c b/checkisomd5.c
index c721f86..af582c1 100644
--- a/checkisomd5.c
+++ b/checkisomd5.c
@@ -22,6 +22,7 @@
  #include<stdlib.h>
  #include<string.h>
  #include<popt.h>
+#include<sys/select.h>

  #include "md5.h"
  #include "libcheckisomd5.h"
@@ -32,7 +33,23 @@ struct progressCBData {
      int gaugeat;
  };

-static void outputCB(void *co, long long offset, long long total) {
+int user_bailing_out() {
+  int retval = 0;
+  struct timeval timev;
+  fd_set rfds;
+
+  FD_ZERO(&rfds);
+  FD_SET(0,&rfds);
+
+  timev.tv_sec = 0;
+  timev.tv_usec = 0;
+
+  retval = select(1,&rfds, NULL, NULL,&timev);
+
+  return retval;
+}
+
+static int outputCB(void *co, long long offset, long long total) {
      struct progressCBData *data = co;
      int gaugeval = -1;

@@ -48,6 +65,8 @@ static void outputCB(void *co, long long offset, long long total) {
              data->gaugeat = gaugeval;
          }
      }
+
+    return user_bailing_out();
  }

  static void usage(void) {
@@ -101,6 +120,8 @@ int main(int argc, char **argv) {
      if (md5only)
  	exit(0);

+    printf("Press [ENTER] to abort check.\n");
+
      rc = mediaCheckFile((char *)args[0], outputCB,&data);

      if (data.verbose)
@@ -108,6 +129,8 @@ int main(int argc, char **argv) {

      if (rc == 0)
  	result = "FAIL.\n\nIt is not recommended to use this media.";
+    else if (rc == 2)
+      result = "UNKNOWN.\n\nThe media check was aborted.";
      else if (rc>  0)
  	result = "PASS.\n\nIt is OK to use this media.";
      else
diff --git a/libcheckisomd5.c b/libcheckisomd5.c
index 435f2c1..7ad93df 100644
--- a/libcheckisomd5.c
+++ b/libcheckisomd5.c
@@ -29,6 +29,7 @@
  #include<unistd.h>
  #include<fcntl.h>
  #include<string.h>
+#include<sys/select.h>

  #include "md5.h"
  #include "libcheckisomd5.h"

This hunk is not necessary.

@@ -270,7 +271,7 @@ static int checkmd5sum(int isofd, char *mediasum, char *computedsum, checkCallba
          }
  	offset = offset + nread;
  	if (cb)
-	    cb(cbdata, offset, isosize - skipsectors*2048);
+          if(cb(cbdata, offset, isosize - skipsectors*2048)) return 2;
      }

      if (cb)
diff --git a/libcheckisomd5.h b/libcheckisomd5.h
index 96f1ae9..5569a85 100644
--- a/libcheckisomd5.h
+++ b/libcheckisomd5.h
@@ -1,7 +1,7 @@
  #ifndef __LIBCHECKISOMD5_H__
  #define  __LIBCHECKISOMD5_H__

-typedef void (*checkCallback)(void *, long long offset, long long total);
+typedef int (*checkCallback)(void *, long long offset, long long total);

  int mediaCheckFile(char *iso, checkCallback cb, void *cbdata);
  void printMD5SUM(char *file);


Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux