Skip to content

Commit

Permalink
afs: Dump bad status record
Browse files Browse the repository at this point in the history
Dump an AFS FileStatus record that is detected as invalid.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
David Howells committed Apr 9, 2018
1 parent 37ab636 commit 888b338
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions fs/afs/fsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ static void xdr_decode_AFSFid(const __be32 **_bp, struct afs_fid *fid)
*_bp = bp;
}

/*
* Dump a bad file status record.
*/
static void xdr_dump_bad(const __be32 *bp)
{
__be32 x[4];
int i;

pr_notice("AFS XDR: Bad status record\n");
for (i = 0; i < 5 * 4 * 4; i += 16) {
memcpy(x, bp, 16);
bp += 4;
pr_notice("%03x: %08x %08x %08x %08x\n",
i, ntohl(x[0]), ntohl(x[1]), ntohl(x[2]), ntohl(x[3]));
}

memcpy(x, bp, 4);
pr_notice("0x50: %08x\n", ntohl(x[0]));
}

/*
* decode an AFSFetchStatus block
*/
Expand Down Expand Up @@ -97,6 +117,20 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
EXTRACT(status->abort_code); /* spare 4 */
*_bp = bp;

switch (status->type) {
case AFS_FTYPE_FILE:
case AFS_FTYPE_DIR:
case AFS_FTYPE_SYMLINK:
break;
case AFS_FTYPE_INVALID:
if (status->abort_code != 0)
goto out;
/* Fall through */
default:
xdr_dump_bad(bp - 2);
goto out;
}

if (size != status->size) {
status->size = size;
changed |= true;
Expand Down Expand Up @@ -145,6 +179,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
status->data_version = data_version;
}

out:
if (vnode)
write_sequnlock(&vnode->cb_lock);
}
Expand Down

0 comments on commit 888b338

Please sign in to comment.