close (fd);
close_ret = close (fd); assert (close_ret == 0);
adir_remove (FCacheEntry *dir,	     const char *name){    fbuf the_fbuf;    int ret;    int fd;    int i;    unsigned len;    DirPage0 *page0;    DirPage1 *page;    unsigned hash_value;    DirEntry *entry = NULL;    DirEntry *prev_entry;    unsigned pageno;    int found;    struct stat sb;    unsigned npages;    assert (CheckLock(&dir->lock) == -1);    assert (dir->flags.datap);    fd = fcache_open_file (dir, O_RDWR, 0);    if (fd < 0)	return errno;#if 0    len = dir->status.Length;#endif    if (fstat (fd, &sb)) {	close (fd);	return errno;    }    len = sb.st_size;    ret = fbuf_create (&the_fbuf, fd, len, FBUF_WRITE);    if (ret) {	close (fd);	return ret;    }    page0 = (DirPage0 *)(the_fbuf.buf);    npages = ntohs(page0->header.pg_pgcount);    hash_value = hashentry (name);    i = ntohs(page0->dheader.hash[hash_value]);    found = i == 0;    prev_entry = NULL;    while (!found) {	entry = getentry (page0, i - 1);	if (strcmp (entry->name, name) == 0) {	    found = TRUE;	} else {	    i = ntohs(entry->next);	    if (i == 0)		found = TRUE;	    prev_entry = entry;	}    }    if (i == 0) {	fbuf_end (&the_fbuf);	return ENOENT;    } else {	if (prev_entry == NULL)	    page0->dheader.hash[hash_value] = entry->next;	else	    prev_entry->next = entry->next;	pageno = (i - 1) / ENTRIESPERPAGE;	page = (DirPage1 *)((char *)page0 + pageno * AFSDIR_PAGESIZE);	remove_from_page (page0, page, pageno, (i - 1) % ENTRIESPERPAGE);	if (pageno == npages - 1	    && page0->dheader.map[pageno] == ENTRIESPERPAGE - 1) {	    do {		len -= AFSDIR_PAGESIZE;		--pageno;		--npages;	    } while(page0->dheader.map[pageno] == ENTRIESPERPAGE - 1);	    page0->header.pg_pgcount = htons(npages);	    fbuf_truncate (&the_fbuf, len);	}	fbuf_end (&the_fbuf);	return 0;    }}