* adfMountHd * * normal not used directly : called by adfMount() * * fills geometry fields and volumes list (dev->nVol and dev->volList[]) */
| 206 | * fills geometry fields and volumes list (dev->nVol and dev->volList[]) |
| 207 | */ |
| 208 | RETCODE adfMountHd(struct Device *dev) |
| 209 | { |
| 210 | struct bRDSKblock rdsk; |
| 211 | struct bPARTblock part; |
| 212 | struct bFSHDblock fshd; |
| 213 | struct bLSEGblock lseg; |
| 214 | int32_t next; |
| 215 | struct List *vList, *listRoot; |
| 216 | int i; |
| 217 | struct Volume* vol; |
| 218 | int len; |
| 219 | |
| 220 | if (adfReadRDSKblock( dev, &rdsk )!=RC_OK) |
| 221 | return RC_ERROR; |
| 222 | |
| 223 | dev->cylinders = rdsk.cylinders; |
| 224 | dev->heads = rdsk.heads; |
| 225 | dev->sectors = rdsk.sectors; |
| 226 | |
| 227 | /* PART blocks */ |
| 228 | listRoot = NULL; |
| 229 | next = rdsk.partitionList; |
| 230 | dev->nVol=0; |
| 231 | vList = NULL; |
| 232 | while( next!=-1 ) { |
| 233 | if (adfReadPARTblock( dev, next, &part )!=RC_OK) { |
| 234 | adfFreeTmpVolList(listRoot); |
| 235 | (*adfEnv.eFct)("adfMountHd : malloc"); |
| 236 | return RC_ERROR; |
| 237 | } |
| 238 | |
| 239 | vol=(struct Volume*)malloc(sizeof(struct Volume)); |
| 240 | if (!vol) { |
| 241 | adfFreeTmpVolList(listRoot); |
| 242 | (*adfEnv.eFct)("adfMountHd : malloc"); |
| 243 | return RC_ERROR; |
| 244 | } |
| 245 | vol->volName=NULL; |
| 246 | dev->nVol++; |
| 247 | |
| 248 | vol->firstBlock = rdsk.cylBlocks * part.lowCyl; |
| 249 | vol->lastBlock = (part.highCyl+1)*rdsk.cylBlocks -1 ; |
| 250 | vol->rootBlock = (vol->lastBlock - vol->firstBlock+1)/2; |
| 251 | vol->blockSize = part.blockSize*4; |
| 252 | |
| 253 | len = min(31, part.nameLen); |
| 254 | vol->volName = (char*)malloc(len+1); |
| 255 | if (!vol->volName) { |
| 256 | adfFreeTmpVolList(listRoot); |
| 257 | (*adfEnv.eFct)("adfMount : malloc"); |
| 258 | return RC_ERROR; |
| 259 | } |
| 260 | memcpy(vol->volName,part.name,len); |
| 261 | vol->volName[len] = '\0'; |
| 262 | |
| 263 | vol->mounted = FALSE; |
| 264 | |
| 265 | /* stores temporaly the volumes in a linked list */ |
no test coverage detected