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>
21 #ifdef HAVE_SYS_FILE_H
28 #include <afs/afsint.h>
29 #include <afs/ihandle.h>
30 #include <afs/vnode.h>
31 #include <afs/volume.h>
32 #include "viced_prototypes.h"
39 afs_int32 lpErrno, lpCount;
41 /* returns 0 on success, errno on failure */
43 ReallyRead(DirHandle * file, int block, char *data)
50 fdP = IH_OPEN(file->dirh_handle);
54 ("ReallyRead(): open failed device %X inode %s errno %d\n",
55 file->dirh_handle->ih_dev, PrintInode(stmp,
60 rdlen = FDH_PREAD(fdP, data, PAGESIZE, ((afs_foff_t)block) * PAGESIZE);
61 if (rdlen != PAGESIZE) {
67 ("ReallyRead(): read failed device %X inode %s errno %d\n",
68 file->dirh_handle->ih_dev, PrintInode(stmp,
79 /* returns 0 on success, errno on failure */
81 ReallyWrite(DirHandle * file, int block, char *data)
87 fdP = IH_OPEN(file->dirh_handle);
90 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
91 file->dirh_handle->ih_dev, PrintInode(stmp,
97 if ((count = FDH_PWRITE(fdP, data, PAGESIZE, ((afs_foff_t)block) * PAGESIZE)) != PAGESIZE) {
99 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
100 file->dirh_handle->ih_dev, PrintInode(stmp,
105 FDH_REALLYCLOSE(fdP);
114 SetDirHandle(DirHandle * dir, Vnode * vnode)
116 Volume *vp = vnode->volumePtr;
118 IH_COPY(h, vnode->handle);
119 dir->dirh_ino = h->ih_ino;
120 dir->dirh_dev = h->ih_dev;
121 dir->dirh_vid = h->ih_vid;
122 dir->dirh_cacheCheck = vp->cacheCheck;
123 dir->dirh_unique = vnode->disk.uniquifier;
124 dir->dirh_vnode = vnode->vnodeNumber;
125 dir->dirh_handle = h;
129 FidZap(DirHandle * file)
131 IH_RELEASE(file->dirh_handle);
132 memset(file, 0, sizeof(DirHandle));
136 FidZero(DirHandle * file)
138 memset(file, 0, sizeof(DirHandle));
142 FidEq(DirHandle * afile, DirHandle * bfile)
144 if (afile->dirh_ino != bfile->dirh_ino)
146 if (afile->dirh_dev != bfile->dirh_dev)
148 if (afile->dirh_vid != bfile->dirh_vid)
150 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck)
152 if (afile->dirh_unique != bfile->dirh_unique)
154 if (afile->dirh_vnode != bfile->dirh_vnode)
161 FidVolEq(DirHandle * afile, afs_int32 vid)
163 if (afile->dirh_vid != vid)
169 FidCpy(DirHandle * tofile, DirHandle * fromfile)
172 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);