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>
31 #include <afs/assert.h>
35 #include <afs/afsint.h>
36 #include <afs/ihandle.h>
37 #include <afs/vnode.h>
38 #include <afs/volume.h>
39 #include "viced_prototypes.h"
46 afs_int32 lpErrno, lpCount;
48 /* returns 0 on success, errno on failure */
50 ReallyRead(DirHandle * file, int block, char *data)
56 fdP = IH_OPEN(file->dirh_handle);
60 ("ReallyRead(): open failed device %X inode %s errno %d\n",
61 file->dirh_handle->ih_dev, PrintInode(NULL,
66 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
69 ("ReallyRead(): lseek failed device %X inode %s errno %d\n",
70 file->dirh_handle->ih_dev, PrintInode(NULL,
76 rdlen = FDH_READ(fdP, data, PAGESIZE);
77 if (rdlen != PAGESIZE) {
83 ("ReallyRead(): read failed device %X inode %s errno %d\n",
84 file->dirh_handle->ih_dev, PrintInode(NULL,
95 /* returns 0 on success, errno on failure */
97 ReallyWrite(DirHandle * file, int block, char *data)
102 fdP = IH_OPEN(file->dirh_handle);
105 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
106 file->dirh_handle->ih_dev, PrintInode(NULL,
112 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
114 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
115 file->dirh_handle->ih_dev, PrintInode(NULL,
119 FDH_REALLYCLOSE(fdP);
122 if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) {
124 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
125 file->dirh_handle->ih_dev, PrintInode(NULL,
130 FDH_REALLYCLOSE(fdP);
139 SetDirHandle(DirHandle * dir, Vnode * vnode)
141 Volume *vp = vnode->volumePtr;
143 IH_COPY(h, vnode->handle);
144 dir->dirh_ino = h->ih_ino;
145 dir->dirh_dev = h->ih_dev;
146 dir->dirh_vid = h->ih_vid;
147 dir->dirh_cacheCheck = vp->cacheCheck;
148 dir->dirh_unique = vnode->disk.uniquifier;
149 dir->dirh_vnode = vnode->vnodeNumber;
150 dir->dirh_handle = h;
154 FidZap(DirHandle * file)
156 IH_RELEASE(file->dirh_handle);
157 memset(file, 0, sizeof(DirHandle));
161 FidZero(DirHandle * file)
163 memset(file, 0, sizeof(DirHandle));
167 FidEq(DirHandle * afile, DirHandle * bfile)
169 if (afile->dirh_ino != bfile->dirh_ino)
171 if (afile->dirh_dev != bfile->dirh_dev)
173 if (afile->dirh_vid != bfile->dirh_vid)
175 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
177 if (afile->dirh_unique != bfile->dirh_unique)
179 if (afile->dirh_vnode != bfile->dirh_vnode)
186 FidVolEq(DirHandle * afile, afs_int32 vid)
188 if (afile->dirh_vid != vid)
194 FidCpy(DirHandle * tofile, DirHandle * fromfile)
197 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);