Commit | Line | Data |
---|---|---|
805e021f CE |
1 | /* |
2 | * Copyright 2000, International Business Machines Corporation and others. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This software has been released under the terms of the IBM Public | |
6 | * License. For details, see the LICENSE file in the top-level source | |
7 | * directory or online at http://www.openafs.org/dl/license10.html | |
8 | */ | |
9 | ||
10 | /* | |
11 | * System independent part of vget VFS call. | |
12 | */ | |
13 | ||
14 | #include <afsconfig.h> | |
15 | #include "afs/param.h" | |
16 | ||
17 | ||
18 | #include "afs/sysincludes.h" /* Standard vendor system headers */ | |
19 | #include "afsincludes.h" /* Afs-based standard headers */ | |
20 | #include "afs/afs_stats.h" /* statistics stuff */ | |
21 | ||
22 | ||
23 | ||
24 | #if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN80_ENV) | |
25 | /* This is the common part of the vget VFS call. */ | |
26 | int | |
27 | afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp) | |
28 | { | |
29 | struct VenusFid vfid; | |
30 | struct SmallFid Sfid; | |
31 | struct cell *tcell; | |
32 | struct vrequest *treq = NULL; | |
33 | afs_int32 code = 0, cellindex; | |
34 | afs_int32 ret; | |
35 | ||
36 | memcpy((char *)&Sfid, afidp->fid_data, SIZEOF_SMALLFID); | |
37 | ||
38 | /* Need to extract fid from SmallFid. Will need a wild card option for | |
39 | * finding the right vcache entry. | |
40 | */ | |
41 | cellindex = (Sfid.CellAndUnique >> 24) & 0xff; | |
42 | tcell = afs_GetCellByIndex(cellindex, READ_LOCK); | |
43 | if (!tcell) | |
44 | return ENOENT; | |
45 | vfid.Cell = tcell->cellNum; | |
46 | afs_PutCell(tcell, WRITE_LOCK); | |
47 | vfid.Fid.Volume = Sfid.Volume; | |
48 | vfid.Fid.Vnode = Sfid.Vnode; | |
49 | vfid.Fid.Unique = Sfid.CellAndUnique & 0xffffff; | |
50 | ||
51 | /* First attempt to find in cache using wildcard. If that fails, | |
52 | * try the usual route to try to get the vcache from the server. | |
53 | * This could be done better by splitting out afs_FindVCache from | |
54 | * afs_GetVCache. | |
55 | */ | |
56 | ||
57 | ret = afs_NFSFindVCache(avcpp, &vfid); | |
58 | if (ret > 1) { | |
59 | /* More than one entry matches. */ | |
60 | code = ENOENT; | |
61 | } else if (ret == 0) { | |
62 | /* didn't find an entry. */ | |
63 | code = afs_CreateReq(&treq, afs_osi_credp); | |
64 | if (code == 0) { | |
65 | *avcpp = afs_GetVCache(&vfid, treq, NULL, NULL); | |
66 | afs_DestroyReq(treq); | |
67 | } | |
68 | } | |
69 | if (!*avcpp) { | |
70 | code = ENOENT; | |
71 | } | |
72 | ||
73 | return code; | |
74 | } | |
75 | #endif /* AFS_LINUX20_ENV */ |