static CMPIStatus LMI_NFS_ShareEnumInstances( CMPIInstanceMI* mi, const CMPIContext* cc, const CMPIResult* cr, const CMPIObjectPath* cop, const char** properties) { LMI_NFS_Share s; struct stat st; LMI_NFS_Share_Init(&s, _cb, KNameSpace (cop)); int i; char buf[256]; struct nfs *exportinfo = malloc(sizeof(struct nfs)); exportinfo=Get_Export_List(); for(i=0;i<exportinfo->countshare;i++) { snprintf(buf, sizeof buf,"%s:%d[of(%d)]", "NFSShare",i+1, exportinfo->countshare); LMI_NFS_Share_Set_InstanceID(&s, buf); LMI_NFS_Share_Set_ElementName(&s, "Nfs Share"); LMI_NFS_Share_Set_Name(&s, exportinfo->share[i]); LMI_NFS_Share_Init_OperationalStatus(&s, 1); if ( stat(exportinfo->share[i], &st) == 0 ) { if(S_ISDIR(st.st_mode)) LMI_NFS_Share_Set_SharingDirectory(&s, 1); else LMI_NFS_Share_Set_SharingDirectory(&s, 0); LMI_NFS_Share_Set_OperationalStatus(&s, 0, 2 ); } else LMI_NFS_Share_Set_OperationalStatus(&s, 0, LMI_NFS_Share_OperationalStatus_Error ); KReturnInstance(cr, s); } CMReturn(CMPI_RC_OK); }
static CMPIStatus LMI_NFSElementSettingDataEnumInstances( CMPIInstanceMI* mi, const CMPIContext* cc, const CMPIResult* cr, const CMPIObjectPath* cop, const char** properties) { int i; char buf[250]; LMI_NFSElementSettingData n; LMI_NFSElementSettingData_Init(&n, _cb, KNameSpace (cop)); LMI_NFS_ShareRef nfsref; LMI_NFS_ShareRef_Init(&nfsref, _cb, KNameSpace (cop)); LMI_ExportedFileShareSettingRef fileref; LMI_ExportedFileShareSettingRef_Init(&fileref, _cb, KNameSpace (cop)); struct nfs *exportinfo = malloc(sizeof(struct nfs)); exportinfo=get_export_list(); for(i=0;i<exportinfo->countshare;i++) { snprintf(buf, sizeof buf,"%s:%d[of(%d)]", "NFSShare",i+1, exportinfo->countshare); LMI_NFS_ShareRef_Set_InstanceID(&nfsref, buf); snprintf(buf, sizeof buf,"%s:%d[of(%d)]", "NFSExportedFileShareSetting",i+1, exportinfo->countshare); LMI_ExportedFileShareSettingRef_Set_InstanceID(&fileref, buf); LMI_NFSElementSettingData_Set_Share(&n, &nfsref); LMI_NFSElementSettingData_Set_ShareSetting(&n, &fileref); KReturnInstance(cr, n); } CMReturn(CMPI_RC_OK); }