From 86fb3a730ac6c3ce58ff031e3e11865829afba60 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 2 Apr 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-04-02 --- port/devmnt.c | 30 +++++++++++++++++++++++------- port/portfns.h | 1 + port/sysfile.c | 31 +++++++++++++++++++++++++++++++ port/systab.h | 6 ++++++ 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/port/devmnt.c b/port/devmnt.c index f65d184caa4cad6d54bae3a1fa6c29106d48d045..df2867fc71908a5971f6591cce1ed9a6a7fb17f5 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -44,7 +44,7 @@ void mntgate(Mnt*); void mntpntfree(Mnt*); void mntqrm(Mnt*, Mntrpc*); Mntrpc* mntralloc(Chan*); -long mntrdwr(int , Chan*, void*,long , ulong); +long mntrdwr(int , Chan*, void*,long , ulong, int); void mntrpcread(Mnt*, Mntrpc*); void mountio(Mnt*, Mntrpc*); void mountmux(Mnt*, Mntrpc*); @@ -168,6 +168,7 @@ mntattach(char *muxattach) mattach(m, c, bogus.spec); poperror(); +#ifdef STUPIDHACK /* Work out how deep we are nested and reduce the blocksize * accordingly */ @@ -182,6 +183,7 @@ mntattach(char *muxattach) mc = mc->mntptr->c; } m->blocksize -= nest * 32; +#endif STUPIDHACK /* * Detect a recursive mount for a mount point served by exportfs. @@ -513,7 +515,7 @@ mntread(Chan *c, void *buf, long n, ulong offset) } } - n = mntrdwr(Tread, c, buf, n, offset); + n = mntrdwr(Tread, c, buf, n, offset, 0); if(c->qid.path & CHDIR) { for(p = (uchar*)buf, e = &p[n]; p < e; p += DIRLEN) mntdirfix(p, c); @@ -526,14 +528,20 @@ mntread(Chan *c, void *buf, long n, ulong offset) return n; } +long +mntwrite9p(Chan *c, void *buf, long n, ulong offset) +{ + return mntrdwr(Twrite, c, buf, n, offset, 1); +} + long mntwrite(Chan *c, void *buf, long n, ulong offset) { - return mntrdwr(Twrite, c, buf, n, offset); + return mntrdwr(Twrite, c, buf, n, offset, 0); } long -mntrdwr(int type, Chan *c, void *buf, long n, ulong offset) +mntrdwr(int type, Chan *c, void *buf, long n, ulong offset, int p9msg) { Mnt *m; Mntrpc *r; @@ -555,7 +563,10 @@ mntrdwr(int type, Chan *c, void *buf, long n, ulong offset) r->request.fid = c->fid; r->request.offset = offset; r->request.data = uba; - r->request.count = limit(n, m->blocksize); + if(p9msg) + r->request.count = limit(n, m->blocksize + MAXMSG - 20); + else + r->request.count = limit(n, m->blocksize); mountrpc(m, r); nr = r->reply.count; if(nr > r->request.count) @@ -629,8 +640,13 @@ mountio(Mnt *m, Mntrpc *r) nexterror(); } else { - if((*devtab[m->c->type].write)(m->c, r->rpc, n, 0) != n) - error(Emountrpc); + if(devchar[m->c->type] == L'M'){ + if(mntwrite9p(m->c, r->rpc, n, 0) != n) + error(Emountrpc); + }else{ + if((*devtab[m->c->type].write)(m->c, r->rpc, n, 0) != n) + error(Emountrpc); + } poperror(); } if(m->mux) { diff --git a/port/portfns.h b/port/portfns.h index d25887481b75ed21d635ef987001e02fe98f67d6..16d959c996ea2791c0f9dcd010dc7ae5dac44285 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -262,6 +262,7 @@ void* vmemchr(void*, int, int); void wakeup(Rendez*); Chan* walk(Chan*, char*, int); void wlock(RWlock*); +long mntwrite9p(Chan*, void*, long, ulong); void wunlock(RWlock*); #define xalloc(s) xallocz(s, 1) void* xallocz(ulong, int); diff --git a/port/sysfile.c b/port/sysfile.c index 3658e0236084681aa0f86b2c5aa08991fed562cc..3333f5f245b4c8f77b687b118cff1dc8f6d49778 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -325,6 +325,37 @@ sysread(ulong *arg) return n; } +long +syswrite9p(ulong *arg) +{ + Chan *c; + long n; + + validaddr(arg[1], arg[2], 0); + c = fdtochan(arg[0], OWRITE, 1, 1); + if(waserror()) { + close(c); + nexterror(); + } + + if(c->qid.path & CHDIR) + error(Eisdir); + + if(devchar[c->type] != L'M') + n = (*devtab[c->type].write)(c, (void*)arg[1], arg[2], c->offset); + else + n = mntwrite9p(c, (void*)arg[1], arg[2], c->offset); + + lock(c); + c->offset += n; + unlock(c); + + poperror(); + close(c); + + return n; +} + long syswrite(ulong *arg) { diff --git a/port/systab.h b/port/systab.h index dd8abb0217e1e9bc6e73db9d76c1aa5a37df1624..a8c967f1ef503e50ccb8cf5722637d7d067538ae 100644 --- a/port/systab.h +++ b/port/systab.h @@ -40,6 +40,8 @@ Syscall syssegflush; Syscall sysrendezvous; Syscall sysunmount; Syscall syswait; +Syscall syswrite9p; +Syscall ; Syscall ; Syscall sysdeath; @@ -81,6 +83,8 @@ Syscall *systab[]={ [RENDEZVOUS] sysrendezvous, [UNMOUNT] sysunmount, [WAIT] syswait, + [WRITE9P] syswrite9p, + }; @@ -122,5 +126,7 @@ char *sysctab[]={ [RENDEZVOUS] "Rendez", [UNMOUNT] "Unmount", [WAIT] "Wait", + [WRITE9P] "Write9p", + };