openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libfdisk/src/label.c
int fdisk_create_disklabel(struct fdisk_context* cxt, const char* name)
{
    int haslabel = 0;
    struct fdisk_label* lb;

    if (!cxt)
        return -EINVAL;

    if (!name)
    { /* use default label creation */
#ifdef __sparc__
        name = "sun";
#else
        name = "dos";
#endif
    }

    if (cxt->label)
    {
        fdisk_deinit_label(cxt->label);
        haslabel = 1;
    }

    lb = fdisk_get_label(cxt, name);
    if (!lb || lb->disabled)
        return -EINVAL;

    if (!haslabel || (lb && cxt->label != lb))
        fdisk_check_collisions(cxt);

    if (!lb->op->create)
        return -ENOSYS;

    __fdisk_switch_label(cxt, lb);
    assert(cxt->label == lb);

    if (haslabel && !cxt->parent)
        fdisk_reset_device_properties(cxt);

    DBG(CXT, ul_debugobj(cxt, "create a new %s label", lb->name));
    return lb->op->create(cxt);
}
/**
 * fdisk_create_disklabel:
 * @cxt: fdisk context
 * @name: label name
 *
 * Creates a new disk label of type @name. If @name is NULL, then it will
 * create a default system label type, either SUN or DOS. The function
 * automatically switches the current label driver to @name. The function
 * fdisk_get_label() returns the current label driver.
 *
 * The function modifies in-memory data only.
 *
 * Returns: 0 on success, otherwise, a corresponding error.
 */
@cxt: fdisk context
@name: label name

Creates a new disk label of type @name. If @name is NULL, then it will
create a default system label type, either SUN or DOS. The function
automatically switches the current label driver to @name. The function
fdisk_get_label() returns the current label driver.

The function modifies in-memory data only.

0 on success, otherwise, a corresponding error.
@cxt : fdisk context @name : label name Creates a new disk label of type @name . If @name is NULL then it will create a default system label type either SUN or DOS . The function automatically switches the current label driver to @name . The function fdisk_get_label () returns the current label driver . The function modifies in - memory data only . 0 on success otherwise a corresponding error .
int fdisk_create_disklabel(struct fdisk_context* cxt, const char* name)
{
    int haslabel = 0;
    struct fdisk_label* lb;
    if (!cxt)
        return -EINVAL;
    if (!name)
    { 
#ifdef __sparc__
        name = "sun";
#else
        name = "dos";
#endif
    }
    if (cxt->label)
    {
        fdisk_deinit_label(cxt->label);
        haslabel = 1;
    }
    lb = fdisk_get_label(cxt, name);
    if (!lb || lb->disabled)
        return -EINVAL;
    if (!haslabel || (lb && cxt->label != lb))
        fdisk_check_collisions(cxt);
    if (!lb->op->create)
        return -ENOSYS;
    __fdisk_switch_label(cxt, lb);
    assert(cxt->label == lb);
    if (haslabel && !cxt->parent)
        fdisk_reset_device_properties(cxt);
    DBG(CXT, ul_debugobj(cxt, "create a new %s label", lb->name));
    return lb->op->create(cxt);
}
int fdisk_create_disklabel ( struct fdisk_context * cxt , const char * name ) { int haslabel = 0 ; struct fdisk_label * lb ; if ( ! cxt ) return - EINVAL ; if ( ! name ) { #ifdef __sparc__ name = " " ; #else name = " " ; #endif } if ( cxt -> label ) { fdisk_deinit_label ( cxt -> label ) ; haslabel = 1 ; } lb = fdisk_get_label ( cxt , name ) ; if ( ! lb || lb -> disabled ) return - EINVAL ; if ( ! haslabel || ( lb && cxt -> label != lb ) ) fdisk_check_collisions ( cxt ) ; if ( ! lb -> op -> create ) return - ENOSYS ; __fdisk_switch_label ( cxt , lb ) ; assert ( cxt -> label == lb ) ; if ( haslabel && ! cxt -> parent ) fdisk_reset_device_properties ( cxt ) ; DBG ( CXT , ul_debugobj ( cxt , " " , lb -> name ) ) ; return lb -> op -> create ( cxt ) ; }
fdisk_create_disklabel:
 @cxt: fdisk context
 @name: label name
fdisk_create_disklabel : @cxt : fdisk context @name : label name
/* use default label creation */