summaryrefslogtreecommitdiffstats
path: root/libmount/src/context.c
diff options
context:
space:
mode:
authorKarel Zak2011-06-21 14:58:37 +0200
committerKarel Zak2011-06-21 14:58:37 +0200
commitd84508cfbdba620d02e37dbd47c3065dfe7ab240 (patch)
tree0c21d49cc675f2c0b26a19e236b5a3ab18319279 /libmount/src/context.c
parentmountpoint: add new command (diff)
downloadkernel-qcow2-util-linux-d84508cfbdba620d02e37dbd47c3065dfe7ab240.tar.gz
kernel-qcow2-util-linux-d84508cfbdba620d02e37dbd47c3065dfe7ab240.tar.xz
kernel-qcow2-util-linux-d84508cfbdba620d02e37dbd47c3065dfe7ab240.zip
libmount: allow to set parser callback to context
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context.c')
-rw-r--r--libmount/src/context.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c
index d65c8f152..f3eaae414 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -696,6 +696,8 @@ int mnt_context_get_fstab(struct libmnt_context *cxt, struct libmnt_table **tb)
cxt->fstab = mnt_new_table();
if (!cxt->fstab)
return -ENOMEM;
+ if (cxt->table_errcb)
+ mnt_table_set_parser_errcb(cxt->fstab, cxt->table_errcb);
cxt->flags &= ~MNT_FL_EXTERN_FSTAB;
rc = mnt_table_parse_fstab(cxt->fstab, NULL);
if (rc)
@@ -736,6 +738,8 @@ int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
cxt->mtab = mnt_new_table();
if (!cxt->mtab)
return -ENOMEM;
+ if (cxt->table_errcb)
+ mnt_table_set_parser_errcb(cxt->fstab, cxt->table_errcb);
rc = mnt_table_parse_mtab(cxt->mtab, cxt->mtab_path);
if (rc)
return rc;
@@ -750,6 +754,30 @@ int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
}
/**
+ * mnt_context_set_tables_errcb
+ * @cxt: mount context
+ * @cb: pointer to callback function
+ *
+ * The error callback is used for all tab files (e.g. mtab, fstab)
+ * parsed within the context.
+ *
+ * See also mnt_context_get_mtab(),
+ * mnt_context_get_fstab(),
+ * mnt_table_set_parser_errcb().
+ *
+ * Returns: 0 on success, negative number in case of error.
+ */
+int mnt_context_set_tables_errcb(struct libmnt_context *cxt,
+ int (*cb)(struct libmnt_table *tb, const char *filename, int line))
+{
+ if (!cxt)
+ return -EINVAL;
+
+ cxt->table_errcb = cb;
+ return 0;
+}
+
+/**
* mnt_context_set_cache:
* @cxt: mount context
* @cache: cache instance or nULL