tlen = len;
ObtainReadLock(&tdc->lock);
tfile = osi_UFSOpen(&tdc->f.inode);
+ if (!tfile) {
+ ReleaseReadLock(&tdc->lock);
+ afs_PutDCache(tdc);
+ osi_FreeLargeSpace(rbuf);
+ return ENOENT;
+ }
code = afs_osi_Read(tfile, -1, rbuf, tlen);
osi_UFSClose(tfile);
ReleaseReadLock(&tdc->lock);
if ((tdc->f.states & DWriting) || tdc->f.fid.Fid.Volume == 0)
fileIsBad = 1;
tfile = osi_UFSOpen(&tdc->f.inode);
+ if (!tfile) {
+ ReleaseWriteLock(&afs_xdcache);
+ ReleaseWriteLock(&tdc->lock);
+ afs_PutDCache(tdc);
+ return ENOENT;
+ }
+
code = afs_osi_Stat(tfile, &tstat);
if (code)
osi_Panic("initcachefile stat");
*
* Environment:
* This function is called only during initialization. The given
- * file should NOT be truncated to 0 lenght; its contents descrebe
+ * file should NOT be truncated to 0 length; its contents describe
* what data is really in the cache.
*
* WARNING: data will be written to this file over time by AFS.
afs_fsfragsize = AFS_MIN_FRAGSIZE;
}
tfile = osi_UFSOpen(&cacheInode);
+ if (!tfile)
+ return ENOENT;
+
afs_osi_Stat(tfile, &tstat);
cacheInfoModTime = tstat.mtime;
code = afs_osi_Read(tfile, -1, &theader, sizeof(theader));
*/
if (afs_FVIndex != tv->vtix) {
tfile = osi_UFSOpen(&volumeInode);
+ if (!tfile) {
+ afs_warn("afs_UFSGetVolSlot: unable to open volumeinfo\n");
+ goto error;
+ }
code =
afs_osi_Read(tfile, sizeof(struct fvolume) * tv->vtix,
&staticFVolume, sizeof(struct fvolume));
(int)code);
goto error;
}
- afs_FVIndex = tv->vtix;
}
}
afs_FVIndex = tv->vtix;
staticFVolume.rootVnode = tv->rootVnode;
staticFVolume.rootUnique = tv->rootUnique;
tfile = osi_UFSOpen(&volumeInode);
+ if (!tfile) {
+ afs_warn("afs_UFSGetVolSlot: unable to open volumeinfo\n");
+ goto error;
+ }
code =
afs_osi_Write(tfile, sizeof(struct fvolume) * afs_FVIndex,
&staticFVolume, sizeof(struct fvolume));
for (j = fvTable[FVHash(tcell->cellNum, volid)]; j != 0; j = tf->next) {
if (afs_FVIndex != j) {
tfile = osi_UFSOpen(&volumeInode);
- code =
- afs_osi_Read(tfile, sizeof(struct fvolume) * j,
- &staticFVolume, sizeof(struct fvolume));
- osi_UFSClose(tfile);
+ if (!tfile) {
+ afs_warn("afs_UFSGetVolSlot: unable to open volumeinfo\n");
+ code = -1; /* indicate error */
+ } else {
+ code =
+ afs_osi_Read(tfile, sizeof(struct fvolume) * j,
+ &staticFVolume, sizeof(struct fvolume));
+ osi_UFSClose(tfile);
+ if (code != sizeof(struct fvolume)) {
+ afs_warn("afs_SetupVolume: error %d reading volumeinfo\n",
+ (int)code);
+ }
+ }
if (code != sizeof(struct fvolume)) {
- afs_warn("afs_SetupVolume: error %d reading volumeinfo\n",
- (int)code);
/* put tv back on the free list; the data in it is not valid */
tv->next = afs_freeVolList;
afs_freeVolList = tv;