1 typedef struct Dosboot Dosboot; 2 typedef struct Dosbpb Dosbpb; 3 typedef struct Dosdir Dosdir; 4 typedef struct Dospart Dospart; 5 typedef struct Dosptr Dosptr; 6 typedef struct Xfs Xfs; 7 typedef struct Xfile Xfile; 8 9 struct Dospart{ 10 uchar active; 11 uchar hstart; 12 uchar cylstart[2]; 13 uchar type; 14 uchar hend; 15 uchar cylend[2]; 16 uchar start[4]; 17 uchar length[4]; 18 }; 19 20 struct Dosboot{ 21 uchar magic[3]; 22 uchar version[8]; 23 uchar sectsize[2]; 24 uchar clustsize; 25 uchar nresrv[2]; 26 uchar nfats; 27 uchar rootsize[2]; 28 uchar volsize[2]; 29 uchar mediadesc; 30 uchar fatsize[2]; 31 uchar trksize[2]; 32 uchar nheads[2]; 33 uchar nhidden[4]; 34 uchar bigvolsize[4]; 35 uchar driveno; 36 uchar reserved0; 37 uchar bootsig; 38 uchar volid[4]; 39 uchar label[11]; 40 uchar reserved1[8]; 41 }; 42 43 struct Dosbpb{ 44 Lock; /* access to fat */ 45 int sectsize; /* in bytes */ 46 int clustsize; /* in sectors */ 47 int nresrv; /* sectors */ 48 int nfats; /* usually 2 */ 49 int rootsize; /* number of entries */ 50 int volsize; /* in sectors */ 51 int mediadesc; 52 int fatsize; /* in sectors */ 53 int fatclusters; 54 int fatbits; /* 12 or 16 */ 55 long fataddr; /* sector number */ 56 long rootaddr; 57 long dataaddr; 58 long freeptr; /* next free cluster candidate */ 59 }; 60 61 struct Dosdir{ 62 uchar name[8]; 63 uchar ext[3]; 64 uchar attr; 65 uchar reserved[10]; 66 uchar time[2]; 67 uchar date[2]; 68 uchar start[2]; 69 uchar length[4]; 70 }; 71 72 #define DRONLY 0x01 73 #define DHIDDEN 0x02 74 #define DSYSTEM 0x04 75 #define DVLABEL 0x08 76 #define DDIR 0x10 77 #define DARCH 0x20 78 79 #define GSHORT(p) (((p)[1]<<8)|(p)[0]) 80 #define GLONG(p) ((GSHORT(p+2)<<16)|GSHORT(p)) 81 82 struct Dosptr{ 83 ulong addr; /* of file's directory entry */ 84 ulong offset; 85 ulong paddr; /* of parent's directory entry */ 86 ulong poffset; 87 ulong iclust; /* ordinal within file */ 88 ulong clust; 89 Iosect *p; 90 Dosdir *d; 91 }; 92 93 struct Xfs{ 94 Xfs * next; 95 char * name; /* of file containing external f.s. */ 96 Qid qid; /* of file containing external f.s. */ 97 long ref; /* attach count */ 98 Qid rootqid; /* of plan9 constructed root directory */ 99 short dev; 100 short fmt; 101 long offset; 102 void * ptr; 103 }; 104 105 struct Xfile{ 106 Xfile * next; /* in hash bucket */ 107 long client; 108 long fid; 109 ulong flags; 110 Qid qid; 111 Xfs * xf; 112 void * ptr; 113 }; 114 115 enum{ 116 Asis, Clean, Clunk 117 }; 118 119 enum{ 120 Oread = 1, Owrite = 2, Orclose = 4, 121 Omodes = 3, 122 }; 123 124 enum{ 125 Enevermind, 126 Eformat, 127 Eio, 128 Enomem, 129 Enonexist, 130 Eperm, 131 Enofilsys, 132 Eauth, 133 }; 134 135 extern int chatty; 136 extern int errno; 137 extern char *deffile; 138