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>
14 #include <sys/types.h>
19 #include <netinet/in.h>
24 #include <sys/fcntl.h>
30 #include <afs/afsint.h>
32 #include <afs/afs_assert.h>
34 #include <afs/ihandle.h>
38 /* returns 0 on success, errno on failure */
40 ReallyRead(DirHandle * file, int block, char *data)
46 fdP = IH_OPEN(file->dirh_handle);
51 nBytes = FDH_PREAD(fdP, data, AFS_PAGESIZE, ((afs_foff_t)block) * AFS_PAGESIZE);
52 if (nBytes != AFS_PAGESIZE) {
64 /* returns 0 on success, errno on failure */
66 ReallyWrite(DirHandle * file, int block, char *data)
69 extern int VolumeChanged;
75 fdP = IH_OPEN(file->dirh_handle);
80 nBytes = FDH_PWRITE(fdP, data, AFS_PAGESIZE, ((afs_foff_t)block) * AFS_PAGESIZE);
81 if (nBytes != AFS_PAGESIZE) {
94 /* SetSalvageDirHandle:
95 * Create a handle to a directory entry and reference it (IH_INIT).
96 * The handle needs to be dereferenced with the FidZap() routine.
99 SetSalvageDirHandle(DirHandle * dir, afs_uint32 volume, afs_int32 device,
102 private int SalvageCacheCheck = 1;
103 memset(dir, 0, sizeof(DirHandle));
105 dir->dirh_volume = volume;
106 dir->dirh_device = device;
107 dir->dirh_inode = inode;
108 IH_INIT(dir->dirh_handle, device, volume, inode);
110 /* Always re-read for a new dirhandle */
111 dir->dirh_cacheCheck = SalvageCacheCheck++;
115 FidZap(DirHandle * file)
117 IH_RELEASE(file->dirh_handle);
118 memset(file, 0, sizeof(DirHandle));
122 FidZero(DirHandle * file)
124 memset(file, 0, sizeof(DirHandle));
128 FidEq(DirHandle * afile, DirHandle * bfile)
130 if (afile->dirh_volume != bfile->dirh_volume)
132 if (afile->dirh_device != bfile->dirh_device)
134 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
136 if (afile->dirh_inode != bfile->dirh_inode)
142 FidVolEq(DirHandle * afile, afs_int32 vid)
144 if (afile->dirh_volume != vid)
150 FidCpy(DirHandle * tofile, DirHandle * fromfile)
153 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);