static void ReadConfigFile(const char* path) { cnode* root = config_node("", ""); cnode* node; config_load_file(root, path); node = root->first_child; while (node) { if (strcmp(node->name, "mount") == 0) { const char* block_device = NULL; const char* mount_point = NULL; const char* driver_store_path = NULL; boolean enable_ums = false; cnode* child = node->first_child; struct asec_cfg asec_stores[ASEC_STORES_MAX]; int asec_idx = 0; memset(asec_stores, 0, sizeof(asec_stores)); while (child) { const char* name = child->name; const char* value = child->value; if (!strncmp(name, "asec_", 5)) { int rc = ProcessAsecData(child, asec_stores, asec_idx); if (rc < 0) { LOG_ERROR("Error processing ASEC cfg data\n"); } else asec_idx = rc; } else if (strcmp(name, "block_device") == 0) block_device = value; else if (strcmp(name, "mount_point") == 0) mount_point = value; else if (strcmp(name, "driver_store_path") == 0) driver_store_path = value; else if (strcmp(name, "enable_ums") == 0 && strcmp(value, "true") == 0) enable_ums = true; child = child->next; } // mount point and removable fields are optional if (block_device && mount_point) { void *mp = AddMountPoint(block_device, mount_point, driver_store_path, enable_ums); int i; for (i = 0; i < asec_idx; i++) { AddAsecToMountPoint(mp, asec_stores[i].name, asec_stores[i].backing_file, asec_stores[i].size, asec_stores[i].mount_point, asec_stores[i].crypt); } } } node = node->next; } }
void HXFileSystemManager::InitMountPoints(IUnknown* pContext) { #if defined(HELIX_CONFIG_NOSTATICS) HXBOOL& zm_IsInited = (HXBOOL&)HXGlobalInt32::Get(&HXFileSystemManager::zm_IsInited); #endif if (zm_IsInited) return; zm_IsInited = TRUE; IHXBuffer* mount_point = 0; IHXBuffer* real_short_name = 0; const char* short_name = 0; IHXValues* options = 0; IHXRegistry* pRegistry; IHXValues* pNameList = NULL; if(HXR_OK != pContext->QueryInterface(IID_IHXRegistry, (void**)&pRegistry)) { return; } if(HXR_OK != pRegistry->GetPropListByName("config.FSMount", pNameList)) { pRegistry->Release(); return; } HX_RESULT res; const char* plugName; UINT32 plug_id; res = pNameList->GetFirstPropertyULONG32(plugName, plug_id); while(res == HXR_OK) { HXPropType plugtype = pRegistry->GetTypeById(plug_id); if(plugtype != PT_COMPOSITE) res = HXR_FAIL; else { short_name = strrchr(plugName, '.'); if(!short_name) short_name = plugName; else short_name++; IHXValues* pPropList; if(HXR_OK == pRegistry->GetPropListById(plug_id, pPropList)) { const char* propName; UINT32 prop_id; CreateValuesCCF(options, pContext); res = pPropList->GetFirstPropertyULONG32(propName, prop_id); while(res == HXR_OK) { HXPropType type = pRegistry->GetTypeById(prop_id); const char*propSubName = strrchr(propName, '.') + 1; switch(type) { case PT_INTEGER: { INT32 val; if(HXR_OK == pRegistry->GetIntById(prop_id, val)) { options->SetPropertyULONG32(propSubName, val); } break; } case PT_STRING: { IHXBuffer* pBuffer; if(HXR_OK == pRegistry->GetStrById(prop_id, pBuffer)) { options->SetPropertyBuffer(propSubName, pBuffer); pBuffer->Release(); } break; } case PT_BUFFER: { IHXBuffer* pBuffer; if(HXR_OK == pRegistry->GetBufById(prop_id, pBuffer)) { options->SetPropertyBuffer(propSubName, pBuffer); pBuffer->Release(); } break; } default: break; } res = pPropList->GetNextPropertyULONG32(propName, prop_id); } res = HXR_OK; } if(HXR_OK == options->GetPropertyBuffer("MountPoint", mount_point)) { if(HXR_OK == options->GetPropertyBuffer("ShortName", real_short_name)) short_name = (const char*) real_short_name->GetBuffer(); AddMountPoint(short_name,(const char*)mount_point->GetBuffer(), options, pContext); if(real_short_name) { real_short_name->Release(); real_short_name = 0; } mount_point->Release(); } res = pNameList->GetNextPropertyULONG32(plugName, plug_id); } } pNameList->Release(); pRegistry->Release(); }