diff options
author | Karel Zak | 2012-04-25 09:49:50 +0200 |
---|---|---|
committer | Karel Zak | 2012-04-25 09:49:50 +0200 |
commit | 677ff053f63f45fcc88d29ea20f8fcb21d54acff (patch) | |
tree | 2300b562d7e9daed9665a31afc756fed1facfa48 /libmount/src/tab.c | |
parent | libmount: fix mnt_context_guess_fstype() (diff) | |
download | kernel-qcow2-util-linux-677ff053f63f45fcc88d29ea20f8fcb21d54acff.tar.gz kernel-qcow2-util-linux-677ff053f63f45fcc88d29ea20f8fcb21d54acff.tar.xz kernel-qcow2-util-linux-677ff053f63f45fcc88d29ea20f8fcb21d54acff.zip |
libmount: add mnt_table_find_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab.c')
-rw-r--r-- | libmount/src/tab.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libmount/src/tab.c b/libmount/src/tab.c index b2662d5ae..9c41c99a2 100644 --- a/libmount/src/tab.c +++ b/libmount/src/tab.c @@ -703,6 +703,40 @@ struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *sourc return NULL; } +/** + * mnt_table_find_devno + * @tb: /proc/self/mountinfo + * @devno: device number + * @direction: MNT_ITER_{FORWARD,BACKWARD} + * + * Note that zero could be valid device number for root pseudo filesystem (e.g. + * tmpfs). + * + * Returns: a tab entry or NULL. + */ +struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb, + dev_t devno, int direction) +{ + struct libmnt_fs *fs = NULL; + struct libmnt_iter itr; + + assert(tb); + + if (!tb) + return NULL; + + DBG(TAB, mnt_debug_h(tb, "lookup DEVNO: %d", (int) devno)); + + mnt_reset_iter(&itr, direction); + + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { + if (mnt_fs_get_devno(fs) == devno) + return fs; + } + + return NULL; +} + /* * tb: /proc/self/mountinfo * fs: filesystem |