wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 58dd7803c29d920df0dfcfce71da8ed1bdc56289
parent c31ed881a0b788d7a74e30260607f4194f98104a
Author: garbeam <garbeam@localhost>
Date:   Thu,  5 Jan 2006 20:22:01 +0200

further debugging of stat stuff


Diffstat:
cmd/wmiibar2.c | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
cmd/wmiir2.c | 4+++-
libixp2/convert.c | 4++--
libixp2/ixp.h | 1-
libixp2/message.c | 6+++---
5 files changed, 69 insertions(+), 25 deletions(-)

diff --git a/cmd/wmiibar2.c b/cmd/wmiibar2.c @@ -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} }; diff --git a/cmd/wmiir2.c b/cmd/wmiir2.c @@ -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 diff --git a/libixp2/convert.c b/libixp2/convert.c @@ -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); diff --git a/libixp2/ixp.h b/libixp2/ixp.h @@ -137,7 +137,6 @@ typedef struct { /* stat structure */ typedef struct { - unsigned short size; unsigned short type; unsigned int dev; Qid qid; diff --git a/libixp2/message.c b/libixp2/message.c @@ -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;