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(DirHandle *file, int block, char *data)
50 fdP = IH_OPEN(file->dirh_handle);
55 if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
60 code = FDH_READ(fdP, data, AFS_PAGESIZE);
61 if (code != AFS_PAGESIZE) {
73 /* returns 0 on success, errno on failure */
74 int ReallyWrite (DirHandle *file, int block, char *data)
77 extern int VolumeChanged;
82 fdP = IH_OPEN(file->dirh_handle);
87 if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
92 code = FDH_WRITE(fdP, data, AFS_PAGESIZE);
93 if (code != AFS_PAGESIZE) {
106 /* SetSalvageDirHandle:
107 * Create a handle to a directory entry and reference it (IH_INIT).
108 * The handle needs to be dereferenced with the FidZap() routine.
110 void SetSalvageDirHandle(DirHandle *dir, afs_int32 volume, Inode inode, afs_int32 device)
112 private SalvageCacheCheck = 1;
113 memset(dir, 0, sizeof(DirHandle));
115 dir->dirh_volume = volume;
116 dir->dirh_device = device;
117 dir->dirh_inode = inode;
118 IH_INIT(dir->dirh_handle, device, volume, inode);
120 /* Always re-read for a new dirhandle */
121 dir->dirh_cacheCheck = SalvageCacheCheck++;
124 void FidZap(DirHandle *file)
126 IH_RELEASE(file->dirh_handle);
127 memset(file, 0, sizeof(DirHandle));
130 void FidZero(DirHandle *file)
132 memset(file, 0, sizeof(DirHandle));
135 int FidEq(DirHandle *afile, DirHandle *bfile)
137 if (afile->dirh_volume != bfile->dirh_volume) return 0;
138 if (afile->dirh_device != bfile->dirh_device) return 0;
139 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck) return 0;
140 if (afile->dirh_inode != bfile->dirh_inode) return 0;
144 int FidVolEq(DirHandle *afile, afs_int32 vid)
146 if (afile->dirh_volume != vid) return 0;
150 void FidCpy(DirHandle *tofile, DirHandle *fromfile)
153 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);