Skip to content

Instantly share code, notes, and snippets.

@madx
Created May 9, 2010 23:55
Show Gist options
  • Save madx/395515 to your computer and use it in GitHub Desktop.
Save madx/395515 to your computer and use it in GitHub Desktop.
void sgf_remove(int inode) {
TBLOCK b;
int adr, i;
read_block (inode, &b.data);
/* Effacement en chaîne si le fichier est sur plusieurs blocs */
if (b.inode.first != FAT_EOF) {
int cur, next;
cur = get_fat(b.inode.first);
while (cur != b.inode.last) {
next = get_fat (cur);
set_fat (cur, FAT_FREE);
cur = next;
}
set_fat(cur, FAT_FREE);
}
/* Dans tous les cas on supprime le premier bloc */
set_fat (b.inode.first, FAT_FREE);
/* Libération de l'inode */
set_fat (inode, FAT_FREE);
/* Suppression du couple dans le répertoire */
read_block (ADR_BLOCK_DEF, &b.data);
adr = b.super.adr_dir;
read_block (adr, &b.data);
for(i = 0; i < BLOCK_DIR_SIZE; i++) {
if(b.dir[i].inode == inode) {
b.dir[i].inode = 0;
break;
}
}
write_block (adr, &b.data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment