[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cdi-devel] [PATCH 05/11] ext2: Implement .fs_probe
Cc: cdi-devel@xxxxxxxxxx
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
src/modules/cdi/ext2/ext2_cdi.h | 1 +
src/modules/cdi/ext2/init.c | 22 ++++++++++++++++++++++
src/modules/cdi/ext2/main.c | 1 +
3 files changed, 24 insertions(+)
diff --git a/src/modules/cdi/ext2/ext2_cdi.h b/src/modules/cdi/ext2/ext2_cdi.h
index 00de2a2..7ad9c46 100644
--- a/src/modules/cdi/ext2/ext2_cdi.h
+++ b/src/modules/cdi/ext2/ext2_cdi.h
@@ -57,6 +57,7 @@ struct ext2_fs_res {
// CDI-IF
+int ext2_fs_probe(struct cdi_fs_filesystem* cdi_fs, char** volname);
int ext2_fs_init(struct cdi_fs_filesystem* fs);
int ext2_fs_destroy(struct cdi_fs_filesystem* fs);
diff --git a/src/modules/cdi/ext2/init.c b/src/modules/cdi/ext2/init.c
index d20f647..2da556f 100644
--- a/src/modules/cdi/ext2/init.c
+++ b/src/modules/cdi/ext2/init.c
@@ -51,6 +51,28 @@ static int dev_write(uint64_t start, size_t size, const void* data, void* prv)
return cdi_fs_data_write(fs, start, size, data);
}
+int ext2_fs_probe(struct cdi_fs_filesystem* cdi_fs, char** volname)
+{
+ ext2_superblock_t sb;
+ int ret;
+
+ ext2_fs_t fs = {
+ .dev_read = dev_read,
+ .dev_private = cdi_fs,
+ };
+
+ ret = ext2_sb_read(&fs, &sb);
+ if (ret == 0) {
+ return 0;
+ }
+
+ *volname = malloc(sizeof(sb.volume_name) + 1);
+ memcpy(*volname, sb.volume_name, sizeof(sb.volume_name));
+ (*volname)[sizeof(sb.volume_name)] = '\0';
+
+ return 1;
+}
+
int ext2_fs_init(struct cdi_fs_filesystem* cdi_fs)
{
struct ext2_fs_res* root_res;
diff --git a/src/modules/cdi/ext2/main.c b/src/modules/cdi/ext2/main.c
index a1d597f..24f4594 100644
--- a/src/modules/cdi/ext2/main.c
+++ b/src/modules/cdi/ext2/main.c
@@ -72,6 +72,7 @@ static struct cdi_fs_driver ext2_driver = {
.init = ext2_driver_init,
.destroy = ext2_driver_destroy,
},
+ .fs_probe = ext2_fs_probe,
.fs_init = ext2_fs_init,
.fs_destroy = ext2_fs_destroy,
};
--
2.1.4