return NULL;
}
+ dest->tab = NULL;
dest->id = src->id;
dest->parent = src->parent;
dest->devno = src->devno;
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
extern const char *mnt_fs_get_source(struct libmnt_fs *fs);
extern int mnt_fs_set_source(struct libmnt_fs *fs, const char *source);
extern const char *mnt_fs_get_srcpath(struct libmnt_fs *fs);
+extern int mnt_fs_get_table(struct libmnt_fs *fs, struct libmnt_table **tb);
extern int mnt_fs_get_tag(struct libmnt_fs *fs, const char **name,
const char **value);
if (!tb || !fs)
return -EINVAL;
- if (!list_empty(&fs->ents))
+ if (fs->tab)
return -EBUSY;
mnt_ref_fs(fs);
list_add_tail(&fs->ents, &tb->ents);
+ fs->tab = tb;
tb->nents++;
DBG(TAB, ul_debugobj(tb, "add entry: %s %s",
else
list_add_tail(&fs->ents, head);
+ fs->tab = tb;
tb->nents++;
DBG(TAB, ul_debugobj(tb, "insert entry: %s %s",
* This function inncrements reference to @fs. Don't forget to use
* mnt_unref_fs() after mnt_table_insert_fs() if you want to keep the @fs
* referenced by the table only.
-
*
* Returns: 0 on success or negative number in case of error.
*/
if (!tb || !fs)
return -EINVAL;
- if (!list_empty(&fs->ents))
+ if (fs->tab)
return -EBUSY;
- if (pos && mnt_table_find_fs(tb, pos) < 1)
+ if (pos && pos->tab != tb)
return -ENOENT;
mnt_ref_fs(fs);
if (!src || !dst || !fs)
return -EINVAL;
- if (mnt_table_find_fs(src, fs) < 1)
- return -ENOENT;
-
- if (pos && mnt_table_find_fs(dst, pos) < 1)
+ if (fs->tab != src || (pos && pos->tab != dst))
return -ENOENT;
/* remove from source */
*/
int mnt_table_remove_fs(struct libmnt_table *tb, struct libmnt_fs *fs)
{
- if (!tb || !fs || mnt_table_find_fs(tb, fs) < 1)
+ if (!tb || !fs || fs->tab != tb)
return -EINVAL;
+ fs->tab = NULL;
list_del_init(&fs->ents);
mnt_unref_fs(fs);
if (!tb || !itr || !fs)
return -EINVAL;
+ if (fs->tab != tb)
+ return -ENOENT;
+
MNT_ITER_INIT(itr, &tb->ents);
itr->p = &fs->ents;