Annotation of cci/sys/stand/devcopy.c, revision 1.1

1.1     ! root        1: /*     devcopy.c */
        !             2: #define        BSIZE   1024
        !             3: char dev[50];
        !             4: char disk[50];
        !             5: char blocks[50] ;
        !             6: int    fsi;
        !             7: int    fso;
        !             8: char   buffer[BSIZE];
        !             9: 
        !            10: main()
        !            11: {
        !            12:        int j, c, i, n;
        !            13:        char buf[50];
        !            14:        int input, output;
        !            15: 
        !            16:        do {
        !            17:                printf("Source device : ");
        !            18:                gets(dev);
        !            19:                printf("Copy to device : ");
        !            20:                gets(disk);
        !            21:                printf("Number of blocks : ");
        !            22:                gets(blocks);
        !            23:                j = number(blocks);
        !            24:                input = open(dev, 0);
        !            25:                if (input <= 0) printf("Cannot open %s\n", dev);
        !            26:                output = open(disk, 1);
        !            27:                if (output <= 0) printf("Cannot open output\n", disk);
        !            28:        } while (input <= 0 || output <= 0);
        !            29: 
        !            30:        i = 0;  /* Block number */
        !            31:        n = BSIZE;
        !            32:        while (n == BSIZE && i < j) {
        !            33:                if (i > 0 && (i%500 == 0) ) printf("%d blocks\n", i);
        !            34:                lseek (input, i*BSIZE, 0);
        !            35:                n = read (input, buffer, BSIZE);
        !            36:                if (n == BSIZE) {
        !            37:                        lseek (output, i*BSIZE, 0);
        !            38:                        n = write(output, buffer, BSIZE);
        !            39:                        if (n != BSIZE) printf("Short write, block %d, %d bytes only\n",i,n);
        !            40:                        i++;
        !            41:                }
        !            42:                else printf("Short read, block %d, %d bytes only\n",i,n);
        !            43:        }
        !            44:        printf ("Total of %d blocks copied\n",i);
        !            45: }
        !            46: 
        !            47: int number (response)
        !            48: char *response;
        !            49: {
        !            50:        int     i, j;
        !            51:        
        !            52:        j = 0;  /* Total */
        !            53:        while (*response == ' ' || *response == '\t') response++;
        !            54:        while (*response >= '0' && *response <= '9') {
        !            55:                j = j*10 + *response - '0';
        !            56:                response++;
        !            57:        }
        !            58:        return (j);
        !            59: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.