From 9d5eb4c46405413a8dd69d01f4e094f4390944d1 Mon Sep 17 00:00:00 2001 From: Tim Hildering Date: Mon, 4 Mar 2019 19:15:08 +0100 Subject: libmount: improve fs referencing in tables * Added member 'struct libmnt_table *tab' to libmnt_fs structure. * Added 'mnt_fs_get_table()'. * Removed overhead from 'mnt_table_{insert,move,remove}_fs(). * Added check to 'mnt_table_set_iter()' that entry is member of table. [kzak@redhat.com: - add to libmount.sys - add to docs - cleanup commit message - set fs->tab = NULL before mnt_unref_fs() in mnt_table_remove_fs()] Signed-off-by: Tim Hildering Signed-off-by: Karel Zak --- libmount/src/fs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'libmount/src/fs.c') diff --git a/libmount/src/fs.c b/libmount/src/fs.c index 9971d6ae3..147398955 100644 --- a/libmount/src/fs.c +++ b/libmount/src/fs.c @@ -190,6 +190,7 @@ struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest, return NULL; } + dest->tab = NULL; dest->id = src->id; dest->parent = src->parent; dest->devno = src->devno; @@ -445,6 +446,22 @@ int mnt_fs_streq_srcpath(struct libmnt_fs *fs, const char *path) return p && path && strcmp(p, path) == 0; } +/** + * mnt_fs_get_table: + * @fs: table entry + * @tb: table that contains @fs + * + * Returns: 0 or negative number on error (if @fs or @tb is NULL). + */ +int mnt_fs_get_table(struct libmnt_fs *fs, struct libmnt_table **tb) +{ + if (!fs || !tb) + return -EINVAL; + + *tb = fs->tab; + return 0; +} + /** * mnt_fs_streq_target: * @fs: fs -- cgit v1.2.3-55-g7522