static rc_t VDBDependenciesReportDepend1(const VDBDependencies *self, const ReportFuncs *f, uint32_t count, uint32_t indent, bool toreport, uint32_t *missing) { KDirectory *dir = NULL; rc_t rc = 0; uint32_t i = ~0; assert(missing); *missing = 0; for (i = 0; i < count; ++i) { bool isMissing = false; bool local = false; const char* seq_id = ""; const char* path = NULL; rc = VDBDependenciesSeqId(self, &seq_id, i); if (rc != 0 && toreport) reportErrorStrInt(indent, rc, "VDBDependenciesSeqId", "origin", "VDatabaseListDependencies", "idx", i); if (rc == 0) { rc = VDBDependenciesLocal(self, &local, i); if (rc != 0 && toreport) { reportErrorStrInt(indent, rc, "VDBDependenciesLocal", "origin", "VDatabaseListDependencies", "idx", i); } } if (rc == 0) { rc = VDBDependenciesPath(self, &path, i); if (rc != 0 && toreport) { reportErrorStrInt(indent, rc, "VDBDependenciesPath", "origin", "VDatabaseListDependencies", "idx", i); } } if (rc == 0) { if (!local && (path == NULL || path[0] == '\0')) { isMissing = true; ++*missing; } if (toreport) { bool reported = false; if (!isMissing && !local) { rc_t rc = 0; bool readable = false; uint64_t size = ~0; KTime_t date = 0; bool ready = false; if (dir == NULL) { rc = KDirectoryNativeDir(&dir); } assert(!local && path && path[0]); if (dir != NULL) { rc = KDirectoryFileSize(dir, &size, "%s", path); if (rc == 0) { rc = KDirectoryDate(dir, &date, "%s", path); } if (rc == 0) { const KFile* f = NULL; rc = KDirectoryOpenFileRead(dir, &f, "%s", path); if (rc == 0) { char buffer[1024]; size_t num_read = 0; size_t bsize = size > sizeof buffer ? sizeof buffer : size; rc = KFileReadAll(f, 0, buffer, bsize, &num_read); if (rc == 0 && num_read != bsize) { rc = RC(rcVDB, rcFile, rcReading, rcBuffer, rcExcessive); } if (rc == 0) { readable = true; } } KFileRelease(f); } if (rc == 0) { ready = true; } } if (ready) { KTime kt; memset(&kt, 0, sizeof kt); KTimeLocal(&kt, date); report(indent, "Dependency", 7, "index", 'd', i, "seq_id", 's', seq_id, "local", 's', local ? "true" : "false", "path", 's', path, "size", 'u', size, "date", 'T', &kt, "readable", 's', readable ? "true" : "false"); reported = true; } else { report(indent, "Dependency", 5, "index", 'd', i, "seq_id", 's', seq_id, "local", 's', local ? "true" : "false", "path", 's', path, "error", 'R', rc); reported = true; } } if (!reported) { report(indent, "Dependency", 4, "index", 'd', i, "seq_id", 's', seq_id, "local", 's', local ? "true" : "false", "path", 's', path == NULL ? "" : path); } } } if (rc != 0 && !toreport) { break; } } RELEASE(KDirectory, dir); return rc; }
static rc_t align_info(const Params* prm) { rc_t rc = 0; const VDatabase* db = NULL; const VDBManager* mgr = NULL; const KDBManager *kmgr = NULL; VSchema* schema = NULL; bool is_db = false; if (prm == NULL) { return RC(rcExe, rcQuery, rcExecuting, rcParam, rcNull); } if (rc == 0) { rc = VDBManagerMakeRead(&mgr, NULL); DISP_RC(rc, "while calling VDBManagerMakeRead"); } if (rc == 0) { rc = VDBManagerOpenKDBManagerRead(mgr, &kmgr); DISP_RC(rc, "while calling VDBManagerOpenKDBManagerRead"); } if (rc == 0) { rc = VDBManagerMakeSRASchema(mgr, &schema); DISP_RC(rc, "while calling VDBManagerMakeSRASchema"); } if (rc == 0) { /* const char path[] = "/panfs/pan1/trace_work/scratch/XXX000013"; */ rc = VDBManagerOpenDBRead(mgr, &db, schema, prm->dbPath); if (rc == 0) { is_db = true; } else if (rc == SILENT_RC(rcDB, rcMgr, rcOpening, rcDatabase, rcIncorrect)) { PLOGMSG(klogWarn, (klogWarn, "'$(path)' is not a database", "path=%s", prm->dbPath)); rc = 0; } else { PLOGERR(klogErr, (klogErr, rc, "$(path)", "path=%s", prm->dbPath)); } } if (is_db) { if (rc == 0) { if (prm->paramRef) { const VDBDependencies* dep = NULL; uint32_t count = 0; int i = 0; rc = VDatabaseListDependencies(db, &dep, false); DISP_RC2(rc, prm->dbPath, "while calling VDatabaseListDependencies"); if (rc == 0) { rc = VDBDependenciesCount(dep, &count); DISP_RC2(rc, prm->dbPath, "while calling VDBDependenciesCount"); } for (i = 0; i < count && rc == 0; ++i) { bool circular = false; const char* name = NULL; const char* path = NULL; const char* remote = NULL; bool local = false; const char* seqId = NULL; rc = VDBDependenciesCircular(dep, &circular, i); if (rc != 0) { DISP_RC2(rc, prm->dbPath, "while calling VDBDependenciesCircular"); break; } rc = VDBDependenciesName(dep, &name, i); if (rc != 0) { DISP_RC2(rc, prm->dbPath, "while calling VDBDependenciesName"); break; } rc = VDBDependenciesPath(dep, &path, i); if (rc != 0) { DISP_RC2(rc, prm->dbPath, "while calling VDBDependenciesPath"); break; } rc = VDBDependenciesLocal(dep, &local, i); if (rc != 0) { DISP_RC2(rc, prm->dbPath, "while calling VDBDependenciesLocal"); break; } rc = VDBDependenciesSeqId(dep, &seqId, i); if (rc != 0) { DISP_RC2(rc, prm->dbPath, "while calling VDBDependenciesSeqId"); break; } rc = VDBDependenciesPathRemote(dep, &remote, i); if (rc != 0) { DISP_RC2(rc, prm->dbPath, "while calling VDBDependenciesRemote"); break; } OUTMSG(("%s,%s,%s,%s", seqId, name, (circular ? "true" : "false"), (local ? "local" : "remote"))); if (path && path[0]) { OUTMSG((":%s", path)); } else if (remote && remote[0]) { OUTMSG(("::%s", remote)); } OUTMSG(("\n")); } DESTRUCT(VDBDependencies, dep); } if (prm->paramBamHeader) { rc_t rc3 = bam_header(db); if (rc3 != 0 && rc == 0) { rc = rc3; } } if (prm->paramQuality) { rc_t rc3 = qual_stats(prm, db); if (rc3 != 0 && rc == 0) { rc = rc3; } } } } DESTRUCT(VSchema, schema); DESTRUCT(KDBManager, kmgr); DESTRUCT(VDBManager, mgr); DESTRUCT(VDatabase, db); return rc; }