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 #include <afsconfig.h>
11 #include <afs/param.h>
17 #include <afs/afsint.h>
20 #include <afs/ihandle.h>
25 /* returns 0 on success, errno on failure */
27 ReallyRead(DirHandle
* file
, int block
, char *data
)
33 fdP
= IH_OPEN(file
->dirh_handle
);
38 nBytes
= FDH_PREAD(fdP
, data
, AFS_PAGESIZE
, ((afs_foff_t
)block
) * AFS_PAGESIZE
);
39 if (nBytes
!= AFS_PAGESIZE
) {
51 /* returns 0 on success, errno on failure */
53 ReallyWrite(DirHandle
* file
, int block
, char *data
)
56 extern int VolumeChanged
;
62 fdP
= IH_OPEN(file
->dirh_handle
);
67 nBytes
= FDH_PWRITE(fdP
, data
, AFS_PAGESIZE
, ((afs_foff_t
)block
) * AFS_PAGESIZE
);
68 if (nBytes
!= AFS_PAGESIZE
) {
81 /* SetSalvageDirHandle:
82 * Create a handle to a directory entry and reference it (IH_INIT).
83 * The handle needs to be dereferenced with the FidZap() routine.
86 SetSalvageDirHandle(DirHandle
* dir
, VolumeId volume
, afs_int32 device
,
89 private int SalvageCacheCheck
= 1;
90 memset(dir
, 0, sizeof(DirHandle
));
92 dir
->dirh_volume
= volume
;
93 dir
->dirh_device
= device
;
94 dir
->dirh_inode
= inode
;
95 IH_INIT(dir
->dirh_handle
, device
, volume
, inode
);
97 /* Always re-read for a new dirhandle */
98 dir
->dirh_cacheCheck
= SalvageCacheCheck
++;
102 FidZap(DirHandle
* file
)
104 IH_RELEASE(file
->dirh_handle
);
105 memset(file
, 0, sizeof(DirHandle
));
109 FidZero(DirHandle
* file
)
111 memset(file
, 0, sizeof(DirHandle
));
115 FidEq(DirHandle
* afile
, DirHandle
* bfile
)
117 if (afile
->dirh_volume
!= bfile
->dirh_volume
)
119 if (afile
->dirh_device
!= bfile
->dirh_device
)
121 if (afile
->dirh_cacheCheck
!= bfile
->dirh_cacheCheck
)
123 if (afile
->dirh_inode
!= bfile
->dirh_inode
)
129 FidVolEq(DirHandle
* afile
, afs_int32 vid
)
131 if (afile
->dirh_volume
!= vid
)
137 FidCpy(DirHandle
* tofile
, DirHandle
* fromfile
)
140 IH_COPY(tofile
->dirh_handle
, fromfile
->dirh_handle
);
147 osi_Panic("%s\n", msg
);