Created
January 3, 2022 15:36
-
-
Save vojtechtrefny/7f379596958a0c4cd4c287c3f7a7dddd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <blockdev/blockdev.h> | |
#include <blockdev/lvm.h> | |
#include <glib.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#define VGNAME "mergetest" | |
#define SNAPNAME "lvol0_snap" | |
void _log (gint level, const gchar *msg) { | |
g_print ("bd log: %s\n", msg); | |
} | |
int main(void) { | |
gboolean ret = FALSE; | |
GError *error = NULL; | |
BDExtraArg lv_arg = {"--background",""}; | |
const BDExtraArg *extra_args[2] = {&lv_arg, NULL}; | |
BDPluginSpec lvm_plugin = {BD_PLUGIN_LVM, "libbd_lvm.so.2"}; | |
BDPluginSpec *plugins[] = {&lvm_plugin, NULL}; | |
ret = bd_switch_init_checks (FALSE, &error); | |
if (!ret) { | |
g_print ("Error disabling dependencies checks during init: %s (%s, %d)\n", | |
error->message, g_quark_to_string (error->domain), error->code); | |
return 1; | |
} | |
ret = bd_ensure_init (plugins, (BDUtilsLogFunc) _log, &error); | |
if (!ret) { | |
g_print ("Error initializing libblockdev library: %s (%s, %d)\n", | |
error->message, g_quark_to_string (error->domain), error->code); | |
return 1; | |
} | |
ret = bd_lvm_set_global_config ("log {level=7 file=/tmp/lvm.log syslog=0}", &error); | |
if (!ret) { | |
g_print ("Error setting LVM global config: %s (%s, %d)\n", | |
error->message, g_quark_to_string (error->domain), error->code); | |
return 1; | |
} | |
ret = bd_lvm_lvsnapshotmerge (VGNAME, SNAPNAME, extra_args, &error); | |
if (!ret) { | |
g_print ("Error running snapshot merge: %s (%s, %d)\n", | |
error->message, g_quark_to_string (error->domain), error->code); | |
return 1; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment