/* * Used to find the block that holds the address search * within a file */ static int ifs_find_block(int vsize, int block, int search, int pos) { IFSBlock parent; ifs_get_block(block, &parent); if(search < pos + vsize) return block; else return ifs_find_block(vsize, parent.next, search, pos + parent.size); }
/* * Frees a block */ static int ifs_free_block(struct device *dev, int block) { struct ifs_volume_hdr hdr; struct ifs_block blk; ifs_get_block(dev, block, &blk); device_read(dev, &hdr, sizeof(struct ifs_volume_hdr), 0); blk.state = IFS_BLOCK_FREE; device_write(dev, &blk, sizeof(struct ifs_block), sizeof(struct ifs_volume_hdr) + (block * sizeof(struct ifs_block))); }
/* * Frees all data associated with a file */ static int ifs_free_blockgroup(struct device *dev, struct ifs_entry *entry) { int blk = entry->data_index; do { struct ifs_block block; ifs_get_block(dev, blk, &block); ifs_free_block(dev, blk); blk = block.next; } while(blk); }