]> git.ozlabs.org Git - petitboot/blobdiff - discover/parser.c
lib: Move ipmi_bootdev enum to types.h
[petitboot] / discover / parser.c
index 21b48debcb31d52e4f788040c1ce391e4ded7fc6..7833981ae3785d11aa072066f4aa834ae3a4acbc 100644 (file)
@@ -5,6 +5,7 @@
 #include <sys/stat.h>
 
 #include "types/types.h"
+#include <file/file.h>
 #include <log/log.h>
 #include <talloc/talloc.h>
 
@@ -12,7 +13,6 @@
 #include "parser.h"
 #include "parser-utils.h"
 #include "paths.h"
-#include "file.h"
 
 struct p_item {
        struct list_item list;
@@ -49,6 +49,25 @@ int parser_request_file(struct discover_context *ctx,
        return rc;
 }
 
+int parser_check_dir(struct discover_context *ctx,
+               struct discover_device *dev, const char *dirname)
+{
+       struct stat statbuf;
+       char *path;
+       int rc;
+
+       if (!dev->mount_path)
+               return -1;
+
+       path = local_path(ctx, dev, dirname);
+
+       rc = stat(path, &statbuf);
+       if (!rc)
+               return -1;
+
+       return S_ISDIR(statbuf.st_mode) ? 0 : -1;
+}
+
 int parser_replace_file(struct discover_context *ctx,
                struct discover_device *dev, const char *filename,
                char *buf, int len)