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
15 Institution: The Information Technology Center, Carnegie-Mellon University
19 #include <afs/param.h>
21 #include <sys/types.h>
29 #include <sys/fcntl.h>
33 #include <afs/afsint.h>
35 #include <afs/afssyscalls.h>
39 #include "afs/assert.h"
42 /* returns 0 on success, errno on failure */
43 int ReallyRead (file, block, data)
51 fdP = IH_OPEN(file->dirh_handle);
56 if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
61 code = FDH_READ(fdP, data, AFS_PAGESIZE);
62 if (code != AFS_PAGESIZE) {
74 /* returns 0 on success, errno on failure */
75 int ReallyWrite (file, block, 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_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.
114 SetSalvageDirHandle(dir, volume, device, inode)
120 static SalvageCacheCheck = 1;
121 bzero(dir, sizeof(DirHandle));
123 dir->dirh_device = device;
124 dir->dirh_volume = volume;
125 dir->dirh_inode = inode;
126 IH_INIT(dir->dirh_handle, device, volume, inode);
127 /* Always re-read for a new dirhandle */
128 dir->dirh_cacheCheck = SalvageCacheCheck++;
135 IH_RELEASE(file->dirh_handle);
136 bzero(file, sizeof(DirHandle));
143 bzero(file, sizeof(DirHandle));
151 if (afile->dirh_volume != bfile->dirh_volume) return 0;
152 if (afile->dirh_device != bfile->dirh_device) return 0;
153 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck) return 0;
154 if (afile->dirh_inode != bfile->dirh_inode) return 0;
158 FidVolEq (afile, vid)
163 if (afile->dirh_volume != vid) return 0;
167 FidCpy (tofile, fromfile)
169 DirHandle * fromfile;
173 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);