LCOV - code coverage report
Current view: top level - app/shared/commands/configure - configure.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 31 0.0 %
Date: 2025-03-20 12:08:36 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_app_shared_commands_configure_configure_h
       2             : #define HEADER_fd_src_app_shared_commands_configure_configure_h
       3             : 
       4             : #include "../../fd_cap_chk.h"
       5             : #include "../../fd_config.h"
       6             : 
       7             : #include <stdarg.h>
       8             : 
       9           0 : #define CONFIGURE_NR_OPEN_FILES (1024000U)
      10             : 
      11             : enum {
      12             :   CONFIGURE_NOT_CONFIGURED,
      13             :   CONFIGURE_PARTIALLY_CONFIGURED,
      14             :   CONFIGURE_OK,
      15             : };
      16             : 
      17             : typedef struct {
      18             :   int  result;
      19             :   char message[ 256 ];
      20             : } configure_result_t;
      21             : 
      22           0 : #define CHECK(x) do {                                    \
      23           0 :     configure_result_t result = (x);                     \
      24           0 :     if( FD_UNLIKELY( result.result != CONFIGURE_OK ) ) { \
      25           0 :       return result;                                     \
      26           0 :     }                                                    \
      27           0 :   } while( 0 )
      28             : 
      29           0 : #define NOT_CONFIGURED(...) do {                             \
      30           0 :     configure_result_t result;                               \
      31           0 :     result.result = CONFIGURE_NOT_CONFIGURED;                \
      32           0 :     FD_TEST( fd_cstr_printf_check( result.message,           \
      33           0 :                                    sizeof( result.message ), \
      34           0 :                                    NULL,                     \
      35           0 :                                    __VA_ARGS__ ) );          \
      36           0 :     return result;                                           \
      37           0 :   } while( 0 )
      38             : 
      39           0 : #define PARTIALLY_CONFIGURED(...) do {                       \
      40           0 :     configure_result_t result;                               \
      41           0 :     result.result = CONFIGURE_PARTIALLY_CONFIGURED;          \
      42           0 :     FD_TEST( fd_cstr_printf_check( result.message,           \
      43           0 :                                    sizeof( result.message ), \
      44           0 :                                    NULL,                     \
      45           0 :                                    __VA_ARGS__ ) );          \
      46           0 :     return result;                                           \
      47           0 :   } while( 0 )
      48             : 
      49           0 : #define CONFIGURE_OK() do {       \
      50           0 :     configure_result_t result;    \
      51           0 :     result.result = CONFIGURE_OK; \
      52           0 :     result.message[ 0 ] = '\0';   \
      53           0 :     return result;                \
      54           0 :   } while( 0 )
      55             : 
      56             : typedef struct configure_stage {
      57             :   const char *       name;
      58             :   int                always_recreate;
      59             :   int                (*enabled)  ( config_t const * config );
      60             :   void               (*init_perm)( fd_cap_chk_t * chk, config_t const * config );
      61             :   void               (*fini_perm)( fd_cap_chk_t * chk, config_t const * config );
      62             :   void               (*init)     ( config_t const * config );
      63             :   void               (*fini)     ( config_t const * config, int pre_init );
      64             :   configure_result_t (*check)    ( config_t const * config );
      65             : } configure_stage_t;
      66             : 
      67             : extern configure_stage_t fd_cfg_stage_hugetlbfs;
      68             : extern configure_stage_t fd_cfg_stage_sysctl;
      69             : extern configure_stage_t fd_cfg_stage_hyperthreads;
      70             : extern configure_stage_t fd_cfg_stage_ethtool_channels;
      71             : extern configure_stage_t fd_cfg_stage_ethtool_gro;
      72             : extern configure_stage_t fd_cfg_stage_ethtool_loopback;
      73             : 
      74             : extern configure_stage_t * STAGES[];
      75             : 
      76             : typedef enum {
      77             :   CONFIGURE_CMD_INIT,
      78             :   CONFIGURE_CMD_CHECK,
      79             :   CONFIGURE_CMD_FINI,
      80             : } configure_cmd_t;
      81             : 
      82             : typedef struct {
      83             :   configure_cmd_t      command;
      84             :   configure_stage_t ** stages;
      85             : } configure_args_t;
      86             : 
      87             : /* Checks if a directory exists and is configured with the given uid,
      88             :    gid, and access mode. */
      89             : configure_result_t
      90             : check_dir( const char * path,
      91             :            uint         uid,
      92             :            uint         gid,
      93             :            uint         mode );
      94             : 
      95             : /* Checks if a file exists and is configured with the given uid, gid,
      96             :    and access mode. */
      97             : configure_result_t
      98             : check_file( const char * path,
      99             :             uint         uid,
     100             :             uint         gid,
     101             :             uint         mode );
     102             : 
     103             : int
     104             : configure_stage( configure_stage_t * stage,
     105             :                  configure_cmd_t     command,
     106             :                  config_t const *    config );
     107             : 
     108             : void configure_cmd_args( int * pargc, char *** pargv, args_t * args );
     109             : void configure_cmd_perm( args_t * args, fd_cap_chk_t * chk, config_t const * config );
     110             : void configure_cmd_fn  ( args_t * args, config_t * config );
     111             : 
     112             : #endif /* HEADER_fd_src_app_shared_commands_configure_configure_h */

Generated by: LCOV version 1.14