Commit 1b55cb29 authored by lw's avatar lw

*** empty log message ***

parent 66397390
......@@ -358,10 +358,11 @@ dbs_sEnv *
dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
{
struct stat sb;
int ret, i;
int ret;
int fd;
//char *buf;
//int c;
#if DBS_DEBUG
int i;
dbs_sFile *fp;
dbs_sSect *sp;
dbs_sVolume *vp;
......@@ -370,17 +371,18 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
dbs_sOid *oidp, *eoidp;
dbs_uRefBits nf, nl, cf, cl, of, ol;
dbs_sClass *cp, *ecp;
#endif
*sts = DBS__SUCCESS;
if ((ret = stat(filename, &sb)) != 0) {
*sts = errno_GetStatus();
perror("stat");
return NULL;
}
*sts = DBS__SUCCESS;
memset(ep, 0, sizeof(*ep));
*sts = errno_GetStatus();
#if DBS_DEBUG
printf("st_dev....: %d\t\t%s\n", (int)sb.st_dev, "device");
printf("st_ino....: %d\t%s\n", sb.st_ino, "inode");
printf("st_mode...: %d\t%s\n", sb.st_mode, "protection");
......@@ -395,21 +397,36 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
printf("st_mtime..: %d\t%s\n", sb.st_mtime, "time of last modification");
printf("st_ctime..: %d\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);
#if DBS_DEBUG
printf("open fd: %d\n", fd);
#endif
errno = 0;
memset(ep, 0, sizeof(*ep));
ep->base = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
perror("mmap");
printf("mmap buf: %d\n", ret);
if (ep->base == NULL) {
*sts = errno_GetStatus();
perror("mmap");
ret = close(fd);
return NULL;
}
ret = close(fd);
printf("close ret: %d\n", ret);
ep->flags.b.isMapped = 1;
ep->sect = (dbs_sSect*)(ep->base + dbs_dAlign(sizeof(dbs_sFile)));
ep->vp = (dbs_sVolume*)(ep->base + ep->sect[dbs_eSect_volume].offset);
ep->vrp = (dbs_sVolRef*)(ep->base + ep->sect[dbs_eSect_volref].offset);
ep->name_bt = (dbs_sBintab*)(ep->base + ep->sect[dbs_eSect_name].offset);
ep->oid_bt = (dbs_sBintab*)(ep->base + ep->sect[dbs_eSect_oid].offset);
ep->class_bt = (dbs_sBintab*)(ep->base + ep->sect[dbs_eSect_class].offset);
#if DBS_DEBUG
fp = (dbs_sFile*)ep->base;
printf("format.......: %d\n", fp->format.m);
......@@ -446,13 +463,6 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
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);
ep->sect = (dbs_sSect*)(ep->base + dbs_dAlign(sizeof(dbs_sFile)));
ep->vp = (dbs_sVolume*)(ep->base + ep->sect[dbs_eSect_volume].offset);
ep->vrp = (dbs_sVolRef*)(ep->base + ep->sect[dbs_eSect_volref].offset);
ep->name_bt = (dbs_sBintab*)(ep->base + ep->sect[dbs_eSect_name].offset);
ep->oid_bt = (dbs_sBintab*)(ep->base + ep->sect[dbs_eSect_oid].offset);
ep->class_bt = (dbs_sBintab*)(ep->base + ep->sect[dbs_eSect_class].offset);
sp = (dbs_sSect*)((char *)fp + dbs_dAlign(sizeof(dbs_sFile)));
for (i = 0; i < dbs_eSect_; i++, sp++) {
......@@ -542,7 +552,7 @@ dbs_Map(pwr_tStatus *sts, dbs_sEnv *ep, const char *filename)
op = dbs_Next(&sts, ep, op);
}
}
#endif
return ep;
}
......@@ -834,3 +844,9 @@ dbs_GetVolumeName(pwr_tStatus *sts, dbs_sEnv *ep, char *name)
strcpy(name, vp->name);
}
dbs_sObject *
dbs_VolumeObject(pwr_tStatus *sts, const dbs_sEnv *ep)
{
return (dbs_sObject *)(ep->base + ep->sect[dbs_eSect_object].offset);
}
......@@ -575,6 +575,7 @@ struct dbs_sName {
%dbs_sObject *dbs_Child(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op, char *name);
%dbs_sObject *dbs_Ancestor(pwr_tStatus *sts, const dbs_sEnv *ep, dbs_sObject *op);
%void dbs_GetVolumeName(pwr_tStatus *sts, dbs_sEnv *ep, char *name);
%dbs_sObject *dbs_VolumeObject(pwr_tStatus *sts, const dbs_sEnv *ep);
%
%
%#ifdef __cplusplus
......
......@@ -35,7 +35,7 @@ public:
virtual wb_orep *object(pwr_tStatus *sts) = 0;
virtual wb_orep *object(pwr_tStatus *sts, pwr_tOid oid) = 0;
virtual wb_orep *object(pwr_tStatus *sts, char *name) = 0;
virtual wb_orep *object(pwr_tStatus *sts, wb_name name) = 0;
virtual wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name) = 0;
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination d, wb_name name) = 0;
......@@ -73,7 +73,7 @@ public:
virtual wb_orep *first(pwr_tStatus *sts, wb_orep *o) = 0;
virtual wb_orep *child(pwr_tStatus *sts, wb_orep *o, char *name) = 0;
virtual wb_orep *child(pwr_tStatus *sts, wb_orep *o, wb_name name) = 0;
virtual wb_orep *last(pwr_tStatus *sts, wb_orep *o) = 0;
......
......@@ -66,9 +66,22 @@ wb_vrepdbs::object(pwr_tStatus *sts, pwr_tOid oid)
}
wb_orep *
wb_vrepdbs::object(pwr_tStatus *sts, char *name)
wb_vrepdbs::object(pwr_tStatus *sts, wb_name name)
{
return 0;
*sts = LDH__SUCCESS;
dbs_sObject *op = dbs_VolumeObject(sts, dbsenv());
for (int i = 0; op && name.hasSegment(i); i++) {
op = dbs_Child(sts, dbsenv(), op, name.normSegment(i));
}
if (op == 0) {
*sts = LDH__NOSUCHOBJ;
return 0;
}
return new (this) wb_orepdbs(op);
}
wb_orep *
......@@ -257,11 +270,11 @@ wb_vrepdbs::first(pwr_tStatus *sts, wb_orep *o)
wb_orep *
wb_vrepdbs::child(pwr_tStatus *sts, wb_orep *o, char *name)
wb_vrepdbs::child(pwr_tStatus *sts, wb_orep *o, wb_name name)
{
*sts = LDH__SUCCESS;
dbs_sObject *op = dbs_Child(sts, dbsenv(), ((wb_orepdbs *)o)->o(), name);
dbs_sObject *op = dbs_Child(sts, dbsenv(), ((wb_orepdbs *)o)->o(), name.normObject());
if (op == 0)
return 0;
......
......@@ -37,7 +37,7 @@ public:
virtual wb_erep *erep() const;
virtual wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
virtual wb_orep *object(pwr_tStatus *sts, char *name);
virtual wb_orep *object(pwr_tStatus *sts, wb_name name);
virtual wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name);
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination d, wb_name name);
......@@ -75,7 +75,7 @@ public:
virtual wb_orep *first(pwr_tStatus *sts, wb_orep *o);
virtual wb_orep *child(pwr_tStatus *sts, wb_orep *o, char *name);
virtual wb_orep *child(pwr_tStatus *sts, wb_orep *o, wb_name name);
virtual wb_orep *last(pwr_tStatus *sts, wb_orep *o);
......
......@@ -1007,7 +1007,7 @@ wb_orep *wb_vrepwbl::first(pwr_tStatus *sts, wb_orep *o)
return orep;
}
wb_orep *wb_vrepwbl::child(pwr_tStatus *sts, wb_orep *o, char *name)
wb_orep *wb_vrepwbl::child(pwr_tStatus *sts, wb_orep *o, wb_name name)
{
return 0;
}
......
......@@ -118,7 +118,7 @@ public:
wb_orep *object(pwr_tStatus *sts);
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
wb_orep *object(pwr_tStatus *sts, char *name);
wb_orep *object(pwr_tStatus *sts, wb_name name);
wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name)
{return 0;};
......@@ -161,7 +161,7 @@ public:
wb_orep *first(pwr_tStatus *sts, wb_orep *o);
wb_orep *child(pwr_tStatus *sts, wb_orep *o, char *name);
wb_orep *child(pwr_tStatus *sts, wb_orep *o, wb_name name);
wb_orep *last(pwr_tStatus *sts, wb_orep *o);
......
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