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>
38 #include <afs/assert.h>
42 #include <afs/afsint.h>
43 #include <afs/ihandle.h>
44 #include <afs/vnode.h>
45 #include <afs/volume.h>
46 #include "viced_prototypes.h"
51 #define PAGESIZE (afs_size_t)2048
55 afs_int32 lpErrno, lpCount;
57 /* returns 0 on success, errno on failure */
58 int ReallyRead (file, block, data)
66 fdP = IH_OPEN(file->dirh_handle);
70 ("ReallyRead(): open failed device %X inode %s errno %d\n",
71 file->dirh_handle->ih_dev,
72 PrintInode(NULL, file->dirh_handle->ih_ino), code));
75 if (FDH_SEEK(fdP, (afs_size_t)block * PAGESIZE, SEEK_SET) < 0) {
78 ("ReallyRead(): lseek failed device %X inode %s errno %d\n",
79 file->dirh_handle->ih_dev,
80 PrintInode(NULL, file->dirh_handle->ih_ino), code));
84 code = FDH_READ(fdP, data, PAGESIZE);
85 if (code != PAGESIZE) {
91 ("ReallyRead(): read failed device %X inode %s errno %d\n",
92 file->dirh_handle->ih_dev,
93 PrintInode(NULL, file->dirh_handle->ih_ino), code));
102 /* returns 0 on success, errno on failure */
103 int ReallyWrite (file, block, data)
111 fdP = IH_OPEN(file->dirh_handle);
114 ("ReallyWrite(): open failed device %X inode %s errno %d\n",
115 file->dirh_handle->ih_dev,
116 PrintInode(NULL, file->dirh_handle->ih_ino), errno));
120 if (FDH_SEEK(fdP, (afs_size_t) block * PAGESIZE, SEEK_SET) < 0) {
122 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
123 file->dirh_handle->ih_dev,
124 PrintInode(NULL, file->dirh_handle->ih_ino), errno));
126 FDH_REALLYCLOSE(fdP);
129 if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) {
131 ("ReallyWrite(): write failed device %X inode %s errno %d\n",
132 file->dirh_handle->ih_dev,
133 PrintInode(NULL, file->dirh_handle->ih_ino), errno));
136 FDH_REALLYCLOSE(fdP);
144 SetDirHandle(dir, vnode)
145 register DirHandle *dir;
146 register Vnode *vnode;
148 register Volume *vp = vnode->volumePtr;
149 register IHandle_t *h;
150 IH_COPY(h, vnode->handle);
151 dir->dirh_ino = h->ih_ino;
152 dir->dirh_dev = h->ih_dev;
153 dir->dirh_vid = h->ih_vid;
154 dir->dirh_cacheCheck = vp->cacheCheck;
155 dir->dirh_unique = vnode->disk.uniquifier;
156 dir->dirh_vnode = vnode->vnodeNumber;
157 dir->dirh_handle = h;
164 IH_RELEASE(file->dirh_handle);
165 memset((char *)file, 0, sizeof(DirHandle));
172 memset((char *)file, 0, sizeof(DirHandle));
180 if (afile->dirh_ino != bfile->dirh_ino) return 0;
181 if (afile->dirh_dev != bfile->dirh_dev) return 0;
182 if (afile->dirh_vid != bfile->dirh_vid) return 0;
183 if (afile->dirh_cacheCheck != bfile->dirh_cacheCheck) return 0;
184 if (afile->dirh_unique != bfile->dirh_unique) return 0;
185 if (afile->dirh_vnode != bfile->dirh_vnode) return 0;
190 FidVolEq (afile, vid)
195 if (afile->dirh_vid != vid) return 0;
199 FidCpy (tofile, fromfile)
201 DirHandle * fromfile;
205 IH_COPY(tofile->dirh_handle, fromfile->dirh_handle);