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>
39 #include <sys/fcntl.h>
43 #include <afs/afsint.h>
45 #include <afs/afssyscalls.h>
49 #include "afs/assert.h"
52 /* returns 0 on success, errno on failure */
54 ReallyRead(DirHandle * file, int block, char *data)
59 fdP = IH_OPEN(file->dirh_handle);
64 if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
69 code = FDH_READ(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
70 if (code != AFS_PAGESIZE) {
82 /* returns 0 on success, errno on failure */
84 ReallyWrite(DirHandle * file, int block, char *data)
87 extern int VolumeChanged;
92 fdP = IH_OPEN(file->dirh_handle);
97 if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
102 code = FDH_WRITE(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
103 if (code != AFS_PAGESIZE) {
108 FDH_REALLYCLOSE(fdP);
116 /* SetSalvageDirHandle:
117 * Create a handle to a directory entry and reference it (IH_INIT).
118 * The handle needs to be dereferenced with the FidZap() routine.
121 SetSalvageDirHandle(DirHandle * dir, afs_int32 volume, Device device,
124 static SalvageCacheCheck = 1;
125 memset(dir, 0, sizeof(DirHandle));
127 dir->dirh_device = device;
128 dir->dirh_volume = volume;
129 dir->dirh_inode = inode;
130 IH_INIT(dir->dirh_handle, device, volume, inode);
131 /* Always re-read for a new dirhandle */
132 dir->dirh_cacheCheck = SalvageCacheCheck++;
136 FidZap(DirHandle * file)
138 IH_RELEASE(file->dirh_handle);
139 memset(file, 0, sizeof(DirHandle));
143 FidZero(DirHandle * file)
145 memset(file, 0, sizeof(DirHandle));
149 FidEq(DirHandle * afile, DirHandle * bfile)
151 if (afile->dirh_volume != bfile->dirh_volume)
153 if (afile->dirh_device != bfile->dirh_device)
155 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
157 if (afile->dirh_inode != bfile->dirh_inode)
163 FidVolEq(DirHandle * afile, afs_int32 vid)
165 if (afile->dirh_volume != vid)
171 FidCpy(DirHandle * tofile, DirHandle * fromfile)
174 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);