prepare_mtab_entry(const char *spec, const char *node, const char *type,
					  const char *opts, unsigned long flags)
{
	struct libmnt_fs *fs = mnt_new_fs();
	int rc = -1;

	if (!mtab_update)
		mtab_update = mnt_new_update();

	if (mtab_update && fs) {
		const char *cn_spec = is_pseudo_fs(type) ? spec : canonicalize(spec);
		const char *cn_node = canonicalize(node);

		mnt_fs_set_source(fs, cn_spec);
		mnt_fs_set_target(fs, cn_node);
		mnt_fs_set_fstype(fs, type);
		mnt_fs_set_options(fs, opts);

		rc = mnt_update_set_fs(mtab_update, flags, NULL, fs);

		if (spec != cn_spec)
			my_free(cn_spec);
		my_free(cn_node);
	}

	mnt_free_fs(fs);

	if (rc) {
		mnt_free_update(mtab_update);
		mtab_update = NULL;
	}
}
prepare_mtab_entry(const char *spec, const char *node, const char *type,
					  const char *opts, unsigned long flags)
{
	struct libmnt_fs *fs = mnt_new_fs();
	int rc = -1;

	if (!mtab_update)
		mtab_update = mnt_new_update();

	if (mtab_update && fs) {
		const char *cn_spec = is_pseudo_fs(type) ? spec : canonicalize(spec);
		const char *cn_node = canonicalize(node);

		mnt_fs_set_source(fs, cn_spec);
		mnt_fs_set_target(fs, cn_node);
		mnt_fs_set_fstype(fs, type);
		mnt_fs_set_options(fs, opts);

		rc = mnt_update_set_fs(mtab_update, flags, NULL, fs);

		if (spec != cn_spec)
			my_free(cn_spec);
		my_free(cn_node);
	}

	mnt_free_fs(fs);

	if (rc) {
		mnt_free_update(mtab_update);
		mtab_update = NULL;
	}
}