]> git.ozlabs.org Git - petitboot/blobdiff - discover/parser.c
discover: Add support for checking directories in parser API
[petitboot] / discover / parser.c
index 21b48debcb31d52e4f788040c1ce391e4ded7fc6..74b2559c8ab9776d138bddc7a8ea51ef9625351d 100644 (file)
@@ -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)