changeset 16404:16183ae98947

lib-fs: Added fs_get_root_driver()
author Timo Sirainen <tss@iki.fi>
date Tue, 28 May 2013 01:03:58 +0300
parents 967ef2a7fa6f
children f9f6467001b9
files src/lib-fs/fs-api.c src/lib-fs/fs-api.h
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-fs/fs-api.c	Mon May 27 21:03:14 2013 +0300
+++ b/src/lib-fs/fs-api.c	Tue May 28 01:03:58 2013 +0300
@@ -140,6 +140,13 @@
 	str_free(&last_error);
 }
 
+const char *fs_get_root_driver(struct fs *fs)
+{
+	while (fs->parent != NULL)
+		fs = fs->parent;
+	return fs->name;
+}
+
 struct fs_file *fs_file_init(struct fs *fs, const char *path, int mode_flags)
 {
 	struct fs_file *file;
--- a/src/lib-fs/fs-api.h	Mon May 27 21:03:14 2013 +0300
+++ b/src/lib-fs/fs-api.h	Tue May 28 01:03:58 2013 +0300
@@ -92,6 +92,9 @@
 	    struct fs **fs_r, const char **error_r);
 void fs_deinit(struct fs **fs);
 
+/* Returns the root fs's driver name (bypassing all wrapper fses) */
+const char *fs_get_root_driver(struct fs *fs);
+
 struct fs_file *fs_file_init(struct fs *fs, const char *path, int mode_flags);
 void fs_file_deinit(struct fs_file **file);