Syscall debugging helper
[akaros.git] / tests / cs.c
index 1d4cdb4..1641c32 100644 (file)
@@ -338,7 +338,6 @@ mountinit(char *service, char *mntpt)
         * ORCLOSE means remove on last close. Handy. Not here yet. 
         */
        f = open(service, O_WRONLY|O_CREAT/*|ORCLOSE*/, 0666);
         * ORCLOSE means remove on last close. Handy. Not here yet. 
         */
        f = open(service, O_WRONLY|O_CREAT/*|ORCLOSE*/, 0666);
-printf("open %s gets %d\n", service, f);
        if(f < 0)
                error(1, 0, "%s: %r",service);
        snprintf(buf, sizeof(buf), "%d", p[1]);
        if(f < 0)
                error(1, 0, "%s: %r",service);
        snprintf(buf, sizeof(buf), "%d", p[1]);
@@ -444,13 +443,10 @@ void *job_thread(void* arg)
        Mfile *mf;
        Job *job = arg;
        //lock(&dblock);
        Mfile *mf;
        Job *job = arg;
        //lock(&dblock);
-printf("JOB!\n");
        mf = newfid(job->request.fid);
 
        mf = newfid(job->request.fid);
 
-printf("NEWFID is %p\n", mf);
        if(debug)
                fprintf(stderr, "CS:%F", &job->request);
        if(debug)
                fprintf(stderr, "CS:%F", &job->request);
-printf("DO %d\n", job->request.type);
        switch(job->request.type){
        default:
                fprintf(stderr, "CS:unknown request type %d", job->request.type);
        switch(job->request.type){
        default:
                fprintf(stderr, "CS:unknown request type %d", job->request.type);
@@ -499,7 +495,8 @@ printf("DO %d\n", job->request.type);
 
        freejob(job);
 
 
        freejob(job);
 
-       fprintf(stderr, "CS:Job done\n");
+       if (debug)
+               fprintf(stderr, "CS:Job done\n");
        return 0;
 }
 
        return 0;
 }
 
@@ -532,9 +529,7 @@ io(void)
                 * later if we want to.
                 */
 #if 0
                 * later if we want to.
                 */
 #if 0
-printf("RUN THAT JOB!\n");
                if (pthread_create(&job->thread, NULL, &job_thread, job)) {
                if (pthread_create(&job->thread, NULL, &job_thread, job)) {
-printf("ERROR!\n");
                        error(1, 0, "%s: %r","Failed to create job");
                        continue;
                }
                        error(1, 0, "%s: %r","Failed to create job");
                        continue;
                }
@@ -627,7 +622,6 @@ rwalk(Job *job, Mfile *mf)
        if(nelems > 0){
                /* walk fid */
                for(i=0; i<nelems && i<MAXWELEM; i++){
        if(nelems > 0){
                /* walk fid */
                for(i=0; i<nelems && i<MAXWELEM; i++){
-printf("cs: i %d nelems %d \n", i, nelems);
                        if((qid.type & QTDIR) == 0){
                                err = "not a directory";
                                break;
                        if((qid.type & QTDIR) == 0){
                                err = "not a directory";
                                break;
@@ -643,7 +637,6 @@ printf("cs: i %d nelems %d \n", i, nelems);
                        if(strcmp(elems[i], "cs") == 0){
                                qid.type = QTFILE;
                                qid.path = Qcs;
                        if(strcmp(elems[i], "cs") == 0){
                                qid.type = QTFILE;
                                qid.path = Qcs;
-printf("found cs, goto Found\n");
                                goto Found;
                        }
                        err = malloc(4096);
                                goto Found;
                        }
                        err = malloc(4096);
@@ -805,7 +798,6 @@ rwrite(Job *job, Mfile *mf)
                goto send;
        }
        job->request.data[cnt] = 0;
                goto send;
        }
        job->request.data[cnt] = 0;
-printf("CS: request data is :%s:\n", job->request.data);
        /*
         *  toggle debugging
         */
        /*
         *  toggle debugging
         */
@@ -848,7 +840,7 @@ printf("CS: request data is :%s:\n", job->request.data);
         *  refresh all state
         */
        if(strncmp(job->request.data, "refresh", 7)==0){
         *  refresh all state
         */
        if(strncmp(job->request.data, "refresh", 7)==0){
-               netinit(1);
+               netinit(0/*1*/);
                goto send;
        }
 
                goto send;
        }
 
@@ -888,7 +880,6 @@ printf("CS: request data is :%s:\n", job->request.data);
                mf->net = strdup(field[0]);
                break;
        }
                mf->net = strdup(field[0]);
                break;
        }
-
        /*
         *  do the first net worth of lookup
         */
        /*
         *  do the first net worth of lookup
         */
@@ -965,7 +956,7 @@ sendmsg(Job *job, char *err)
        }
        job->reply.tag = job->request.tag;
        n = convS2M(&job->reply, mdata, sizeof mdata);
        }
        job->reply.tag = job->request.tag;
        n = convS2M(&job->reply, mdata, sizeof mdata);
-       if(n == 0){
+       if(n == 1){
                fprintf(stderr,  "CS:sendmsg convS2M of %F returns 0", &job->reply);
                abort();
        }
                fprintf(stderr,  "CS:sendmsg convS2M of %F returns 0", &job->reply);
                abort();
        }
@@ -1107,11 +1098,16 @@ netinit(int background)
 
        /* add the mounted networks to the default list */
        for(np = network; np->net; np++){
 
        /* add the mounted networks to the default list */
        for(np = network; np->net; np++){
+               int fuckup;
                if(np->considered)
                        continue;
                snprintf(clone, sizeof(clone), "%s/%s/clone", mntpt, np->net);
                if(np->considered)
                        continue;
                snprintf(clone, sizeof(clone), "%s/%s/clone", mntpt, np->net);
-               if(access(clone, R_OK))
+               fuckup = open(clone, O_RDONLY);
+               if (fuckup < 0)
                        continue;
                        continue;
+               close(fuckup);
+               //if(access(clone, R_OK))
+                       //continue;
                if(netlist)
                        last->next = np;
                else
                if(netlist)
                        last->next = np;
                else
@@ -1330,7 +1326,6 @@ ipserv(Network *np, char *name, char *buf, int blen)
        }
        snprintf(buf, blen, "%s%s", p, restr ? "!r" : "");
        free(p);
        }
        snprintf(buf, blen, "%s%s", p, restr ? "!r" : "");
        free(p);
-
        return buf;
 }
 
        return buf;
 }
 
@@ -1679,7 +1674,7 @@ qreply(Mfile *mf, struct ndbtuple *t)
                        len = 0;
                else {
                        len -= amt;
                        len = 0;
                else {
                        len -= amt;
-                       cur += len;
+                       cur += amt;
                }
 
                if(nt->line != nt->entry){
                }
 
                if(nt->line != nt->entry){
@@ -1693,7 +1688,7 @@ qreply(Mfile *mf, struct ndbtuple *t)
                                len = 0;
                        else {
                                len -= amt;
                                len = 0;
                        else {
                                len -= amt;
-                               cur += len;
+                               cur += amt;
                        }
                }
 
                        }
                }