X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fchecksum.c;h=24232650cea7b59591638e43a58991e2443fd880;hp=3654b650715af3165427e198474e5c92cdedf061;hb=ac2a53bbab44fe94306092b47aeddb899c55345a;hpb=56bef498f46ac3dd580f4bde3c8f3ed2fe688826 diff --git a/daemon/checksum.c b/daemon/checksum.c index 3654b65..2423265 100644 --- a/daemon/checksum.c +++ b/daemon/checksum.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,15 +28,13 @@ #include "actions.h" char * -do_checksum (char *csumtype, char *path) +do_checksum (const char *csumtype, const char *path) { const char *program; char *buf; char *out, *err; - int r, len; - - NEED_ROOT (NULL); - ABS_PATH (path, NULL); + int r; + int len; if (strcasecmp (csumtype, "crc") == 0) program = "cksum"; @@ -58,13 +56,11 @@ do_checksum (char *csumtype, char *path) } /* Make the path relative to /sysroot. */ - len = strlen (path) + 9; - buf = malloc (len); + buf = sysroot_path (path); if (!buf) { reply_with_perror ("malloc"); return NULL; } - snprintf (buf, len, "/sysroot%s", path); r = command (&out, &err, program, buf, NULL); free (buf);