diff options
author | Karel Zak | 2013-08-20 13:48:43 +0200 |
---|---|---|
committer | Karel Zak | 2013-08-20 13:48:43 +0200 |
commit | 686a64670e34250c8dce934d936ac63494d62076 (patch) | |
tree | cf334caac306cd4496cfa2d13d17cd021a4dcd6f /libmount/src/tab.c | |
parent | libmount: add new function to docs (diff) | |
download | kernel-qcow2-util-linux-686a64670e34250c8dce934d936ac63494d62076.tar.gz kernel-qcow2-util-linux-686a64670e34250c8dce934d936ac63494d62076.tar.xz kernel-qcow2-util-linux-686a64670e34250c8dce934d936ac63494d62076.zip |
libmount: add mnt_table_{first,last}_fs()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab.c')
-rw-r--r-- | libmount/src/tab.c | 40 |
1 files changed, 40 insertions, 0 deletions
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 |