static void vpr(int code, const char *fmt, va_list ap) { char path[MAXPATHLEN+1]; char siz[5], ino[5]; int64_t s, i; s = df(); i = inodes(); if (errno == ENOSPC && (flags & MNT_SOFTDEP) && (flags & MNT_QUOTA) == 0 && s > 100 && i > 100) { if (getcwd(path, sizeof(path)) == NULL) err(1, "getcwd()"); humanize_number(siz, sizeof(siz), s, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); humanize_number(ino, sizeof(ino), i, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); printf("A syscall has failed with ENOSPC even though free disk " "space for %s is reported as %s and %s inodes.\n", path, siz, ino); } fprintf(stderr, "%s: ", getprogname()); if (fmt != NULL) { vfprintf(stderr, fmt, ap); fprintf(stderr, ": "); } fprintf(stderr, "%s\n", strerror(code)); }
XmlTree CanvasComponent::getXml() { XmlTree cComp("CanvasComponent", ""); cComp.setAttribute("id", id); cComp.setAttribute("type", ci::toString(type)); cComp.setAttribute("name", name); cComp.setAttribute("position.x", canvasRect.x1); cComp.setAttribute("position.y", canvasRect.y1); cComp.setAttribute("size.x", localRect.getWidth()); cComp.setAttribute("size.y", localRect.getHeight()); cComp.setAttribute("showInputPlus", showInputPlus); cComp.setAttribute("showOutputPlus", showOutputPlus); XmlTree inodes("InputNodes", ""); for (int i=0; i<inputNodes.size(); i++) { inodes.push_back(inputNodes[i]->getXml()); } cComp.push_back(inodes); XmlTree onodes("OutputNodes", ""); for (int i=0; i<outputNodes.size(); i++) { onodes.push_back(outputNodes[i]->getXml()); } cComp.push_back(onodes); return cComp; }
void getdf(int64_t *block, int64_t *inode) { int i, j; char buf[128]; snprintf(lockpath, sizeof(lockpath), "%s/lock", op->cd); for (j = 0; j < 10; j++) { for (i = 0; i < 10000; i++) { if ((lockfd = open(lockpath, O_CREAT | O_TRUNC | O_WRONLY | O_EXCL, 0644)) != -1) break; usleep(10000); /* sleep 1/100 sec */ } if (lockfd != -1) break; fprintf(stderr, "%s. Removing stale %s\n", getprogname(), lockpath); unlink(lockpath); } if (lockfd == -1) errx(1, "%s. Can not create %s\n", getprogname(), lockpath); snprintf(dfpath, sizeof(dfpath), "%s/df", op->cd); if ((dffd = open(dfpath, O_RDWR, 0644)) == -1) { if ((dffd = open(dfpath, O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) { unlink(lockpath); err(1, "creat(%s) %s:%d", dfpath, __FILE__, __LINE__); } atexit(cleanupdf); *block = df(); *inode = inodes(); snprintf(buf, sizeof(buf), "%jd %jd", *block, *inode); if (write(dffd, buf, strlen(buf) + 1) != strlen(buf) +1) err(1, "write df. %s:%d", __FILE__, __LINE__); } else { if (read(dffd, buf, sizeof(buf)) < 1) { system("ls -l /tmp/stressX.control"); unlink(lockpath); err(1, "read df. %s:%d", __FILE__, __LINE__); } sscanf(buf, "%jd %jd", block, inode); } close(dffd); }
bool SpidirParams::order(SpeciesTree *stree) { if (stree->nnodes != nsnodes) { printError("wrong number of parameters: %d %d\n", stree->nnodes, nsnodes); return false; } ExtendArray<Node*> nodeorder(0, stree->nnodes); getTreePreOrder(stree, &nodeorder); // make interior node names ExtendArray<int> inodes(stree->nnodes); int inodename = 1; for (int i=0; i<stree->nnodes; i++) { Node *node = nodeorder[i]; if (node->isLeaf()) { inodes[node->name] = -1; } else { inodes[node->name] = inodename++; } } // loop through preordered nodes to construct permutation ExtendArray<int> invperm(0, stree->nnodes); for (int j=0; j<nsnodes; j++) { if (invperm.size() != j) { printError("unable to match '%s' to the species tree", names[j].c_str()); return false; } // try to parse node id as an int int id; bool isint = (sscanf(names[j].c_str(), "%d", &id) == 1); for (int i=0; i<stree->nnodes; i++) { if (stree->nodes[i]->isLeaf()) { // if leaf, check if names match if (names[j] == stree->nodes[i]->longname) { invperm.append(i); break; } } else { if (isint && id == inodes[i]) { invperm.append(i); break; } } } } // apply permutation ExtendArray<int> perm(stree->nnodes); invertPerm(invperm, perm, nsnodes); permute(names, perm, nsnodes); permute(sp_alpha, perm, nsnodes); permute(sp_beta, perm, nsnodes); return true; }