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

Generated by: LCOV version 1.14