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>
23 #include <sys/types.h>
31 #include <sys/fcntl.h>
35 #include <afs/afsint.h>
37 #include <afs/afssyscalls.h>
41 #include "afs/assert.h"
44 /* returns 0 on success, errno on failure */
45 int ReallyRead (file, block, 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_PAGESIZE);
64 if (code != AFS_PAGESIZE) {
76 /* returns 0 on success, errno on failure */
77 int ReallyWrite (file, block, data)
83 extern int VolumeChanged;
88 fdP = IH_OPEN(file->dirh_handle);
93 if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
98 code = FDH_WRITE(fdP, data, AFS_PAGESIZE);
99 if (code != AFS_PAGESIZE) {
104 FDH_REALLYCLOSE(fdP);
112 /* SetSalvageDirHandle:
113 * Create a handle to a directory entry and reference it (IH_INIT).
114 * The handle needs to be dereferenced with the FidZap() routine.
116 SetSalvageDirHandle(dir, volume, device, inode)
122 static SalvageCacheCheck = 1;
123 memset(dir, 0, sizeof(DirHandle));
125 dir->dirh_device = device;
126 dir->dirh_volume = volume;
127 dir->dirh_inode = inode;
128 IH_INIT(dir->dirh_handle, device, volume, inode);
129 /* Always re-read for a new dirhandle */
130 dir->dirh_cacheCheck = SalvageCacheCheck++;
137 IH_RELEASE(file->dirh_handle);
138 memset(file, 0, sizeof(DirHandle));
145 memset(file, 0, sizeof(DirHandle));
153 if (afile->dirh_volume != bfile->dirh_volume) return 0;
154 if (afile->dirh_device != bfile->dirh_device) return 0;
155 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck) return 0;
156 if (afile->dirh_inode != bfile->dirh_inode) return 0;
160 FidVolEq (afile, vid)
165 if (afile->dirh_volume != vid) return 0;
169 FidCpy (tofile, fromfile)
171 DirHandle * fromfile;
175 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);