X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fdocker%2Frootfs_prefix%2Frootfs_prefix.c;h=2b831518dce43e09dc99e20b4283efeb6f3aee9e;hb=9c6c1bdb92537f307d245c52349d3f196ec4d33d;hp=c27a67afd12eeebfcc94dfba288c5a464bbe4373;hpb=fe6da88c2eb1637ef6dce0a7d928c202ededc450;p=collectd.git diff --git a/contrib/docker/rootfs_prefix/rootfs_prefix.c b/contrib/docker/rootfs_prefix/rootfs_prefix.c index c27a67af..2b831518 100644 --- a/contrib/docker/rootfs_prefix/rootfs_prefix.c +++ b/contrib/docker/rootfs_prefix/rootfs_prefix.c @@ -11,28 +11,22 @@ #define BUFSIZE 256 const char *add_prefix(const char *orig, char *prefixed) { - int status; - int errno; - - if ((strncmp(orig, "/proc", 5) == 0) || (strncmp(orig, "/sys", 4) == 0)) { - - status = snprintf(prefixed, BUFSIZE, "%s%s", PREFIX, orig); - if ((unsigned int)status >= BUFSIZE) { - error(status, ENAMETOOLONG, - "'%s' got truncated when adding '%s' prefix: '%s'", orig, PREFIX, - prefixed); - return orig; - } else if (status < 1) { - error(status, errno, - "adding '%s' prefix to file path failed: '%s' -> '%s'", PREFIX, - orig, prefixed); - return orig; - } else { - return (const char *)prefixed; - } + if ((strncmp(orig, "/proc", strlen("/proc")) != 0) && + (strncmp(orig, "/sys", strlen("/sys")) != 0)) + return orig; - } else { + int status = snprintf(prefixed, BUFSIZE, "%s%s", PREFIX, orig); + if (status < 1) { + error(status, errno, "adding '%s' prefix to file path failed: '%s' -> '%s'", + PREFIX, orig, prefixed); + return orig; + } else if ((unsigned int)status >= BUFSIZE) { + error(status, ENAMETOOLONG, + "'%s' got truncated when adding '%s' prefix: '%s'", orig, PREFIX, + prefixed); return orig; + } else { + return (const char *)prefixed; } }