[hackers] [libixp] Add wstat support. || sqweek

From: <hg_AT_suckless.org>
Date: Sun, 21 Sep 2008 03:40:55 +0000 (UTC)

changeset: 105:4d802c927f36
user: sqweek <sqweek_AT_gmail.com>
date: Sat Sep 20 22:51:02 2008 +0800
files: include/ixp.h libixp/message.c libixp/request.c
description:
Add wstat support.

diff -r e2cdba30ec8a -r 4d802c927f36 include/ixp.h
--- a/include/ixp.h Sat Sep 20 21:59:34 2008 +0800
+++ b/include/ixp.h Sat Sep 20 22:51:02 2008 +0800
@@ -7,7 +7,7 @@
 #include <sys/types.h>
 #include <sys/select.h>
 
-#define IXP_API 97
+#define IXP_API 105
 
 /* Gunk */
 #if defined(IXP_NEEDAPI) && IXP_API < IXP_NEEDAPI
@@ -271,6 +271,21 @@
         uchar dir_type;
 };
 
+/* stat structure */
+struct IxpStat {
+ ushort type;
+ ulong dev;
+ IxpQid qid;
+ ulong mode;
+ ulong atime;
+ ulong mtime;
+ uvlong length;
+ char* name;
+ char* uid;
+ char* gid;
+ char* muid;
+};
+
 typedef struct IxpFHdr IxpFHdr;
 typedef struct IxpFError IxpFError;
 typedef struct IxpFROpen IxpFRAttach;
@@ -290,7 +305,7 @@
 typedef struct IxpFVersion IxpFTVersion;
 typedef struct IxpFTWalk IxpFTWalk;
 typedef struct IxpFIO IxpFTWrite;
-typedef struct IxpFRStat IxpFTWstat;
+typedef struct IxpFTWStat IxpFTWStat;
 typedef struct IxpFAttach IxpFAttach;
 typedef struct IxpFIO IxpFIO;
 typedef struct IxpFVersion IxpFVersion;
@@ -356,6 +371,10 @@
         ushort nstat;
         uchar* stat;
 };
+struct IxpFTWStat {
+ IxpFHdr hdr;
+ IxpStat stat;
+};
 #if defined(IXP_NEEDAPI) && IXP_NEEDAPI <= 89
 /* from fcall(3) in plan9port */
 typedef struct IxpFcall IxpFcall;
@@ -406,9 +425,12 @@
                         ulong count; /* Tread, Twrite, Rread */
                         char *data; /* Twrite, Rread */
                 )
- STRUCT ( /* Twstat, Rstat */
+ STRUCT ( /* Rstat */
                         ushort nstat;
                         uchar *stat;
+ )
+ STRUCT ( /* Twstat */
+ IxpStat st;
                 )
         )
 };
@@ -431,7 +453,7 @@
         IxpFTCreate topen;
         IxpFTWalk twalk;
         IxpFRWalk rwalk;
- IxpFRStat twstat;
+ IxpFTWStat twstat;
         IxpFRStat rstat;
         IxpFIO twrite;
         IxpFIO rwrite;
@@ -440,21 +462,6 @@
         IxpFIO io;
 };
 #endif
-
-/* stat structure */
-struct IxpStat {
- ushort type;
- ulong dev;
- IxpQid qid;
- ulong mode;
- ulong atime;
- ulong mtime;
- uvlong length;
- char* name;
- char* uid;
- char* gid;
- char* muid;
-};
 
 struct IxpConn {
         IxpServer* srv;
@@ -564,6 +571,7 @@
         void (*stat)(Ixp9Req *r);
         void (*walk)(Ixp9Req *r);
         void (*write)(Ixp9Req *r);
+ void (*wstat)(Ixp9Req *r);
         void (*freefid)(IxpFid *f);
 };
 
diff -r e2cdba30ec8a -r 4d802c927f36 libixp/message.c
--- a/libixp/message.c Sat Sep 20 21:59:34 2008 +0800
+++ b/libixp/message.c Sat Sep 20 22:51:02 2008 +0800
@@ -159,11 +159,13 @@
                 ixp_pu16(msg, &fcall->rstat.nstat);
                 ixp_pdata(msg, (char**)&fcall->rstat.stat, fcall->rstat.nstat);
                 break;
- case TWStat:
+ case TWStat: {
+ ushort size;
                 ixp_pu32(msg, &fcall->hdr.fid);
- ixp_pu16(msg, &fcall->twstat.nstat);
- ixp_pdata(msg, (char**)&fcall->twstat.stat, fcall->twstat.nstat);
+ ixp_pu16(msg, &size);
+ ixp_pstat(msg, &fcall->twstat.stat);
                 break;
+ }
         }
 }
 
diff -r e2cdba30ec8a -r 4d802c927f36 libixp/request.c
--- a/libixp/request.c Sat Sep 20 21:59:34 2008 +0800
+++ b/libixp/request.c Sat Sep 20 22:51:02 2008 +0800
@@ -310,7 +310,34 @@
                 }
                 pc->srv->write(r);
                 break;
- /* Still to be implemented: wstat, auth */
+ case TWStat:
+ if(!(r->fid = lookupkey(&pc->fidmap, r->ifcall.hdr.fid))) {
+ respond(r, Enofid);
+ return;
+ }
+ if((ushort)~r->ifcall.twstat.stat.type) {
+ respond(r, "wstat of type");
+ return;
+ }
+ if((uint)~r->ifcall.twstat.stat.dev) {
+ respond(r, "wstat of dev");
+ return;
+ }
+ if((uchar)~r->ifcall.twstat.stat.qid.type || (ulong)~r->ifcall.twstat.stat.qid.version || (uvlong)~r->ifcall.twstat.stat.qid.path) {
+ respond(r, "wstat of qid");
+ return;
+ }
+ if(r->ifcall.twstat.stat.muid && r->ifcall.twstat.stat.muid[0]) {
+ respond(r, "wstat of muid");
+ return;
+ }
+ if((ulong)~r->ifcall.twstat.stat.mode && ((r->ifcall.twstat.stat.mode&DMDIR)>>24) != r->fid->qid.type&QTDIR) {
+ respond(r, "wstat on DMDIR bit");
+ return;
+ }
+ pc->srv->wstat(r);
+ break;
+ /* Still to be implemented: auth */
         }
 }
 
@@ -386,10 +413,13 @@
                 if((r->oldreq = lookupkey(&pc->tagmap, r->ifcall.tflush.oldtag)))
                         respond(r->oldreq, Eintr);
                 break;
+ case TWStat:
+ ixp_freestat(&r->ifcall.twstat.stat);
+ break;
         case TRead:
         case TStat:
- break;
- /* Still to be implemented: wstat, auth */
+ break;
+ /* Still to be implemented: auth */
         }
 
         r->ofcall.hdr.tag = r->ifcall.hdr.tag;
Received on Sun Sep 21 2008 - 03:40:55 UTC

This archive was generated by hypermail 2.2.0 : Sun Sep 21 2008 - 03:48:05 UTC