From 540da0bc1999deda670e846b8db7291826a1a728 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sat, 10 Apr 2010 21:23:27 +0100 Subject: [PATCH] New API: checksum-device for checksumming devices. Analogous to the usual 'checksum' call. --- daemon/checksum.c | 36 ++++++++++++++++++++++++------------ src/MAX_PROC_NR | 2 +- src/generator.ml | 10 ++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/daemon/checksum.c b/daemon/checksum.c index 499d19d..13719fd 100644 --- a/daemon/checksum.c +++ b/daemon/checksum.c @@ -27,11 +27,10 @@ #include "daemon.h" #include "actions.h" -char * -do_checksum (const char *csumtype, const char *path) +static char * +checksum (const char *csumtype, const char *path) { const char *program; - char *buf; char *out, *err; int r; int len; @@ -55,15 +54,7 @@ do_checksum (const char *csumtype, const char *path) return NULL; } - /* Make the path relative to /sysroot. */ - buf = sysroot_path (path); - if (!buf) { - reply_with_perror ("malloc"); - return NULL; - } - - r = command (&out, &err, program, buf, NULL); - free (buf); + r = command (&out, &err, program, path, NULL); if (r == -1) { reply_with_error ("%s: %s", program, err); free (out); @@ -79,3 +70,24 @@ do_checksum (const char *csumtype, const char *path) return out; /* Caller frees. */ } + +char * +do_checksum (const char *csumtype, const char *path) +{ + /* Make the path relative to /sysroot. */ + char *buf = sysroot_path (path); + if (!buf) { + reply_with_perror ("malloc"); + return NULL; + } + + char *r = checksum (csumtype, buf); + free (buf); + return r; +} + +char * +do_checksum_device (const char *csumtype, const char *device) +{ + return checksum (csumtype, device); +} diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index f1f094b..997def4 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -236 +237 diff --git a/src/generator.ml b/src/generator.ml index 50ae91d..535c412 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -4443,6 +4443,16 @@ Note that only MBR (old DOS-style) partitions have type bytes. You will get undefined results for other partition table types (see C)."); + ("checksum_device", (RString "checksum", [String "csumtype"; Device "device"]), 237, [], + [InitISOFS, Always, TestOutput ( + [["checksum_device"; "md5"; "/dev/sdd"]], + (Digest.to_hex (Digest.file "images/test.iso")))], + "compute MD5, SHAx or CRC checksum of the contents of a device", + "\ +This call computes the MD5, SHAx or CRC checksum of the +contents of the device named C. For the types of +checksums supported see the C command."); + ] let all_functions = non_daemon_functions @ daemon_functions -- 1.8.3.1