int si_nodecreate(sinode *n, sr *r, sischeme *scheme, sdid *id, sdindex *i, sdbuild *build) { si_branchset(&n->self, i); sspath path; ss_pathAB(&path, scheme->path, id->parent, id->id, ".db.incomplete"); int rc = ss_filenew(&n->file, path.path); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' create error: %s", path.path, strerror(errno)); return -1; } rc = sd_commit(build, r, &n->self.index, &n->file); if (ssunlikely(rc == -1)) return -1; if (scheme->mmap) { rc = si_nodemap(n, r); if (ssunlikely(rc == -1)) return -1; } n->branch = &n->self; n->branch_count++; return 0; }
int si_nodecreate(sinode *n, sr *r, sischeme *scheme, sdid *id) { sspath path; ss_pathAB(&path, scheme->path, id->parent, id->id, ".db.incomplete"); int rc = ss_filenew(&n->file, path.path); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' create error: %s", path.path, strerror(errno)); return -1; } return 0; }
int si_nodeseal(sinode *n, sr *r, sischeme *scheme) { sspath path; ss_pathAB(&path, scheme->path, n->self.id.parent, n->self.id.id, ".db.seal"); int rc = ss_filerename(&n->file, path.path); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' rename error: %s", n->file.file, strerror(errno)); } return rc; }
int si_nodeseal(sinode *n, sr *r, sischeme *scheme) { int rc; if (scheme->sync) { rc = ss_filesync(&n->file); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' sync error: %s", ss_pathof(&n->file.path), strerror(errno)); return -1; } } sspath path; ss_pathAB(&path, scheme->path, n->self.id.parent, n->self.id.id, ".db.seal"); rc = ss_filerename(&n->file, path.path); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' rename error: %s", ss_pathof(&n->file.path), strerror(errno)); return -1; } return 0; }