fd = fcache_open_file (dir, O_RDWR, 0);
fd = fcache_open_file (dir, O_RDWR);
adir_creat (FCacheEntry *dir,	    const char *name,	    AFSFid fid){    fbuf the_fbuf;    int ret;    int fd;    int i;    size_t len;    unsigned npages;    DirPage0 *page0;    DirPage1 *page;    int ind = 0;    unsigned hash_value, next;    struct stat statbuf;    assert (CheckLock(&dir->lock) == -1);    assert (dir->flags.datap);    fd = fcache_open_file (dir, O_RDWR, 0);    if (fd < 0)	return errno;    if(fstat (fd, &statbuf) < 0) {	close (fd);	return errno;    }    len = statbuf.st_size;    ret = fbuf_create (&the_fbuf, fd, len, FBUF_WRITE);    if (ret)	return ret;    page0 = (DirPage0 *)(the_fbuf.buf);    npages = ntohs(page0->header.pg_pgcount);    assert (npages == the_fbuf.len / AFSDIR_PAGESIZE);    hash_value = hashentry (name);    next = page0->dheader.hash[hash_value];    for (i = 0; i < npages; ++i)	if (page0->dheader.map[i]) {	    page = (DirPage1 *)((char *)page0 + i * AFSDIR_PAGESIZE);	    ind = add_to_page (page0, page, i, name, fid, next);	    if (ind >= 0)		break;	}    if (i == npages) {	ret = create_new_page (&page, &the_fbuf);	if (ret)	    goto out;	page0 = (DirPage0 *)(the_fbuf.buf);	page0->header.pg_pgcount = htons(npages + 1);	page0->dheader.map[i] = ENTRIESPERPAGE - 1;	ind = add_to_page (page0, page, i, name, fid, next);	assert (ind >= 0);    }    ind += i * ENTRIESPERPAGE;    page0->dheader.hash[hash_value] = htons(ind + 1);    out:    /* assert (dir->status.Length == the_fbuf.len); */    fbuf_end (&the_fbuf);    return ret;}