Annotation of dmsdos/doc/ioctl.doc, revision 1.1.1.1

1.1       root        1: DMSDOS ioctl commands (outdated.... newers are missing here)
                      2: 
                      3: *****************************************************************************
                      4: WARNING: INFORMATION IN THIS FILE IS OUTDATED AND PARTIALLY WRONG. SEE THE
                      5:          DMSDOS UTILITIES SOURCE CODE FOR PROGRAMMING EXAMPLES.
                      6: 
                      7:          When I have enough time I write better documentation.....
                      8: *****************************************************************************
                      9: 
                     10: Example code:
                     11: 
                     12:   #include<stdio.h>
                     13:   #include<linux/dmsdos_fs.h>
                     14:   #include<sys/ioctl.h>
                     15:   #include<sys/types.h>
                     16:   #include<sys/stat.h>
                     17:   #include<fcntl.h>
                     18:   #include<string.h>
                     19:   #include<errno.h>
                     20: 
                     21:   Dblsb dblsb;
                     22:   int fd;
                     23:   int ret;
                     24:   unsigned long w[10];
                     25:   Mdfat_entry mde;
                     26: 
                     27:   /* open file descriptor fd */
                     28:   fd=open(CVF_name,O_RDONLY);
                     29:   if(fd<0)
                     30:   { printf("No such file or directory.\n");
                     31:     return;
                     32:   }
                     33: 
                     34: DMSDOS_GET_DBLSB:
                     35: read DMSDOS version number and read CVF parameters in dblsb structure.
                     36: This function also performs a version check, i.e. if the dmsdos driver in
                     37: the kernel thinks the version number you supply in s_dcluster is too old, 
                     38: it "or"s the returned value with 0x0f000000 and doesn't fill in the values
                     39: for the dblsb structure.
                     40: 
                     41: ** Since not all DMSDOS versions support all commands, this ioctl should be
                     42: always issued first **
                     43: 
                     44:   dblsb.s_dcluster=DMSDOS_VERSION;  
                     45:   ret=ioctl(fd,DMSDOS_GET_DBLSB,&dblsb);
                     46:   if(ret<0)
                     47:   { printf("This is not a DMSDOS directory.\n");
                     48:     exit(1);
                     49:   }
                     50:   printf("You are running DMSDOS Version %d.%d.%d.\n\n",(ret&0xff0000)>>16,
                     51:          (ret&0x00ff00)>>8,ret&0xff);
                     52:   if(ret&0x0f000000)
                     53:   { printf("This program is too old for the DMSDOS version you are running.\n");
                     54:     exit(1);
                     55:   }
                     56: 
                     57:   dblsb structure see dmsdos.h.
                     58: 
                     59: DMSDOS_READ_BITFAT:
                     60: read bitfat entry
                     61: w[0]=sectornr; returns 0 in w[1] if sector free
                     62: 
                     63:   ret=ioctl(fd,DMSDOS_READ_BITFAT,w);
                     64:   if(ret<0)error.....;
                     65: 
                     66: DMSDOS_WRITE_BITFAT:
                     67: write bitfat entry
                     68: w[0]=sectornr, w[1]=new value (0=free, 1=allocated)
                     69: 
                     70:   ret=ioctl(fd,DMSDOS_WRITE_BITFAT,w);
                     71:   if(ret<0)error.....;
                     72: 
                     73: DMSDOS_READ_MDFAT:
                     74: read mdfat entry
                     75: w[0]=clusternr; returns result in mde structure.
                     76: 
                     77:   w[1]=&mde;
                     78:   ret=ioctl(fd,DMSDOS_READ_MDFAT,w);
                     79:   if(ret<0)error......;
                     80:   
                     81: DMSDOS_WRITE_MDFAT:
                     82: write mdfat entry
                     83: w[0]=clusternr; mde=new mdfat entry value.
                     84:   
                     85:   w[1]=&mde;
                     86:   ret=ioctl(fd,DMSDOS_WRITE_MDFAT,w);
                     87:   if(ret<0)error......;
                     88: 
                     89: raw MDFAT entry: 32/40 bit number (hidden to the user)
                     90: 
                     91:   dos 6.x, Win95 without drivespace 3:
                     92:   3322222222221111111111
                     93:   10987654321098765432109876543210 
                     94:   ucaaaammmm?sssssssssssssssssssss
                     95: 
                     96:   Win95 with drivespace 3:
                     97:   33333333322222222221111111111
                     98:   9876543210987654321098765432109876543210 
                     99:   ucaaaaaammmmmm??ssssssssssssssssssssssss
                    100: 
                    101: Mdfat_entry structure: (the dmsdos driver automatically converts it to the
                    102:                         appropriate 32 or 40 bit number)
                    103: 
                    104:   mde.sector_minus_1= ('ssss...' bits)
                    105:   mde.size_lo_minus_1= ('mmmmmm' bits)
                    106:   mde.size_hi_minus_1= ('aaaaaa' bits)
                    107:   mde.flags= ('uc' bits)
                    108:   mde.unknown= ('?' bit(s)), are NOT written, always set to zero
                    109:   
                    110:   u: 1=entry is used, 0=entry is free
                    111:   c: 1=cluster is uncompressed, 0=cluster is compressed
                    112:   a: uncompressed size minus 1 (number of sectors belonging to this cluster)
                    113:   m: compressed size minus 1 (      "      "        "          )
                    114:   ?: unknown, but seem(s) to be used sometimes
                    115:   s: sector number minus 1 (theoretical 2 GB limit)
                    116:      The sector number is counted from the beginning of the CVF file
                    117:      starting with sector number 0.
                    118: 
                    119: DMSDOS_SET_COMP:
                    120: set compression method for write access.
                    121:   
                    122:   ioctl(fd,DMSDOS_SET_COMP,READ_ONLY); or:
                    123:   ioctl(fd,DMSDOS_SET_COMP,UNCOMPRESSED); or:
                    124:   ioctl(fd,DMSDOS_SET_COMP,GUESS); or:
                    125:   ioctl(fd,DMSDOS_SET_COMP,DS_0_0); or:
                    126:   ioctl(fd,DMSDOS_SET_COMP,DS_0_1); or:
                    127:   ioctl(fd,DMSDOS_SET_COMP,DS_0_2); or:
                    128:   ioctl(fd,DMSDOS_SET_COMP,JM_0_0); or:
                    129:   ioctl(fd,DMSDOS_SET_COMP,JM_0_1); or:
                    130:   ioctl(fd,DMSDOS_SET_COMP,SQ_0_0);
                    131: 
                    132: DMSDOS_SET_CF:
                    133: set compression level:
                    134:   
                    135:   ioctl(fd,DMSDOS_SET_CF,level-1);
                    136: 
                    137: DMSDOS_EXTRA_STATFS:
                    138: special statfs command for dmsdos
                    139: reads special info in w.
                    140: 
                    141:   ioctl(fd,DMSDOS_EXTRA_STATFS,w);
                    142: 
                    143: w[0]= free sectors in CVF.
                    144: w[1]= used sectors.
                    145: w[2]= maximum free unfragmented sectors (contiguous sectors)
                    146: w[3]= free fat clusters
                    147: w[4]= used fat clusters
                    148: w[5]= clusters allocated in fat but free in MDFAT (filesystem error if > 0)
                    149: w[6]= sum of sectors used by compressed clusters
                    150: w[7]= sum of sectors used by uncompressed clusters
                    151: w[8]= number of compressed clusters
                    152: w[9]= number of uncompressed clusters
                    153: 
                    154: DMSDOS_READ_BLOCK:
                    155: read sector from CVF; returns sector contents in bstruct.data;
                    156: 
                    157:   struct bstruct
                    158:   { unsigned long sectornr;
                    159:     unsigned char data[512];
                    160:   };
                    161: 
                    162:   bstruct.sectornr= sector number;
                    163: 
                    164:   ioctl(fd,DMSDOS_READ_BLOCK,&bstruct);
                    165: 
                    166: DMSDOS_WRITE_BLOCK:
                    167: 
                    168:   analogue to read_block...
                    169: 
                    170: DMSDOS_READ_DIRENTRY:
                    171: DMSDOS_WRITE_DIRENTRY:
                    172: 
                    173:   removed and unsupported...
                    174: 
                    175: DMSDOS_READ_DFAT:
                    176: w[0]=clusternr; returns fat entry value in w[1]; (last=-1 or 0xFFFFFFFF)
                    177: 
                    178:   ret=ioctl(fd,DMSDOS_READ_DFAT,w);
                    179:   if(ret<0)error......;
                    180: 
                    181: DMSDOS_WRITE_DFAT:
                    182: w[0]=clusternr; w[1]=new value;
                    183: 
                    184:   ret=ioctl(fd,DMSDOS_WRITE_DFAT,w);
                    185:   if(ret<0)error......;
                    186: 
                    187: DMSDOS_SIMPLE_CHECK:
                    188: performs simple filesystem check (crosslinks & allocation errors)
                    189: w[0]=0; means do not try to repair errors
                    190: 
                    191: returns result in w[0] (0=ok, -1=FAT error, -2=MDFAT error, -3=BITFAT error,
                    192:                         1=out of memory, check aborted,
                    193:                         2=FAT ok, but out of memory for MDFAT check)
                    194: 
                    195:   ioctl(fd,DMSDOS_SIMPLE_CHECK,w);
                    196:   if(w[0]==....)printf(.....);
                    197: 
                    198: 
                    199: dmsdos daemon ioctls missing here....

unix.superglobalmegacorp.com

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