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"
54 afs_int32 lpErrno, lpCount;
56 /* returns 0 on success, errno on failure */
58 ReallyRead(DirHandle * file, int block, char *data)
63 fdP = IH_OPEN(file->dirh_handle);
67 ("ReallyRead(): open failed device %X inode %s errno %d\n",
68 file->dirh_handle->ih_dev, PrintInode(NULL,
73 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
76 ("ReallyRead(): lseek failed device %X inode %s errno %d\n",
77 file->dirh_handle->ih_dev, PrintInode(NULL,
83 code = FDH_READ(fdP, data, PAGESIZE);
84 if (code != PAGESIZE) {
90 ("ReallyRead(): read failed device %X inode %s errno %d\n",
91 file->dirh_handle->ih_dev, PrintInode(NULL,
102 /* returns 0 on success, errno on failure */
104 ReallyWrite(DirHandle * file, int block, char *data)
109 fdP = IH_OPEN(file->dirh_handle);
112 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
113 file->dirh_handle->ih_dev, PrintInode(NULL,
119 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
121 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
122 file->dirh_handle->ih_dev, PrintInode(NULL,
126 FDH_REALLYCLOSE(fdP);
129 if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) {
131 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
132 file->dirh_handle->ih_dev, PrintInode(NULL,
137 FDH_REALLYCLOSE(fdP);
146 SetDirHandle(register DirHandle * dir, register Vnode * vnode)
148 register Volume *vp = vnode->volumePtr;
149 register IHandle_t *h;
150 IH_COPY(h, vnode->handle);
151 dir->dirh_ino = h->ih_ino;
152 dir->dirh_dev = h->ih_dev;
153 dir->dirh_vid = h->ih_vid;
154 dir->dirh_cacheCheck = vp->cacheCheck;
155 dir->dirh_unique = vnode->disk.uniquifier;
156 dir->dirh_vnode = vnode->vnodeNumber;
157 dir->dirh_handle = h;
161 FidZap(DirHandle * file)
163 IH_RELEASE(file->dirh_handle);
164 memset((char *)file, 0, sizeof(DirHandle));
168 FidZero(DirHandle * file)
170 memset((char *)file, 0, sizeof(DirHandle));
174 FidEq(DirHandle * afile, DirHandle * bfile)
176 if (afile->dirh_ino != bfile->dirh_ino)
178 if (afile->dirh_dev != bfile->dirh_dev)
180 if (afile->dirh_vid != bfile->dirh_vid)
182 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
184 if (afile->dirh_unique != bfile->dirh_unique)
186 if (afile->dirh_vnode != bfile->dirh_vnode)
193 FidVolEq(DirHandle * afile, afs_int32 vid)
195 if (afile->dirh_vid != vid)
201 FidCpy(DirHandle * tofile, DirHandle * fromfile)
204 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);