summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmount/docs/libmount-sections.txt2
-rw-r--r--libmount/src/libmount.h.in2
-rw-r--r--libmount/src/libmount.sym2
-rw-r--r--libmount/src/tab.c40
4 files changed, 46 insertions, 0 deletions
diff --git a/libmount/docs/libmount-sections.txt b/libmount/docs/libmount-sections.txt
index 5f8f1acbb..d5083216e 100644
--- a/libmount/docs/libmount-sections.txt
+++ b/libmount/docs/libmount-sections.txt
@@ -296,6 +296,7 @@ mnt_table_find_source
mnt_table_find_srcpath
mnt_table_find_tag
mnt_table_find_target
+mnt_table_first_fs
mnt_table_get_cache
mnt_table_get_intro_comment
mnt_table_get_nents
@@ -303,6 +304,7 @@ mnt_table_get_root_fs
mnt_table_get_trailing_comment
mnt_table_get_userdata
mnt_table_is_fs_mounted
+mnt_table_last_fs
mnt_table_next_child_fs
mnt_table_next_fs
mnt_table_parse_dir
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in
index c2aa4fa83..0a4f57a6c 100644
--- a/libmount/src/libmount.h.in
+++ b/libmount/src/libmount.h.in
@@ -429,6 +429,8 @@ extern int mnt_table_set_cache(struct libmnt_table *tb, struct libmnt_cache *mpc
extern struct libmnt_cache *mnt_table_get_cache(struct libmnt_table *tb);
extern int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs);
extern int mnt_table_remove_fs(struct libmnt_table *tb, struct libmnt_fs *fs);
+extern int mnt_table_first_fs(struct libmnt_table *tb, struct libmnt_fs **fs);
+extern int mnt_table_last_fs(struct libmnt_table *tb, struct libmnt_fs **fs);
extern int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
struct libmnt_fs **fs);
extern int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
diff --git a/libmount/src/libmount.sym b/libmount/src/libmount.sym
index 508c5cd38..f9870e3c4 100644
--- a/libmount/src/libmount.sym
+++ b/libmount/src/libmount.sym
@@ -265,9 +265,11 @@ global:
mnt_table_append_intro_comment;
mnt_table_append_trailing_comment;
mnt_table_enable_comments;
+ mnt_table_first_fs;
mnt_table_get_intro_comment;
mnt_table_get_trailing_comment;
mnt_table_get_userdata;
+ mnt_table_last_fs;
mnt_table_replace_file;
mnt_table_set_intro_comment;
mnt_table_set_trailing_comment;
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index a8b462faa..2b258c7da 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -552,6 +552,46 @@ int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, struct l
}
/**
+ * mnt_table_first_fs:
+ * @tb: tab pointer
+ * @fs: returns the first tab entry
+ *
+ * Returns: 0 on success, negative number in case of error or 1 at the end of list.
+ */
+int mnt_table_first_fs(struct libmnt_table *tb, struct libmnt_fs **fs)
+{
+ assert(tb);
+ assert(fs);
+
+ if (!tb || !fs)
+ return -EINVAL;
+ if (list_empty(&tb->ents))
+ return 1;
+ *fs = list_first_entry(&tb->ents, struct libmnt_fs, ents);
+ return 0;
+}
+
+/**
+ * mnt_table_last_fs:
+ * @tb: tab pointer
+ * @fs: returns the last tab entry
+ *
+ * Returns: 0 on success, negative number in case of error or 1 at the end of list.
+ */
+int mnt_table_last_fs(struct libmnt_table *tb, struct libmnt_fs **fs)
+{
+ assert(tb);
+ assert(fs);
+
+ if (!tb || !fs)
+ return -EINVAL;
+ if (list_empty(&tb->ents))
+ return 1;
+ *fs = list_last_entry(&tb->ents, struct libmnt_fs, ents);
+ return 0;
+}
+
+/**
* mnt_table_find_next_fs:
* @tb: table
* @itr: iterator