LCOV - code coverage report
Current view: top level - app/shared/commands/configure - configure.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 39 0.0 %
Date: 2025-11-26 04:52:47 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           0 : #define FD_CONFIGURE_CHECK_TYPE_INIT_PERM (0)
      58             : #define FD_CONFIGURE_CHECK_TYPE_FINI_PERM (1)
      59           0 : #define FD_CONFIGURE_CHECK_TYPE_PRE_INIT  (2)
      60           0 : #define FD_CONFIGURE_CHECK_TYPE_UNDO_INIT (3)
      61           0 : #define FD_CONFIGURE_CHECK_TYPE_POST_INIT (4)
      62           0 : #define FD_CONFIGURE_CHECK_TYPE_CHECK     (5)
      63           0 : #define FD_CONFIGURE_CHECK_TYPE_PRE_FINI  (6)
      64           0 : #define FD_CONFIGURE_CHECK_TYPE_POST_FINI (7)
      65           0 : #define FD_CONFIGURE_CHECK_TYPE_RUN       (8)
      66             : 
      67             : /* fini() returns whether or not it took any actions. */
      68             : 
      69             : typedef struct configure_stage {
      70             :   const char *       name;
      71             :   int                always_recreate;
      72             :   int                (*enabled)  ( config_t const * config );
      73             :   void               (*init_perm)( fd_cap_chk_t * chk, config_t const * config );
      74             :   void               (*fini_perm)( fd_cap_chk_t * chk, config_t const * config );
      75             :   void               (*init)     ( config_t const * config );
      76             :   int                (*fini)     ( config_t const * config, int pre_init );
      77             :   configure_result_t (*check)    ( config_t const * config, int check_type );
      78             : } configure_stage_t;
      79             : 
      80             : extern configure_stage_t fd_cfg_stage_hugetlbfs;
      81             : extern configure_stage_t fd_cfg_stage_sysctl;
      82             : extern configure_stage_t fd_cfg_stage_hyperthreads;
      83             : extern configure_stage_t fd_cfg_stage_bonding;
      84             : extern configure_stage_t fd_cfg_stage_ethtool_channels;
      85             : extern configure_stage_t fd_cfg_stage_ethtool_offloads;
      86             : extern configure_stage_t fd_cfg_stage_ethtool_loopback;
      87             : extern configure_stage_t fd_cfg_stage_snapshots;
      88             : 
      89             : extern configure_stage_t * STAGES[];
      90             : 
      91             : typedef enum {
      92             :   CONFIGURE_CMD_INIT,
      93             :   CONFIGURE_CMD_CHECK,
      94             :   CONFIGURE_CMD_FINI,
      95             : } configure_cmd_t;
      96             : 
      97             : typedef struct {
      98             :   configure_cmd_t      command;
      99             :   configure_stage_t ** stages;
     100             : } configure_args_t;
     101             : 
     102             : /* Checks if a directory exists and is configured with the given uid,
     103             :    gid, and access mode. */
     104             : configure_result_t
     105             : check_dir( const char * path,
     106             :            uint         uid,
     107             :            uint         gid,
     108             :            uint         mode );
     109             : 
     110             : /* Checks if a file exists and is configured with the given uid, gid,
     111             :    and access mode. */
     112             : configure_result_t
     113             : check_file( const char * path,
     114             :             uint         uid,
     115             :             uint         gid,
     116             :             uint         mode );
     117             : 
     118             : int
     119             : configure_stage( configure_stage_t * stage,
     120             :                  configure_cmd_t     command,
     121             :                  config_t const *    config );
     122             : 
     123             : void configure_cmd_args( int * pargc, char *** pargv, args_t * args );
     124             : void configure_cmd_perm( args_t * args, fd_cap_chk_t * chk, config_t const * config );
     125             : void configure_cmd_fn  ( args_t * args, config_t * config );
     126             : 
     127             : extern action_t fd_action_configure;
     128             : 
     129             : #endif /* HEADER_fd_src_app_shared_commands_configure_configure_h */

Generated by: LCOV version 1.14