From d43b9552b98ff9143a360fb9a4f396c04820dd51 Mon Sep 17 00:00:00 2001 From: TS6320 Date: Tue, 16 Jul 2019 10:43:20 -0400 Subject: [PATCH] Added warning message if plugin doesn't have program control attribute Signed-off-by: TS6320 Fixed spacing issues Signed-off-by: TS6320 Removed unneeded variable and added check for status Signed-off-by: TS6320 Added status warning message Signed-off-by: TS6320 Fixed tabs spacing Signed-off-by: TS6320 Changed check to happen before dll loaded therefore it will not be loaded if failed check, and changed print statements to zowe logs Signed-off-by: TS6320 Changed plugin to dataservice in log message Signed-off-by: sakeerthy Changed hard coded number to defined value Signed-off-by: sakeerthy --- c/dataservice.c | 39 ++++++++++++++++++++++++++++----------- h/unixfile.h | 8 +++++++- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/c/dataservice.c b/c/dataservice.c index a4d7afbed..7293c92eb 100644 --- a/c/dataservice.c +++ b/c/dataservice.c @@ -107,18 +107,35 @@ static void *lookupDLLEntryPoint(char *libraryName, char *functionName){ | RTLD_NOW #endif ; - void *library = dlopen(libraryName,flags); - if (library){ - printf("dll handle for %s = 0x%" PRIxPTR "\n",libraryName, library); - ep = dlsym(library,functionName); - /* dlclose(library); - this will really close the DLL, like not be able to call */ - if (ep == NULL){ - printf("%s.%s could not be found - dlsym error %s\n", libraryName, functionName, dlerror()); + FileInfo info; + int status = 0; + int returnCode = 0; + int reasonCode = 0; + status = fileInfo(libraryName, &info, &returnCode, &reasonCode); + if (status == 0) { + if (!(info.attributeFlags & BPXYSTAT_ATTR_PROGCTL)) { + zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_SEVERE, + "FAILURE: Dataservice: %s does not have the Program Control attribute this may cause unexpected errors therefore will not be loaded\n", + libraryName); } else { - printf("%s.%s is at 0x%" PRIxPTR "\n", libraryName, functionName, ep); - } - } else{ - printf("dlopen error for %s - %s\n",libraryName, dlerror()); + void *library = dlopen(libraryName,flags); + if (library){ + zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_INFO, "dll handle for %s = 0x%" PRIxPTR "\n", libraryName, library); + ep = dlsym(library,functionName); + /* dlclose(library); - this will really close the DLL, like not be able to call */ + if (ep == NULL){ + zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_SEVERE, "%s.%s could not be found - dlsym error %s\n", libraryName, functionName, dlerror()); + } else { + zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_INFO, "%s.%s is at 0x%" PRIxPTR "\n", libraryName, functionName, ep); + } + } else { + zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_SEVERE, "dlopen error for %s - %s\n",libraryName, dlerror()); + } + } + } else { + zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_SEVERE, + "FAILURE: Dataservice: %s status not available therefore will not be loaded, please check the provided file name: (return = 0x%x, reason = 0x%x)\n", + libraryName, returnCode, reasonCode); } #endif /* not METTLE */ return ep; diff --git a/h/unixfile.h b/h/unixfile.h index 581ba894a..a6734e8d1 100644 --- a/h/unixfile.h +++ b/h/unixfile.h @@ -164,7 +164,13 @@ typedef struct BPXYSTAT_tag{ short fileTaggingTags; int reserved2[2]; int64 blocks; - int attributeFlags; + uint32_t reservedAttributeFlags: 24; + uint8_t attributeFlags; + #define BPXYSTAT_ATTR_SHARELIB 0x10 + #define BPXYSTAT_ATTR_NOSHAREAS 0x08 + #define BPXYSTAT_ATTR_APFAUTH 0x04 + #define BPXYSTAT_ATTR_PROGCTL 0x02 + #define BPXYSTAT_ATTR_EXTLINK 0x01 /* 0x10 shared lib 0x08 no shareas 0x04 APF