[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH 07/11] cdi/fs: Implementierung für .fs_probe
+ cdi/fs: lio_probe_service() benutzt jetzt den .fs_probe-Callbacks von
Dateisystemtreibern, um tatsächlich ein nützliches Ergebnis zu liefern
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
src/modules/cdi/include/cdi-osdep.h | 1 +
src/modules/cdi/lib/fs/fs.c | 8 ++++++--
src/modules/cdi/lib/fs/lostio_if.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/src/modules/cdi/include/cdi-osdep.h b/src/modules/cdi/include/cdi-osdep.h
index 94eba73..96f3e05 100644
--- a/src/modules/cdi/include/cdi-osdep.h
+++ b/src/modules/cdi/include/cdi-osdep.h
@@ -91,6 +91,7 @@ typedef struct {
*/
typedef struct {
struct lio_tree* tree;
+ lio_stream_t source;
} cdi_fs_osdep;
struct storage_drv_osdep {
diff --git a/src/modules/cdi/lib/fs/fs.c b/src/modules/cdi/lib/fs/fs.c
index aeca3ea..64a668b 100644
--- a/src/modules/cdi/lib/fs/fs.c
+++ b/src/modules/cdi/lib/fs/fs.c
@@ -40,6 +40,9 @@
#include "cdi/fs.h"
+int cdi_fs_lio_probe(struct lio_service* service,
+ lio_stream_t source,
+ struct lio_probe_service_result* probe_data);
struct lio_resource* cdi_fs_lio_load_root(struct lio_tree* tree);
int cdi_fs_lio_load_children(struct lio_resource* res);
int cdi_fs_lio_read(struct lio_resource* res, uint64_t offset,
@@ -74,6 +77,7 @@ void cdi_fs_driver_register(struct cdi_fs_driver* driver)
service->name = driver->drv.name;
service->opaque = driver;
service->lio_ops = (struct lio_driver) {
+ .probe = cdi_fs_lio_probe,
.load_root = cdi_fs_lio_load_root,
.load_children = cdi_fs_lio_load_children,
.read = cdi_fs_lio_read,
@@ -106,7 +110,7 @@ size_t cdi_fs_data_read(struct cdi_fs_filesystem* fs, uint64_t start,
{
ssize_t result;
- if ((result = lio_pread(fs->osdep.tree->source, start, size, buffer)) < 0) {
+ if ((result = lio_pread(fs->osdep.source, start, size, buffer)) < 0) {
// FIXME: Das ist irgendwie ein bescheiden
return 0;
}
@@ -130,7 +134,7 @@ size_t cdi_fs_data_write(struct cdi_fs_filesystem* fs, uint64_t start,
{
ssize_t result;
- if ((result = lio_pwrite(fs->osdep.tree->source, start, size, buffer)) < 0) {
+ if ((result = lio_pwrite(fs->osdep.source, start, size, buffer)) < 0) {
// FIXME: Das ist irgendwie ein bescheiden
return 0;
}
diff --git a/src/modules/cdi/lib/fs/lostio_if.c b/src/modules/cdi/lib/fs/lostio_if.c
index 2823c5f..2adf696 100644
--- a/src/modules/cdi/lib/fs/lostio_if.c
+++ b/src/modules/cdi/lib/fs/lostio_if.c
@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <syscall.h>
+#include <errno.h>
#include "cdi/fs.h"
@@ -104,6 +105,37 @@ static struct lio_resource* create_liores(struct cdi_fs_filesystem* fs,
return liores;
}
+int cdi_fs_lio_probe(struct lio_service* service,
+ lio_stream_t source,
+ struct lio_probe_service_result* probe_data)
+{
+ struct cdi_fs_driver* driver = service->opaque;
+ struct cdi_fs_filesystem* fs;
+ char* volname = NULL;
+ int ret;
+
+ if (driver->fs_probe == NULL) {
+ return -EINVAL;
+ }
+
+ fs = calloc(1, sizeof(*fs));
+ fs->driver = driver;
+ fs->osdep.source = source;
+
+ ret = driver->fs_probe(fs, &volname);
+ if (ret == 1) {
+ strlcpy(probe_data->volname, volname, sizeof(probe_data->volname));
+ ret = 0;
+ } else {
+ ret = -EINVAL;
+ }
+
+ free(volname);
+ free(fs);
+
+ return ret;
+}
+
struct lio_resource* cdi_fs_lio_load_root(struct lio_tree* tree)
{
struct cdi_fs_driver* driver = tree->service->opaque;
@@ -116,6 +148,7 @@ struct lio_resource* cdi_fs_lio_load_root(struct lio_tree* tree)
fs = calloc(1, sizeof(*fs));
fs->driver = driver;
fs->osdep.tree = tree;
+ fs->osdep.source = tree->source;
tree->opaque = fs;
if (!driver->fs_init(fs)) {
--
2.1.4