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)
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(stmp,
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 rdlen = FDH_READ(fdP, data, PAGESIZE);
78 if (rdlen != PAGESIZE) {
84 ("ReallyRead(): read failed device %X inode %s errno %d\n",
85 file->dirh_handle->ih_dev, PrintInode(stmp,
96 /* returns 0 on success, errno on failure */
98 ReallyWrite(DirHandle * file, int block, char *data)
104 fdP = IH_OPEN(file->dirh_handle);
107 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
108 file->dirh_handle->ih_dev, PrintInode(stmp,
114 if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
116 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
117 file->dirh_handle->ih_dev, PrintInode(NULL,
121 FDH_REALLYCLOSE(fdP);
124 if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) {
126 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
127 file->dirh_handle->ih_dev, PrintInode(stmp,
132 FDH_REALLYCLOSE(fdP);
141 SetDirHandle(DirHandle * dir, Vnode * vnode)
143 Volume *vp = vnode->volumePtr;
145 IH_COPY(h, vnode->handle);
146 dir->dirh_ino = h->ih_ino;
147 dir->dirh_dev = h->ih_dev;
148 dir->dirh_vid = h->ih_vid;
149 dir->dirh_cacheCheck = vp->cacheCheck;
150 dir->dirh_unique = vnode->disk.uniquifier;
151 dir->dirh_vnode = vnode->vnodeNumber;
152 dir->dirh_handle = h;
156 FidZap(DirHandle * file)
158 IH_RELEASE(file->dirh_handle);
159 memset(file, 0, sizeof(DirHandle));
163 FidZero(DirHandle * file)
165 memset(file, 0, sizeof(DirHandle));
169 FidEq(DirHandle * afile, DirHandle * bfile)
171 if (afile->dirh_ino != bfile->dirh_ino)
173 if (afile->dirh_dev != bfile->dirh_dev)
175 if (afile->dirh_vid != bfile->dirh_vid)
177 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
179 if (afile->dirh_unique != bfile->dirh_unique)
181 if (afile->dirh_vnode != bfile->dirh_vnode)
188 FidVolEq(DirHandle * afile, afs_int32 vid)
190 if (afile->dirh_vid != vid)
196 FidCpy(DirHandle * tofile, DirHandle * fromfile)
199 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);