2 * Copyright 2000, International Business Machines Corporation and others.
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
13 Institution: The Information Technology Center, Carnegie-Mellon University
17 #include <afsconfig.h>
18 #include <afs/param.h>
24 #include <sys/types.h>
33 #include <sys/fcntl.h>
37 #include <afs/afsint.h>
39 #include <afs/afssyscalls.h>
43 #include "afs/assert.h"
46 /* returns 0 on success, errno on failure */
48 ReallyRead(DirHandle * file, int block, char *data)
53 fdP = IH_OPEN(file->dirh_handle);
58 if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
63 code = FDH_READ(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
64 if (code != AFS_PAGESIZE) {
76 /* returns 0 on success, errno on failure */
78 ReallyWrite(DirHandle * file, int block, char *data)
81 extern int VolumeChanged;
86 fdP = IH_OPEN(file->dirh_handle);
91 if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
96 code = FDH_WRITE(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
97 if (code != AFS_PAGESIZE) {
102 FDH_REALLYCLOSE(fdP);
110 /* SetSalvageDirHandle:
111 * Create a handle to a directory entry and reference it (IH_INIT).
112 * The handle needs to be dereferenced with the FidZap() routine.
115 SetSalvageDirHandle(DirHandle * dir, afs_int32 volume, Device device,
118 static SalvageCacheCheck = 1;
119 memset(dir, 0, sizeof(DirHandle));
121 dir->dirh_device = device;
122 dir->dirh_volume = volume;
123 dir->dirh_inode = inode;
124 IH_INIT(dir->dirh_handle, device, volume, inode);
125 /* Always re-read for a new dirhandle */
126 dir->dirh_cacheCheck = SalvageCacheCheck++;
130 FidZap(DirHandle * file)
132 IH_RELEASE(file->dirh_handle);
133 memset(file, 0, sizeof(DirHandle));
137 FidZero(DirHandle * file)
139 memset(file, 0, sizeof(DirHandle));
143 FidEq(DirHandle * afile, DirHandle * bfile)
145 if (afile->dirh_volume != bfile->dirh_volume)
147 if (afile->dirh_device != bfile->dirh_device)
149 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
151 if (afile->dirh_inode != bfile->dirh_inode)
157 FidVolEq(DirHandle * afile, afs_int32 vid)
159 if (afile->dirh_volume != vid)
165 FidCpy(DirHandle * tofile, DirHandle * fromfile)
168 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);