(root)/
util-linux-2.39/
libfdisk/
src/
init.c
       1  
       2  #include "fdiskP.h"
       3  
       4  
       5  /**
       6   * SECTION: init
       7   * @title: Library initialization
       8   * @short_description: initialize debug stuff
       9   *
      10   */
      11  
      12  UL_DEBUG_DEFINE_MASK(libfdisk);
      13  UL_DEBUG_DEFINE_MASKNAMES(libfdisk) =
      14  {
      15  	{ "all",	LIBFDISK_DEBUG_ALL,	"info about all subsystems" },
      16  	{ "ask",	LIBFDISK_DEBUG_ASK,	"fdisk dialogs" },
      17  	{ "help",	LIBFDISK_DEBUG_HELP,	"this help" },
      18  	{ "cxt",	LIBFDISK_DEBUG_CXT,	"library context (handler)" },
      19  	{ "label",	LIBFDISK_DEBUG_LABEL,	"disk label utils" },
      20  	{ "part",	LIBFDISK_DEBUG_PART,	"partition utils" },
      21  	{ "parttype",	LIBFDISK_DEBUG_PARTTYPE,"partition type utils" },
      22  	{ "script",	LIBFDISK_DEBUG_SCRIPT,	"sfdisk-like scripts" },
      23  	{ "tab",	LIBFDISK_DEBUG_TAB,	"table utils"},
      24  	{ "wipe",       LIBFDISK_DEBUG_WIPE,    "wipe area utils" },
      25  	{ "item",       LIBFDISK_DEBUG_ITEM,    "disklabel items" },
      26  	{ "gpt",        LIBFDISK_DEBUG_GPT,     "GPT subsystems" },
      27  	{ NULL, 0 }
      28  };
      29  
      30  /**
      31   * fdisk_init_debug:
      32   * @mask: debug mask (0xffff to enable full debugging)
      33   *
      34   * If the @mask is not specified then this function reads
      35   * LIBFDISK_DEBUG environment variable to get the mask.
      36   *
      37   * Already initialized debugging stuff cannot be changed. It does not
      38   * have effect to call this function twice.
      39   *
      40   * It's strongly recommended to use fdisk_init_debug(0) in your code.
      41   */
      42  void fdisk_init_debug(int mask)
      43  {
      44  	if (libfdisk_debug_mask)
      45  		return;
      46  
      47  	__UL_INIT_DEBUG_FROM_ENV(libfdisk, LIBFDISK_DEBUG_, mask, LIBFDISK_DEBUG);
      48  
      49  
      50  	if (libfdisk_debug_mask != LIBFDISK_DEBUG_INIT
      51  	    && libfdisk_debug_mask != (LIBFDISK_DEBUG_HELP|LIBFDISK_DEBUG_INIT)) {
      52  		const char *ver = NULL;
      53  
      54  		fdisk_get_library_version(&ver);
      55  
      56  		DBG(INIT, ul_debug("library debug mask: 0x%04x", libfdisk_debug_mask));
      57  		DBG(INIT, ul_debug("library version: %s", ver));
      58  	}
      59  
      60  	ON_DBG(HELP, ul_debug_print_masks("LIBFDISK_DEBUG",
      61  				UL_DEBUG_MASKNAMES(libfdisk)));
      62  }