further debugging of stat stuff

This commit is contained in:
garbeam 2006-01-05 20:22:01 +02:00
parent c31ed881a0
commit 58dd7803c2
5 changed files with 69 additions and 25 deletions

View File

@ -217,7 +217,7 @@ make_qid(Qid * dir, char *wname, Qid * new)
}
static int
attach(IXPServer * s, IXPConn * c)
xattach(IXPServer * s, IXPConn * c)
{
Map *maps = c->aux;
Map *m, *new = cext_emallocz(sizeof(Map));
@ -238,7 +238,7 @@ attach(IXPServer * s, IXPConn * c)
}
static int
walk(IXPServer * s, IXPConn * c)
xwalk(IXPServer * s, IXPConn * c)
{
unsigned short nwqid = 0;
Qid qid;
@ -295,7 +295,7 @@ walk(IXPServer * s, IXPConn * c)
}
static int
_open(IXPServer * s, IXPConn * c)
xopen(IXPServer * s, IXPConn * c)
{
Map *map = fid_to_map(c->aux, s->fcall.fid);
@ -316,7 +316,7 @@ _open(IXPServer * s, IXPConn * c)
}
static int
_read(IXPServer * s, IXPConn * c)
xread(IXPServer * s, IXPConn * c)
{
Map *map = fid_to_map(c->aux, s->fcall.fid);
Stat stat = { 0 };
@ -342,20 +342,17 @@ _read(IXPServer * s, IXPConn * c)
cext_strlcpy(stat.name, "display", sizeof(stat.name));
stat.length = strlen(align);
make_qid(&root_qid, "display", &stat.qid);
stat.size = ixp_sizeof_stat(&stat);
s->fcall.count = stat.size;
s->fcall.count += ixp_sizeof_stat(&stat) + sizeof(unsigned short);
p = ixp_enc_stat(p, &stat);
cext_strlcpy(stat.name, "font", sizeof(stat.name));
stat.length = strlen(font);
make_qid(&root_qid, "font", &stat.qid);
stat.size = ixp_sizeof_stat(&stat);;
s->fcall.count += stat.size;
s->fcall.count += ixp_sizeof_stat(&stat) + sizeof(unsigned short);
p = ixp_enc_stat(p, &stat);
cext_strlcpy(stat.name, "new", sizeof(stat.name));
stat.length = 0;
make_qid(&root_qid, "new", &stat.qid);
stat.size = ixp_sizeof_stat(&stat);;
s->fcall.count += stat.size;
s->fcall.count += ixp_sizeof_stat(&stat) + sizeof(unsigned short);
p = ixp_enc_stat(p, &stat);
s->fcall.id = RREAD;
if(s->fcall.offset >= s->fcall.count)
@ -381,13 +378,58 @@ _read(IXPServer * s, IXPConn * c)
}
static int
_write(IXPServer * s, IXPConn * c)
xstat(IXPServer * s, IXPConn * c)
{
Map *map = fid_to_map(c->aux, s->fcall.fid);
fprintf(stderr, "%s", "stating\n");
if(!map) {
s->errstr = "invalid fid";
return -1;
}
s->fcall.id = RSTAT;
s->fcall.stat.mode = 0xff;
s->fcall.stat.atime = s->fcall.stat.mtime = time(0);
cext_strlcpy(s->fcall.stat.uid, getenv("USER"), sizeof(s->fcall.stat.uid));
cext_strlcpy(s->fcall.stat.gid, getenv("USER"), sizeof(s->fcall.stat.gid));
cext_strlcpy(s->fcall.stat.muid, getenv("USER"), sizeof(s->fcall.stat.muid));
fprintf(stderr, "%d\n", qpath_item(map->qid.path));
switch (qpath_type(map->qid.path)) {
default:
case Droot:
s->fcall.stat.name[0] = '/';
s->fcall.stat.name[1] = 0;
s->fcall.stat.length = 0;
s->fcall.stat.qid = root_qid;
break;
case Ditem:
break;
case Fdisplay:
break;
case Fnew:
break;
case Fdata:
break;
case Fevent:
break;
case Fcolor:
break;
case Ffont:
break;
}
return 0;
}
static int
xwrite(IXPServer * s, IXPConn * c)
{
return -1;
}
static int
clunk(IXPServer * s, IXPConn * c)
xclunk(IXPServer * s, IXPConn * c)
{
Map *maps = c->aux;
Map *m, *map = fid_to_map(maps, s->fcall.fid);
@ -422,12 +464,13 @@ freeconn(IXPServer * s, IXPConn * c)
static IXPTFunc funcs[] = {
{TVERSION, ixp_server_tversion},
{TATTACH, attach},
{TWALK, walk},
{TOPEN, _open},
{TREAD, _read},
{TWRITE, _write},
{TCLUNK, clunk},
{TATTACH, xattach},
{TWALK, xwalk},
{TOPEN, xopen},
{TREAD, xread},
{TWRITE, xwrite},
{TCLUNK, xclunk},
{TSTAT, xstat},
{0, 0}
};

View File

@ -95,9 +95,11 @@ print_dir(void *result, unsigned int msize)
void *p = result;
static Stat stat, zerostat = { 0 };
unsigned int len = 0;
unsigned short size;
do {
p = ixp_dec_u16(p, &size);
len += size + sizeof(unsigned short);
p = ixp_dec_stat(p, &stat);
len += stat.size + sizeof(unsigned short);
if(stat.qid.type == IXP_QTDIR)
fprintf(stdout, "%s/\n", stat.name);
else

View File

@ -164,7 +164,7 @@ ixp_dec_qid(unsigned char *msg, Qid * qid)
void *
ixp_enc_stat(unsigned char *msg, Stat * stat)
{
msg = ixp_enc_u16(msg, stat->size);
msg = ixp_enc_u16(msg, ixp_sizeof_stat(stat));
msg = ixp_enc_u16(msg, stat->type);
msg = ixp_enc_u32(msg, stat->dev);
msg = ixp_enc_qid(msg, &stat->qid);
@ -182,7 +182,7 @@ void *
ixp_dec_stat(unsigned char *msg, Stat * stat)
{
unsigned short len;
msg = ixp_dec_u16(msg, &stat->size);
msg += sizeof(unsigned short);
msg = ixp_dec_u16(msg, &stat->type);
msg = ixp_dec_u32(msg, &stat->dev);
msg = ixp_dec_qid(msg, &stat->qid);

View File

@ -137,7 +137,6 @@ typedef struct {
/* stat structure */
typedef struct {
unsigned short size;
unsigned short type;
unsigned int dev;
Qid qid;

View File

@ -21,7 +21,7 @@ unsigned short
ixp_sizeof_stat(Stat * stat)
{
return IXP_QIDSZ
+ 2 * sizeof(unsigned short)
+ sizeof(unsigned short)
+ 4 * sizeof(unsigned int)
+ sizeof(unsigned long long)
+ sizeof_string(stat->name)
@ -101,10 +101,10 @@ ixp_fcall_to_msg(Fcall * fcall, void *msg, unsigned int msglen)
fcall->count;
break;
case RSTAT:
msize += ixp_sizeof_stat(&fcall->stat);
msize += sizeof(unsigned short) + ixp_sizeof_stat(&fcall->stat);
break;
case TWSTAT:
msize += sizeof(unsigned int) + ixp_sizeof_stat(&fcall->stat);
msize += sizeof(unsigned int) + sizeof(unsigned short) + ixp_sizeof_stat(&fcall->stat);
break;
default:
break;