#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;
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);
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);
+}
You will get undefined results for other partition table
types (see C<guestfs_part_get_parttype>).");
+ ("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<device>. For the types of
+checksums supported see the C<guestfs_checksum> command.");
+
]
let all_functions = non_daemon_functions @ daemon_functions