Exemple #1
0
void mark(int *p) {
  int size;
  int *ptr;
  int i = 0;

  //go for it
  ptr = isPtr(p);
  if (ptr != NULL && blockAllocated(ptr)){
  	if (!blockMarked(ptr)){
  		markBlock(ptr);
  	}
  	size = length(ptr)/4;
  	while (++i < size){
  		mark(ptr+i);
  	}
  }
}
Exemple #2
0
/*	deleteFID()
 *
 *	Remove an FID from the directory
 *	If fileLinkCount now zero, deallocate FileEntry and any data extents
 */
int 
deleteFID(Directory * dir, struct fileIdentDesc * fid)
{
    int		rv;
    struct fileEntry *fe;

    rv = CMND_OK;

//    if( fid->icb.extLocation.partitionReferenceNum != pd->partitionNumber )
//	return NOT_IN_RW_PARTITION;

    fe = readTaggedBlock(fid->icb.extLocation.logicalBlockNum, fid->icb.extLocation.partitionReferenceNum);

    /* check permission */

    freeBlock(fid->icb.extLocation.logicalBlockNum, fid->icb.extLocation.partitionReferenceNum);

    if( fe->fileLinkCount > 1 ) {
	fe->fileLinkCount--;
	setChecksum(fe);
	if( medium == CDRW ) 
	    dirtyBlock(fid->icb.extLocation.logicalBlockNum, fid->icb.extLocation.partitionReferenceNum);
	else
	    vat[fid->icb.extLocation.logicalBlockNum] = writeCDR(fe);
    } else {
	if( medium == CDR ) {
	    if( fe->icbTag.fileType == ICBTAG_FILE_TYPE_DIRECTORY )
		dir->fe.fileLinkCount--;
	    vat[fid->icb.extLocation.logicalBlockNum] = 0xFFFFFFFF;	
	} else {
	    if( fe->icbTag.fileType == ICBTAG_FILE_TYPE_DIRECTORY ) {
		dir->fe.fileLinkCount--;
		((struct logicalVolIntegrityDescImpUse*)
		    (lvid->impUse + 2 * sizeof(uint32_t) * lvid->numOfPartitions))->numDirs--;
	    } else {
		((struct logicalVolIntegrityDescImpUse*)
		    (lvid->impUse + 2 * sizeof(uint32_t) * lvid->numOfPartitions))->numFiles--;
	    }

	    /* free file data */
	    switch( fe->icbTag.flags & ICBTAG_FLAG_AD_MASK ) {
	    case ICBTAG_FLAG_AD_IN_ICB:
		break;
	    case ICBTAG_FLAG_AD_SHORT:
		freeShortExtents((short_ad*)(fe->allocDescs + fe->lengthExtendedAttr));
		break;
	    case ICBTAG_FLAG_AD_LONG:
		freeLongExtents((long_ad*)(fe->allocDescs + fe->lengthExtendedAttr));
		break;
	    default:
		printf("UDF does not use Extended Alloc Descs\n");
		rv = CMND_FAILED;
	    }
	/* free the File Entry itself */
	markBlock(FREE, fid->icb.extLocation.logicalBlockNum);
	}
    }

    removeFID(dir, fid);
    dir->dirDirty = 1;

    return rv;
}