/* The directory blob is empty, apparently. This is not a valid dir
* blob, so throw an error. */
code = EIO;
+ goto error;
} else if (page * AFS_BUFFER_PAGESIZE >= adc->f.chunkBytes) {
code = ENOENT; /* past the end */
+ goto error;
}
- if (code) {
- tb->fid = NULLIDX;
- afs_reset_inode(&tb->inode);
- tb->lockers--;
- ReleaseWriteLock(&tb->lock);
- return code;
- }
+
tfile = afs_CFileOpen(&adc->f.inode);
- osi_Assert(tfile);
+ if (!tfile) {
+ code = EIO;
+ goto error;
+ }
code =
afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data,
AFS_BUFFER_PAGESIZE);
afs_CFileClose(tfile);
if (code < AFS_BUFFER_PAGESIZE) {
- tb->fid = NULLIDX;
- afs_reset_inode(&tb->inode);
- tb->lockers--;
- ReleaseWriteLock(&tb->lock);
- return EIO;
+ code = EIO;
+ goto error;
}
/* Note that findslot sets the page field in the buffer equal to
* what it is searching for. */
entry->buffer = tb;
entry->data = tb->data;
return 0;
+
+ error:
+ tb->fid = NULLIDX;
+ afs_reset_inode(&tb->inode);
+ tb->lockers--;
+ ReleaseWriteLock(&tb->lock);
+ return code;
}
static void
if (lp->dirty) {
/* see DFlush for rationale for not getting and locking the dcache */
tfile = afs_CFileOpen(&lp->inode);
- osi_Assert(tfile);
+ if (!tfile)
+ return NULL; /* Callers will flag as EIO */
+
afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
AFS_BUFFER_PAGESIZE);
lp->dirty = 0;