Annotation of 3BSD/cmd/flcopy.c, revision 1.1.1.1

1.1       root        1: int floppydes;
                      2: char *flopname = "/dev/floppy";
                      3: 
                      4: main(argc,argv)
                      5: char *argv[];
                      6: {
                      7:        static char buff[512];
                      8:        register count = 77 * 26 * 128, startad = -26 * 128;
                      9:        register int n, file;
                     10: 
                     11:        if(argc==2) {
                     12:                printf("Halftime!\n");
                     13:                if(strcmp(argv[1],"-h")!=0)
                     14:                        printf("Bad halftime option.\n"),
                     15:                        exit(1);
                     16:                if((file = open("floppy",0))<0)
                     17:                        printf("failed to open floppy image"),
                     18:                        exit(1);
                     19:                goto halftime;
                     20:        }
                     21:        file = creat("floppy",0666);
                     22:        close(file);
                     23:        file = open("floppy",2);
                     24:        if(file < 0) exit(1);
                     25:        for( ; count > 0 ; count -= 512) {
                     26:                n = count > 512 ? 512 : count ;
                     27:                lread(startad,n,buff);
                     28:                write(file,buff,n);
                     29:                startad += 512;
                     30:        }
                     31: halftime:
                     32:        printf("Change Floppy, Hit return when done.\n");
                     33:        gets(buff);
                     34:        lseek(file,0,0);
                     35:        count = 77 * 26 * 128; startad = -26 * 128;
                     36:        for( ; count > 0 ; count -= 512) {
                     37:                n = count > 512 ? 512 : count ;
                     38:                read(file,buff,n);
                     39:                lwrite(startad,n,buff);
                     40:                startad += 512;
                     41:        }
                     42: }
                     43: rt_init()
                     44: {
                     45:        static initized = 0;
                     46:        int mode = 2;
                     47: 
                     48:        if(initized) return;
                     49:        initized = 1;
                     50:        if((floppydes = open(flopname,mode)) < 0) {
                     51:                printf("Floppy open failed\n");
                     52:                exit(1);
                     53:        }
                     54: }
                     55:                
                     56: long trans(logical)
                     57: register int logical;
                     58: {
                     59:        /*  Logical to physical adress translation */
                     60:        register int sector, bytes, track;
                     61: 
                     62:        logical += 26 * 128;
                     63:        bytes = (logical & 127);
                     64:        logical >>= 7;
                     65:        sector = logical % 26;
                     66:        if(sector >= 13)
                     67:                sector = sector *2 +1;
                     68:        else
                     69:                sector *= 2;
                     70:        sector += 26 + ((track = (logical / 26)) - 1) * 6;
                     71:        sector %= 26;
                     72:        return( (((track *26) + sector) << 7) + bytes);
                     73: }
                     74: lread(startad,count,obuff)
                     75: register startad, count;
                     76: register char * obuff;
                     77: {
                     78:        long trans();
                     79:        extern floppydes;
                     80:        rt_init();
                     81:                while( (count -= 128) >= 0) {
                     82:                        lseek(floppydes, trans(startad), 0);
                     83:                        read(floppydes,obuff,128);
                     84:                        obuff += 128;
                     85:                        startad += 128;
                     86:                }
                     87: }
                     88: lwrite(startad,count,obuff)
                     89: register startad, count;
                     90: register char * obuff;
                     91: {
                     92:        long trans();
                     93:        extern floppydes;
                     94:        rt_init();
                     95:                while( (count -= 128) >= 0) {
                     96:                        lseek(floppydes, trans(startad), 0);
                     97:                        write(floppydes,obuff,128);
                     98:                        obuff += 128;
                     99:                        startad += 128;
                    100:                }
                    101: }

unix.superglobalmegacorp.com

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