MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / adfCreateVol

Function adfCreateVol

dep/adflib/src/adf_disk.c:238–358  ·  view source on GitHub ↗

* adfCreateVol * * */

Source from the content-addressed store, hash-verified

236 *
237 */
238struct Volume* adfCreateVol( struct Device* dev, int32_t start, int32_t len,
239 char* volName, int volType )
240{
241 struct bBootBlock boot;
242 struct bRootBlock root;
243/* struct bDirCacheBlock dirc;*/
244 SECTNUM blkList[2];
245 struct Volume* vol;
246 int nlen;
247
248 if (adfEnv.useProgressBar)
249 (*adfEnv.progressBar)(0);
250
251 vol=(struct Volume*)malloc(sizeof(struct Volume));
252 if (!vol) {
253 (*adfEnv.eFct)("adfCreateVol : malloc vol");
254 return NULL;
255 }
256
257 vol->dev = dev;
258 vol->firstBlock = (dev->heads * dev->sectors)*start;
259 vol->lastBlock = (vol->firstBlock + (dev->heads * dev->sectors)*len)-1;
260 vol->rootBlock = (vol->lastBlock - vol->firstBlock+1)/2;
261/*printf("first=%ld last=%ld root=%ld\n",vol->firstBlock,
262 vol->lastBlock, vol->rootBlock);
263*/
264 vol->curDirPtr = vol->rootBlock;
265
266 vol->readOnly = dev->readOnly;
267
268 vol->mounted = TRUE;
269
270 nlen = min( MAXNAMELEN, strlen(volName) );
271 vol->volName = (char*)malloc(nlen+1);
272 if (!vol->volName) {
273 (*adfEnv.eFct)("adfCreateVol : malloc");
274 free(vol); return NULL;
275 }
276 memcpy(vol->volName, volName, nlen);
277 vol->volName[nlen]='\0';
278
279 if (adfEnv.useProgressBar)
280 (*adfEnv.progressBar)(25);
281
282 memset(&boot, 0, 1024);
283 boot.dosType[3] = volType;
284/*printf("first=%d last=%d\n", vol->firstBlock, vol->lastBlock);
285printf("name=%s root=%d\n", vol->volName, vol->rootBlock);
286*/
287 if (adfWriteBootBlock(vol, &boot)!=RC_OK) {
288 free(vol->volName); free(vol);
289 return NULL;
290 }
291
292 if (adfEnv.useProgressBar)
293 (*adfEnv.progressBar)(20);
294
295 if (adfCreateBitmap( vol )!=RC_OK) {

Callers 3

adfCreateFlopFunction · 0.85
adfCreateHdFunction · 0.85
adfCreateHdFileFunction · 0.85

Calls 10

adfWriteBootBlockFunction · 0.85
adfCreateBitmapFunction · 0.85
adfGetFreeBlocksFunction · 0.85
adfTime2AmigaTimeFunction · 0.85
adfGiveCurrentTimeFunction · 0.85
adfCreateEmptyCacheFunction · 0.85
adfWriteRootBlockFunction · 0.85
adfWriteNewBitmapFunction · 0.85
adfUpdateBitmapFunction · 0.85
adfFreeBitmapFunction · 0.85

Tested by

no test coverage detected