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>
33 #include <afs/assert.h>
37 #include <afs/afsint.h>
38 #include <afs/ihandle.h>
39 #include <afs/vnode.h>
40 #include <afs/volume.h>
41 #include "viced_prototypes.h"
48 afs_int32 lpErrno, lpCount;
50 /* returns 0 on success, errno on failure */
52 ReallyRead(DirHandle * file, int block, char *data)
57 fdP = IH_OPEN(file->dirh_handle);
61 ("ReallyRead(): open failed device %X inode %s errno %d\n",
62 file->dirh_handle->ih_dev, PrintInode(NULL,
67 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
70 ("ReallyRead(): lseek failed device %X inode %s errno %d\n",
71 file->dirh_handle->ih_dev, PrintInode(NULL,
77 code = FDH_READ(fdP, data, PAGESIZE);
78 if (code != PAGESIZE) {
84 ("ReallyRead(): read failed device %X inode %s errno %d\n",
85 file->dirh_handle->ih_dev, PrintInode(NULL,
96 /* returns 0 on success, errno on failure */
98 ReallyWrite(DirHandle * file, int block, char *data)
103 fdP = IH_OPEN(file->dirh_handle);
106 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
107 file->dirh_handle->ih_dev, PrintInode(NULL,
113 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
115 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
116 file->dirh_handle->ih_dev, PrintInode(NULL,
120 FDH_REALLYCLOSE(fdP);
123 if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) {
125 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
126 file->dirh_handle->ih_dev, PrintInode(NULL,
131 FDH_REALLYCLOSE(fdP);
140 SetDirHandle(register DirHandle * dir, register Vnode * vnode)
142 register Volume *vp = vnode->volumePtr;
143 register IHandle_t *h;
144 IH_COPY(h, vnode->handle);
145 dir->dirh_ino = h->ih_ino;
146 dir->dirh_dev = h->ih_dev;
147 dir->dirh_vid = h->ih_vid;
148 dir->dirh_cacheCheck = vp->cacheCheck;
149 dir->dirh_unique = vnode->disk.uniquifier;
150 dir->dirh_vnode = vnode->vnodeNumber;
151 dir->dirh_handle = h;
155 FidZap(DirHandle * file)
157 IH_RELEASE(file->dirh_handle);
158 memset((char *)file, 0, sizeof(DirHandle));
162 FidZero(DirHandle * file)
164 memset((char *)file, 0, sizeof(DirHandle));
168 FidEq(DirHandle * afile, DirHandle * bfile)
170 if (afile->dirh_ino != bfile->dirh_ino)
172 if (afile->dirh_dev != bfile->dirh_dev)
174 if (afile->dirh_vid != bfile->dirh_vid)
176 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
178 if (afile->dirh_unique != bfile->dirh_unique)
180 if (afile->dirh_vnode != bfile->dirh_vnode)
187 FidVolEq(DirHandle * afile, afs_int32 vid)
189 if (afile->dirh_vid != vid)
195 FidCpy(DirHandle * tofile, DirHandle * fromfile)
198 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);