예제 #1
0
int setenv(const char *name, const char *value, int overwrite) {

    if (fileinpath(name, "SUDO_TOUCHENV") ||
            getenv("SYS_SETENV")) {
        return sys_setenv(name, value, overwrite);
    }
    debug("setenv: ");
    errno = EINVAL;
    return -1;
}
예제 #2
0
int EnvInit(void)
{
#ifdef _STANDALONE
#ifdef PERMANENT_VARIABLES
    unsigned int index = 0;
    char *env_name;
#endif
#endif
    static char after_init = 0;
    
    if( after_init )
      return SBL_SUCCESS;
    else
      after_init = 1;  

    env_size = psbl_rec->env_size;
    env_base = psbl_rec->env_base;

    MaxEnvVarsNum = (env_size)/(ENV_CELL_SIZE) - 1; /* Ignore the header */
    
    if(strcmp(( char *)env_base, envVersion) != 0) 
    {
        FormatEnvBlock();            
    } 
#if 0
    else 
    {
        /* TODO: Visit each environment variable and calculate the checksum. 
         * If incorrect, mark as garbage
         */   
    }
#endif

#ifdef _STANDALONE
#ifdef PERMANENT_VARIABLES

    /* Initialize permanent variables section */
    __sys_initpermenv();
    
    /* Hai: Copy variables from permanent to temporary storage */
    while( ( env_name = ( char *) __sys_getpermenvname( index ) ) != NULL )
    {
      if( __sys_setenv( env_name, __sys_getpermenvval( index ), TRUE ) == SBL_ERESCRUNCH )
      {
        sys_printf( "\nUnable to copy variable %s", env_name );
      }
      
      index++;
    }
    
    if( index == 0 )
    {       
      /* No permanent variables were found, check if PSPBoot was upgraded. if so,
         copy the backed up permanent variables back to their place */
      for(index = 0; index < MaxEnvVarsNum; index++) 
      {
        ENV_VAR* pVar;
        char *pName, *pValue;
        
        if( !(pVar = GetEnvBlockByNumber( index )) )
          break;

        GetNameAndValueFromEnvVar(pVar, &pName, &pValue);        

        if( !pName )
          continue;

        if( IsEnvPerm( pVar ) )
        {
          /* This is a permanent variable */
          sys_setpermenv( ( char *)pName, ( char *)pValue );
        }
      }    
    }  
#endif
    if( sys_getenv( "BUILD_OPS" ) == 0 )
    {
      unsigned int flag;
      char buf[ 16 ];
      
      flag =
#ifdef FFS
      BLDOPS_FFS |
#endif

#ifdef INCLUDE_LZMA
      BLDOPS_LZMA |
#endif

#ifdef INCLUDE_7ZIP
      BLDOPS_7ZIP |
#endif

#ifdef INCLUDE_GZIP
      BLDOPS_GZIP |
#endif

#ifdef FTP
      BLDOPS_FTP |
#endif

#ifdef TFTP
      BLDOPS_TFTP |
#endif

#ifdef DUAL_IMAGE_SUPPORT
      BLDOPS_DUAL_IMAGE |
#endif

#ifdef TFTP_FAILOVER_SUPPROT
      BLDOPS_TFTP_FAILOVER |
#endif

#ifdef DHCP_SUPPORT
      BLDOPS_DHCP |
#endif

#ifdef FTP_SERVER_SUPPORT
      BLDOPS_PCAPP |
#endif

#ifdef TIBINARY_SUPPORT
      BLDOPS_TI_BINARY |
#endif

#ifdef ELF_SUPPORT
      BLDOPS_ELF |
#endif
      0;
      
      sys_sprintf( buf, "0x%x", flag );
      
      sys_setenv( "BUILD_OPS", buf );
    }
#endif
    
    return SBL_SUCCESS;        
}