コード例 #1
0
ファイル: linux.c プロジェクト: marker55/hp-ams
void init_rec(void)  {

    int  start = -1;
    char dev[256] = "";
    char *max_ccb = NULL;
    struct stat buf;

    if (rec_fd != -1 )
        return;

    if ((max_ccb = get_sysfs_str("/sys/module/hpilo/parameters/max_ccb")) == NULL) {
        start = MAXHPILOCHANNELS - 1;
        
        sprintf(dev,"%s%d", HPILO_CCB, start);
        while ((start > 0) &&  (stat(dev, &buf) < 0)) {
            start = start - 8;
            sprintf(dev,"%s%d", HPILO_CCB, start);
        }
    } else {
        start = atoi(max_ccb) - 1;
        free(max_ccb);
    }

    while (start >= 0 && ((rec_fd = open(dev, O_RDWR|O_EXCL)) == -1)) 
        sprintf(dev,"%s%d", HPILO_CCB, --start);

    if (start <  0) {
        snmp_log(LOG_ERR, "Failed: no available HP iLO channels\n");
        rec_fd = -1;
    }  
    DEBUGMSGTL(("rec:arch", "open %d\n", rec_fd));
    /* give the iLO a change to digest the open */
    usleep(1000);
    return;
}
コード例 #2
0
static int amlGetPropInterlaced(GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
    GstAmlVdec *amlvdec = GST_AMLVDEC (object); 
    gboolean interlaced = FALSE;
    char format[64] = {0};
    if(get_sysfs_str("/sys/class/video/frame_format", format, sizeof(format))){
        return -1;
    }
    if(!strncmp(format, "interlace", strlen("interlace"))){
        interlaced = TRUE;
    }
    g_value_set_boolean (value, interlaced);
    return 0;
}
コード例 #3
0
ファイル: EGLNativeTypeIMX.cpp プロジェクト: tomlohave/xbmc
bool CEGLNativeTypeIMX::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
{
  if (m_readonly)
    return false;

  std::string valstr;
  get_sysfs_str("/sys/class/graphics/fb0/modes", valstr);
  std::vector<CStdString> probe_str;
  StringUtils::SplitString(valstr, "\n", probe_str);

  resolutions.clear();
  RESOLUTION_INFO res;
  for (size_t i = 0; i < probe_str.size(); i++)
  {
    if(!StringUtils::StartsWith(probe_str[i], "S:"))
      continue;
    if(ModeToResolution(probe_str[i], &res))
      resolutions.push_back(res);
  }
  return resolutions.size() > 0;
}
コード例 #4
0
ファイル: EGLNativeTypeIMX.cpp プロジェクト: tomlohave/xbmc
bool CEGLNativeTypeIMX::SetNativeResolution(const RESOLUTION_INFO &res)
{
  if (m_readonly)
    return false;

  std::string mode;
  get_sysfs_str("/sys/class/graphics/fb0/mode", mode);
  if (res.strId == mode)
    return false;

  DestroyNativeWindow();
  DestroyNativeDisplay();

  set_sysfs_str("/sys/class/graphics/fb0/mode", res.strId);

  CreateNativeDisplay();

  CLog::Log(LOGDEBUG, "%s: %s",__FUNCTION__, res.strId.c_str());

  // Reset AE
  CAEFactory::DeviceChange();

  return true;
}
コード例 #5
0
ファイル: EGLNativeTypeIMX.cpp プロジェクト: tomlohave/xbmc
bool CEGLNativeTypeIMX::GetNativeResolution(RESOLUTION_INFO *res) const
{
  std::string mode;
  get_sysfs_str("/sys/class/graphics/fb0/mode", mode);
  return ModeToResolution(mode, res);
}
コード例 #6
0
ファイル: ide_linux.c プロジェクト: vejta66/hp-ams
int netsnmp_arch_idecntlr_container_load(netsnmp_container* container)
{

    cpqIdeControllerTable_entry *entry;

    int CntlrIndex=0, Host;
    char buffer[256];
    char attribute[256];
    char *value;
    long  rc = 0;
    int i;

    DEBUGMSGTL(("idecntlr:container:load", "loading\n"));
    DEBUGMSGTL(("idecntlr:container:load", "Container=%p\n",container));

    /* Find all SCSI Hosts */
    if ((NumScsiHost =
            scandir(ScsiHostDir, &ScsiHostlist, file_select, alphasort)) <= 0)
        /* Should not happen */
        return -1;

    for (i=0; i < NumScsiHost; i++) {

        entry = NULL;
        memset(&buffer, 0, sizeof(buffer));
        strncpy(buffer, ScsiHostDir, sizeof(buffer) - 1);
        strncat(buffer, ScsiHostlist[i]->d_name,
                    sizeof(buffer) - strlen(buffer) - 1);

        strncpy(attribute, buffer, sizeof(attribute) - 1);
        strncat(attribute, sysfs_attr[CLASS_PROC_NAME],
            sizeof(attribute) - strlen(attribute) - 1);
        if ((value = get_sysfs_str(attribute)) != NULL) {
            if ((strcmp(value, "ahci") == 0) || 
                (strcmp(value, "ata_piix") == 0)) {
               /*  We will need the host name later on */
                sscanf(ScsiHostlist[i]->d_name, "host%d", &Host);
                CntlrIndex = Host;

                entry = cpqIdeControllerTable_createEntry(container,
                                                          (oid)CntlrIndex);
            }
            free(value);
        }
        
        if (NULL != entry) {
            DEBUGMSGTL(("idecntlr:container:load", "Entry created %d\n", CntlrIndex));
            /*  We will need the host name later on */
            sprintf(entry->host, "%d:", Host);
            entry->cpqIdeControllerOverallCondition = IDE_CONTROLLER_STATUS_OK;
            entry->cpqIdeControllerStatus = CPQ_REG_OTHER;
    
            entry->cpqIdeControllerSlot =  pcislot_scsi_host(buffer);

            strncpy(attribute, buffer, sizeof(attribute) - 1);
            strncat(attribute, sysfs_attr[CLASS_STATE],
                    sizeof(attribute) - strlen(attribute) - 1);
            if ((value = get_sysfs_str(attribute)) != NULL) {
                if (strcmp(value, "running") == 0)
                    entry->cpqIdeControllerStatus = IDE_CONTROLLER_STATUS_OK;
                free(value);
            }
    
            strcpy(entry->cpqIdeControllerModel, "Standard IDE Controller");
            entry->cpqIdeControllerModel_len = 
                                        strlen(entry->cpqIdeControllerModel);

            entry->cpqIdeControllerCondition = 
                    MAKE_CONDITION(entry->cpqIdeControllerCondition, 
                                   entry->cpqIdeControllerStatus);
            rc = CONTAINER_INSERT(container, entry);
            DEBUGMSGTL(("idecntlr:container:load", "container inserted\n"));
        }
        free(ScsiHostlist[i]);
    }
    free(ScsiHostlist);

    return(rc);
}