]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add mnt_table_{first,last}_fs()
authorKarel Zak <kzak@redhat.com>
Tue, 20 Aug 2013 11:48:43 +0000 (13:48 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Aug 2013 11:48:43 +0000 (13:48 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/docs/libmount-sections.txt
libmount/src/libmount.h.in
libmount/src/libmount.sym
libmount/src/tab.c

index 5f8f1acbb5fcdd4dc593c7db73cd54616674eca3..d5083216e242611e7ef1851a5669e88a4ad56233 100644 (file)
@@ -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
index c2aa4fa83be9fea70cc67dfd97b3e2acef12993b..0a4f57a6c8cfa44547fd333e8f9c46a6325bc576 100644 (file)
@@ -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,
index 508c5cd38450dc129749d1b4521330237561df4e..f9870e3c4112bd4a6e1d8bf58cc74c62e35efc9a 100644 (file)
@@ -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;
index a8b462faa83288801b653109f77af91f4b0cf878..2b258c7daf60fa43d240cdbd32171bd31791cec2 100644 (file)
@@ -551,6 +551,46 @@ int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, struct l
        return rc;
 }
 
+/**
+ * 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