summaryrefslogtreecommitdiffstats
path: root/__root__/ccs-flatten
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-05-07 19:34:59 +0200
committerJan Pokorný <jpokorny@redhat.com>2014-05-07 19:34:59 +0200
commit8c8cefa4d1caa5e0fa1727b5f9f2261ac4d07338 (patch)
tree0c641d944bc1c1c5b77b341dd9485691db3d598e /__root__/ccs-flatten
parentfe0497db4db4e4e5e2ac6f374f0dbba1c3b0fc83 (diff)
downloadclufter-8c8cefa4d1caa5e0fa1727b5f9f2261ac4d07338.tar.gz
clufter-8c8cefa4d1caa5e0fa1727b5f9f2261ac4d07338.tar.xz
clufter-8c8cefa4d1caa5e0fa1727b5f9f2261ac4d07338.zip
ccs-flatten: code both removed-stale and added-needed
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to '__root__/ccs-flatten')
-rw-r--r--__root__/ccs-flatten/flatten.c13
-rw-r--r--__root__/ccs-flatten/resrules.c8
2 files changed, 9 insertions, 12 deletions
diff --git a/__root__/ccs-flatten/flatten.c b/__root__/ccs-flatten/flatten.c
index e2f0662..f7ef546 100644
--- a/__root__/ccs-flatten/flatten.c
+++ b/__root__/ccs-flatten/flatten.c
@@ -108,7 +108,7 @@ replace_resource(xmlNodePtr rm, char *restype, char *primattr, char *ident, xmlN
}
static int
-flatten(int argc, char **argv, xmlDocPtr * doc)
+flatten(int argc, char **argv)
{
xmlDocPtr d = NULL;
xmlNode *n = NULL, *rm = NULL, *new_rb = NULL;
@@ -142,7 +142,6 @@ flatten(int argc, char **argv, xmlDocPtr * doc)
/* allow fallback to rawmetadata, but not the other way around */
do {
- fprintf(stderr, "%s\n", rawmetadata ? "raw":"noraw");
load_resource_rules(agentpath, &rulelist, rawmetadata);
if (rulelist)
break;
@@ -200,11 +199,6 @@ flatten(int argc, char **argv, xmlDocPtr * doc)
fclose(f);
out:
- if (ret < 0) {
- xmlFreeDoc(d);
- } else {
- *doc = d;
- }
conf_close();
destroy_resource_tree(&tree);
destroy_resources(&reslist);
@@ -232,7 +226,6 @@ main(int argc, char **argv)
{
char *arg0 = basename(argv[0]);
int ret = 0;
- xmlDocPtr doc = NULL;
if (argc < 2) {
usage(arg0, 1);
@@ -247,10 +240,8 @@ main(int argc, char **argv)
xmlKeepBlanksDefault(0);
shift();
- ret = flatten(argc, argv, &doc);
+ ret = flatten(argc, argv);
- //if (doc)
- //xmlFreeDoc(doc);
xmlCleanupParser();
return ret;
}
diff --git a/__root__/ccs-flatten/resrules.c b/__root__/ccs-flatten/resrules.c
index 9187c00..db2078d 100644
--- a/__root__/ccs-flatten/resrules.c
+++ b/__root__/ccs-flatten/resrules.c
@@ -938,7 +938,7 @@ load_resource_rules(const char *rpath, resource_rule_t ** rules,
/* 1st cond: 8+ items symloop (if 8 <= SYMLOOP_MAX) or readlink fail */
if (i >= 8 || !(dir = opendir(dirname(*path1))))
return -1;
- rpath = *path1;
+ rpath = *path1;
}
xmlInitParser();
@@ -967,6 +967,12 @@ load_resource_rules(const char *rpath, resource_rule_t ** rules,
}
}
+#ifdef RAWMETADATA_EXT
+ /* when only raw metadata accepted */
+ if (rawmetadata && (!dot || strcmp(dot + 1, RAWMETADATA_EXT)))
+ continue;
+#endif
+
snprintf(path, sizeof(path), "%s/%s", rpath, de->d_name);
if (stat(path, &st_buf) < 0)