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
13 Institution: The Information Technology Center, Carnegie-Mellon University
17 #include <afsconfig.h>
18 #include <afs/param.h>
22 #ifdef HAVE_SYS_FILE_H
27 #include <afs/afsint.h>
28 #include <afs/afssyscalls.h>
33 #include "vol_internal.h"
35 /* returns 0 on success, errno on failure */
37 ReallyRead(DirHandle
* file
, int block
, char *data
)
43 fdP
= IH_OPEN(file
->dirh_handle
);
48 nBytes
= FDH_PREAD(fdP
, data
, (afs_fsize_t
) AFS_PAGESIZE
,
49 ((afs_foff_t
)block
) * AFS_PAGESIZE
);
50 if (nBytes
!= AFS_PAGESIZE
) {
62 /* returns 0 on success, errno on failure */
64 ReallyWrite(DirHandle
* file
, int block
, char *data
)
72 fdP
= IH_OPEN(file
->dirh_handle
);
77 nBytes
= FDH_PWRITE(fdP
, data
, (afs_fsize_t
) AFS_PAGESIZE
,
78 ((afs_foff_t
)block
) * AFS_PAGESIZE
);
79 if (nBytes
!= AFS_PAGESIZE
) {
88 *(file
->volumeChanged
) = 1;
92 /* SetSalvageDirHandle:
93 * Create a handle to a directory entry and reference it (IH_INIT).
94 * The handle needs to be dereferenced with the FidZap() routine.
97 SetSalvageDirHandle(DirHandle
* dir
, VolumeId volume
, Device device
,
98 Inode inode
, int *volumeChanged
)
100 static int SalvageCacheCheck
= 1;
101 memset(dir
, 0, sizeof(DirHandle
));
103 dir
->dirh_device
= device
;
104 dir
->dirh_volume
= volume
;
105 dir
->dirh_inode
= inode
;
106 IH_INIT(dir
->dirh_handle
, device
, volume
, inode
);
107 /* Always re-read for a new dirhandle */
108 dir
->dirh_cacheCheck
= SalvageCacheCheck
++;
109 dir
->volumeChanged
= volumeChanged
;
113 FidZap(DirHandle
* file
)
115 IH_RELEASE(file
->dirh_handle
);
116 memset(file
, 0, sizeof(DirHandle
));
120 FidZero(DirHandle
* file
)
122 memset(file
, 0, sizeof(DirHandle
));
126 FidEq(DirHandle
* afile
, DirHandle
* bfile
)
128 if (afile
->dirh_volume
!= bfile
->dirh_volume
)
130 if (afile
->dirh_device
!= bfile
->dirh_device
)
132 if (afile
->dirh_cacheCheck
!= bfile
->dirh_cacheCheck
)
134 if (afile
->dirh_inode
!= bfile
->dirh_inode
)
140 FidVolEq(DirHandle
* afile
, VolumeId vid
)
142 if (afile
->dirh_volume
!= vid
)
148 FidCpy(DirHandle
* tofile
, DirHandle
* fromfile
)
151 IH_COPY(tofile
->dirh_handle
, fromfile
->dirh_handle
);
158 osi_Panic("%s\n", msg
);