Commit bd7a82e0 authored by lw's avatar lw

Implemented paste in volrepdb

parent 1350c290
...@@ -45,14 +45,47 @@ dbs_AlignedRead(pwr_tStatus *sts, void *buf, pwr_tUInt32 size, const dbs_sEnv *e ...@@ -45,14 +45,47 @@ dbs_AlignedRead(pwr_tStatus *sts, void *buf, pwr_tUInt32 size, const dbs_sEnv *e
return YES; return YES;
} }
dbs_sVolRef *
dbs_VolRef(pwr_tStatus *sts, pwr_tUInt32 index, dbs_sVolRef *vp, const dbs_sEnv *ep)
{
dbs_sSect sect;
int nVolref = 0;
fseek(ep->f, ep->file.offset + (dbs_eSect_volref * dbs_dAlign(sizeof(sect))), SEEK_SET);
if (fread(&sect, sizeof(sect), 1, ep->f) == 0) {
*sts = errno_GetStatus();
return NULL;
}
nVolref = sect.size / dbs_dAlign(sizeof(*vp));
if (index >= nVolref)
return NULL;
fseek(ep->f, sect.offset + (index * dbs_dAlign(sizeof(*vp))), SEEK_SET);
if (fread(vp, sizeof(*vp), 1, ep->f) == 0) {
*sts = errno_GetStatus();
return NULL;
}
return vp;
}
pwr_tBoolean pwr_tBoolean
dbs_Close(pwr_tStatus *sts, dbs_sEnv *ep) dbs_Close(pwr_tStatus *sts, dbs_sEnv *ep)
{ {
*sts = DBS__SUCCESS; *sts = DBS__SUCCESS;
fclose(ep->f); if (ep->f != NULL) {
ep->f = NULL; fclose(ep->f);
ep->f = NULL;
return TRUE; } else {
printf("ERROR, dbs_Close, trying to close a non opened file\n");
}
return TRUE;
} }
dbs_sEnv * dbs_sEnv *
...@@ -61,6 +94,7 @@ dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename) ...@@ -61,6 +94,7 @@ dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
FILE *f; FILE *f;
co_mFormat srcFormat, ownFormat; co_mFormat srcFormat, ownFormat;
PDR pdrs; PDR pdrs;
dbs_sSect sect;
*sts = DBS__SUCCESS; *sts = DBS__SUCCESS;
memset(ep, 0, sizeof(*ep)); memset(ep, 0, sizeof(*ep));
...@@ -77,6 +111,17 @@ dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename) ...@@ -77,6 +111,17 @@ dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
return NULL; return NULL;
} }
fseek(f, ep->file.offset, SEEK_SET);
if (fread(&sect, sizeof(sect), 1, f) == 0) {
*sts = errno_GetStatus();
fclose(f);
return NULL;
}
ep->nSect = sect.size / dbs_dAlign(sizeof(sect));
#if 0 #if 0
srcFormat.m = ntohl(ep->file.format.m); srcFormat.m = ntohl(ep->file.format.m);
#else #else
...@@ -102,7 +147,7 @@ dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename) ...@@ -102,7 +147,7 @@ dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
#if defined(OS_LINUX) || defined(OS_LYNX) #if defined(OS_LINUX) || defined(OS_LYNX)
static pwr_tBoolean static pwr_tBoolean
checkQ(const dbs_sEnv *ep, dbs_sQlink *item) checkQ(const dbs_sVenv *vep, dbs_sQlink *item)
{ {
dbs_sQlink *link; dbs_sQlink *link;
...@@ -115,7 +160,7 @@ checkQ(const dbs_sEnv *ep, dbs_sQlink *item) ...@@ -115,7 +160,7 @@ checkQ(const dbs_sEnv *ep, dbs_sQlink *item)
return NO; return NO;
} }
link = dbs_Address(NULL, ep, item->self); link = dbs_Address(NULL, vep, item->self);
if (item != link) { if (item != link) {
printf("checkQ in volume: %s, item != dbs_Address(NULL, ep, item->self),\n item: %u != %u", printf("checkQ in volume: %s, item != dbs_Address(NULL, ep, item->self),\n item: %u != %u",
"not known", (unsigned int)item, (unsigned int)link); "not known", (unsigned int)item, (unsigned int)link);
...@@ -126,34 +171,38 @@ checkQ(const dbs_sEnv *ep, dbs_sQlink *item) ...@@ -126,34 +171,38 @@ checkQ(const dbs_sEnv *ep, dbs_sQlink *item)
} }
void * void *
dbs_Address(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_tRef r) dbs_Address(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_tRef r)
{ {
dbs_uRefBits bits; dbs_uRefBits bits;
if (r == dbs_cNref) if (r == dbs_cNref)
return NULL; return NULL;
if (!ep->flags.b.isMapped) if (!vep->mp->flags.b.isMapped)
pwr_Return(NULL, sts, DBS__NOTMAPPED); pwr_Return(NULL, sts, DBS__NOTMAPPED);
if (vep->index != 0) {
/*printf("index: %d, name %s\n", vep->index, vep->vp->name)*/;
}
bits.m = r; bits.m = r;
if (bits.b.sect > dbs_eSect_) if (bits.b.sect > dbs_eSect_)
pwr_Return(NULL, sts, DBS__BADSECT); pwr_Return(NULL, sts, DBS__BADSECT);
if (bits.b.offs >= ep->sect[bits.b.sect].size) if (bits.b.offs >= vep->sect[bits.b.sect].size)
pwr_Return(NULL, sts, DBS__BADOFFS); pwr_Return(NULL, sts, DBS__BADOFFS);
return (void *)(ep->base + ep->sect[bits.b.sect].offset + bits.b.offs); return (void *)(vep->base + vep->sect[bits.b.sect].offset + bits.b.offs);
} }
void *dbs_Bfind(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBintab *tp, void *key, int (comp)(void *key, void *record)) void *dbs_Bfind(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sBintab *tp, void *key, int (comp)(void *key, void *record))
{ {
char *p; char *p;
int c; int c;
char *start = dbs_Address(sts, ep, tp->start); char *start = dbs_Address(sts, vep, tp->start);
char *end = dbs_Address(sts, ep, tp->end); char *end = dbs_Address(sts, vep, tp->end);
int rsize = tp->rsize; int rsize = tp->rsize;
while (start <= end) { while (start <= end) {
...@@ -171,58 +220,19 @@ void *dbs_Bfind(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBintab *tp, void *key ...@@ -171,58 +220,19 @@ void *dbs_Bfind(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBintab *tp, void *key
return 0; return 0;
} }
#if 0
dbs_sEnv *
dbs_Create(pwr_tStatus*, dbs_sEnv*, char*, pwr_tUInt32, pwr_tUInt32)
{
}
void
dbs_Dump(pwr_tStatus*, dbs_sEnv*)
{
}
pwr_tBoolean
dbs_Free(pwr_tStatus*, dbs_sEnv*, void*)
{
}
pwr_tBoolean pwr_tBoolean
dbs_FreeReference(pwr_tStatus*, dbs_sEnv*, dbs_tRef) dbs_QhasOne(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sQlink *item)
{
}
dbs_tRef
dbs_InDbs(pwr_tStatus*, dbs_sEnv*, void*, pwr_tUInt32)
{
}
dbs_tRef
dbs_ItemReference(pwr_tStatus*, dbs_sEnv*, void*)
{
}
dbs_sQlink *
dbs_Qalloc(pwr_tStatus*, dbs_sEnv*)
{
}
#endif
pwr_tBoolean
dbs_QhasOne(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item)
{ {
dbs_sQlink *pred; dbs_sQlink *pred;
dbs_sQlink *succ; dbs_sQlink *succ;
pwr_Assert(checkQ(ep, item)); pwr_Assert(checkQ(vep, item));
pred = dbs_Address(sts, ep, item->pred); pred = dbs_Address(sts, vep, item->pred);
succ = dbs_Address(sts, ep, item->succ); succ = dbs_Address(sts, vep, item->succ);
pwr_Assert(checkQ(ep, succ)); pwr_Assert(checkQ(vep, succ));
pwr_Assert(checkQ(ep, pred)); pwr_Assert(checkQ(vep, pred));
pwr_Assert(item->pred == pred->self); pwr_Assert(item->pred == pred->self);
pwr_Assert(item->succ == succ->self); pwr_Assert(item->succ == succ->self);
pwr_Assert(pred->succ == item->self); pwr_Assert(pred->succ == item->self);
...@@ -257,24 +267,19 @@ dbs_Qinsert(pwr_tStatus *sts, dbs_sQlink *pred, dbs_sQlink *item, dbs_sQlink *su ...@@ -257,24 +267,19 @@ dbs_Qinsert(pwr_tStatus *sts, dbs_sQlink *pred, dbs_sQlink *item, dbs_sQlink *su
} }
#if 0
dbs_sQlink *dbs_QinsertPred(pwr_tStatus*, dbs_sEnv*, dbs_sQlink*, dbs_sQlink*);
dbs_sQlink *dbs_QinsertSucc(pwr_tStatus*, dbs_sEnv*, dbs_sQlink*, dbs_sQlink*);
#endif
#if 1
pwr_tBoolean pwr_tBoolean
dbs_QisEmpty(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) dbs_QisEmpty(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sQlink *item)
{ {
dbs_sQlink *pred; dbs_sQlink *pred;
dbs_sQlink *succ; dbs_sQlink *succ;
pwr_Assert(checkQ(ep, item)); pwr_Assert(checkQ(vep, item));
pred = dbs_Address(sts, ep, item->pred); pred = dbs_Address(sts, vep, item->pred);
succ = dbs_Address(sts, ep, item->succ); succ = dbs_Address(sts, vep, item->succ);
pwr_Assert(checkQ(ep, succ)); pwr_Assert(checkQ(vep, succ));
pwr_Assert(checkQ(ep, pred)); pwr_Assert(checkQ(vep, pred));
pwr_Assert(item->pred == pred->self); pwr_Assert(item->pred == pred->self);
pwr_Assert(item->succ == succ->self); pwr_Assert(item->succ == succ->self);
pwr_Assert(pred->succ == item->self); pwr_Assert(pred->succ == item->self);
...@@ -284,18 +289,18 @@ dbs_QisEmpty(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) ...@@ -284,18 +289,18 @@ dbs_QisEmpty(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item)
} }
pwr_tBoolean pwr_tBoolean
dbs_QisLinked(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) dbs_QisLinked(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sQlink *item)
{ {
dbs_sQlink *pred; dbs_sQlink *pred;
dbs_sQlink *succ; dbs_sQlink *succ;
pwr_Assert(checkQ(ep, item)); pwr_Assert(checkQ(vep, item));
pred = dbs_Address(sts, ep, item->pred); pred = dbs_Address(sts, vep, item->pred);
succ = dbs_Address(sts, ep, item->succ); succ = dbs_Address(sts, vep, item->succ);
pwr_Assert(checkQ(ep, succ)); pwr_Assert(checkQ(vep, succ));
pwr_Assert(checkQ(ep, pred)); pwr_Assert(checkQ(vep, pred));
pwr_Assert(item->pred == pred->self); pwr_Assert(item->pred == pred->self);
pwr_Assert(item->succ == succ->self); pwr_Assert(item->succ == succ->self);
pwr_Assert(pred->succ == item->self); pwr_Assert(pred->succ == item->self);
...@@ -305,7 +310,7 @@ dbs_QisLinked(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) ...@@ -305,7 +310,7 @@ dbs_QisLinked(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item)
} }
pwr_tBoolean pwr_tBoolean
dbs_QisNull(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) dbs_QisNull(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sQlink *item)
{ {
pwr_tBoolean nullQ; pwr_tBoolean nullQ;
...@@ -321,16 +326,16 @@ dbs_QisNull(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) ...@@ -321,16 +326,16 @@ dbs_QisNull(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item)
} }
dbs_sQlink * dbs_sQlink *
dbs_Qpred(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) dbs_Qpred(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sQlink *item)
{ {
dbs_sQlink *pred; dbs_sQlink *pred;
pwr_Assert(checkQ(ep, item)); pwr_Assert(checkQ(vep, item));
pred = dbs_Address(NULL, ep, item->pred); pred = dbs_Address(NULL, vep, item->pred);
if (pred != NULL) { if (pred != NULL) {
pwr_Assert(checkQ(ep, pred)); pwr_Assert(checkQ(vep, pred));
pwr_Assert(pred->succ == item->self); pwr_Assert(pred->succ == item->self);
pwr_Assert(pred->self == item->pred); pwr_Assert(pred->self == item->pred);
} }
...@@ -339,16 +344,16 @@ dbs_Qpred(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) ...@@ -339,16 +344,16 @@ dbs_Qpred(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item)
} }
dbs_sQlink * dbs_sQlink *
dbs_Qsucc(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) dbs_Qsucc(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sQlink *item)
{ {
dbs_sQlink *succ; dbs_sQlink *succ;
pwr_Assert(checkQ(ep, item)); pwr_Assert(checkQ(vep, item));
succ = dbs_Address(NULL, ep, item->succ); succ = dbs_Address(NULL, vep, item->succ);
if (succ != NULL) { if (succ != NULL) {
pwr_Assert(checkQ(ep, succ)); pwr_Assert(checkQ(vep, succ));
pwr_Assert(succ->pred == item->self); pwr_Assert(succ->pred == item->self);
pwr_Assert(item->succ == succ->self); pwr_Assert(item->succ == succ->self);
} }
...@@ -360,81 +365,37 @@ dbs_Qsucc(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item) ...@@ -360,81 +365,37 @@ dbs_Qsucc(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sQlink *item)
Return a dbs_tRef, and signals errors. */ Return a dbs_tRef, and signals errors. */
dbs_tRef dbs_tRef
dbs_Reference(pwr_tStatus *sts, const dbs_sEnv *ep, void *adrs) dbs_Reference(pwr_tStatus *sts, const dbs_sVenv *vep, void *adrs)
{ {
long iadrs = (long)adrs; long iadrs = (long)adrs;
long ofs; long ofs;
//long base = ep->sect[] //long base = ep->sect[]
if (iadrs < (long)ep->base) if (iadrs < (long)vep->base)
return dbs_cNref; return dbs_cNref;
ofs = iadrs - (long)ep->base; ofs = iadrs - (long)vep->base;
if (ofs >= ep->size) if (ofs >= vep->size)
return dbs_cNref; return dbs_cNref;
return (dbs_tRef)ofs; return (dbs_tRef)ofs;
} }
#endif dbs_sMenv *
dbs_Map(pwr_tStatus *sts, const char *filename)
static void
printTree(dbs_sEnv *ep, dbs_sObject *op, int indent)
{
pwr_tStatus sts;
static char space[] = " ";
cdh_uOid oid;
if (op == NULL)
return;
oid.pwr = op->oid;
space[indent] = '\0';
printf("T %3.3d.%3.3d.%3.3d.%3.3d:[%d|%5.5d|%2.2d|%d|%5.5d]: %s %s\n", oid.c.vid_0, oid.c.vid_1, oid.c.vid_2, oid.c.vid_3,
oid.c.must_be_two, oid.c.cix, oid.c.bix, oid.c.reserved, oid.c.aix, space, op->name);
space[indent] = ' ';
printTree(ep, dbs_First(&sts, ep, op), indent + 1);
printTree(ep, dbs_After(&sts, ep, op), indent);
}
static void
printTree1(dbs_sEnv *ep, dbs_sObject *op)
{
pwr_tStatus sts;
char name[512];
if (op == NULL)
return;
dbs_ObjectToName(&sts, ep, op, name);
printf("T1 %s\n", name);
printTree1(ep, dbs_First(&sts, ep, op));
printTree1(ep, dbs_After(&sts, ep, op));
}
dbs_sEnv *
dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
{ {
struct stat sb; struct stat sb;
int ret; int ret;
int fd; int fd;
#define DBS_DEBUG 0
#if DBS_DEBUG
int i; int i;
dbs_sFile *fp; dbs_sSect *sect;
dbs_sSect *sp; dbs_sFile file;
dbs_sVolume *vp; void *base = 0;
dbs_sObject *op, *eop; int nVolRef;
dbs_sName *np, *enp; dbs_sVolRef *vrp;
dbs_sOid *oidp, *eoidp; dbs_sMenv *mep = 0;
dbs_uRefBits nf, nl, cf, cl, of, ol; dbs_sVenv *vep = 0;
dbs_sClass *cp, *ecp;
#endif
*sts = DBS__SUCCESS; *sts = DBS__SUCCESS;
if ((ret = stat(filename, &sb)) != 0) { if ((ret = stat(filename, &sb)) != 0) {
...@@ -443,35 +404,16 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename) ...@@ -443,35 +404,16 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
return NULL; return NULL;
} }
#if DBS_DEBUG
printf("st_dev....: %d\t\t%s\n", (int)sb.st_dev, "device");
printf("st_ino....: %ld\t%s\n", sb.st_ino, "inode");
printf("st_mode...: %d\t%s\n", sb.st_mode, "protection");
printf("st_nlink..: %d\t\t%s\n", sb.st_nlink, "number of hard links");
printf("st_uid....: %d\t%s\n", sb.st_uid, "user ID of owner");
printf("st_gid....: %d\t\t%s\n", sb.st_gid, "group ID of owner");
printf("st_redv...: %d\t\t%s\n", (int)sb.st_rdev, "device type (if inode device)");
printf("st_size...: %ld\t\t%s\n", sb.st_size, "total size, in bytes");
printf("st_blksize: %ld\t%s\n", sb.st_blksize, "blocksize for filesystem I/O");
printf("st_blocks.: %ld\t\t%s\n", sb.st_blocks, "number of blocks allocated");
printf("st_atime..: %ld\t%s\n", sb.st_atime, "time of last access");
printf("st_mtime..: %ld\t%s\n", sb.st_mtime, "time of last modification");
printf("st_ctime..: %ld\t%s\n", sb.st_ctime, "time of last change");
printf("st_mode...: %d\t%s\n", sb.st_mode, "mode");
#endif
fd = open(filename, O_RDWR); fd = open(filename, O_RDWR);
#if DBS_DEBUG
printf("open fd: %d\n", fd);
#endif
errno = 0; errno = 0;
memset(ep, 0, sizeof(*ep));
ep->base = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); ret = read(fd, &file, sizeof(file));
if (ep->base == NULL) { printf("st_size...: %ld\n", sb.st_size);
printf("size......: %d\n", file.size);
base = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (base == NULL) {
*sts = errno_GetStatus(); *sts = errno_GetStatus();
perror("mmap"); perror("mmap");
ret = close(fd); ret = close(fd);
...@@ -479,147 +421,142 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename) ...@@ -479,147 +421,142 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
} }
ret = close(fd); ret = close(fd);
ep->flags.b.isMapped = 1; sect = (dbs_sSect*)(base + dbs_dAlign(sizeof(dbs_sFile)));
ep->sect = (dbs_sSect*)(ep->base + dbs_dAlign(sizeof(dbs_sFile))); vrp = (dbs_sVolRef*)(base + sect[dbs_eSect_volref].offset);
ep->vp = (dbs_sVolume*)(ep->base + ep->sect[dbs_eSect_volume].offset); nVolRef = sect[dbs_eSect_volref].size / dbs_dAlign(sizeof(dbs_sVolRef));
ep->vrp = (dbs_sVolRef*)(ep->base + ep->sect[dbs_eSect_volref].offset);
ep->name_bt = &ep->vp->name_bt; mep = (dbs_sMenv *)calloc(1, sizeof(dbs_sMenv) + (nVolRef * sizeof(dbs_sVenv)));
ep->oid_bt = &ep->vp->oid_bt;
ep->class_bt = &ep->vp->class_bt; mep->size = sb.st_size;
mep->flags.b.isMapped = 1;
#if DBS_DEBUG mep->vrp = vrp;
fp = (dbs_sFile*)ep->base; mep->nVolRef = nVolRef;
mep->base = base;
printf("format.......: %d\n", fp->format.m); vep = mep->venv;
printf("cookie.......: %d\n", fp->cookie);
printf("size.........: %d\n", fp->size); vep->mp = mep;
printf("offset.......: %d\n", fp->offset); vep->index = 0;
printf("formatVersion: %d\n", fp->formatVersion); vep->base = base;
printf("version......: %d\n", fp->version); vep->sect = (dbs_sSect*)(vep->base + dbs_dAlign(sizeof(dbs_sFile)));
printf("sectVersion..: %d\n", fp->sectVersion); vep->vp = (dbs_sVolume*)(vep->base + vep->sect[dbs_eSect_volume].offset);
printf("pwrVersion...: %d\n", fp->pwrVersion); vep->name_bt = &vep->vp->name_bt;
printf("time.........: %ld\n", fp->time.tv_sec); vep->oid_bt = &vep->vp->oid_bt;
printf("fileType.....: %d\n", fp->fileType); vep->class_bt = &vep->vp->class_bt;
printf("userName.....: %s\n", fp->userName);
for (i = 0; i < nVolRef; i++) {
sp = (dbs_sSect*)((char *)fp + dbs_dAlign(sizeof(dbs_sFile))); vep = &mep->venv[i + 1];
vp = (dbs_sVolume*)((char *)fp + sp[dbs_eSect_volume].offset);
vep->mp = mep;
printf("vid........: %d\n", vp->vid); vep->index = i + 1;
printf("name.......: %s\n", vp->name); vep->base = base + vrp[i].offset;
printf("cid........: %d\n", vp->cid); vep->sect = (dbs_sSect*)(vep->base + dbs_dAlign(sizeof(dbs_sFile)));
printf("className..: %s\n", vp->className); vep->vp = (dbs_sVolume*)(vep->base + vep->sect[dbs_eSect_volume].offset);
printf("time.......: %ld\n", vp->time.tv_sec); vep->name_bt = &vep->vp->name_bt;
printf("cardinality: %d\n", vp->cardinality); vep->oid_bt = &vep->vp->oid_bt;
printf("rbodysize..: %d\n", vp->rbodySize); vep->class_bt = &vep->vp->class_bt;
vep->size = ((dbs_sFile*)vep->base)->size;
nf.m = vp->name_bt.start;
nl.m = vp->name_bt.end;
cf.m = vp->class_bt.start;
cl.m = vp->class_bt.end;
of.m = vp->oid_bt.start;
ol.m = vp->oid_bt.end;
printf("name_bt....: %d.%d -> %d.%d %d\n", nf.b.sect, nf.b.offs, nl.b.sect, nl.b.offs, vp->name_bt.rsize);
printf("class_bt...: %d.%d -> %d.%d %d\n", cf.b.sect, cf.b.offs, cl.b.sect, cl.b.offs, vp->class_bt.rsize);
printf("oid_bt.....: %d.%d -> %d.%d %d\n", of.b.sect, of.b.offs, ol.b.sect, ol.b.offs, vp->oid_bt.rsize);
sp = (dbs_sSect*)((char *)fp + dbs_dAlign(sizeof(dbs_sFile)));
for (i = 0; i < dbs_eSect_; i++, sp++) {
printf("sect: i:%d, version:%d, type:%d, size:%d, offset:%d\n", i, sp->version,
sp->type, sp->size, sp->offset);
}
sp = (dbs_sSect*)((char *)fp + dbs_dAlign(sizeof(dbs_sFile)));
op = (dbs_sObject*)((char *)fp + sp[dbs_eSect_object].offset);
eop = (dbs_sObject*)((char *)op + sp[dbs_eSect_object].size);
for (; op < eop; op = (dbs_sObject*)((char *)op + dbs_dAlign(sizeof(dbs_sObject)))) {
dbs_uRefBits r, p, s, bf, bl;
r.m = op->rbody.ref;
p.m = op->pref;
s.m = op->sib_ll.self;
bf.m = op->name_bt.start;
bl.m = op->name_bt.end;
printf("O %s, %d.%d, %d r[%d.%d] p[%d.%d] s[%d.%d] bs[%d.%d] be[%d.%d] %d\n",
op->name, op->oid.vid, op->oid.oix, op->rbody.size, r.b.sect, r.b.offs,
p.b.sect, p.b.offs, s.b.sect, s.b.offs, bf.b.sect, bf.b.offs, bl.b.sect, bl.b.offs, op->name_bt.rsize);
} }
oidp = (dbs_sOid*)((char *)fp + sp[dbs_eSect_oid].offset); return mep;
eoidp = (dbs_sOid*)((char *)oidp + sp[dbs_eSect_oid].size); }
for (; oidp < eoidp; oidp = (dbs_sOid*)((char *)oidp + dbs_dAlign(sizeof(dbs_sOid)))) {
dbs_uRefBits s;
dbs_sObject *op, *oop, *aop;
pwr_tStatus sts;
s.m = oidp->ref;
op = dbs_Address(&sts, ep, oidp->ref);
oop = dbs_OidToObject(&sts, ep, op->oid);
aop = dbs_After(&sts, ep, op);
printf("Oid %d.%d, [%d.%d] -> %s %d.%d ", oidp->oid.vid, oidp->oid.oix, s.b.sect, s.b.offs,
op->name, op->oid.vid, op->oid.oix);
if (oop == NULL)
printf(" NULL");
else
printf("(%d.%d)", oop->oid.vid, oop->oid.oix);
if (aop == NULL) dbs_sVenv*
printf(" NULL\n"); dbs_Vmap(pwr_tStatus *sts, int index, dbs_sMenv *mep)
else {
printf(" (%s)\n", aop->name); *sts = DBS__SUCCESS;
}
if (index > mep->nVolRef)
return 0;
return &mep->venv[index];
}
int
dbs_nVolRef(pwr_tStatus *sts, const dbs_sMenv *mep)
{
return mep->nVolRef;
}
static dbs_sVolRef *findVolref(dbs_sMenv *mep, pwr_tVid vid)
{
return NULL;
}
void
dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep)
{
int i;
for (i = 0; i < mep->nVolRef; i++) {
dbs_sVenv *vep;
dbs_sVolRef *vrp;
int n;
int j;
int offset;
size_t bytes;
size_t size;
FILE *fp;
char fileName[256];
char *p;
np = (dbs_sName*)((char *)fp + sp[dbs_eSect_name].offset); vep = &mep->venv[i + 1];
enp = (dbs_sName*)((char *)np + sp[dbs_eSect_name].size);
for (; np < enp; np = (dbs_sName*)((char *)np + dbs_dAlign(sizeof(dbs_sName)))) { vrp = (dbs_sVolRef*)(vep->base + vep->sect[dbs_eSect_volref].offset);
dbs_uRefBits r; n = vep->sect[dbs_eSect_volref].size / sizeof(*vrp);
dbs_sObject *op, *oop, *nop; printf("Write meta file %s, %d volrefs\n", vep->vp->name, n);
pwr_tStatus sts; printf(" size %d, index %d, nSect %d\n", vep->size, vep->index, vep->nSect);
size = offset = vep->size;
r.m = np->ref; sprintf(fileName, "%s.dbs", vep->vp->name);
op = dbs_Address(&sts, ep, np->ref); cdh_ToLower(fileName, fileName);
oop = dbs_OidToObject(&sts, ep, op->oid);
nop = dbs_NameToObject(&sts, ep, op->poid, op->normname); fp = fopen(fileName, "w+b");
if (fp == NULL) {
printf("** Cannot open file: %s\n", fileName);
printf("N %d %s, [%d.%d] -> %s %d.%d ", np->poix, np->normname, r.b.sect, r.b.offs, perror(" Reason");
op->name, op->oid.vid, op->oid.oix); return;
if (oop == NULL) } else {
printf("NULL"); printf("!! Opened file: %s\n", fileName);
else
printf("(%d.%d)", oop->oid.vid, oop->oid.oix);
if (oop == NULL)
printf(" NULL\n");
else
printf(" (%d.%d)\n", nop->oid.vid, nop->oid.oix);
} }
cp = (dbs_sClass*)((char *)fp + sp[dbs_eSect_class].offset);
ecp = (dbs_sClass*)((char *)np + sp[dbs_eSect_class].size); p = vep->base;
for (; cp < ecp; cp = (dbs_sClass*)((char *)cp + dbs_dAlign(sizeof(dbs_sClass)))) {
dbs_sObject *op; while (size > 0) {
pwr_tStatus sts; if (size > 512) {
bytes = 512;
printf("C %d\n", cp->cid); } else {
op = dbs_ClassToObject(&sts, ep, cp->cid); bytes = size;
while (op != NULL) { }
printf(" %d %d.%d %s\n", op->cid, op->oid.vid, op->oid.oix, op->name); size -= bytes;
op = dbs_Next(&sts, ep, op); if (fwrite(p, bytes, 1, fp) < 1)
} return;
p += bytes;
} }
op = dbs_VolumeObject(sts, ep); fclose(fp);
printTree(ep, op, 0);
printTree1(ep, op);
#endif for (j = 0; j < n; j++, vrp++) {
return ep; //vrp->offset = offset;
printf(" %s, size %d, offset %d\n", vrp->name, vrp->size, offset);
offset += vrp->size;
}
}
}
pwr_tBoolean
dbs_Unmap(pwr_tStatus *sts, dbs_sMenv *mep)
{
*sts = DBS__SUCCESS;
if (mep->flags.b.isMapped) {
return TRUE;
} else if (mep->f != NULL) {
printf("ERROR, dbs_Unmap, trying to unmap a non mapped file\n");
}
return TRUE;
} }
static int static int
...@@ -672,129 +609,129 @@ comp_name(void *key, void *record) ...@@ -672,129 +609,129 @@ comp_name(void *key, void *record)
dbs_sObject * dbs_sObject *
dbs_OidToObject(pwr_tStatus *sts, const dbs_sEnv *ep, pwr_tOid oid) dbs_OidToObject(pwr_tStatus *sts, const dbs_sVenv *vep, pwr_tOid oid)
{ {
dbs_sOid *oidp; dbs_sOid *oidp;
dbs_sObject *op; dbs_sObject *op;
oidp = (dbs_sOid *)dbs_Bfind(sts, ep, ep->oid_bt, &oid, comp_oid); oidp = (dbs_sOid *)dbs_Bfind(sts, vep, vep->oid_bt, &oid, comp_oid);
if (oidp == NULL) if (oidp == NULL)
return NULL; return NULL;
op = dbs_Address(sts, ep, oidp->ref); op = dbs_Address(sts, vep, oidp->ref);
return op; return op;
} }
dbs_sObject * dbs_sObject *
dbs_After(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_After(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
dbs_sOid *oidp; dbs_sOid *oidp;
dbs_sQlink *ol; dbs_sQlink *ol;
dbs_sObject *pop; dbs_sObject *pop;
oidp = (dbs_sOid *)dbs_Bfind(sts, ep, ep->oid_bt, &op->poid, comp_oid); oidp = (dbs_sOid *)dbs_Bfind(sts, vep, vep->oid_bt, &op->poid, comp_oid);
if (oidp == NULL) if (oidp == NULL)
return NULL; return NULL;
pop = dbs_Address(sts, ep, oidp->ref); pop = dbs_Address(sts, vep, oidp->ref);
ol = dbs_Qsucc(sts, ep, &op->sib_ll); ol = dbs_Qsucc(sts, vep, &op->sib_ll);
if (ol == &pop->sib_lh) if (ol == &pop->sib_lh)
return NULL; return NULL;
return dbs_Qitem(ol, dbs_sObject, sib_ll); return dbs_Qitem(ol, dbs_sObject, sib_ll);
} }
dbs_sObject * dbs_sObject *
dbs_Before(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_Before(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
dbs_sOid *oidp; dbs_sOid *oidp;
dbs_sQlink *ol; dbs_sQlink *ol;
dbs_sObject *pop; dbs_sObject *pop;
oidp = (dbs_sOid *)dbs_Bfind(sts, ep, ep->oid_bt, &op->poid, comp_oid); oidp = (dbs_sOid *)dbs_Bfind(sts, vep, vep->oid_bt, &op->poid, comp_oid);
if (oidp == NULL) if (oidp == NULL)
return NULL; return NULL;
pop = dbs_Address(sts, ep, oidp->ref); pop = dbs_Address(sts, vep, oidp->ref);
ol = dbs_Qpred(sts, ep, &op->sib_ll); ol = dbs_Qpred(sts, vep, &op->sib_ll);
if (ol == &pop->sib_lh) if (ol == &pop->sib_lh)
return NULL; return NULL;
return dbs_Qitem(ol, dbs_sObject, sib_ll); return dbs_Qitem(ol, dbs_sObject, sib_ll);
} }
dbs_sObject * dbs_sObject *
dbs_Parent(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_Parent(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
return dbs_Address(sts, ep, op->pref); return dbs_Address(sts, vep, op->pref);
} }
dbs_sObject * dbs_sObject *
dbs_First(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_First(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
dbs_sQlink *ol; dbs_sQlink *ol;
if (dbs_QisEmpty(sts, ep, &op->sib_lh)) if (dbs_QisEmpty(sts, vep, &op->sib_lh))
return NULL; return NULL;
ol = dbs_Qsucc(sts, ep, &op->sib_lh); ol = dbs_Qsucc(sts, vep, &op->sib_lh);
return dbs_Qitem(ol, dbs_sObject, sib_ll); return dbs_Qitem(ol, dbs_sObject, sib_ll);
} }
dbs_sObject * dbs_sObject *
dbs_Last(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_Last(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
dbs_sQlink *ol; dbs_sQlink *ol;
if (dbs_QisEmpty(sts, ep, &op->sib_lh)) if (dbs_QisEmpty(sts, vep, &op->sib_lh))
return NULL; return NULL;
ol = dbs_Qpred(sts, ep, &op->sib_lh); ol = dbs_Qpred(sts, vep, &op->sib_lh);
return dbs_Qitem(ol, dbs_sObject, sib_ll); return dbs_Qitem(ol, dbs_sObject, sib_ll);
} }
dbs_sObject * dbs_sObject *
dbs_NameToObject(pwr_tStatus *sts, const dbs_sEnv *ep, pwr_tOid oid, char *name) dbs_NameToObject(pwr_tStatus *sts, const dbs_sVenv *vep, pwr_tOid oid, char *name)
{ {
dbs_sOid *oidp; dbs_sOid *oidp;
dbs_sObject *op; dbs_sObject *op;
dbs_sName n; dbs_sName n;
dbs_sName *np; dbs_sName *np;
oidp = (dbs_sOid *)dbs_Bfind(sts, ep, ep->oid_bt, &oid, comp_oid); oidp = (dbs_sOid *)dbs_Bfind(sts, vep, vep->oid_bt, &oid, comp_oid);
if (oidp == NULL) if (oidp == NULL)
return NULL; return NULL;
op = dbs_Address(sts, ep, oidp->ref); op = dbs_Address(sts, vep, oidp->ref);
if (op == NULL) if (op == NULL)
return NULL; return NULL;
n.poix = oid.oix; n.poix = oid.oix;
strcpy(n.normname, name); strcpy(n.normname, name);
np = (dbs_sName *)dbs_Bfind(sts, ep, ep->name_bt, &n, comp_name); np = (dbs_sName *)dbs_Bfind(sts, vep, vep->name_bt, &n, comp_name);
if (np == NULL) if (np == NULL)
return NULL; return NULL;
op = dbs_Address(sts, ep, np->ref); op = dbs_Address(sts, vep, np->ref);
return op; return op;
} }
static void static void
objectName(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name, int level) objectName(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op, char *name, int level)
{ {
if (op == NULL) if (op == NULL)
return; return;
...@@ -803,7 +740,7 @@ objectName(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name, in ...@@ -803,7 +740,7 @@ objectName(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name, in
strcpy(name, op->name); strcpy(name, op->name);
strcat(name, ":"); strcat(name, ":");
} else { } else {
objectName(sts, ep, dbs_Address(sts, ep, op->pref), name, level+1); objectName(sts, vep, dbs_Address(sts, vep, op->pref), name, level+1);
strcat(name, op->name); strcat(name, op->name);
if (level > 0) if (level > 0)
strcat(name, "-"); strcat(name, "-");
...@@ -811,13 +748,13 @@ objectName(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name, in ...@@ -811,13 +748,13 @@ objectName(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name, in
} }
void void
dbs_ObjectToName(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name) dbs_ObjectToName(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op, char *name)
{ {
objectName(sts, ep, op, name, 0); objectName(sts, vep, op, name, 0);
} }
dbs_sObject * dbs_sObject *
dbs_Child(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name) dbs_Child(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op, char *name)
{ {
dbs_sName n; dbs_sName n;
dbs_sName *np; dbs_sName *np;
...@@ -828,44 +765,44 @@ dbs_Child(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name) ...@@ -828,44 +765,44 @@ dbs_Child(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name)
n.poix = op->oid.oix; n.poix = op->oid.oix;
strcpy(n.normname, name); strcpy(n.normname, name);
np = (dbs_sName *)dbs_Bfind(sts, ep, &op->name_bt, &n, comp_name); np = (dbs_sName *)dbs_Bfind(sts, vep, &op->name_bt, &n, comp_name);
if (np == NULL) if (np == NULL)
return NULL; return NULL;
op = dbs_Address(sts, ep, np->ref); op = dbs_Address(sts, vep, np->ref);
return op; return op;
} }
dbs_sObject * dbs_sObject *
dbs_ClassToObject(pwr_tStatus *sts, const dbs_sEnv *ep, pwr_tCid cid) dbs_ClassToObject(pwr_tStatus *sts, const dbs_sVenv *vep, pwr_tCid cid)
{ {
dbs_sClass *cp; dbs_sClass *cp;
dbs_sQlink *ol; dbs_sQlink *ol;
cp = (dbs_sClass *)dbs_Bfind(sts, ep, ep->class_bt, &cid, comp_cid); cp = (dbs_sClass *)dbs_Bfind(sts, vep, vep->class_bt, &cid, comp_cid);
if (cp == NULL) if (cp == NULL)
return NULL; return NULL;
if (dbs_QisEmpty(sts, ep, &cp->o_lh)) if (dbs_QisEmpty(sts, vep, &cp->o_lh))
return NULL; return NULL;
ol = dbs_Qsucc(sts, ep, &cp->o_lh); ol = dbs_Qsucc(sts, vep, &cp->o_lh);
return dbs_Qitem(ol, dbs_sObject, o_ll); return dbs_Qitem(ol, dbs_sObject, o_ll);
} }
dbs_sObject * dbs_sObject *
dbs_Next(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_Next(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
dbs_sClass *cp; dbs_sClass *cp;
dbs_sQlink *ol; dbs_sQlink *ol;
cp = (dbs_sClass *)dbs_Bfind(sts, ep, ep->class_bt, &op->cid, comp_cid); cp = (dbs_sClass *)dbs_Bfind(sts, vep, vep->class_bt, &op->cid, comp_cid);
if (cp == NULL) if (cp == NULL)
return NULL; return NULL;
ol = dbs_Qsucc(sts, ep, &op->o_ll); ol = dbs_Qsucc(sts, vep, &op->o_ll);
if (ol == &cp->o_lh) if (ol == &cp->o_lh)
return NULL; return NULL;
...@@ -874,16 +811,16 @@ dbs_Next(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) ...@@ -874,16 +811,16 @@ dbs_Next(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op)
} }
dbs_sObject * dbs_sObject *
dbs_Previous(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_Previous(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
dbs_sClass *cp; dbs_sClass *cp;
dbs_sQlink *ol; dbs_sQlink *ol;
cp = (dbs_sClass *)dbs_Bfind(sts, ep, ep->class_bt, &op->cid, comp_cid); cp = (dbs_sClass *)dbs_Bfind(sts, vep, vep->class_bt, &op->cid, comp_cid);
if (cp == NULL) if (cp == NULL)
return NULL; return NULL;
ol = dbs_Qpred(sts, ep, &op->o_ll); ol = dbs_Qpred(sts, vep, &op->o_ll);
if (ol == &cp->o_lh) if (ol == &cp->o_lh)
return NULL; return NULL;
...@@ -892,52 +829,52 @@ dbs_Previous(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) ...@@ -892,52 +829,52 @@ dbs_Previous(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op)
} }
dbs_sObject * dbs_sObject *
dbs_Ancestor(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_Ancestor(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
while (op != NULL) { while (op != NULL) {
if (op->oid.oix == 1) if (op->oid.oix == 1)
return NULL; return NULL;
if (op->poid.oix == 1) if (op->poid.oix == 1)
return op; return op;
op = dbs_Address(sts, ep, op->pref); op = dbs_Address(sts, vep, op->pref);
} }
return op; return op;
} }
void void
dbs_GetVolumeName(pwr_tStatus *sts, dbs_sEnv *ep, char *name) dbs_GetVolumeName(pwr_tStatus *sts, dbs_sVenv *vep, char *name)
{ {
dbs_sVolume *vp = (dbs_sVolume *)(ep->base + ep->sect[dbs_eSect_volume].offset); dbs_sVolume *vp = (dbs_sVolume *)(vep->base + vep->sect[dbs_eSect_volume].offset);
strcpy(name, vp->name); strcpy(name, vp->name);
} }
dbs_sObject * dbs_sObject *
dbs_VolumeObject(pwr_tStatus *sts, const dbs_sEnv *ep) dbs_VolumeObject(pwr_tStatus *sts, const dbs_sVenv *vep)
{ {
return (dbs_sObject *)(ep->base + ep->sect[dbs_eSect_object].offset); return (dbs_sObject *)(vep->base + vep->sect[dbs_eSect_object].offset);
} }
dbs_sObject * dbs_sObject *
dbs_Object(pwr_tStatus *sts, const dbs_sEnv *ep) dbs_Object(pwr_tStatus *sts, const dbs_sVenv *vep)
{ {
dbs_sObject *op = dbs_VolumeObject(sts, ep); dbs_sObject *op = dbs_VolumeObject(sts, vep);
if (op == NULL) if (op == NULL)
return NULL; return NULL;
return dbs_First(sts, ep, op); return dbs_First(sts, vep, op);
} }
void * void *
dbs_Body(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, pwr_eBix bix) dbs_Body(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op, pwr_eBix bix)
{ {
char *p = NULL; char *p = NULL;
switch (bix) { switch (bix) {
case pwr_eBix_rt: case pwr_eBix_rt:
p = dbs_Address(sts, ep, op->rbody.ref); p = dbs_Address(sts, vep, op->rbody.ref);
break; break;
case pwr_eBix_dev: case pwr_eBix_dev:
p = dbs_Address(sts, ep, op->dbody.ref); p = dbs_Address(sts, vep, op->dbody.ref);
break; break;
default: default:
*sts = DBS__NOSUCHBODY; *sts = DBS__NOSUCHBODY;
...@@ -948,12 +885,12 @@ dbs_Body(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, pwr_eBix bix) ...@@ -948,12 +885,12 @@ dbs_Body(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, pwr_eBix bix)
} }
dbs_sObject * dbs_sObject *
dbs_NextHead(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) dbs_NextHead(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op)
{ {
dbs_sObject *eop = (dbs_sObject*)(ep->base + ep->sect[dbs_eSect_object].offset + ep->sect[dbs_eSect_object].size); dbs_sObject *eop = (dbs_sObject*)(vep->base + vep->sect[dbs_eSect_object].offset + vep->sect[dbs_eSect_object].size);
if (op == NULL) if (op == NULL)
op = (dbs_sObject*)(ep->base + ep->sect[dbs_eSect_object].offset); op = (dbs_sObject*)(vep->base + vep->sect[dbs_eSect_object].offset);
else else
op = (dbs_sObject*)((char *)op + dbs_dAlign(sizeof(dbs_sObject))); op = (dbs_sObject*)((char *)op + dbs_dAlign(sizeof(dbs_sObject)));
...@@ -964,12 +901,12 @@ dbs_NextHead(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op) ...@@ -964,12 +901,12 @@ dbs_NextHead(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op)
} }
dbs_sBody * dbs_sBody *
dbs_NextRbody(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBody *bp) dbs_NextRbody(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sBody *bp)
{ {
dbs_sBody *ebp = (dbs_sBody*)(ep->base + ep->sect[dbs_eSect_rbody].offset + ep->sect[dbs_eSect_rbody].size); dbs_sBody *ebp = (dbs_sBody*)(vep->base + vep->sect[dbs_eSect_rbody].offset + vep->sect[dbs_eSect_rbody].size);
if (bp == NULL) if (bp == NULL)
bp = (dbs_sBody*)(ep->base + ep->sect[dbs_eSect_rbody].offset); bp = (dbs_sBody*)(vep->base + vep->sect[dbs_eSect_rbody].offset);
else else
bp = (dbs_sBody*)((char *)bp + dbs_dAlign(sizeof(dbs_sBody)) + dbs_dAlign(bp->size)); bp = (dbs_sBody*)((char *)bp + dbs_dAlign(sizeof(dbs_sBody)) + dbs_dAlign(bp->size));
...@@ -981,12 +918,12 @@ dbs_NextRbody(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBody *bp) ...@@ -981,12 +918,12 @@ dbs_NextRbody(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBody *bp)
dbs_sBody * dbs_sBody *
dbs_NextDbody(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBody *bp) dbs_NextDbody(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sBody *bp)
{ {
dbs_sBody *ebp = (dbs_sBody*)(ep->base + ep->sect[dbs_eSect_dbody].offset + ep->sect[dbs_eSect_dbody].size); dbs_sBody *ebp = (dbs_sBody*)(vep->base + vep->sect[dbs_eSect_dbody].offset + vep->sect[dbs_eSect_dbody].size);
if (bp == NULL) if (bp == NULL)
bp = (dbs_sBody*)(ep->base + ep->sect[dbs_eSect_dbody].offset); bp = (dbs_sBody*)(vep->base + vep->sect[dbs_eSect_dbody].offset);
else else
bp = (dbs_sBody*)((char *)bp + dbs_dAlign(sizeof(dbs_sBody)) + dbs_dAlign(bp->size)); bp = (dbs_sBody*)((char *)bp + dbs_dAlign(sizeof(dbs_sBody)) + dbs_dAlign(bp->size));
......
...@@ -166,6 +166,8 @@ ...@@ -166,6 +166,8 @@
%#define dbs_dAlign(size) (((size) + dbs_cAlignInc) & ~dbs_cAlignInc) %#define dbs_dAlign(size) (((size) + dbs_cAlignInc) & ~dbs_cAlignInc)
%#define dbs_dPadding(size) ((((size) + dbs_cAlignInc) & ~dbs_cAlignInc) - (size)) %#define dbs_dPadding(size) ((((size) + dbs_cAlignInc) & ~dbs_cAlignInc) - (size))
%#define dbs_dMakeRef(sect, offset) (0 | ((sect) << dbs_cOffsBits) | (offset)) %#define dbs_dMakeRef(sect, offset) (0 | ((sect) << dbs_cOffsBits) | (offset))
%#define dbs_cAlignPage 511
%#define dbs_dAlignPage(size) (((size) + dbs_cAlignPage) & ~dbs_cAlignPage)
% %
%typedef union { %typedef union {
% struct { % struct {
...@@ -526,6 +528,7 @@ struct dbs_sScObject { ...@@ -526,6 +528,7 @@ struct dbs_sScObject {
#ifdef PDR_HDR #ifdef PDR_HDR
%#define dbs_cVersionFixup 1 %#define dbs_cVersionFixup 1
% %
%
%typedef union { %typedef union {
% pwr_tBitMask m; % pwr_tBitMask m;
% pwr_32Bits ( % pwr_32Bits (
...@@ -543,7 +546,9 @@ struct dbs_sScObject { ...@@ -543,7 +546,9 @@ struct dbs_sScObject {
%#define dbs_mEnv_ (~dbs_mEnv__) %#define dbs_mEnv_ (~dbs_mEnv__)
%} dbs_mEnv; %} dbs_mEnv;
% %
%typedef struct dbs_sMenv dbs_sMenv;
%typedef struct { %typedef struct {
% //dbs_sFileEnv *fp;
% FILE *f; % FILE *f;
% dbs_sFile file; % dbs_sFile file;
% pwr_tUInt32 nSect; % pwr_tUInt32 nSect;
...@@ -552,13 +557,39 @@ struct dbs_sScObject { ...@@ -552,13 +557,39 @@ struct dbs_sScObject {
% /* the rest is used only if mapped */ % /* the rest is used only if mapped */
% pwr_tUInt32 size; /**< size of mapped file */ % pwr_tUInt32 size; /**< size of mapped file */
% char *base; % char *base;
% dbs_mEnv flags; % //dbs_sVolume *vp;
% //dbs_sBintab *name_bt; /**< search for object with parent and name */
% //dbs_sBintab *oid_bt; /**< search for object with identity */
% //dbs_sBintab *class_bt; /**< search for object with class */
%} dbs_sEnv;
%
%typedef struct {
% dbs_sMenv *mp;
% pwr_tUInt32 index;
% pwr_tUInt32 nSect;
% dbs_sSect *sect;
%
% /* the rest is used only if mapped */
% pwr_tUInt32 size; /**< size of mapped file */
% char *base;
% dbs_sVolume *vp; % dbs_sVolume *vp;
% dbs_sVolRef *vrp;
% dbs_sBintab *name_bt; /**< search for object with parent and name */ % dbs_sBintab *name_bt; /**< search for object with parent and name */
% dbs_sBintab *oid_bt; /**< search for object with identity */ % dbs_sBintab *oid_bt; /**< search for object with identity */
% dbs_sBintab *class_bt; /**< search for object with class */ % dbs_sBintab *class_bt; /**< search for object with class */
%} dbs_sEnv; %} dbs_sVenv;
%
%struct dbs_sMenv {
% FILE *f;
% dbs_sFile file;
% dbs_mEnv flags;
% pwr_tUInt32 nVolRef;
%
% /* the rest is used only if mapped */
% pwr_tUInt32 size; /**< size of mapped file */
% char *base;
% dbs_sVolRef *vrp;
% dbs_sVenv venv[1];
%};
% %
% %
%#define dbs_Qitem(a, b, c) ((b *)((char *)a - offsetof(b, c))) %#define dbs_Qitem(a, b, c) ((b *)((char *)a - offsetof(b, c)))
...@@ -568,56 +599,47 @@ struct dbs_sScObject { ...@@ -568,56 +599,47 @@ struct dbs_sScObject {
%pwr_tBoolean dbs_Close(pwr_tStatus *sts, dbs_sEnv *ep); %pwr_tBoolean dbs_Close(pwr_tStatus *sts, dbs_sEnv *ep);
%dbs_sEnv *dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename); %dbs_sEnv *dbs_Open(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename);
%#if defined(OS_LINUX) || defined(OS_LYNX) %#if defined(OS_LINUX) || defined(OS_LYNX)
%void *dbs_Address(pwr_tStatus*, const dbs_sEnv*, dbs_tRef); %dbs_sVolRef *dbs_VolRef(pwr_tStatus *sts, pwr_tUInt32 index, dbs_sVolRef *vp, const dbs_sEnv *ep);
%void *dbs_Alloc(pwr_tStatus*, const dbs_sEnv*, pwr_tUInt32); %void *dbs_Address(pwr_tStatus*, const dbs_sVenv*, dbs_tRef);
%pwr_tBoolean dbs_AllocLookasideSegment(pwr_tStatus*, const dbs_sEnv*, pwr_tUInt32, pwr_tUInt32);
%void *dbs_AllocNamedSegment(pwr_tStatus*, const dbs_sEnv*, pwr_tUInt32, char*);
%dbs_sEnv *dbs_Create(pwr_tStatus*, dbs_sEnv*, char*, pwr_tUInt32, pwr_tUInt32);
%void dbs_Dump(pwr_tStatus*, const dbs_sEnv*); %void dbs_Dump(pwr_tStatus*, const dbs_sEnv*);
%pwr_tBoolean dbs_Free(pwr_tStatus*, const dbs_sEnv*, void*);
%pwr_tBoolean dbs_FreeReference(pwr_tStatus*, const dbs_sEnv*, dbs_tRef);
%dbs_tRef dbs_InDbs(pwr_tStatus*, const dbs_sEnv*, void*, pwr_tUInt32); %dbs_tRef dbs_InDbs(pwr_tStatus*, const dbs_sEnv*, void*, pwr_tUInt32);
%dbs_tRef dbs_ItemReference(pwr_tStatus*, const dbs_sEnv*, void*); %dbs_tRef dbs_ItemReference(pwr_tStatus*, const dbs_sEnv*, void*);
%dbs_sQlink *dbs_Qalloc(pwr_tStatus*, const dbs_sEnv*); %pwr_tBoolean dbs_QhasOne(pwr_tStatus*, const dbs_sVenv*, dbs_sQlink*);
%pwr_tBoolean dbs_QhasOne(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*);
%dbs_tRef dbs_Qinit(pwr_tStatus*, dbs_sQlink*, dbs_tRef); %dbs_tRef dbs_Qinit(pwr_tStatus*, dbs_sQlink*, dbs_tRef);
%dbs_sQlink *dbs_Qinsert(pwr_tStatus*, dbs_sQlink*, dbs_sQlink*, dbs_sQlink*); %dbs_sQlink *dbs_Qinsert(pwr_tStatus*, dbs_sQlink*, dbs_sQlink*, dbs_sQlink*);
%dbs_sQlink *dbs_QinsertPred(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*, dbs_sQlink*); %pwr_tBoolean dbs_QisEmpty(pwr_tStatus*, const dbs_sVenv*, dbs_sQlink*);
%dbs_sQlink *dbs_QinsertSucc(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*, dbs_sQlink*); %pwr_tBoolean dbs_QisLinked(pwr_tStatus*, const dbs_sVenv*, dbs_sQlink*);
%pwr_tBoolean dbs_QisEmpty(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %pwr_tBoolean dbs_QisNull(pwr_tStatus*, const dbs_sVenv*, dbs_sQlink*);
%pwr_tBoolean dbs_QisLinked(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %dbs_sQlink *dbs_Qpred(pwr_tStatus*, const dbs_sVenv*, dbs_sQlink*);
%pwr_tBoolean dbs_QisNull(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %dbs_sQlink *dbs_Qsucc(pwr_tStatus*, const dbs_sVenv*, dbs_sQlink*);
%dbs_sQlink *dbs_Qmove(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*, dbs_sQlink*); %dbs_tRef dbs_Reference(pwr_tStatus*, const dbs_sVenv*, void*);
%dbs_sQlink *dbs_Qpred(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %
%dbs_sQlink *dbs_Qremove(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %dbs_sMenv *dbs_Map(pwr_tStatus*, const char*);
%dbs_sQlink *dbs_QremovePred(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %dbs_sVenv *dbs_Vmap(pwr_tStatus*, int index, dbs_sMenv *);
%dbs_sQlink *dbs_QremoveSucc(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %void dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep);
%dbs_sQlink *dbs_Qsucc(pwr_tStatus*, const dbs_sEnv*, dbs_sQlink*); %pwr_tBoolean dbs_Unmap(pwr_tStatus *sts, dbs_sMenv *);
%dbs_tRef dbs_RefAlloc(pwr_tStatus*, const dbs_sEnv*, pwr_tUInt32); %int dbs_nVolRef(pwr_tStatus *sts, const dbs_sMenv *mep);
%dbs_tRef dbs_Reference(pwr_tStatus*, const dbs_sEnv*, void*); %
% %dbs_sObject *dbs_OidToObject(pwr_tStatus *sts, const dbs_sVenv *vep, pwr_tOid oid);
%dbs_sEnv *dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename); %dbs_sObject *dbs_NameToObject(pwr_tStatus *sts, const dbs_sVenv *vep, pwr_tOid oid, char *name);
% %dbs_sObject *dbs_Parent(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_OidToObject(pwr_tStatus *sts, const dbs_sEnv *ep, pwr_tOid oid); %dbs_sObject *dbs_After(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_NameToObject(pwr_tStatus *sts, const dbs_sEnv *ep, pwr_tOid oid, char *name); %dbs_sObject *dbs_Before(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_Parent(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %dbs_sObject *dbs_First(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_After(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %dbs_sObject *dbs_Last(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_Before(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %dbs_sObject *dbs_ClassToObject(pwr_tStatus *sts, const dbs_sVenv *vep, pwr_tCid cid);
%dbs_sObject *dbs_First(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %dbs_sObject *dbs_Next(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_Last(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %dbs_sObject *dbs_Previous(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_ClassToObject(pwr_tStatus *sts, const dbs_sEnv *ep, pwr_tCid cid); %dbs_sObject *dbs_Child(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op, char *name);
%dbs_sObject *dbs_Next(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %dbs_sObject *dbs_Ancestor(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%dbs_sObject *dbs_Previous(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %void dbs_GetVolumeName(pwr_tStatus *sts, dbs_sVenv *vep, char *name);
%dbs_sObject *dbs_Child(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name); %dbs_sObject *dbs_VolumeObject(pwr_tStatus *sts, const dbs_sVenv *vep);
%dbs_sObject *dbs_Ancestor(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op); %dbs_sObject *dbs_Object(pwr_tStatus *sts, const dbs_sVenv *vep);
%void dbs_GetVolumeName(pwr_tStatus *sts, dbs_sEnv *ep, char *name); %void dbs_ObjectToName(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op, char *name);
%dbs_sObject *dbs_VolumeObject(pwr_tStatus *sts, const dbs_sEnv *ep); %void *dbs_Body(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op, pwr_eBix bix);
%dbs_sObject *dbs_Object(pwr_tStatus *sts, const dbs_sEnv *ep); %dbs_sObject *dbs_NextHead(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sObject *op);
%void dbs_ObjectToName(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name); %dbs_sBody *dbs_NextRbody(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sBody *bp);
%void *dbs_Body(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, pwr_eBix bix); %dbs_sBody *dbs_NextDbody(pwr_tStatus *sts, const dbs_sVenv *vep, dbs_sBody *bp);
%dbs_sObject *dbs_NextHead(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op);
%dbs_sBody *dbs_NextRbody(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBody *bp);
%dbs_sBody *dbs_NextDbody(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sBody *bp);
%#endif %#endif
% %
%#ifdef __cplusplus %#ifdef __cplusplus
......
...@@ -169,6 +169,8 @@ printname(pwr_tOid poid, pwr_tObjName name, pwr_tOid oid) ...@@ -169,6 +169,8 @@ printname(pwr_tOid poid, pwr_tObjName name, pwr_tOid oid)
sOentry *oep; sOentry *oep;
count_name++; count_name++;
printf("N [%10.10d.%10.10d] %d:%s\n", oid.vid, oid.oix, strlen(name), name);
oep = (sOentry *)tree_Find(&sts, oid_th, &oid); oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
if (EVEN(sts)) { if (EVEN(sts)) {
printf("Name: object not found %d.%d, %s\n", oid.vid, oid.oix, name); printf("Name: object not found %d.%d, %s\n", oid.vid, oid.oix, name);
...@@ -195,6 +197,8 @@ printclass(pwr_tOid oid, pwr_tCid cid) ...@@ -195,6 +197,8 @@ printclass(pwr_tOid oid, pwr_tCid cid)
sOentry *oep; sOentry *oep;
count_class++; count_class++;
printf("C [%10.10d.%10.10d] <%d>\n", oid.vid, oid.oix, cid);
oep = (sOentry *)tree_Find(&sts, oid_th, &oid); oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
if (EVEN(sts)) { if (EVEN(sts)) {
printf("Class: object not found %d.%d, %d\n", oid.vid, oid.oix, cid); printf("Class: object not found %d.%d, %d\n", oid.vid, oid.oix, cid);
...@@ -218,6 +222,9 @@ printohead(pwr_tOid oid, db_sObject *op) ...@@ -218,6 +222,9 @@ printohead(pwr_tOid oid, db_sObject *op)
if (cdh_ObjidIsNotEqual(oid, op->oid)) if (cdh_ObjidIsNotEqual(oid, op->oid))
printf("Ohead: oid not equal %s oid: %d.%d != %d.%d\n", op->name, oid.vid, oid.oix, op->oid.vid, op->oid.oix); printf("Ohead: oid not equal %s oid: %d.%d != %d.%d\n", op->name, oid.vid, oid.oix, op->oid.vid, op->oid.oix);
// printf("O [%10.10d.%10.10d] [%10.10d.%10.10d] P [%10.10d.%10.10d] %d:%s\n B [%10.10d.%10.10d] A [%10.10d.%10.10d] F [%10.10d.%10.10d] L [%10.10d.%10.10d] \n", oid.vid, oid.oix, op->oid.vid, op->oid.oix, op->poid.vid, op->poid.oix, strlen(op->name), op->name, op->boid.vid, op->boid.oix, op->aoid.vid, op->aoid.oix, op->foid.vid, op->foid.oix, op->loid.vid, op->loid.oix);
printf("P [%6.6d] B [%6.6d] O [%6.6d] A [%6.6d] F [%6.6d] L [%6.6d]\n", op->poid.oix, op->boid.oix, op->oid.oix, op->aoid.oix, op->foid.oix, op->loid.oix);
oep = (sOentry *)tree_Insert(&sts, oid_th, &oid); oep = (sOentry *)tree_Insert(&sts, oid_th, &oid);
if (sts == TREE__INSERTED) { if (sts == TREE__INSERTED) {
oep->flags.b.inOhead = 1; oep->flags.b.inOhead = 1;
......
...@@ -18,6 +18,114 @@ ...@@ -18,6 +18,114 @@
#include "co_time.h" #include "co_time.h"
#if 1 #if 1
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main( int argc, char *argv[])
{
struct stat sb;
int ret;
pwr_tStatus sts;
dbs_sMenv *mep;
if (argc < 2)
exit(0);
if ((ret = stat(argv[1], &sb)) != 0) {
perror("stat");
exit(ret);
}
printf("stat %s\n", argv[1]);
printf("st_atime...: %ld\n", sb.st_atime);
printf("st_mtime...: %ld\n", sb.st_mtime);
printf("st_ctime...: %ld\n", sb.st_ctime);
mep = dbs_Map(&sts, argv[1]);
dbs_Split(&sts, mep);
return 0;
}
#elif 0
int main( int argc, char *argv[])
{
int a;
int b;
int i;
int c;
for (i = 0; i < 100; i++) {
if (i % 3 == 0) {
a = rand() % 101;
b = rand() % 101;
printf("[%d] vad blir %d + %d = ", i + 1, a, b);
scanf("%d", &c);
if (c == a + b) {
printf("\nKorrekt!\n");
} else {
printf("Fel\007! Det blir: %d\n", a + b);
}
}
else if (i % 3 == 1) {
int tmp;
a = rand() % 101;
b = rand() % 101;
if (a < b) {
tmp = b;
b = a;
a = tmp;
}
printf("[%d] vad blir %d - %d = ", i + 1, a, b);
scanf("%d", &c);
if (c == a - b) {
printf("\nKorrekt!\n");
} else {
printf("Fel\007! Det blir %d\n", a - b);
}
}
else if (i % 3 == 2) {
a = rand() % 11;
b = rand() % 11;
printf("[%d] vad blir %d * %d = ", i + 1, a, b);
scanf("%d", &c);
if (c == a * b) {
printf("\nKorrekt!\n");
} else {
printf("Fel\007! Det blir %d\n", a * b);
}
}
}
}
#elif 0
int main( int argc, char *argv[])
{
char namn[50];
char bnamn[50];
int len;
printf("Vad heter du? ");
scanf("%s", namn);
len = strlen(namn);
for (int i = 0; i < len; i++) {
bnamn[len - i -1] = namn[i];
}
bnamn[len+1] = '\0';
printf("\nDitt namn baklnges r: %s\n", bnamn);
}
#elif 0
int main( int argc, char *argv[]) int main( int argc, char *argv[])
{ {
pwr_tStatus sts; pwr_tStatus sts;
......
...@@ -976,6 +976,23 @@ pwr_tOid wb_db::new_oid(wb_db_txn *txn) ...@@ -976,6 +976,23 @@ pwr_tOid wb_db::new_oid(wb_db_txn *txn)
return oid; return oid;
} }
pwr_tOid wb_db::new_oid(wb_db_txn *txn, pwr_tOid oid)
{
if (oid.vid == m_vid) {
try {
wb_db_ohead o(this, txn, oid);
} catch (DbException &e) {
cout << e.what() << " old oid not found, keep\n";
return oid;
}
cout << " Old oid found, force new!\n";
} else {
cout << "in an other volume\n";
}
return new_oid(txn);
}
int wb_db::del_family(wb_db_txn *txn, Dbc *cp, pwr_tOid poid) int wb_db::del_family(wb_db_txn *txn, Dbc *cp, pwr_tOid poid)
{ {
int ret = 0; int ret = 0;
...@@ -1133,7 +1150,19 @@ bool wb_db::importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid, ...@@ -1133,7 +1150,19 @@ bool wb_db::importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
o.put(m_txn); o.put(m_txn);
//printf("head put: %d.%d %s\n", oid.vid, oid.oix, name); //printf("head put: %d.%d %s\n", oid.vid, oid.oix, name);
wb_db_name n(this, oid, poid, normname); wb_db_name n(this, oid, poid, normname);
n.put(m_txn); int rc = n.put(m_txn);
if (rc) {
//printf("importHead: n.put: %d, %d.%d %s\n", rc, poid.vid, poid.oix, name);
char newName[50];
sprintf(newName, "O%u_%s", oid.oix, name);
newName[31] = '\0';
wb_name nn(newName);
o.name(nn);
o.put(m_txn);
n.name(nn);
n.put(m_txn);
}
wb_db_class c(this, cid, oid); wb_db_class c(this, cid, oid);
c.put(m_txn); c.put(m_txn);
if (oid.oix == pwr_cNOix) { // This is the volume object if (oid.oix == pwr_cNOix) { // This is the volume object
......
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
char *volumeName() { return m_volumeName;} char *volumeName() { return m_volumeName;}
pwr_tOid new_oid(wb_db_txn *txn); pwr_tOid new_oid(wb_db_txn *txn);
pwr_tOid new_oid(wb_db_txn *txn, pwr_tOid oid);
void close(); void close();
void open(const char *fileName); void open(const char *fileName);
......
...@@ -9,6 +9,9 @@ This module contains functions to create database snapshot files. */ ...@@ -9,6 +9,9 @@ This module contains functions to create database snapshot files. */
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h> #include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "pwr.h" #include "pwr.h"
#include "pwr_class.h" #include "pwr_class.h"
...@@ -17,6 +20,7 @@ This module contains functions to create database snapshot files. */ ...@@ -17,6 +20,7 @@ This module contains functions to create database snapshot files. */
#include "co_tree.h" #include "co_tree.h"
#include "co_pdr.h" #include "co_pdr.h"
#include "co_dbs.h" #include "co_dbs.h"
#include "co_errno.h"
#include "wb_dbs.h" #include "wb_dbs.h"
#include "wb_vrep.h" #include "wb_vrep.h"
#include "wb_mvrep.h" #include "wb_mvrep.h"
...@@ -57,6 +61,9 @@ wb_dbs::wb_dbs(wb_vrep *v) : ...@@ -57,6 +61,9 @@ wb_dbs::wb_dbs(wb_vrep *v) :
m_class_th = tree_CreateTable(&sts, sizeof(pwr_tCid), offsetof(sCentry, c), m_class_th = tree_CreateTable(&sts, sizeof(pwr_tCid), offsetof(sCentry, c),
sizeof(sCentry), 1000, tree_Comp_cid); sizeof(sCentry), 1000, tree_Comp_cid);
m_vol_th = tree_CreateTable(&sts, sizeof(pwr_tVid), offsetof(sVentry, v.vid),
sizeof(sVentry), 10, tree_Comp_vid);
} }
wb_dbs::~wb_dbs() wb_dbs::~wb_dbs()
...@@ -327,10 +334,6 @@ wb_dbs::createFile() ...@@ -327,10 +334,6 @@ wb_dbs::createFile()
sts = openFile(); sts = openFile();
if (EVEN(sts)) goto error_handler; if (EVEN(sts)) goto error_handler;
printf("-- Writing file section...\n");
sts = writeSectFile();
if (EVEN(sts)) goto error_handler;
size = dbs_dAlign(sizeof(dbs_sFile)); size = dbs_dAlign(sizeof(dbs_sFile));
m_sect[dbs_eSect_dir].size = sizeof(m_sect); m_sect[dbs_eSect_dir].size = sizeof(m_sect);
...@@ -347,8 +350,8 @@ wb_dbs::createFile() ...@@ -347,8 +350,8 @@ wb_dbs::createFile()
size += m_sect[dbs_eSect_volume].size; size += m_sect[dbs_eSect_volume].size;
m_sect[dbs_eSect_volref].offset = size; m_sect[dbs_eSect_volref].offset = size;
printf("-- Writing volref section...\n"); printf("-- Preparing volref section...\n");
sts = writeSectVolref(); sts = prepareSectVolref();
if (EVEN(sts)) goto error_handler; if (EVEN(sts)) goto error_handler;
size += m_sect[dbs_eSect_volref].size; size += m_sect[dbs_eSect_volref].size;
...@@ -393,10 +396,24 @@ wb_dbs::createFile() ...@@ -393,10 +396,24 @@ wb_dbs::createFile()
sts = writeSectClass(); sts = writeSectClass();
if (EVEN(sts)) goto error_handler; if (EVEN(sts)) goto error_handler;
size += m_sect[dbs_eSect_class].size;
printf("-- Writing directory section...\n"); printf("-- Writing directory section...\n");
sts = writeSectDirectory(); sts = writeSectDirectory();
if (EVEN(sts)) goto error_handler; if (EVEN(sts)) goto error_handler;
printf("-- Writing file section...\n");
sts = writeSectFile(size);
if (EVEN(sts)) goto error_handler;
printf("-- Writing volref section...\n");
sts = writeSectVolref(size);
if (EVEN(sts)) goto error_handler;
printf("-- Writing volref volumes...\n");
sts = writeReferencedVolumes();
if (EVEN(sts)) goto error_handler;
printf("-- Close file...\n"); printf("-- Close file...\n");
sts = closeFile(0); sts = closeFile(0);
if (EVEN(sts)) goto error_handler; if (EVEN(sts)) goto error_handler;
...@@ -418,6 +435,10 @@ pwr_tStatus ...@@ -418,6 +435,10 @@ pwr_tStatus
wb_dbs::openFile() wb_dbs::openFile()
{ {
char *fn; char *fn;
struct stat sb;
pwr_tStatus sts;
int ret;
cdh_ToLower(m_fileName, m_fileName); cdh_ToLower(m_fileName, m_fileName);
...@@ -431,11 +452,21 @@ wb_dbs::openFile() ...@@ -431,11 +452,21 @@ wb_dbs::openFile()
if (fn != NULL) if (fn != NULL)
printf("-- Opened load file: %s\n", m_fileName); printf("-- Opened load file: %s\n", m_fileName);
if ((ret = stat(m_fileName, &sb)) != 0) {
sts = errno_GetStatus();
perror("stat");
return sts;
}
printf("st_atime...: %ld\n", sb.st_atime);
printf("st_mtime...: %ld\n", sb.st_mtime);
printf("st_ctime...: %ld\n", sb.st_ctime);
return LDH__SUCCESS; return LDH__SUCCESS;
} }
pwr_tStatus pwr_tStatus
wb_dbs::writeSectFile() wb_dbs::writeSectFile(size_t size)
{ {
char f[dbs_dAlign(sizeof(dbs_sFile))]; char f[dbs_dAlign(sizeof(dbs_sFile))];
dbs_sFile *fp = (dbs_sFile*)f; dbs_sFile *fp = (dbs_sFile*)f;
...@@ -443,7 +474,7 @@ wb_dbs::writeSectFile() ...@@ -443,7 +474,7 @@ wb_dbs::writeSectFile()
co_GetOwnFormat(&fp->format); co_GetOwnFormat(&fp->format);
fp->cookie = dbs_cMagicCookie; fp->cookie = dbs_cMagicCookie;
fp->size = 0; fp->size = size;
fp->offset = dbs_dAlign(sizeof(*fp)); fp->offset = dbs_dAlign(sizeof(*fp));
fp->formatVersion = dbs_cVersionFormat; fp->formatVersion = dbs_cVersionFormat;
fp->version = dbs_cVersionFile; fp->version = dbs_cVersionFile;
...@@ -470,6 +501,9 @@ wb_dbs::writeSectFile() ...@@ -470,6 +501,9 @@ wb_dbs::writeSectFile()
if (!pdr_dbs_sFile(&pdrs, fp)) if (!pdr_dbs_sFile(&pdrs, fp))
return LDH__XDR; return LDH__XDR;
if (fseek(m_fp, 0, SEEK_SET) != 0)
return LDH__FILEPOS;
if (fwrite(f, sizeof(f) , 1, m_fp) < 1) return LDH__FILEWRITE; if (fwrite(f, sizeof(f) , 1, m_fp) < 1) return LDH__FILEWRITE;
return LDH__SUCCESS; return LDH__SUCCESS;
...@@ -555,13 +589,14 @@ wb_dbs::writeSectVolume() ...@@ -555,13 +589,14 @@ wb_dbs::writeSectVolume()
pwr_tStatus pwr_tStatus
wb_dbs::writeSectVolref() wb_dbs::prepareSectVolref()
{ {
char v[dbs_dAlign(sizeof(dbs_sVolRef))]; char v[dbs_dAlign(sizeof(dbs_sVolRef))];
dbs_sVolRef *vp = (dbs_sVolRef*)v; dbs_sVolRef *vp = (dbs_sVolRef*)v;
cdh_uTid cid; cdh_uTid cid;
sCentry *cep; sCentry *cep;
pwr_tStatus sts; pwr_tStatus sts;
if (fseek(m_fp, m_sect[dbs_eSect_volref].offset, SEEK_SET) != 0) if (fseek(m_fp, m_sect[dbs_eSect_volref].offset, SEEK_SET) != 0)
return LDH__FILEPOS; return LDH__FILEPOS;
...@@ -580,21 +615,56 @@ wb_dbs::writeSectVolref() ...@@ -580,21 +615,56 @@ wb_dbs::writeSectVolref()
if (vid.pwr != m_volume.vid) { if (vid.pwr != m_volume.vid) {
printf("volref: %d.%d.%d.%d\n", vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0); printf("volref: %d.%d.%d.%d\n", vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0);
vp->vid = vid.pwr;
wb_mvrep *mvrep = m_v->merep()->volume( &sts, vp->vid); wb_mvrep *mvrep = m_v->merep()->volume(&sts, vid.pwr);
if ( EVEN(sts)) throw wb_error_str("Metavolume not found"); if ( EVEN(sts)) throw wb_error_str("Metavolume not found");
strcpy(vp->name, mvrep->name()); sVentry *vep;
vp->cid = 0;
vp->time.tv_sec = 0; vep = (sVentry*)tree_Insert(&sts, m_vol_th, &vid.pwr);
vp->time.tv_nsec = 0; if (sts == TREE__INSERTED) {
vp->size = 0; /* was inserted now */
vp->offset = 0; dbs_Open(&sts, &vep->env, mvrep->fileName());
printf(" sts...: %d\n", sts);
if (fwrite(v, sizeof(v), 1, m_fp) < 1) printf(" cookie: %d\n", vep->env.file.cookie);
return LDH__FILEWRITE; printf(" size..: %d\n", vep->env.file.size);
m_sect[dbs_eSect_volref].size += sizeof(v); printf(" time..: %ld\n", vep->env.file.time.tv_sec);
printf("VolRef File: %s\n", mvrep->fileName());
strcpy(vep->v.name, mvrep->name());
vep->v.cid = mvrep->cid();
vep->v.time = vep->env.file.time;
vep->v.size = vep->env.file.size;
vep->v.offset = 0;
int i = 0;
while ((vp = dbs_VolRef(&sts, i, (dbs_sVolRef *)v, &vep->env)) != NULL) {
sVentry *nvep;
printf(" vid.....: %d\n", vp->vid);
printf(" sts...: %d\n", sts);
printf(" name..: %s\n", vp->name);
printf(" size..: %d\n", vp->size);
printf(" time..: %ld\n", vp->time.tv_sec);
i++;
nvep = (sVentry*)tree_Insert(&sts, m_vol_th, &vp->vid);
if (sts == TREE__INSERTED) {
printf(" Inserted, sts...: %d\n", sts);
strcpy(nvep->v.name, vp->name);
nvep->v.cid = vp->cid;
nvep->v.time = vp->time;
nvep->v.size = vp->size;
nvep->v.offset = 0;
} else {
printf(" Not inserted, sts...: %d\n", sts);
}
}
}
//if (fwrite(v, sizeof(v), 1, m_fp) < 1)
//return LDH__FILEWRITE;
// m_sect[dbs_eSect_volref].size += sizeof(v);
} }
vid.pwr++; vid.pwr++;
cid.pwr = pwr_cNCid; cid.pwr = pwr_cNCid;
...@@ -602,44 +672,128 @@ wb_dbs::writeSectVolref() ...@@ -602,44 +672,128 @@ wb_dbs::writeSectVolref()
cid.c.vid_1 = vid.v.vid_1; cid.c.vid_1 = vid.v.vid_1;
cep = (sCentry*)tree_FindSuccessor(&sts, m_class_th, &cid.pwr); cep = (sCentry*)tree_FindSuccessor(&sts, m_class_th, &cid.pwr);
} }
// Search trhough all found volumes and get their volrefs
int nVolume = 0;
sVentry *vep;
vep = (sVentry*)tree_Minimum(&sts, m_vol_th);
while (vep) {
printf("vid: %d\n", vep->v.vid);
printf(" cookie: %d\n", vep->env.file.cookie);
printf(" name..: %s\n", vep->v.name);
if (vep->env.file.cookie == 0) {
printf(" volume not found: %d\n", vep->v.vid);
} else {
nVolume++;
m_sect[dbs_eSect_volref].size += sizeof(v);
}
vep = (sVentry*)tree_Successor(&sts, m_vol_th, vep);
}
#if 0 printf("Found %d volumes.\n", nVolume);
sts = OpenSect(dbs_eSect_volref);
if (EVEN(sts)) return sts; return LDH__SUCCESS;
for ( }
vtp = (ldhi_sVidEntry *) tree_Minimum(&sts, m_sp->wb->vidtab);
vtp != NULL; pwr_tStatus
vtp = (ldhi_sVidEntry *) tree_Successor(&sts, m_sp->wb->vidtab, vtp) wb_dbs::writeSectVolref(size_t size)
) { {
/* +++++++++ A workaround for Claes Sjfors 1998-03-02 */ pwr_tStatus sts;
/* if this is the pwrs-volume then
we are not depending on any volume */ if (fseek(m_fp, m_sect[dbs_eSect_volref].offset, SEEK_SET) != 0)
return LDH__FILEPOS;
if (m_ohp->db.oid.vid == 1) continue;
// Search trhough all found volumes and get their volrefs
/* if this is a class volume then sVentry *vep;
we depend only on pwrs */ vep = (sVentry*)tree_Minimum(&sts, m_vol_th);
while (vep) {
if (m_ohp->db.cid == pwr_eClass_ClassVolume) { printf("vid.......: %d\n", vep->v.vid);
if (vtp->vhp->ohp->db.oid.vid != 1) continue; printf(" cookie..: %d\n", vep->env.file.cookie);
printf(" name....: %s\n", vep->v.name);
printf(" size....: %d\n", vep->v.size);
printf(" offset..: %d\n", vep->v.offset);
if (vep->env.file.cookie == 0) {
printf(" volume not found: %d\n", vep->v.vid);
} else {
vep->v.offset = dbs_dAlign(size);
size += vep->v.size = dbs_dAlign(vep->v.size);
char v[dbs_dAlign(sizeof(dbs_sVolRef))];
dbs_sVolRef *vp = (dbs_sVolRef*)v;
printf(" size....: %d\n", vep->v.size);
printf(" offset..: %d\n", vep->v.offset);
*vp = vep->v;
if (fwrite(v, sizeof(v), 1, m_fp) < 1)
return LDH__FILEWRITE;
} }
/* --------- End of workaround */
vep = (sVentry*)tree_Successor(&sts, m_vol_th, vep);
}
if (vtp->vhp->ohp->db.cid == pwr_eClass_ClassVolume) { assert(ftell(m_fp) == (long)(m_sect[dbs_eSect_volref].offset + m_sect[dbs_eSect_volref].size));
sts = ldhi_GetObjectBody(m_sp, vtp->vhp->ohp, ldhi_eBid_SysBody, &obp);
if (EVEN(sts)) return sts;
classVolume = (pwr_sClassVolume *) obp->body;
volref.vid = vtp->vhp->ohp->db.oid.vid; printf(" Total file size....: %d\n", size);
volref.cid = pwr_eClass_ClassVolume; return LDH__SUCCESS;
volref.time = classVolume->RtVersion; }
// xdrmem_create(&xdrs, (char *) &VolRef, sizeof(VolRef), XDR_ENCODE); static pwr_tStatus
// if(!xdr_dbs_sVolRef(&xdrs, &VolRef)) return LDH__XDR; copyFile(FILE *sfp, FILE *tfp, size_t size)
{
char buf[512];
size_t bytes;
while (size > 0) {
if (size > sizeof(buf)) {
bytes = sizeof(buf);
} else {
bytes = size;
} }
size -= bytes;
if (fread(buf, bytes, 1, sfp) < 1)
return LDH__FILEWRITE;
if (fwrite(buf, bytes, 1, tfp) < 1)
return LDH__FILEWRITE;
}
return LDH__SUCCESS;
}
pwr_tStatus
wb_dbs::writeReferencedVolumes()
{
pwr_tStatus sts;
// Search trhough all found volumes and get their volrefs
sVentry *vep;
vep = (sVentry*)tree_Minimum(&sts, m_vol_th);
while (vep) {
printf("vid.......: %d\n", vep->v.vid);
printf(" cookie..: %d\n", vep->env.file.cookie);
printf(" name....: %s\n", vep->v.name);
printf(" size....: %d\n", vep->v.size);
printf(" offset..: %d\n", vep->v.offset);
if (vep->env.file.cookie == 0) {
printf(" volume not found: %d\n", vep->v.vid);
} else {
if (fseek(m_fp, vep->v.offset, SEEK_SET) != 0)
return LDH__FILEPOS;
if (fseek(vep->env.f, 0, SEEK_SET) != 0)
return LDH__FILEPOS;
sts = copyFile(vep->env.f, m_fp, vep->env.file.size);
if (EVEN(sts))
return LDH__FILEWRITE;
printf("ftell %ld, offset + size %d, offset %d, size %d\n", ftell(m_fp), vep->v.offset + vep->env.file.size, vep->v.offset, vep->env.file.size);
assert(ftell(m_fp) == (long)(vep->v.offset + vep->env.file.size));
}
vep = (sVentry*)tree_Successor(&sts, m_vol_th, vep);
} }
#endif
return LDH__SUCCESS; return LDH__SUCCESS;
} }
......
...@@ -31,7 +31,8 @@ public: ...@@ -31,7 +31,8 @@ public:
struct sOentry; struct sOentry;
struct sNentry; struct sNentry;
struct sCentry; struct sCentry;
struct sVentry;
struct sOentry { struct sOentry {
tree_sNode node; tree_sNode node;
dbs_sObject o; dbs_sObject o;
...@@ -67,6 +68,12 @@ public: ...@@ -67,6 +68,12 @@ public:
sOentry *o_lt; // Tail of object list sOentry *o_lt; // Tail of object list
}; };
struct sVentry {
tree_sNode node;
dbs_sVolRef v;
dbs_sEnv env;
};
FILE *m_fp; /**< file pointer */ FILE *m_fp; /**< file pointer */
char m_fileName[512]; /**< name of load file */ char m_fileName[512]; /**< name of load file */
// wb_object *m_o; /* Volume object header. */ // wb_object *m_o; /* Volume object header. */
...@@ -90,6 +97,7 @@ public: ...@@ -90,6 +97,7 @@ public:
tree_sTable *m_oid_th; tree_sTable *m_oid_th;
tree_sTable *m_name_th; tree_sTable *m_name_th;
tree_sTable *m_class_th; tree_sTable *m_class_th;
tree_sTable *m_vol_th;
wb_dbs(); wb_dbs();
wb_dbs(wb_vrep *); wb_dbs(wb_vrep *);
...@@ -119,16 +127,18 @@ public: ...@@ -119,16 +127,18 @@ public:
void classInsert(sOentry *oep); void classInsert(sOentry *oep);
pwr_tStatus openFile(); pwr_tStatus openFile();
pwr_tStatus writeSectFile(); pwr_tStatus writeSectFile(size_t size);
pwr_tStatus writeSectDirectory(); pwr_tStatus writeSectDirectory();
pwr_tStatus writeSectVolume(); pwr_tStatus writeSectVolume();
pwr_tStatus writeSectVolref(); pwr_tStatus prepareSectVolref();
pwr_tStatus writeSectVolref(size_t size);
pwr_tStatus writeSectOid(); pwr_tStatus writeSectOid();
pwr_tStatus writeSectObject(); pwr_tStatus writeSectObject();
pwr_tStatus writeSectRbody(); pwr_tStatus writeSectRbody();
pwr_tStatus writeSectName(); pwr_tStatus writeSectName();
pwr_tStatus writeSectClass(); pwr_tStatus writeSectClass();
pwr_tStatus writeSectDbody(); pwr_tStatus writeSectDbody();
pwr_tStatus writeReferencedVolumes();
virtual bool importVolume(wb_export &e); virtual bool importVolume(wb_export &e);
......
...@@ -230,7 +230,7 @@ void wb_erep::addDbs( pwr_tStatus *sts, wb_vrep *vrep) ...@@ -230,7 +230,7 @@ void wb_erep::addDbs( pwr_tStatus *sts, wb_vrep *vrep)
vrep_iterator it = m_vrepdbs.find( vrep->vid()); vrep_iterator it = m_vrepdbs.find( vrep->vid());
if ( it == m_vrepdbs.end()) { if ( it == m_vrepdbs.end()) {
m_vrepdbs[vrep->vid()] = vrep; m_vrepdbs[vrep->vid()] = vrep;
vrep->ref(); vrep->ref();
*sts = LDH__SUCCESS; *sts = LDH__SUCCESS;
} }
else { else {
...@@ -238,8 +238,9 @@ void wb_erep::addDbs( pwr_tStatus *sts, wb_vrep *vrep) ...@@ -238,8 +238,9 @@ void wb_erep::addDbs( pwr_tStatus *sts, wb_vrep *vrep)
return; return;
} }
if ( vrep->cid() == pwr_eClass_ClassVolume) if ( vrep->cid() == pwr_eClass_ClassVolume) {
m_merep->addDbs( sts, (wb_mvrep *)vrep); m_merep->addDbs( sts, (wb_mvrep *)vrep);
}
} }
void wb_erep::addExtern( pwr_tStatus *sts, wb_vrep *vrep) void wb_erep::addExtern( pwr_tStatus *sts, wb_vrep *vrep)
......
...@@ -952,8 +952,10 @@ ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, i ...@@ -952,8 +952,10 @@ ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, i
char name[200]; char name[200];
strcpy( name, o.name()); strcpy( name, o.name());
*size = strlen( name); *size = strlen( name);
if ( *size > maxsize - 1) if ( *size > maxsize - 1) {
return LDH__NAMEBUF; return LDH__NAMEBUF;
}
strcpy( buf, name); strcpy( buf, name);
} }
catch ( wb_error& e) { catch ( wb_error& e) {
...@@ -976,8 +978,9 @@ ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, i ...@@ -976,8 +978,9 @@ ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, i
char name[200]; char name[200];
strcpy( name, o.longName().name( type)); strcpy( name, o.longName().name( type));
*size = strlen( name); *size = strlen( name);
if ( *size > maxsize - 1) if ( *size > maxsize - 1) {
return LDH__NAMEBUF; return LDH__NAMEBUF;
}
strcpy( buf, name); strcpy( buf, name);
} }
catch ( wb_error& e) { catch ( wb_error& e) {
...@@ -996,8 +999,9 @@ ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, i ...@@ -996,8 +999,9 @@ ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, i
wb_name n = wb_name( cdh_ObjidToString( NULL, oid, 1)); wb_name n = wb_name( cdh_ObjidToString( NULL, oid, 1));
strcpy( str, n.name( type)); strcpy( str, n.name( type));
*size = strlen(str); *size = strlen(str);
if ( *size > maxsize - 1) if ( *size > maxsize - 1) {
return LDH__NAMEBUF; return LDH__NAMEBUF;
}
strcpy( buf, str); strcpy( buf, str);
break; break;
} }
......
...@@ -58,19 +58,31 @@ wb_mvrep *wb_merep::volume(pwr_tStatus *sts, const char *name) ...@@ -58,19 +58,31 @@ wb_mvrep *wb_merep::volume(pwr_tStatus *sts, const char *name)
return 0; return 0;
} }
wb_orep *wb_merep::object(pwr_tStatus *sts, pwr_tOid oid)
{
wb_vrep *vrep = volume( sts, oid.vid);
if ( EVEN(*sts)) return 0;
return vrep->object( sts, oid);
}
void wb_merep::addDbs( pwr_tStatus *sts, wb_mvrep *mvrep) void wb_merep::addDbs( pwr_tStatus *sts, wb_mvrep *mvrep)
{ {
printf("wb_merep::addDbs: %d, %s\n", mvrep->vid(), mvrep->name());
mvrep_iterator it = m_mvrepdbs.find( mvrep->vid()); mvrep_iterator it = m_mvrepdbs.find( mvrep->vid());
if ( it == m_mvrepdbs.end()) { if ( it == m_mvrepdbs.end()) {
// Look for vrep in erep list... TODO // Look for vrep in erep list... TODO
m_mvrepdbs[mvrep->vid()] = mvrep; m_mvrepdbs[mvrep->vid()] = mvrep;
mvrep->ref(); mvrep->ref();
cout << "Metavolume " << mvrep->vid() << " inserted\n"; cout << "merep Metavolume " << mvrep->vid() << ": " << mvrep->name() << " inserted\n";
*sts = LDH__SUCCESS; *sts = LDH__SUCCESS;
} }
else else {
printf("wb_merep::addDbs, existed: %d, %s\n", mvrep->vid(), mvrep->name());
*sts = LDH__VOLIDALREXI; *sts = LDH__VOLIDALREXI;
}
} }
void wb_merep::removeDbs(pwr_tStatus *sts, wb_mvrep *mvrep) void wb_merep::removeDbs(pwr_tStatus *sts, wb_mvrep *mvrep)
......
...@@ -28,6 +28,7 @@ public: ...@@ -28,6 +28,7 @@ public:
wb_mvrep *volume(pwr_tStatus *sts, pwr_tVid vid); wb_mvrep *volume(pwr_tStatus *sts, pwr_tVid vid);
wb_mvrep *volume(pwr_tStatus *sts, const char *name); wb_mvrep *volume(pwr_tStatus *sts, const char *name);
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
void addDbs( pwr_tStatus *sts, wb_mvrep *mvrep); void addDbs( pwr_tStatus *sts, wb_mvrep *mvrep);
void removeDbs( pwr_tStatus *sts, wb_mvrep *mvrep); void removeDbs( pwr_tStatus *sts, wb_mvrep *mvrep);
......
...@@ -112,6 +112,8 @@ wb_object wb_volume::object(pwr_tOid oid) const ...@@ -112,6 +112,8 @@ wb_object wb_volume::object(pwr_tOid oid) const
if (oid.vid == m_vrep->vid()) if (oid.vid == m_vrep->vid())
// This volume // This volume
orep = m_vrep->object( &sts, oid); orep = m_vrep->object( &sts, oid);
else if (oid.vid < 65536)
orep = m_vrep->merep()->object(&sts, oid);
else else
// Other volume // Other volume
orep = m_vrep->erep()->object(&sts, oid); orep = m_vrep->erep()->object(&sts, oid);
......
...@@ -140,6 +140,8 @@ public: ...@@ -140,6 +140,8 @@ public:
void removeSrep( wb_srep *srep); void removeSrep( wb_srep *srep);
wb_srep *srep( pwr_tStatus *sts); wb_srep *srep( pwr_tStatus *sts);
wb_srep *nextSrep( pwr_tStatus *sts, wb_srep* srep); wb_srep *nextSrep( pwr_tStatus *sts, wb_srep* srep);
virtual const char *fileName() = 0;
}; };
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include "co_cdh.h" #include "co_cdh.h"
#include "co_tree.h"
#include "wb_db.h" #include "wb_db.h"
#include "wb_vrepdb.h" #include "wb_vrepdb.h"
#include "wb_orepdb.h" #include "wb_orepdb.h"
...@@ -24,7 +25,7 @@ wb_vrep *wb_vrepdb::ref() ...@@ -24,7 +25,7 @@ wb_vrep *wb_vrepdb::ref()
wb_vrepdb::wb_vrepdb(wb_erep *erep, const char *fileName) : wb_vrepdb::wb_vrepdb(wb_erep *erep, const char *fileName) :
m_erep(erep), m_nRef(0), m_ohead() m_erep(erep), m_nRef(0), m_ohead(), m_oid_th(0)
{ {
strcpy(m_fileName, fileName); strcpy(m_fileName, fileName);
...@@ -39,7 +40,7 @@ wb_vrepdb::wb_vrepdb(wb_erep *erep, const char *fileName) : ...@@ -39,7 +40,7 @@ wb_vrepdb::wb_vrepdb(wb_erep *erep, const char *fileName) :
} }
wb_vrepdb::wb_vrepdb(wb_erep *erep, pwr_tVid vid, pwr_tCid cid, const char *volumeName, const char *fileName) : wb_vrepdb::wb_vrepdb(wb_erep *erep, pwr_tVid vid, pwr_tCid cid, const char *volumeName, const char *fileName) :
m_erep(erep), m_nRef(0), m_ohead() m_erep(erep), m_nRef(0), m_ohead(), m_oid_th(0)
{ {
strcpy(m_fileName, fileName); strcpy(m_fileName, fileName);
...@@ -684,8 +685,41 @@ void *wb_vrepdb::readBody(pwr_tStatus *sts, const wb_orep *orp, pwr_eBix bix, vo ...@@ -684,8 +685,41 @@ void *wb_vrepdb::readBody(pwr_tStatus *sts, const wb_orep *orp, pwr_eBix bix, vo
bool wb_vrepdb::writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p) bool wb_vrepdb::writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p)
{ {
*sts = LDH__NYI; try {
return true; int rc = 0;
m_ohead.get(m_db->m_txn, o->oid());
*sts = LDH__SUCCESS;
switch (bix) {
case pwr_eBix_rt:
{
wb_db_rbody rb(m_db, m_ohead.oid());
rc = rb.put(m_db->m_txn, 0, m_ohead.rbSize(), p);
if (rc)
printf("wb_vrepdb::writeBody rb.put rc %d\n", rc);
break;
}
case pwr_eBix_dev:
{
wb_db_dbody db(m_db, m_ohead.oid());
rc = db.put(m_db->m_txn, 0, m_ohead.dbSize(), p);
if (rc)
printf("wb_vrepdb::writeBody db.put rc %d\n", rc);
break;
}
default:
break;
}
return true;
}
catch (DbException &e) {
*sts = LDH__NOSUCHOBJ;
printf("vrepdb: %s\n", e.what());
return false;
}
} }
wb_orep *wb_vrepdb::ancestor(pwr_tStatus *sts, const wb_orep *o) wb_orep *wb_vrepdb::ancestor(pwr_tStatus *sts, const wb_orep *o)
...@@ -1143,3 +1177,195 @@ void wb_vrepdb::delete_wb_orepdb(void *p) ...@@ -1143,3 +1177,195 @@ void wb_vrepdb::delete_wb_orepdb(void *p)
{ {
free(p); free(p);
} }
bool wb_vrepdb::importPasteObject(pwr_tOid doid, ldh_eDest destcode,
bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name, pwr_mClassDef flags,
size_t rbSize, size_t dbSize, void *rbody, void *dbody,
pwr_tOid *roid)
{
pwr_tStatus sts;
static pwr_tTime oTime;
if (cdh_ObjidIsNull(poid) && cdh_ObjidIsNull(boid)) {
if (m_oid_th) {
tree_DeleteTable(&sts, m_oid_th);
}
importTranslationTableClear();
importSetSourceVid(oid.vid);
m_oid_th = tree_CreateTable(&sts, sizeof(pwr_tOid), offsetof(sOentry, o_oid), sizeof(sOentry), 1000, tree_Comp_oid);
m_poep = (sOentry *)tree_Insert(&sts, m_oid_th, &poid);
clock_gettime(CLOCK_REALTIME, &oTime);
memset(&m_destination, 0, sizeof(m_destination));
m_destination.oid = doid;
if (cdh_ObjidIsNotNull(doid)) {
try {
m_ohead.get(m_db->m_txn, doid);
//printf("vrepdb, desination (%d.%d, %s) does exist\n", doid.vid, doid.oix, m_ohead.name());
//printf(" p (%d.%d), b (%d.%d), a (%d.%d), f (%d.%d), l (%d.%d)\n", m_ohead.poid().vid, m_ohead.poid().oix, m_ohead.boid().vid, m_ohead.boid().oix, m_ohead.aoid().vid, m_ohead.aoid().oix, m_ohead.foid().vid, m_ohead.foid().oix, m_ohead.loid().vid, m_ohead.loid().oix);
//return m_ohead.name();
}
catch (DbException &e) {
//*sts = LDH__NOSUCHOBJ;
printf("vrepdb, desination (%d.%d) does not exist: %s\n", doid.vid, doid.oix, e.what());
throw wb_error(LDH__PASTEINCON);
}
}
switch (destcode) {
case ldh_eDest_After:
//printf("After\n");
m_destination.poid = m_ohead.poid();
m_destination.foid = m_ohead.oid();
m_destination.loid = m_ohead.aoid();
break;
case ldh_eDest_IntoFirst:
//printf("Into first\n");
m_destination.poid = m_ohead.oid();
m_destination.loid = m_ohead.foid();
break;
default:
printf("Into other\n");
throw wb_error(LDH__NYI);
}
//printf("dest o (%d.%d), p (%d.%d), f (%d.%d), l (%d.%d)\n", m_destination.oid.vid, m_destination.oid.oix, m_destination.poid.vid, m_destination.poid.oix, m_destination.foid.vid, m_destination.foid.oix, m_destination.loid.vid, m_destination.loid.oix);
m_poep->n_oid = m_destination.poid;
}
//printf("wb_vrepdb::importPasteObject: %s, poid: %d.%d boid: %d.%d\n", name, poid.vid, poid.oix, boid.vid, boid.oix);
sOentry *oep = (sOentry *)tree_Insert(&sts, m_oid_th, &oid);
sOentry *poep = oep->parent = (sOentry *)tree_Insert(&sts, m_oid_th, &poid);
if (cdh_ObjidIsNotNull(boid)) {
oep->before = (sOentry *)tree_Insert(&sts, m_oid_th, &boid);
poep->last = oep->before->after = oep;
} else {
poep->first = poep->last = oep;
}
if (keepoid) {
oep->n_oid = m_db->new_oid(m_db->m_txn, oid);
} else {
oep->n_oid = m_db->new_oid(m_db->m_txn);
}
importTranslationTableInsert(oid.oix, oep->n_oid.oix);
wb_name n(name);
m_db->importHead(oep->n_oid, cid, oep->parent->n_oid, pwr_cNOid, pwr_cNOid, pwr_cNOid, pwr_cNOid,
name, n.normName(), flags, oTime, oTime, oTime, rbSize, dbSize);
if (rbSize > 0) {
m_db->importRbody(oep->n_oid, rbSize, rbody);
}
if (dbSize > 0) {
m_db->importDbody(oep->n_oid, dbSize, dbody);
}
return true;
}
bool wb_vrepdb::importPaste()
{
pwr_tStatus sts;
pwr_tTime oTime;
clock_gettime(CLOCK_REALTIME, &oTime);
sOentry *oep = (sOentry*)tree_Minimum(&sts, m_oid_th);
while (oep) {
if (oep != m_poep) {
m_ohead.get(m_db->m_txn, oep->n_oid);
m_ohead.poid(oep->parent->n_oid);
if (oep->before)
m_ohead.boid(oep->before->n_oid);
if (oep->after)
m_ohead.aoid(oep->after->n_oid);
if (oep->first)
m_ohead.foid(oep->first->n_oid);
if (oep->last)
m_ohead.loid(oep->last->n_oid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
}
oep = (sOentry*)tree_Successor(&sts, m_oid_th, oep);
}
if (cdh_ObjidIsNull(m_destination.foid)) {
m_ohead.get(m_db->m_txn, m_destination.poid);
m_ohead.foid(m_poep->first->n_oid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
if (cdh_ObjidIsNotNull(m_destination.loid)) {
m_ohead.get(m_db->m_txn, m_destination.loid);
m_ohead.boid(m_poep->last->n_oid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
m_ohead.get(m_db->m_txn, m_poep->last->n_oid);
m_ohead.aoid(m_destination.loid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
}
}
if (cdh_ObjidIsNull(m_destination.loid)) {
m_ohead.get(m_db->m_txn, m_destination.poid);
m_ohead.loid(m_poep->last->n_oid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
if (cdh_ObjidIsNotNull(m_destination.foid)) {
m_ohead.get(m_db->m_txn, m_destination.foid);
m_ohead.aoid(m_poep->first->n_oid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
m_ohead.get(m_db->m_txn, m_poep->first->n_oid);
m_ohead.boid(m_destination.foid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
}
}
if (cdh_ObjidIsNotNull(m_destination.foid) && cdh_ObjidIsNotNull(m_destination.loid)) {
m_ohead.get(m_db->m_txn, m_destination.foid);
m_ohead.aoid(m_poep->first->n_oid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
m_ohead.get(m_db->m_txn, m_poep->first->n_oid);
m_ohead.boid(m_destination.foid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
m_ohead.get(m_db->m_txn, m_destination.loid);
m_ohead.boid(m_poep->last->n_oid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
m_ohead.get(m_db->m_txn, m_poep->last->n_oid);
m_ohead.aoid(m_destination.loid);
m_ohead.ohTime(oTime);
m_ohead.put(m_db->m_txn);
}
importUpdateTree(this);
importTranslationTableClear();
tree_DeleteTable(&sts, m_oid_th);
m_oid_th = 0;
return true;
}
...@@ -5,12 +5,50 @@ ...@@ -5,12 +5,50 @@
#include "wb_orepdb.h" #include "wb_orepdb.h"
#include "wb_db.h" #include "wb_db.h"
#include "db_cxx.h" #include "db_cxx.h"
#include "co_tree.h"
class wb_vrepdb : public wb_vrep class wb_vrepdb : public wb_vrep
{ {
private: private:
bool deleteFamilyMember(pwr_tOid oid, wb_db_txn *txn); bool deleteFamilyMember(pwr_tOid oid, wb_db_txn *txn);
typedef union {
struct {
pwr_tBit temporary : 1;
pwr_tBit exist : 1;
} b;
pwr_tBitMask m;
#define mOentry_temporary 1
#define mOentry_exist 2
} mOentry;
typedef struct sOentry
{
tree_sNode node;
pwr_tOid o_oid;
pwr_tOid n_oid;
struct sOentry *parent;
struct sOentry *before;
struct sOentry *after;
struct sOentry *first;
struct sOentry *last;
} sOentry;
sOentry *m_poep;
typedef struct sDestination
{
pwr_tOid oid;
pwr_tOid poid;
pwr_tOid foid;
pwr_tOid loid;
} sDestination;
sDestination m_destination;
protected: protected:
wb_erep *m_erep; wb_erep *m_erep;
wb_merep *m_merep; wb_merep *m_merep;
...@@ -27,6 +65,8 @@ public: ...@@ -27,6 +65,8 @@ public:
wb_vrepdb(wb_erep *erep, const char *fileName); wb_vrepdb(wb_erep *erep, const char *fileName);
wb_vrepdb(wb_erep *erep, pwr_tVid, pwr_tCid, const char *volumeName, const char *fileName); wb_vrepdb(wb_erep *erep, pwr_tVid, pwr_tCid, const char *volumeName, const char *fileName);
tree_sTable *m_oid_th;
virtual void unref(); virtual void unref();
virtual wb_vrep *ref(); virtual wb_vrep *ref();
...@@ -132,17 +172,16 @@ public: ...@@ -132,17 +172,16 @@ public:
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid) { return false;} virtual bool exportTree(wb_treeimport &i, pwr_tOid oid) { return false;}
virtual bool importTree(bool keepref) { return false;} virtual bool importTree(bool keepref) { return false;}
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid, virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name, pwr_mClassDef flags, pwr_tOid boid, const char *name, pwr_mClassDef flags,
size_t rbSize, size_t dbSize, void *rbody, void *dbody) size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;} { return false;}
virtual bool importPaste() { return false;} virtual bool importPaste();
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode, virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode,
bool keepoid, pwr_tOid oid, bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name, pwr_mClassDef flags, pwr_tOid boid, const char *name, pwr_mClassDef flags,
size_t rbSize, size_t dbSize, void *rbody, void *dbody, size_t rbSize, size_t dbSize, void *rbody, void *dbody,
pwr_tOid *roid) pwr_tOid *roid);
{ return false;}
#if 0 #if 0
int del_family(DbTxn *txn, Dbc *cp, pwr_tOid poid); int del_family(DbTxn *txn, Dbc *cp, pwr_tOid poid);
...@@ -153,7 +192,7 @@ public: ...@@ -153,7 +192,7 @@ public:
wb_orepdb *new_wb_orepdb(size_t size); wb_orepdb *new_wb_orepdb(size_t size);
void delete_wb_orepdb(void *p); void delete_wb_orepdb(void *p);
virtual bool accessSupported( ldh_eAccess access) { return true;} virtual bool accessSupported( ldh_eAccess access) { return true;}
virtual const char *fileName() { return m_fileName;}
}; };
#endif #endif
...@@ -19,42 +19,66 @@ wb_vrep *wb_vrepdbs::ref() ...@@ -19,42 +19,66 @@ wb_vrep *wb_vrepdbs::ref()
wb_vrepdbs::wb_vrepdbs(wb_erep *erep, const char *fileName) : m_erep(erep), m_nRef(0), m_duplicate(false) wb_vrepdbs::wb_vrepdbs(wb_erep *erep, const char *fileName) : m_erep(erep), m_nRef(0), m_duplicate(false)
{ {
printf("wb_vrepdbs(erep, fileName):%s\n", fileName);
strcpy(m_fileName, fileName); strcpy(m_fileName, fileName);
m_isDbsenvLoaded = false; m_isDbsenvLoaded = false;
if ( isCommonMeta()) if (false && isCommonMeta())
m_merep = m_erep->merep(); m_merep = m_erep->merep();
else else
m_merep = new wb_merep(m_erep, (wb_mvrep *)this); m_merep = new wb_merep(m_erep, (wb_mvrep *)this);
} }
dbs_sEnv *wb_vrepdbs::dbsenv() wb_vrepdbs::wb_vrepdbs(wb_erep *erep, wb_merep * merep, const char *fileName, dbs_sMenv *mep, dbs_sVenv *vep) : m_erep(erep), m_merep(merep), m_nRef(0), m_dbsmep(mep), m_dbsvep(vep), m_duplicate(false)
{ {
dbs_sEnv *ep; printf("wb_vrepdbs(erep, fileName, mep, vep):%d,%s\n", vep->vp->vid, fileName);
strcpy(m_fileName, fileName);
strcpy(m_name, m_dbsvep->vp->name);
m_vid = m_dbsvep->vp->vid;
m_cid = m_dbsvep->vp->cid;
printf("m_name: %s, m_vid: %d, m_cid: %d\n", m_name, m_vid, m_cid);
m_isDbsenvLoaded = true;
}
dbs_sVenv *wb_vrepdbs::dbsenv()
{
pwr_tStatus sts; pwr_tStatus sts;
if (!m_isDbsenvLoaded) { if (!m_isDbsenvLoaded) {
ep = dbs_Map(&sts, &m_dbsenv, m_fileName); m_dbsmep = dbs_Map(&sts, m_fileName);
if (!ep) { if (!m_dbsmep) {
throw wb_error(sts); throw wb_error(sts);
} }
m_isDbsenvLoaded = true; m_isDbsenvLoaded = true;
strcpy(m_name, m_dbsenv.vp->name);
m_vid = m_dbsenv.vp->vid; m_dbsvep = dbs_Vmap(&sts, 0, m_dbsmep);
m_cid = m_dbsenv.vp->cid;
strcpy(m_name, m_dbsvep->vp->name);
m_vid = m_dbsvep->vp->vid;
m_cid = m_dbsvep->vp->cid;
printf("m_name: %s, m_vid: %d, m_cid: %d\n", m_name, m_vid, m_cid);
for (int i = 0; i < dbs_nVolRef(&sts, m_dbsmep); i++) {
dbs_sVenv *vep = dbs_Vmap(&sts, i + 1, m_dbsmep);
wb_vrepdbs *vp = new wb_vrepdbs(m_erep, m_merep, m_fileName, m_dbsmep, vep);
printf("before addDbs, i:%d, name: %s, vid: %d\n", i, vep->vp->name, vep->vp->vid);
m_merep->addDbs(&sts, (wb_mvrep *)vp);
}
} else { } else {
ep = &m_dbsenv; if (strstr(m_fileName, "x86")) {
//printf("%s::%s\n", m_dbsvep->vp->name, m_fileName);
}
} }
return m_dbsvep;
return ep;
} }
bool wb_vrepdbs::load() bool wb_vrepdbs::load()
{ {
pwr_tStatus sts; pwr_tStatus sts;
bool rsts = ( dbsenv() != 0); bool rsts = (dbsenv() != 0);
if ( isMeta()) if (isMeta())
m_merep->addDbs(&sts, (wb_mvrep *)this); m_merep->addDbs(&sts, (wb_mvrep *)this);
return rsts; return rsts;
...@@ -387,7 +411,7 @@ bool wb_vrepdbs::isLocal(const wb_orep *) ...@@ -387,7 +411,7 @@ bool wb_vrepdbs::isLocal(const wb_orep *)
pwr_tCid wb_vrepdbs::cid() const pwr_tCid wb_vrepdbs::cid() const
{ {
return m_dbsenv.vp->cid;; return m_dbsvep->vp->cid;;
} }
pwr_tVid wb_vrepdbs::vid() const pwr_tVid wb_vrepdbs::vid() const
......
...@@ -18,12 +18,14 @@ public: ...@@ -18,12 +18,14 @@ public:
char m_fileName[200]; char m_fileName[200];
bool m_isDbsenvLoaded; bool m_isDbsenvLoaded;
dbs_sEnv m_dbsenv; dbs_sMenv *m_dbsmep;
dbs_sVenv *m_dbsvep;
bool m_duplicate; bool m_duplicate;
wb_vrepdbs(wb_erep *erep, const char *fileName); wb_vrepdbs(wb_erep *erep, const char *fileName);
wb_vrepdbs(wb_erep *erep, wb_merep * merep, const char *fileName, dbs_sMenv *mep, dbs_sVenv *vep);
dbs_sEnv *dbsenv(); dbs_sVenv *dbsenv();
bool load(); bool load();
void objectName(const wb_orep *o, char *str); void objectName(const wb_orep *o, char *str);
...@@ -123,7 +125,7 @@ public: ...@@ -123,7 +125,7 @@ public:
virtual wb_merep *merep () const; virtual wb_merep *merep () const;
virtual bool createSnapshot (const char *); virtual bool createSnapshot (const char *);
virtual bool isCommonMeta() const { return true;} virtual bool isCommonMeta() const { return false;}
virtual bool isMeta() const { return (cid() == pwr_eClass_ClassVolume);} virtual bool isMeta() const { return (cid() == pwr_eClass_ClassVolume);}
...@@ -151,6 +153,7 @@ public: ...@@ -151,6 +153,7 @@ public:
virtual bool accessSupported( ldh_eAccess access) { return access == ldh_eAccess_ReadOnly; } virtual bool accessSupported( ldh_eAccess access) { return access == ldh_eAccess_ReadOnly; }
virtual bool duplicateDb() const { return m_duplicate;} virtual bool duplicateDb() const { return m_duplicate;}
virtual void setDuplicateDb( bool duplicate) { m_duplicate = duplicate;} virtual void setDuplicateDb( bool duplicate) { m_duplicate = duplicate;}
virtual const char *fileName() { return m_fileName;}
}; };
......
...@@ -321,6 +321,7 @@ public: ...@@ -321,6 +321,7 @@ public:
bool updateObject( wb_orep *o, bool keepref); bool updateObject( wb_orep *o, bool keepref);
bool updateSubClass( wb_adrep *subattr, char *body, bool keepref); bool updateSubClass( wb_adrep *subattr, char *body, bool keepref);
virtual bool accessSupported( ldh_eAccess access) { return true;} virtual bool accessSupported( ldh_eAccess access) { return true;}
virtual const char *fileName() { return "";}
virtual bool importVolume(wb_export &e); virtual bool importVolume(wb_export &e);
virtual bool importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid, virtual bool importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
......
...@@ -202,6 +202,7 @@ public: ...@@ -202,6 +202,7 @@ public:
pwr_tOid *roid) pwr_tOid *roid)
{ return false;} { return false;}
virtual bool accessSupported( ldh_eAccess access) { return access == ldh_eAccess_ReadOnly;} virtual bool accessSupported( ldh_eAccess access) { return access == ldh_eAccess_ReadOnly;}
virtual const char *fileName() { return "";}
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment