summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/cbfs_core.h4
-rw-r--r--src/lib/cbfs_core.c16
2 files changed, 20 insertions, 0 deletions
diff --git a/src/include/cbfs_core.h b/src/include/cbfs_core.h
index 3cef9031ab..b01a30718f 100644
--- a/src/include/cbfs_core.h
+++ b/src/include/cbfs_core.h
@@ -224,6 +224,10 @@ struct cbfs_media {
ssize_t cbfs_locate_file(struct cbfs_media *media, struct cbfs_file *file,
const char *name);
+/* Read count bytes at offset into dest. Return number of bytes read. */
+size_t cbfs_read(struct cbfs_media *media, void *dest, size_t offset,
+ size_t count);
+
/* returns pointer to a file entry inside CBFS or NULL */
struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name);
diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c
index 24e5998f71..6455a07708 100644
--- a/src/lib/cbfs_core.c
+++ b/src/lib/cbfs_core.c
@@ -194,6 +194,22 @@ ssize_t cbfs_locate_file(struct cbfs_media *media, struct cbfs_file *file,
return -1;
}
+size_t cbfs_read(struct cbfs_media *media, void *dest, size_t offset,
+ size_t count)
+{
+ struct cbfs_media default_media;
+ size_t nread;
+
+ if (init_media(&media, &default_media))
+ return 0;
+
+ media->open(media);
+ nread = media->read(media, dest, offset, count);
+ media->close(media);
+
+ return nread;
+}
+
struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
{
struct cbfs_media default_media;