From: Chris B. <buc...@us...> - 2013-07-24 20:26:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "sfcb - Small Footprint CIM Broker". The branch, master has been updated via a8dd746ddcb115a28abe2bcd1af1be929cd3b15b (commit) via 33fe8f3d103e3930d0802f7e44ce21e7c7eafb53 (commit) via 05954c4d337032980763ce719d10a1fe598b9016 (commit) from 87e189a4a2d69057c482fe03092d5e39114b857b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a8dd746ddcb115a28abe2bcd1af1be929cd3b15b Merge: 33fe8f3 87e189a Author: buccella <buc...@li...> Date: Fri Jul 19 16:50:47 2013 -0400 Merge branch 'master' of ssh://git.code.sf.net/p/sblim/sfcb commit 33fe8f3d103e3930d0802f7e44ce21e7c7eafb53 Author: buccella <buc...@li...> Date: Thu Jul 18 13:10:14 2013 -0400 [sfcb-tix:#63] Improve NamespaceProvider and ClassProvider Consistency commit 05954c4d337032980763ce719d10a1fe598b9016 Author: buccella <buc...@li...> Date: Mon Jul 15 16:55:01 2013 -0400 [sfcb-tix:#61] classProviderSf.c SIGSEGV if repo is not initialized ----------------------------------------------------------------------- Summary of changes: classProvider.c | 32 ++++++++++++ classProviderGz.c | 32 ++++++++++++ classProviderMem.c | 32 ++++++++++++ classProviderSf.c | 41 ++++++++++++++-- interopServerProvider.c | 128 +++++++++++++++-------------------------------- 5 files changed, 174 insertions(+), 91 deletions(-) diff --git a/classProvider.c b/classProvider.c index 583997a..9a8765b 100644 --- a/classProvider.c +++ b/classProvider.c @@ -1208,6 +1208,38 @@ ClassProviderInvokeMethod(CMPIMethodMI * mi, st.rc = traverseChildren(cReg, parent, chldn); } + else if (strcasecmp(methodName, "listnamespaces") == 0) { + + HashTableIterator *hit; + char *key; + ClassRegister *cReg; + + CMPIArray* ar = CMNewArray(_broker, nsHt->ft->size(nsHt), CMPI_string, NULL); + int i = 0; + + /* req for specific ns */ + CMPIData nsd = CMGetArg(in, "ns", &st); + if (st.rc == CMPI_RC_OK) { + char* ns = CMGetCharPtr(nsd.value.string); + ClassRegister *cReg = NULL; + cReg = nsHt->ft->get(nsHt, ns); + st.rc = (cReg) ? CMPI_RC_OK : CMPI_RC_ERR_NOT_FOUND; + } + else { + for (hit = nsHt->ft->getFirst(nsHt, (void **) &key, (void **) &cReg); + key && hit; + hit = + nsHt->ft->getNext(nsHt, hit, (void **) &key, (void **) &cReg)) { + + CMSetArrayElementAt(ar, i++, key, CMPI_chars); + } + + CMAddArg(out, "nslist", &ar, CMPI_stringA); + st.rc = CMPI_RC_OK; + } + + } + else if (strcasecmp(methodName, "_startup") == 0) { /* let providerMgr know that we're odne init'ing */ diff --git a/classProviderGz.c b/classProviderGz.c index 34b0558..eb17c36 100644 --- a/classProviderGz.c +++ b/classProviderGz.c @@ -1078,6 +1078,38 @@ ClassProviderInvokeMethod(CMPIMethodMI * mi, st.rc = traverseChildren(cReg, parent, chldn); } + else if (strcasecmp(methodName, "listnamespaces") == 0) { + + HashTableIterator *hit; + char *key; + ClassRegister *cReg; + + CMPIArray* ar = CMNewArray(_broker, nsHt->ft->size(nsHt), CMPI_string, NULL); + int i = 0; + + /* req for specific ns */ + CMPIData nsd = CMGetArg(in, "ns", &st); + if (st.rc == CMPI_RC_OK) { + char* ns = CMGetCharPtr(nsd.value.string); + ClassRegister *cReg = NULL; + cReg = nsHt->ft->get(nsHt, ns); + st.rc = (cReg) ? CMPI_RC_OK : CMPI_RC_ERR_NOT_FOUND; + } + else { + for (hit = nsHt->ft->getFirst(nsHt, (void **) &key, (void **) &cReg); + key && hit; + hit = + nsHt->ft->getNext(nsHt, hit, (void **) &key, (void **) &cReg)) { + + CMSetArrayElementAt(ar, i++, key, CMPI_chars); + } + + CMAddArg(out, "nslist", &ar, CMPI_stringA); + st.rc = CMPI_RC_OK; + } + + } + else if (strcasecmp(methodName, "_startup") == 0) { /* diff --git a/classProviderMem.c b/classProviderMem.c index 1a2ce6b..411abca 100644 --- a/classProviderMem.c +++ b/classProviderMem.c @@ -1026,6 +1026,38 @@ ClassProviderInvokeMethod(CMPIMethodMI * mi, st.rc = traverseChildren(cReg, parent, chldn); } + else if (strcasecmp(methodName, "listnamespaces") == 0) { + + HashTableIterator *hit; + char *key; + ClassRegister *cReg; + + CMPIArray* ar = CMNewArray(_broker, nsHt->ft->size(nsHt), CMPI_string, NULL); + int i = 0; + + /* req for specific ns */ + CMPIData nsd = CMGetArg(in, "ns", &st); + if (st.rc == CMPI_RC_OK) { + char* ns = CMGetCharPtr(nsd.value.string); + ClassRegister *cReg = NULL; + cReg = nsHt->ft->get(nsHt, ns); + st.rc = (cReg) ? CMPI_RC_OK : CMPI_RC_ERR_NOT_FOUND; + } + else { + for (hit = nsHt->ft->getFirst(nsHt, (void **) &key, (void **) &cReg); + key && hit; + hit = + nsHt->ft->getNext(nsHt, hit, (void **) &key, (void **) &cReg)) { + + CMSetArrayElementAt(ar, i++, key, CMPI_chars); + } + + CMAddArg(out, "nslist", &ar, CMPI_stringA); + st.rc = CMPI_RC_OK; + } + + } + else if (strcasecmp(methodName, "_startup") == 0) { /* let providerMgr know that we're odne init'ing */ diff --git a/classProviderSf.c b/classProviderSf.c index b1f8f68..8e69599 100644 --- a/classProviderSf.c +++ b/classProviderSf.c @@ -493,7 +493,9 @@ gatherNameSpaces(char *dn, UtilHashTable * ns, int first) closedir(dir_test); cr = newClassRegister(n); if (cr) { - ns->ft->put(ns, strdup(n + nsBaseLen), cr); + /* couldn't open classSchemas, don't put it in the ht */ + if (cr->f) + ns->ft->put(ns, strdup(n + nsBaseLen), cr); gatherNameSpaces(n, ns, 0); } free(n); @@ -1387,7 +1389,7 @@ ClassProviderInvokeMethod(CMPIMethodMI * mi, cReg = getNsReg(ref, &rc); if (cReg == NULL) { - CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; + st.rc = CMPI_RC_ERR_INVALID_NAMESPACE; semRelease(sfcbSem,INIT_CLASS_PROV_ID); _SFCB_RETURN(st); } @@ -1422,7 +1424,6 @@ ClassProviderInvokeMethod(CMPIMethodMI * mi, else if (strcasecmp(methodName, "getallchildren") == 0) { int ignprov = 0; - CMPIStatus st; CMPIData cn = CMGetArg(in, "class", &st); cReg->ft->wLock(cReg); @@ -1483,9 +1484,41 @@ ClassProviderInvokeMethod(CMPIMethodMI * mi, st.rc = traverseChildren(cReg, parent, chldn); } + else if (strcasecmp(methodName, "listnamespaces") == 0) { + + HashTableIterator *hit; + char *key; + ClassRegister *cReg; + + CMPIArray* ar = CMNewArray(_broker, nsHt->ft->size(nsHt), CMPI_string, NULL); + int i = 0; + + /* req for specific ns */ + CMPIData nsd = CMGetArg(in, "ns", &st); + if (st.rc == CMPI_RC_OK) { + char* ns = CMGetCharPtr(nsd.value.string); + ClassRegister *cReg = NULL; + cReg = nsHt->ft->get(nsHt, ns); + st.rc = (cReg) ? CMPI_RC_OK : CMPI_RC_ERR_NOT_FOUND; + } + else { + for (hit = nsHt->ft->getFirst(nsHt, (void **) &key, (void **) &cReg); + key && hit; + hit = + nsHt->ft->getNext(nsHt, hit, (void **) &key, (void **) &cReg)) { + + CMSetArrayElementAt(ar, i++, key, CMPI_chars); + } + + CMAddArg(out, "nslist", &ar, CMPI_stringA); + st.rc = CMPI_RC_OK; + } + + } + else if (strcasecmp(methodName, "_startup") == 0) { - /* let providerMgr know that we're odne init'ing */ + /* let providerMgr know that we're done init'ing */ semRelease(sfcbSem,INIT_CLASS_PROV_ID); st.rc = CMPI_RC_OK; diff --git a/interopServerProvider.c b/interopServerProvider.c index 1a9e8e0..23ae182 100644 --- a/interopServerProvider.c +++ b/interopServerProvider.c @@ -103,55 +103,36 @@ getSfcbUuid() // ------------------------------------------------------------------ static int -genNameSpaceData(const char *ns, int dbl, - const CMPIResult *rslt, CMPIObjectPath * op, +genNameSpaceData(const char *ns, const CMPIResult *rslt, CMPIObjectPath * op, CMPIInstance *ci) { if (ci) { - CMSetProperty(ci, "Name", ns + dbl + 1, CMPI_chars); + CMSetProperty(ci, "Name", ns, CMPI_chars); CMReturnInstance(rslt, ci); } else if (op) { - CMAddKey(op, "Name", ns + dbl + 1, CMPI_chars); + CMAddKey(op, "Name", ns, CMPI_chars); CMReturnObjectPath(rslt, op); } return 0; } static void -gatherNameSpacesData(const char *dn, int dbl, - const CMPIResult *rslt, +gatherNameSpacesData(const CMPIResult *rslt, const CMPIContext* ctx, CMPIObjectPath * op, CMPIInstance *ci) { - DIR *dir, - *de_test; - struct dirent *de; - char *n; - int l; - - dir = opendir(dn); - if (dir) { - while ((de = readdir(dir)) != NULL) { - if (strcmp(de->d_name, ".") == 0) - continue; - if (strcmp(de->d_name, "..") == 0) - continue; - l = strlen(dn) + strlen(de->d_name) + 4; - n = malloc(l + 8); - strcpy(n, dn); - strcat(n, "/"); - strcat(n, de->d_name); - de_test = opendir(n); - if (de_test == NULL) { - free(n); - continue; - } - closedir(de_test); - - genNameSpaceData(n,dbl,rslt,op,ci); - gatherNameSpacesData(n,dbl,rslt,op,ci); - free(n); - } - closedir(dir); + /* get the namespaces */ + CMPIObjectPath* cpop = CMNewObjectPath(_broker, "root/interop", "$ClassProvider$", NULL); + CMPIArgs* outarg = CMNewArgs(_broker, NULL); + CBInvokeMethod(_broker, ctx, cpop, "listnamespaces", NULL, outarg, NULL); + CMPIData nsd = CMGetArgAt(outarg, 0, NULL, NULL); + CMPIArray* nsarray = nsd.value.array; + + int i = 0; + int ac = CMGetArrayCount(nsarray, NULL); + CMPIData ns; + for (; i < ac; i++) { + ns = CMGetArrayElementAt(nsarray, i, NULL); + genNameSpaceData(CMGetCharPtr(ns.value.string), rslt, op, ci); } } @@ -163,34 +144,27 @@ NameSpaceProviderGetInstance(CMPIInstanceMI * mi, const char **properties) { CMPIStatus st = { CMPI_RC_OK, NULL }; - char *dirn, - *dn, - hostName[512]; - DIR *dir; + char hostName[512]; CMPIObjectPath *op; CMPIInstance *ci; CMPIString *name; - unsigned short info = 0, - dbl; + unsigned short info = 0; _SFCB_ENTER(TRACE_PROVIDERS, "NameSpaceProviderGetInstance"); - if (getControlChars("registrationDir", &dirn)) { - dirn = "/var/lib/sfcb/registration"; - } - name = CMGetKey(cop, "name", NULL).value.string; if (name && name->hdl) { - dn = alloca(strlen(dirn) + 32 + strlen((char *) name->hdl)); - strcpy(dn, dirn); - if (dirn[strlen(dirn) - 1] != '/') - strcat(dn, "/"); - strcat(dn, "repository/"); - dbl = strlen(dn); - strcat(dn, (char *) name->hdl); - - if ((dir = opendir(dn)) != NULL) { + + /* ask ClassProvider if ns exists */ + CMPIObjectPath* cpop = CMNewObjectPath(_broker, "root/interop", "$ClassProvider$", NULL); + CMPIArgs* inarg = CMNewArgs(_broker, NULL); + CMPIValue nameval; + nameval.string = name; + CMAddArg(inarg, "ns", &nameval, CMPI_string); + CBInvokeMethod(_broker, ctx, cpop, "listnamespaces", inarg, NULL, &st); + + if (st.rc == CMPI_RC_OK) { op=CMNewObjectPath(_broker,"root/interop","CIM_Namespace",NULL); ci=CMNewInstance(_broker,op,NULL); @@ -202,13 +176,16 @@ NameSpaceProviderGetInstance(CMPIInstanceMI * mi, gethostname(hostName,511); CMSetProperty(ci,"SystemName",hostName,CMPI_chars); CMSetProperty(ci,"ClassInfo",&info,CMPI_uint16); - CMSetProperty(ci,"Name",dn+dbl,CMPI_chars); + CMSetProperty(ci,"Name",&nameval,CMPI_string); CMReturnInstance(rslt,ci); - closedir(dir); - } else + } + else { st.rc = CMPI_RC_ERR_NOT_FOUND; - } else + } + } + else { st.rc = CMPI_RC_ERR_INVALID_PARAMETER; + } _SFCB_RETURN(st); } @@ -221,25 +198,13 @@ NameSpaceProviderEnumInstances(CMPIInstanceMI * mi, const char **properties) { CMPIStatus st = { CMPI_RC_OK, NULL }; - char *dir, - *dn, - hostName[512]; + char hostName[512]; CMPIObjectPath *op; CMPIInstance *ci; unsigned short info = 0; _SFCB_ENTER(TRACE_PROVIDERS, "NameSpaceProviderEnumInstances"); - if (getControlChars("registrationDir", &dir)) { - dir = "/var/lib/sfcb/registration"; - } - - dn = alloca(strlen(dir) + 32); - strcpy(dn, dir); - if (dir[strlen(dir) - 1] != '/') - strcat(dn, "/"); - strcat(dn, "repository"); - op = CMNewObjectPath(_broker, "root/interop", "CIM_Namespace", NULL); ci = CMNewInstance(_broker, op, NULL); @@ -254,7 +219,7 @@ NameSpaceProviderEnumInstances(CMPIInstanceMI * mi, CMSetProperty(ci, "SystemName", hostName, CMPI_chars); CMSetProperty(ci, "ClassInfo", &info, CMPI_uint16); - gatherNameSpacesData(dn, strlen(dn), rslt, NULL, ci); + gatherNameSpacesData(rslt, ctx, NULL, ci); _SFCB_RETURN(st); } @@ -266,23 +231,11 @@ NameSpaceProviderEnumInstanceNames(CMPIInstanceMI * mi, const CMPIObjectPath * ref) { CMPIStatus st = { CMPI_RC_OK, NULL }; - char *dir, - *dn, - hostName[512]; + char hostName[512]; CMPIObjectPath *op; _SFCB_ENTER(TRACE_PROVIDERS, "NameSpaceProviderEnumInstanceNames"); - if (getControlChars("registrationDir", &dir)) { - dir = "/var/lib/sfcb/registration"; - } - - dn = alloca(strlen(dir) + 32); - strcpy(dn, dir); - if (dir[strlen(dir) - 1] != '/') - strcat(dn, "/"); - strcat(dn, "repository"); - op = CMNewObjectPath(_broker, "root/interop", "CIM_Namespace", NULL); CMAddKey(op, "CreationClassName", "CIM_Namespace", CMPI_chars); @@ -295,7 +248,7 @@ NameSpaceProviderEnumInstanceNames(CMPIInstanceMI * mi, gethostname(hostName, 511); CMAddKey(op, "SystemName", hostName, CMPI_chars); - gatherNameSpacesData(dn, strlen(dn), rslt, op, NULL); + gatherNameSpacesData(rslt, ctx, op, NULL); _SFCB_RETURN(st); } @@ -838,6 +791,7 @@ ServerProviderInitInstances(const CMPIContext *ctx) ISinst = CMNewInstance(_broker, ISop, &st); makeIndService(ISinst); memUnlinkInstance(ISinst); // Prevent cleanup of the instance + return; } hooks/post-receive -- sfcb - Small Footprint CIM Broker |