From f60214edd96b33abda2095db316a46e8df33d5ea Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Fri, 20 Jan 2006 19:43:27 +0200 Subject: [PATCH] now even fsreaddir works withe libixp2 (actually Rstat message of 9P is pretty braindamaged) --- cmd/wmiibar2.c | 35 ++++++++++++++++------------------- cmd/wmiir2.c | 6 +----- libixp2/ixp.h | 7 +++++++ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cmd/wmiibar2.c b/cmd/wmiibar2.c index cbf46428..74f6a20e 100644 --- a/cmd/wmiibar2.c +++ b/cmd/wmiibar2.c @@ -310,9 +310,9 @@ xopen(IXPServer * s, IXPConn * c) } static unsigned int -mkstat(Stat *stat, char *name, unsigned long long length) +mkstat(Stat *stat, char *name, unsigned long long length, unsigned int mode) { - stat->mode = 0xfff; + stat->mode = 0xfff | mode; /* --rwxrwxrwx */ stat->atime = stat->mtime = time(0); cext_strlcpy(stat->uid, getenv("USER"), sizeof(stat->uid)); cext_strlcpy(stat->gid, getenv("USER"), sizeof(stat->gid)); @@ -332,7 +332,7 @@ xread(IXPServer * s, IXPConn * c) Map *map = fid_to_map(c->aux, s->fcall.fid); unsigned char *p = s->fcall.data; - fprintf(stderr, "%s", "reading\n"); + fprintf(stderr, "reading %lld\n", s->fcall.offset); if(!map) { s->errstr = "invalid fid"; return -1; @@ -341,25 +341,22 @@ xread(IXPServer * s, IXPConn * c) switch (qpath_type(map->qid.path)) { default: case Droot: - s->fcall.count = mkstat(&stat, "display", strlen(align)) + sizeof(unsigned short); - p = ixp_enc_u16(p, ixp_sizeof_stat(&stat)); + s->fcall.count = mkstat(&stat, "display", strlen(align), 0x0); +/* p = ixp_enc_u16(p, ixp_sizeof_stat(&stat));*/ p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, "font", strlen(font)) + sizeof(unsigned short); - p = ixp_enc_u16(p, ixp_sizeof_stat(&stat)); + s->fcall.count += mkstat(&stat, "font", strlen(font), 0x0); p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, "new", 0) + sizeof(unsigned short); - p = ixp_enc_u16(p, ixp_sizeof_stat(&stat)); + s->fcall.count += mkstat(&stat, "new", 0, 0x0); p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, "event", 0) + sizeof(unsigned short); - p = ixp_enc_u16(p, ixp_sizeof_stat(&stat)); + s->fcall.count += mkstat(&stat, "event", 0, 0x0); p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, "default", 0) + sizeof(unsigned short); - p = ixp_enc_u16(p, ixp_sizeof_stat(&stat)); + s->fcall.count += mkstat(&stat, "default", 0, DMDIR); p = ixp_enc_stat(p, &stat); /* todo: add all labels */ s->fcall.id = RREAD; if(s->fcall.offset >= s->fcall.count) s->fcall.count = 0; /* EOF */ + fprintf(stderr, "returning message size=%d\n", s->fcall.count); break; case Ditem: break; @@ -392,7 +389,7 @@ xstat(IXPServer * s, IXPConn * c) } s->fcall.id = RSTAT; - s->fcall.stat.mode = 0xfff; + s->fcall.stat.mode = 0xfff | DMDIR; s->fcall.stat.atime = s->fcall.stat.mtime = time(0); fprintf(stderr, "atime=%ld\n", s->fcall.stat.atime); @@ -405,7 +402,7 @@ xstat(IXPServer * s, IXPConn * c) default: case Droot: s->fcall.stat.name[0] = '/'; - s->fcall.stat.name[1] = '\0'; + s->fcall.stat.name[1] = 0; s->fcall.stat.length = 0; s->fcall.stat.qid = root_qid; fprintf(stderr, "stat: %ld %ld \n", s->fcall.stat.type, s->fcall.stat.dev); @@ -447,11 +444,12 @@ xclunk(IXPServer * s, IXPConn * c) return -1; } if(maps == map) - maps = maps->next; + c->aux = maps = maps->next; else { for(m = maps; m && m->next != map; m = m->next); m->next = map->next; } + fprintf(stderr, "xclunk 0x%x (maps=0x%x)\n", map, c->aux); free(map); s->fcall.id = RCLUNK; return 0; @@ -462,12 +460,11 @@ freeconn(IXPServer * s, IXPConn * c) { Map *m, *maps = c->aux; + fprintf(stderr, "%s", "freecon\n"); while((m = maps)) { - maps = maps->next; + c->aux = maps = maps->next; free(m); } - c->aux = nil; - printf("freecon\n"); } static IXPTFunc funcs[] = { diff --git a/cmd/wmiir2.c b/cmd/wmiir2.c index 3e39a9c4..f2a0ba02 100644 --- a/cmd/wmiir2.c +++ b/cmd/wmiir2.c @@ -94,19 +94,15 @@ 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); p = ixp_dec_stat(p, &stat); - len += size + sizeof(unsigned short); if(stat.qid.type == IXP_QTDIR) fprintf(stdout, "%s/\n", stat.name); else fprintf(stdout, "%s\n", stat.name); stat = zerostat; } - while(len < msize); + while(p - result < msize); } static int diff --git a/libixp2/ixp.h b/libixp2/ixp.h index 643d0348..40aa499b 100644 --- a/libixp2/ixp.h +++ b/libixp2/ixp.h @@ -100,6 +100,13 @@ enum { RWSTAT, }; +#define DMDIR 0x80000000 /* mode bit for directories */ +#define DMAPPEND 0x40000000 /* mode bit for append only files */ +#define DMEXCL 0x20000000 /* mode bit for exclusive use files */ +#define DMMOUNT 0x10000000 /* mode bit for mounted channel */ +#define DMAUTH 0x08000000 /* mode bit for authentication file */ +#define DMTMP 0x04000000 /* mode bit for non-backed-up file */ + /* modes */ enum { IXP_OREAD = 0x00,