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
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #include <sys/types.h>
20 #include <netinet/in.h>
31 #include <sys/fcntl.h>
37 #include <afs/afsint.h>
39 #include <afs/assert.h>
41 #include <afs/ihandle.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 private SalvageCacheCheck = 1;
123 memset(dir, 0, sizeof(DirHandle));
125 dir->dirh_volume = volume;
126 dir->dirh_device = device;
127 dir->dirh_inode = inode;
128 IH_INIT(dir->dirh_handle, device, volume, inode);
130 /* Always re-read for a new dirhandle */
131 dir->dirh_cacheCheck = SalvageCacheCheck++;
138 IH_RELEASE(file->dirh_handle);
139 memset(file, 0, sizeof(DirHandle));
146 memset(file, 0, sizeof(DirHandle));
154 if (afile->dirh_volume != bfile->dirh_volume) return 0;
155 if (afile->dirh_device != bfile->dirh_device) return 0;
156 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck) return 0;
157 if (afile->dirh_inode != bfile->dirh_inode) return 0;
161 FidVolEq (afile, vid)
166 if (afile->dirh_volume != vid) return 0;
170 FidCpy (tofile, fromfile)
172 DirHandle * fromfile;
176 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);