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>
22 #ifdef HAVE_SYS_FILE_H
27 #include <afs/afsint.h>
28 #include <afs/afssyscalls.h>
33 #include "vol_internal.h"
36 * Read the specified page from a directory object
38 * \parm[in] file handle to the directory object
39 * \parm[in] block requested page from the directory object
40 * \parm[out] data buffer for the returned page
41 * \parm[out] physerr (optional) pointer to errno if physical error
44 * \retval EIO physical or logical error;
45 * if physerr is supplied by caller, it will be set to:
46 * 0 for logical errors
47 * errno for physical errors
50 ReallyRead(DirHandle *file, int block, char *data, int *physerr)
58 fdP = IH_OPEN(file->dirh_handle);
64 nBytes = FDH_PREAD(fdP, data, (afs_fsize_t) AFS_PAGESIZE,
65 ((afs_foff_t)block) * AFS_PAGESIZE);
66 if (nBytes != AFS_PAGESIZE) {
70 saverr = 0; /* logical error: short read */
83 /* returns 0 on success, errno on failure */
85 ReallyWrite(DirHandle * file, int block, char *data)
93 fdP = IH_OPEN(file->dirh_handle);
98 nBytes = FDH_PWRITE(fdP, data, (afs_fsize_t) AFS_PAGESIZE,
99 ((afs_foff_t)block) * AFS_PAGESIZE);
100 if (nBytes != AFS_PAGESIZE) {
105 FDH_REALLYCLOSE(fdP);
109 *(file->volumeChanged) = 1;
113 /* SetSalvageDirHandle:
114 * Create a handle to a directory entry and reference it (IH_INIT).
115 * The handle needs to be dereferenced with the FidZap() routine.
118 SetSalvageDirHandle(DirHandle * dir, VolumeId volume, Device device,
119 Inode inode, int *volumeChanged)
121 static int SalvageCacheCheck = 1;
122 memset(dir, 0, sizeof(DirHandle));
124 dir->dirh_device = device;
125 dir->dirh_volume = volume;
126 dir->dirh_inode = inode;
127 IH_INIT(dir->dirh_handle, device, volume, inode);
128 /* Always re-read for a new dirhandle */
129 dir->dirh_cacheCheck = SalvageCacheCheck++;
130 dir->volumeChanged = volumeChanged;
134 FidZap(DirHandle * file)
136 IH_RELEASE(file->dirh_handle);
137 memset(file, 0, sizeof(DirHandle));
141 FidZero(DirHandle * file)
143 memset(file, 0, sizeof(DirHandle));
147 FidEq(DirHandle * afile, DirHandle * bfile)
149 if (afile->dirh_volume != bfile->dirh_volume)
151 if (afile->dirh_device != bfile->dirh_device)
153 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
155 if (afile->dirh_inode != bfile->dirh_inode)
161 FidVolEq(DirHandle * afile, VolumeId vid)
163 if (afile->dirh_volume != vid)
169 FidCpy(DirHandle * tofile, DirHandle * fromfile)
172 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);
179 osi_Panic("%s\n", msg);