diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-09-27 14:19:20 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-10-01 12:52:00 +0800 |
commit | b86a7a0533c4d723ea940ac2071f845f165f832c (patch) | |
tree | c01b932e9a31960e3acf6bbeddd4cc7f9d657ea1 /discover/parser.c | |
parent | e28232f4b8941ccd151abaaae3f18c32400436f3 (diff) | |
download | talos-petitboot-b86a7a0533c4d723ea940ac2071f845f165f832c.tar.gz talos-petitboot-b86a7a0533c4d723ea940ac2071f845f165f832c.zip |
discover: Add parser_request_file
Add a function to allow parsers to access files on a local device.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/parser.c')
-rw-r--r-- | discover/parser.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/discover/parser.c b/discover/parser.c index a304f0c..d34600d 100644 --- a/discover/parser.c +++ b/discover/parser.c @@ -22,9 +22,31 @@ struct p_item { STATIC_LIST(parsers); static char *local_path(struct discover_context *ctx, + struct discover_device *dev, const char *filename) { - return join_paths(ctx, ctx->device->mount_path, filename); + return join_paths(ctx, dev->mount_path, filename); +} + +int parser_request_file(struct discover_context *ctx, + struct discover_device *dev, const char *filename, + char **buf, int *len) + +{ + char *path; + int rc; + + /* we only support local files at present */ + if (!dev->mount_path) + return -1; + + path = local_path(ctx, dev, filename); + + rc = read_file(ctx, path, buf, len); + + talloc_free(path); + + return rc; } static int download_config(struct discover_context *ctx, char **buf, int *len) @@ -61,7 +83,7 @@ static void iterate_parser_files(struct discover_context *ctx, int rc, len; char *buf; - path = local_path(ctx, *filename); + path = local_path(ctx, ctx->device, *filename); if (!path) continue; |