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>
22 #include <sys/types.h>
31 #include <sys/fcntl.h>
35 #include <afs/afsint.h>
37 #include <afs/afssyscalls.h>
43 #include "vol_internal.h"
45 /* returns 0 on success, errno on failure */
47 ReallyRead(DirHandle * file, int block, char *data)
53 fdP = IH_OPEN(file->dirh_handle);
58 if (FDH_SEEK(fdP, ((afs_foff_t)block) * AFS_PAGESIZE, SEEK_SET) < 0) {
63 nBytes = FDH_READ(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
64 if (nBytes != AFS_PAGESIZE) {
76 /* returns 0 on success, errno on failure */
78 ReallyWrite(DirHandle * file, int block, char *data)
81 extern int VolumeChanged;
87 fdP = IH_OPEN(file->dirh_handle);
92 if (FDH_SEEK(fdP, ((afs_foff_t)block) * AFS_PAGESIZE, SEEK_SET) < 0) {
97 nBytes = FDH_WRITE(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
98 if (nBytes != AFS_PAGESIZE) {
103 FDH_REALLYCLOSE(fdP);
111 /* SetSalvageDirHandle:
112 * Create a handle to a directory entry and reference it (IH_INIT).
113 * The handle needs to be dereferenced with the FidZap() routine.
116 SetSalvageDirHandle(DirHandle * dir, afs_int32 volume, Device device,
119 static int SalvageCacheCheck = 1;
120 memset(dir, 0, sizeof(DirHandle));
122 dir->dirh_device = device;
123 dir->dirh_volume = volume;
124 dir->dirh_inode = inode;
125 IH_INIT(dir->dirh_handle, device, volume, inode);
126 /* Always re-read for a new dirhandle */
127 dir->dirh_cacheCheck = SalvageCacheCheck++;
131 FidZap(DirHandle * file)
133 IH_RELEASE(file->dirh_handle);
134 memset(file, 0, sizeof(DirHandle));
138 FidZero(DirHandle * file)
140 memset(file, 0, sizeof(DirHandle));
144 FidEq(DirHandle * afile, DirHandle * bfile)
146 if (afile->dirh_volume != bfile->dirh_volume)
148 if (afile->dirh_device != bfile->dirh_device)
150 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
152 if (afile->dirh_inode != bfile->dirh_inode)
158 FidVolEq(DirHandle * afile, afs_int32 vid)
160 if (afile->dirh_volume != vid)
166 FidCpy(DirHandle * tofile, DirHandle * fromfile)
169 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);