Beispiel #1
0
static lvm_t _lvm_init(const char *system_dir)
{
	struct cmd_context *cmd;

	/* FIXME: logging bound to handle
	 */

	if (!udev_init_library_context())
		stack;

	/*
	 * It's not necessary to use name mangling for LVM:
	 *   - the character set used for VG-LV names is subset of udev character set
	 *   - when we check other devices (e.g. device_is_usable fn), we use major:minor, not dm names
	 */
	dm_set_name_mangling_mode(DM_STRING_MANGLING_NONE);

	/* create context */
	/* FIXME: split create_toolcontext */
	/* FIXME: make all globals configurable */
	cmd = create_toolcontext(0, system_dir, 0, 0, 1, 1);
	if (!cmd)
		return NULL;

	if (stored_errno())
		return (lvm_t) cmd;

	/*
	 * FIXME: if an non memory error occured, return the cmd (maybe some
	 * cleanup needed).
	 */

	/* initialization from lvm_run_command */
	init_error_message_produced(0);

	/* FIXME: locking_type config option needed? */
	/* initialize locking */
	if (!init_locking(-1, cmd, 0)) {
		/* FIXME: use EAGAIN as error code here */
		lvm_quit((lvm_t) cmd);
		return NULL;
	}
	/*
	 * FIXME: Use cmd->cmd_line as audit trail for liblvm calls.  Used in
	 * archive() call.  Possible example:
	 * cmd_line = "lvm_vg_create: vg1\nlvm_vg_extend vg1 /dev/sda1\n"
	 */
	cmd->cmd_line = "liblvm";

	/*
	 * Turn off writing to stdout/stderr.
	 * FIXME Fix lib/ to support a non-interactive mode instead.
	 */
	log_suppress(1);

	return (lvm_t) cmd;
}
Beispiel #2
0
lvm_t lvm_init(const char *system_dir)
{
    struct cmd_context *cmd;

    /* FIXME: logging bound to handle
     */

    if (!udev_init_library_context())
        stack;

    /* create context */
    /* FIXME: split create_toolcontext */
    /* FIXME: make all globals configurable */
    cmd = create_toolcontext(0, system_dir, 0, 0);
    if (!cmd)
        return NULL;

    if (stored_errno())
        return (lvm_t) cmd;

    /*
     * FIXME: if an non memory error occured, return the cmd (maybe some
     * cleanup needed).
     */

    /* initialization from lvm_run_command */
    init_error_message_produced(0);

    /* FIXME: locking_type config option needed? */
    /* initialize locking */
    if (!init_locking(-1, cmd, 0)) {
        /* FIXME: use EAGAIN as error code here */
        lvm_quit((lvm_t) cmd);
        return NULL;
    }
    /*
     * FIXME: Use cmd->cmd_line as audit trail for liblvm calls.  Used in
     * archive() call.  Possible example:
     * cmd_line = "lvm_vg_create: vg1\nlvm_vg_extend vg1 /dev/sda1\n"
     */
    cmd->cmd_line = "liblvm";

    /*
     * Turn off writing to stdout/stderr.
     * FIXME Fix lib/ to support a non-interactive mode instead.
     */
    log_suppress(1);

    return (lvm_t) cmd;
}