]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/cwfs/main.c
cwfs: remove reflock
[plan9front.git] / sys / src / cmd / cwfs / main.c
index 7f9b96a8dd8a984b035b589a6fa4855bc602ba46..8cf0ebc79aa2899f62ee77b2afc056c4b926a800 100644 (file)
@@ -15,38 +15,6 @@ machinit(void)
        active.exiting = 0;
 }
 
-/*
- * Put a string on the console.
- */
-void
-puts(char *s, int n)
-{
-       print("%.*s", n, s);
-}
-
-void
-prflush(void)
-{
-}
-
-/*
- * Print a string on the console.
- */
-void
-putstrn(char *str, int n)
-{
-       puts(str, n);
-}
-
-/*
- * get a character from the console
- */
-int
-getc(void)
-{
-       return Bgetrune(&bin);
-}
-
 void
 panic(char *fmt, ...)
 {
@@ -191,7 +159,7 @@ postservice(void)
        if(pipe(p) < 0)
                panic("can't make a pipe");
        snprint(buf, sizeof(buf), "#s/%s.cmd", service);
-       srvfd(buf, 0220, p[0]);
+       srvfd(buf, 0660, p[0]);
        close(p[0]);
 
        /* use it as stdin */
@@ -200,7 +168,7 @@ postservice(void)
 }
 
 /*
- * compute BUFSIZE*(NDBLOCK+INDPERBUF+INDPERBUFâ\81²+INDPERBUFâ\81³+INDPERBUFâ\81´)
+ * compute BUFSIZE*(NDBLOCK+INDPERBUF+INDPERBUF²+INDPERBUF³+INDPERBUFâ\81´)
  * while watching for overflow; in that case, return 0.
  */
 
@@ -242,8 +210,8 @@ maxsize(void)
 }
 
 enum {
-       INDPERBUF⁲ = ((uvlong)INDPERBUF *INDPERBUF),
-       INDPERBUF⁴ = ((uvlong)INDPERBUFâ\81²*INDPERBUFâ\81²),
+       INDPERBUF² = ((uvlong)INDPERBUF*INDPERBUF),
+       INDPERBUF⁴ = ((uvlong)INDPERBUF²*INDPERBUF²),
 };
 
 static void
@@ -261,9 +229,9 @@ printsizes(void)
                        max = offlim - 1;
                print("max file size = %,llud\n", (Wideoff)max);
        }
-       if (INDPERBUFâ\81²/INDPERBUF != INDPERBUF)
-               print("overflow computing INDPERBUFâ\81²\n");
-       if (INDPERBUF⁴/INDPERBUFâ\81² != INDPERBUFâ\81²)
+       if (INDPERBUF²/INDPERBUF != INDPERBUF)
+               print("overflow computing INDPERBUF²\n");
+       if (INDPERBUF⁴/INDPERBUF² != INDPERBUF²)
                print("overflow computing INDPERBUF⁴\n");
        print("\tINDPERBUF = %d, INDPERBUF^4 = %,lld, ", INDPERBUF,
                (Wideoff)INDPERBUF⁴);
@@ -346,8 +314,6 @@ main(int argc, char **argv)
                printsizes();
        }
 
-       qlock(&reflock);
-       qunlock(&reflock);
        serveq = newqueue(1000, "9P service");  /* tunable */
        raheadq = newqueue(1000, "readahead");  /* tunable */
 
@@ -483,7 +449,6 @@ serve(void *)
        Msgbuf *mb;
 
        for (;;) {
-               qlock(&reflock);
                /* read 9P request from a network input process */
                mb = fs_recv(serveq, 0);
                assert(mb->magic == Mbmagic);
@@ -492,7 +457,6 @@ serve(void *)
                if (cp == nil)
                        panic("serve: nil mb->chan");
                rlock(&cp->reflock);
-               qunlock(&reflock);
 
                rlock(&mainlock);
 
@@ -508,7 +472,7 @@ serve(void *)
                                        break;
                                }
                        if(cp->protocol == nil && (chatty > 1)){
-                               print("no protocol for message\n");
+                               fprint(2, "no protocol for message\n");
                                hexdump(mb->data, 12);
                        }
                } else
@@ -528,7 +492,7 @@ exit(void)
        active.exiting = 1;
        unlock(&active);
 
-       print("halted at %T.\n", time(nil));
+       fprint(2, "halted at %T.\n", time(nil));
        postnote(PNGROUP, getpid(), "die");
        exits(nil);
 }
@@ -548,7 +512,7 @@ nextdump(Timet t)
        Timet nddate = nextime(t+MINUTE(100), DUMPTIME, WEEKMASK);
 
        if(!conf.nodump && chatty)
-               print("next dump at %T\n", nddate);
+               fprint(2, "next dump at %T\n", nddate);
        return nddate;
 }
 
@@ -583,7 +547,7 @@ wormcopy(void *)
                        ntoytime = time(nil) + HOUR(1);
                else if(t > nddate) {
                        if(!conf.nodump) {
-                               print("automatic dump %T\n", t);
+                               fprint(2, "automatic dump %T\n", t);
                                for(fs=filsys; fs->name; fs++)
                                        if(fs->dev->type == Devcw)
                                                cfsdump(fs);