ref: c89f394017d3cd8f0755e7a569d9dd49e4840f1e
parent: b5e697fda5842e1bf9016b983dfbff17f53683f6
author: cinap_lenrek <[email protected]>
date: Wed Mar 9 15:58:29 EST 2016
implement iounit() as kernel function, try to set iounit to 64K before mount on remote side
--- a/cpu.c
+++ b/cpu.c
@@ -2,7 +2,7 @@
* cpu.c - Make a connection to a cpu server
*
* Invoked by listen as 'cpu -R | -N service net netdir'
- * by users as 'cpu [-h system] [-c cmd args ...]'
+ * by users as 'cpu [-h host] [-c cmd args ...]'
*/
#include <u.h>
@@ -14,7 +14,6 @@
#include "args.h"
#include "drawterm.h"
-#define Maxfdata 8192
#define MaxStr 128
static void fatal(int, char*, ...);
@@ -22,11 +21,10 @@
static void writestr(int, char*, char*, int);
static int readstr(int, char*, int);
static char *rexcall(int*, char*, char*);
-static char *keyspec = "";
+static char *keyspec = "";
static AuthInfo *p9any(int);
-#define system csystem
-static char *system;
+static char *host;
static int nokbd;
static int cflag;
extern int dbg;
@@ -34,9 +32,6 @@
static char *srvname = "ncpu";
static char *ealgs = "rc4_256 sha1";
-/* message size for exportfs; may be larger so we can do big graphics in CPU window */
-static int msgsize = Maxfdata+IOHDRSZ;
-
/* authentication mechanisms */
static int p9auth(int);
@@ -56,7 +51,6 @@
fprint(2, "usage: drawterm [-a authserver] [-c cpuserver] [-s secstore] [-u user] [-r root]\n");
exits("usage");
}
-int fdd;
int
mountfactotum(void)
@@ -154,6 +148,7 @@
rcpu(char *host)
{
static char script[] =
+"syscall fversion 0 65536 9P2000 7 >/dev/null >[2=1]\n"
"mount -nc /fd/0 /mnt/term || exit\n"
"bind -q /mnt/term/dev/cons /dev/cons\n"
"if(test -r /mnt/term/dev/kbd){\n"
@@ -185,7 +180,7 @@
fatal(1, "sending script");
/* Begin serving the namespace */
- exportfs(fd, msgsize);
+ exportfs(fd);
fatal(1, "starting exportfs");
}
@@ -193,27 +188,18 @@
cpumain(int argc, char **argv)
{
char dat[MaxStr], buf[MaxStr], cmd[MaxStr], *err, *secstoreserver, *p, *s;
- int fd, ms, data;
+ int data;
- /* see if we should use a larger message size */
- fd = open("/dev/draw", OREAD);
- if(fd > 0){
- ms = iounit(fd);
- if(msgsize < ms+IOHDRSZ)
- msgsize = ms+IOHDRSZ;
- close(fd);
- }
-
user = getenv("USER");
secstoreserver = nil;
authserver = getenv("auth");
- system = getenv("cpu");
+ host = getenv("cpu");
ARGBEGIN{
case 'a':
authserver = EARGF(usage());
break;
case 'c':
- system = EARGF(usage());
+ host = EARGF(usage());
break;
case 'd':
dbg++;
@@ -263,14 +249,14 @@
if(bind("/root", "/", MAFTER) < 0)
panic("bind /root: %r");
- if(system == nil)
- system = readcons("cpu", "cpu", 0);
+ if(host == nil)
+ host = readcons("cpu", "cpu", 0);
if(user == nil)
user = readcons("user", "glenda", 0);
if(authserver == nil)
- authserver = readcons("auth", system, 0);
+ authserver = readcons("auth", host, 0);
if(mountfactotum() < 0){
if(secstoreserver == nil)
@@ -285,10 +271,10 @@
}
}
- rcpu(system);
+ rcpu(host);
- if((err = rexcall(&data, system, srvname)))
- fatal(1, "%s: %s", err, system);
+ if((err = rexcall(&data, host, srvname)))
+ fatal(1, "%s: %s", err, host);
/* Tell the remote side the command to execute and where our working directory is */
if(cflag)
@@ -318,7 +304,7 @@
write(data, "OK", 2);
/* Begin serving the gnot namespace */
- exportfs(data, msgsize);
+ exportfs(data);
fatal(1, "starting exportfs");
}
--- a/drawterm.h
+++ b/drawterm.h
@@ -4,7 +4,7 @@
extern char *secstorefetch(char *addr, char *owner, char *passwd);
extern char *authserver;
extern char *readcons(char *prompt, char *def, int secret);
-extern int exportfs(int, int);
+extern int exportfs(int);
extern char *user;
extern char *getkey(char*, char*, char*);
extern char *findkey(char**, char*, char*);
--- a/exportfs/exportfs.c
+++ b/exportfs/exportfs.c
@@ -24,7 +24,7 @@
int netfd;
int
-exportfs(int fd, int msgsz)
+exportfs(int fd)
{
char buf[ERRMAX], ebuf[ERRMAX];
Fsrpc *r;
@@ -54,12 +54,9 @@
// rfork(RFNOTEG);
- messagesize = msgsz;
- if(messagesize == 0){
- messagesize = iounit(netfd);
- if(messagesize == 0)
- messagesize = 8*8192+IOHDRSZ;
- }
+ messagesize = iounit(netfd);
+ if(messagesize == 0)
+ messagesize = 8192+IOHDRSZ;
Workq = emallocz(sizeof(Fsrpc)*Nr_workbufs);
// for(i=0; i<Nr_workbufs; i++)
--- a/exportfs/exportsrv.c
+++ b/exportfs/exportsrv.c
@@ -14,11 +14,6 @@
char Enomem[] = "No memory";
char Eversion[] = "Bad 9P2000 version";
-int iounit(int x)
-{
- return 8*8192+IOHDRSZ;
-}
-
void*
emallocz(ulong n)
{
--- a/include/u.h
+++ b/include/u.h
@@ -24,3 +24,4 @@
#undef wstat
#undef unmount
#undef pipe
+#undef iounit
--- a/include/user.h
+++ b/include/user.h
@@ -25,6 +25,7 @@
#define pwrite syspwrite
#undef sleep
#define sleep osmsleep
+#define iounit sysiounit
extern int bind(char*, char*, int);
extern int chdir(char*);
@@ -52,6 +53,7 @@
extern int dirwstat(char*, Dir*);
extern int dirfwstat(int, Dir*);
extern long dirread(int, Dir*, long);
+extern ulong iounit(int);
extern int lfdfd(int);
@@ -71,7 +73,6 @@
extern ulong truerand(void);
extern int pushssl(int, char*, char*, char*, int*);
-extern int iounit(int);
extern long pread(int, void*, long, vlong);
extern long pwrite(int, void*, long, vlong);
extern void* rendezvous(void*, void*);
--- a/kern/sysfile.c
+++ b/kern/sysfile.c
@@ -16,6 +16,7 @@
#undef close
#undef fstat
#undef fwstat
+#undef iounit
/*
* The sys*() routines needn't poperror() as they return directly to syscall().
@@ -1125,6 +1126,23 @@
n = _syspwrite(fd, buf, n, (uvlong) ~0);
enderror();
return n;
+}
+
+ulong
+sysiounit(int fd)
+{
+ Chan *c;
+ ulong m;
+
+ starterror();
+ if(waserror()){
+ _syserror();
+ return (ulong)-1;
+ }
+ c = fdtochan(fd, -1, 0, 0);
+ m = c->iounit;
+ enderror();
+ return m;
}
int