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)
55 fdP = IH_OPEN(file->dirh_handle);
59 ("ReallyRead(): open failed device %X inode %s errno %d\n",
60 file->dirh_handle->ih_dev, PrintInode(NULL,
65 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
68 ("ReallyRead(): lseek failed device %X inode %s errno %d\n",
69 file->dirh_handle->ih_dev, PrintInode(NULL,
75 code = FDH_READ(fdP, data, PAGESIZE);
76 if (code != PAGESIZE) {
82 ("ReallyRead(): read failed device %X inode %s errno %d\n",
83 file->dirh_handle->ih_dev, PrintInode(NULL,
94 /* returns 0 on success, errno on failure */
96 ReallyWrite(DirHandle * file, int block, char *data)
101 fdP = IH_OPEN(file->dirh_handle);
104 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
105 file->dirh_handle->ih_dev, PrintInode(NULL,
111 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
113 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
114 file->dirh_handle->ih_dev, PrintInode(NULL,
118 FDH_REALLYCLOSE(fdP);
121 if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) {
123 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
124 file->dirh_handle->ih_dev, PrintInode(NULL,
129 FDH_REALLYCLOSE(fdP);
138 SetDirHandle(register DirHandle * dir, register Vnode * vnode)
140 register Volume *vp = vnode->volumePtr;
141 register IHandle_t *h;
142 IH_COPY(h, vnode->handle);
143 dir->dirh_ino = h->ih_ino;
144 dir->dirh_dev = h->ih_dev;
145 dir->dirh_vid = h->ih_vid;
146 dir->dirh_cacheCheck = vp->cacheCheck;
147 dir->dirh_unique = vnode->disk.uniquifier;
148 dir->dirh_vnode = vnode->vnodeNumber;
149 dir->dirh_handle = h;
153 FidZap(DirHandle * file)
155 IH_RELEASE(file->dirh_handle);
156 memset((char *)file, 0, sizeof(DirHandle));
160 FidZero(DirHandle * file)
162 memset((char *)file, 0, sizeof(DirHandle));
166 FidEq(DirHandle * afile, DirHandle * bfile)
168 if (afile->dirh_ino != bfile->dirh_ino)
170 if (afile->dirh_dev != bfile->dirh_dev)
172 if (afile->dirh_vid != bfile->dirh_vid)
174 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
176 if (afile->dirh_unique != bfile->dirh_unique)
178 if (afile->dirh_vnode != bfile->dirh_vnode)
185 FidVolEq(DirHandle * afile, afs_int32 vid)
187 if (afile->dirh_vid != vid)
193 FidCpy(DirHandle * tofile, DirHandle * fromfile)
196 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);