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 /* physio.c - Physical I/O routines for the buffer package */
14 /************************************************************************/
16 #include <afsconfig.h>
17 #include <afs/param.h>
39 #include <afs/assert.h>
43 #include <afs/afsint.h>
44 #include <afs/ihandle.h>
45 #include <afs/vnode.h>
46 #include <afs/volume.h>
47 #include "viced_prototypes.h"
56 afs_int32 lpErrno, lpCount;
58 /* returns 0 on success, errno on failure */
60 ReallyRead(DirHandle * file, int block, char *data)
65 fdP = IH_OPEN(file->dirh_handle);
69 ("ReallyRead(): open failed device %X inode %s errno %d\n",
70 file->dirh_handle->ih_dev, PrintInode(NULL,
75 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
78 ("ReallyRead(): lseek failed device %X inode %s errno %d\n",
79 file->dirh_handle->ih_dev, PrintInode(NULL,
85 code = FDH_READ(fdP, data, PAGESIZE);
86 if (code != PAGESIZE) {
92 ("ReallyRead(): read failed device %X inode %s errno %d\n",
93 file->dirh_handle->ih_dev, PrintInode(NULL,
104 /* returns 0 on success, errno on failure */
106 ReallyWrite(DirHandle * file, int block, char *data)
111 fdP = IH_OPEN(file->dirh_handle);
114 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
115 file->dirh_handle->ih_dev, PrintInode(NULL,
121 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
123 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
124 file->dirh_handle->ih_dev, PrintInode(NULL,
128 FDH_REALLYCLOSE(fdP);
131 if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) {
133 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
134 file->dirh_handle->ih_dev, PrintInode(NULL,
139 FDH_REALLYCLOSE(fdP);
148 SetDirHandle(register DirHandle * dir, register Vnode * vnode)
150 register Volume *vp = vnode->volumePtr;
151 register IHandle_t *h;
152 IH_COPY(h, vnode->handle);
153 dir->dirh_ino = h->ih_ino;
154 dir->dirh_dev = h->ih_dev;
155 dir->dirh_vid = h->ih_vid;
156 dir->dirh_cacheCheck = vp->cacheCheck;
157 dir->dirh_unique = vnode->disk.uniquifier;
158 dir->dirh_vnode = vnode->vnodeNumber;
159 dir->dirh_handle = h;
163 FidZap(DirHandle * file)
165 IH_RELEASE(file->dirh_handle);
166 memset((char *)file, 0, sizeof(DirHandle));
170 FidZero(DirHandle * file)
172 memset((char *)file, 0, sizeof(DirHandle));
176 FidEq(DirHandle * afile, DirHandle * bfile)
178 if (afile->dirh_ino != bfile->dirh_ino)
180 if (afile->dirh_dev != bfile->dirh_dev)
182 if (afile->dirh_vid != bfile->dirh_vid)
184 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
186 if (afile->dirh_unique != bfile->dirh_unique)
188 if (afile->dirh_vnode != bfile->dirh_vnode)
195 FidVolEq(DirHandle * afile, afs_int32 vid)
197 if (afile->dirh_vid != vid)
203 FidCpy(DirHandle * tofile, DirHandle * fromfile)
206 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);