struct DirBuffer entrybuf, prevbuf, headerbuf;
struct DirEntry *ep;
struct DirHeader *dhp;
+ int code;
/* check name quality */
if (*entry == 0)
return EINVAL;
/* First check if file already exists. */
- if (FindItem(dir, entry, &prevbuf, &entrybuf) == 0) {
+ code = FindItem(dir, entry, &prevbuf, &entrybuf);
+ if (code && code != ENOENT) {
+ return code;
+ }
+ if (code == 0) {
DRelease(&entrybuf, 0);
DRelease(&prevbuf, 0);
return EEXIST;
struct DirBuffer entrybuf, prevbuf;
struct DirEntry *firstitem;
unsigned short *previtem;
+ int code;
- if (FindItem(dir, entry, &prevbuf, &entrybuf) != 0)
- return ENOENT;
+ code = FindItem(dir, entry, &prevbuf, &entrybuf);
+ if (code) {
+ return code;
+ }
firstitem = (struct DirEntry *)entrybuf.data;
previtem = (unsigned short *)prevbuf.data;
afs_int32 *fid = (afs_int32 *) voidfid;
struct DirBuffer firstbuf, prevbuf;
struct DirEntry *firstitem;
+ int code;
- if (FindItem(dir, entry, &prevbuf, &firstbuf) != 0)
- return ENOENT;
+ code = FindItem(dir, entry, &prevbuf, &firstbuf);
+ if (code) {
+ return code;
+ }
DRelease(&prevbuf, 0);
firstitem = (struct DirEntry *)firstbuf.data;
afs_int32 *fid = (afs_int32 *) voidfid;
struct DirBuffer firstbuf, prevbuf;
struct DirEntry *firstitem;
+ int code;
- if (FindItem(dir, entry, &prevbuf, &firstbuf) != 0)
- return ENOENT;
+ code = FindItem(dir, entry, &prevbuf, &firstbuf);
+ if (code) {
+ return code;
+ }
DRelease(&prevbuf, 0);
firstitem = (struct DirEntry *)firstbuf.data;
i = afs_dir_DirHash(ename);
if (dhp->hashTable[i] == 0) {
/* no such entry */
- DRelease(&prev, 0);
- return ENOENT;
+ code = ENOENT;
+ goto out;
}
code = afs_dir_GetVerifiedBlob(dir,
(u_short) ntohs(dhp->hashTable[i]),
&curr);
if (code) {
- DRelease(&prev, 0);
- return code;
+ goto out;
}
prev.data = &(dhp->hashTable[i]);
prev = curr;
prev.data = &(tp->next);
- if (tp->next == 0)
- goto out; /* The end of the line */
+ if (tp->next == 0) {
+ /* The end of the line */
+ code = ENOENT;
+ goto out;
+ }
code = afs_dir_GetVerifiedBlob(dir, (u_short) ntohs(tp->next),
&curr);
goto out;
}
+ /* If we've reached here, we've hit our loop limit. Something is weird with
+ * the directory; maybe a circular hash chain? */
+ code = EIO;
+
out:
DRelease(&prev, 0);
- return ENOENT;
+ return code;
}
static int
struct DirEntry *entry;
int code = 0;
- if (FindFid(dir, vnode, unique, &entrybuf) != 0)
- return ENOENT;
+ code = FindFid(dir, vnode, unique, &entrybuf);
+ if (code) {
+ return code;
+ }
entry = (struct DirEntry *)entrybuf.data;
if (strlen(entry->name) >= length)
struct DirEntry *firstitem;
struct MKFid *fid_old = (struct MKFid *) old_fid;
struct MKFid *fid_new = (struct MKFid *) new_fid;
+ int code;
/* Find entry. */
- if (FindItem(dir, entry, &prevbuf, &entrybuf) != 0)
- return ENOENT;
+ code = FindItem(dir, entry, &prevbuf, &entrybuf);
+ if (code) {
+ return code;
+ }
firstitem = (struct DirEntry *)entrybuf.data;
DRelease(&prevbuf, 1);
/* check that the file is in the directory */
SetDirHandle(dir, parentptr);
- if (afs_dir_Lookup(dir, Name, fileFid))
- return (ENOENT);
+ errorCode = afs_dir_Lookup(dir, Name, fileFid);
+ if (errorCode && errorCode != ENOENT) {
+ errorCode = EIO;
+ }
+ if (errorCode) {
+ return errorCode;
+ }
fileFid->Volume = V_id(volptr);
/* just-in-case check for something causing deadlock */
SetDirHandle(&newdir, newvptr);
/* Lookup the file to delete its vnode */
- if (afs_dir_Lookup(&olddir, OldName, &fileFid)) {
- errorCode = ENOENT;
+ errorCode = afs_dir_Lookup(&olddir, OldName, &fileFid);
+ if (errorCode && errorCode != ENOENT) {
+ errorCode = EIO;
+ }
+ if (errorCode) {
goto Bad_Rename;
}
if (fileFid.Vnode == oldvptr->vnodeNumber
}
/* Lookup the new file */
- if (!(afs_dir_Lookup(&newdir, NewName, &newFileFid))) {
+ code = afs_dir_Lookup(&newdir, NewName, &newFileFid);
+ if (code && code != ENOENT) {
+ errorCode = EIO;
+ goto Bad_Rename;
+ }
+ if (!code) {
if (readonlyServer) {
errorCode = VREADONLY;
goto Bad_Rename;
struct AFSFid unused;
code = afs_dir_Lookup(&filedir, "..", &unused);
+ if (code && code != ENOENT) {
+ errorCode = EIO;
+ goto Bad_Rename;
+ }
if (code == ENOENT) {
/* only update .. if it doesn't already exist */
updatefile = 1;