vol: Restore inode OS_READ/WRITE
[openafs.git] / src / vol / ihandle.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
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
8  */
9
10 /* An IHandle_t is an abstraction allowing the file and volume operations to
11  * pass the elements required to identify a file to the underlying file
12  * systen. For the usual Vice inode operations, this is no more than the
13  * usual device and inode numbers. For the user space file system used on NT
14  * we also need the volume id to identify the file.
15  *
16  * An FdHandle_t is an abstraction used to associate file descroptors
17  * with Inode handles. IH_OPEN is used to get a file descriptor that
18  * can be used in subsequent I/O operations. File descriptor handles are
19  * cached by IO_CLOSE. To make sure a file descriptor is really closed call
20  * IH_REALLYCLOSE.
21  *
22  * The IHandle_t also provides a place to do other optimizations. In the
23  * NT user space file system, we keep a separate special file for the
24  * link counts and using the IHandle_t allows keeping the details of
25  * that at a lower level than the IDEC and IINC calls.
26  *
27  * To use the IHandle_t there are a new set of IH_xxxx/FDH_XXXX operations.
28  * Each takes a pointer to an IHandle_t or an FdHandle_t as the first
29  * argument. This pointer is  considered an in/out variable. In particular,
30  * the open file descriptors for a given Inode are stored in a linked list
31  * of FdHandle_t hanging off of each IHandle_t. IH_OPEN returns NULL on error,
32  * and a valid FdHandle_t otherwise. All other IH_xxxx/FDH_xxxx macros return
33  * -1 on error and 0 on success.
34  *
35  * Inode handle operations:
36  * IH_INIT - Initialize the Inode handle with the device, volume id, and ino
37  * IH_COPY - Copy Inode handle info to a new handle with no open descriptors.
38  * IH_REALLYCLOSE - Close all cached file descriptors for Inode handle
39  * IH_RELEASE - release a Inode handle, close all cached file descriptors
40  * IH_CONDSYNC -  snyc the Inode if it has any open file descriptors
41  *
42  * Inode operation replacements:
43  * IH_CREATE - create a file in the underlying filesystem and setup the
44  *      information needed to reference this file in the IHandle_t.
45  * IH_OPEN - open the file belonging to the associated inode and set the
46  *      file descriptor.
47  * IH_IREAD/IH_IWRITE - read/write an Inode.
48  * IH_INC/IH_DEC - increment/decrement the link count.
49  *
50  * Replacements for C runtime file operations
51  * FDH_READ/FDH_WRITE - read/write using the file descriptor.
52  * FDH_READV/FDH_WRITEV - readv/writev (Unix only)
53  * FDH_SEEK - set file handle's read/write position
54  * FDH_CLOSE - return a file descriptor to the cache
55  * FDH_REALLYCLOSE - Close a file descriptor, do not return to the cache
56  * FDH_SYNC - Unconditionally sync an open file.
57  * FDH_TRUNC - Truncate a file
58  * FDH_LOCKFILE - Lock a whole file
59  * FDH_UNLOCKFILE - Unlock a whole file
60  *
61  * status information:
62  * FDH_SIZE - returns the size of the file.
63  * FDH_NLINK - returns the link count of the file.
64  *
65  * Miscellaneous:
66  * FDH_FDOPEN - create a descriptor for buffered I/O
67  * STREAM_READ/STREAM_WRITE - buffered file I/O
68  */
69
70 #ifndef _IHANDLE_H_
71 #define _IHANDLE_H_
72
73 #ifdef AFS_PTHREAD_ENV
74 #include <pthread.h>
75 extern pthread_once_t ih_glock_once;
76 extern pthread_mutex_t ih_glock_mutex;
77 extern void ih_glock_init(void);
78 #define IH_LOCK \
79     do { osi_Assert(pthread_once(&ih_glock_once, ih_glock_init) == 0);  \
80         MUTEX_ENTER(&ih_glock_mutex); \
81     } while (0)
82 #define IH_UNLOCK MUTEX_EXIT(&ih_glock_mutex)
83 #else /* AFS_PTHREAD_ENV */
84 #define IH_LOCK
85 #define IH_UNLOCK
86 #endif /* AFS_PTHREAD_ENV */
87
88 #ifndef DLL_INIT_LIST
89 /*
90  * Macro to initialize a doubly linked list, lifted from Encina
91  */
92 #define DLL_INIT_LIST(head, tail)       \
93     do {                                \
94         (head) = NULL;                  \
95         (tail) = NULL;                  \
96     } while(0)
97
98 /*
99  * Macro to remove an element from a doubly linked list
100  */
101 #define DLL_DELETE(ptr,head,tail,next,prev)     \
102     do {                                        \
103         if ((ptr)->next)                        \
104             (ptr)->next->prev = (ptr)->prev;    \
105         else                                    \
106             (tail) = (ptr)->prev;               \
107         if ((ptr)->prev)                        \
108             (ptr)->prev->next = (ptr)->next;    \
109         else                                    \
110             (head) = (ptr)->next;               \
111         (ptr)->next = (ptr)->prev = NULL;       \
112         osi_Assert(!(head) || !((head)->prev)); \
113     } while(0)
114
115 /*
116  * Macro to insert an element at the tail of a doubly linked list
117  */
118 #define DLL_INSERT_TAIL(ptr,head,tail,next,prev) \
119     do {                                         \
120         (ptr)->next = NULL;                      \
121         (ptr)->prev = (tail);                    \
122         (tail) = (ptr);                          \
123         if ((ptr)->prev)                         \
124             (ptr)->prev->next = (ptr);           \
125         else                                     \
126             (head) = (ptr);                      \
127         osi_Assert((head) && ((head)->prev == NULL));   \
128     } while(0)
129
130 #endif /* DLL_INIT_LIST */
131
132 #ifdef AFS_NT40_ENV
133 typedef __int64 Inode;
134 #else
135 #include <afs/afssyscalls.h>
136 #endif
137
138 /* The dir package's page hashing function is dependent upon the layout of
139  * IHandle_t as well as the containing DirHandle in viced/viced.h. Make
140  * Sure the volume id is still used as the hash after any changes to either
141  * structure.
142  */
143
144 /* forward declaration */
145 struct IHandle_s;
146
147 /* File descriptors are HANDLE's on NT. The following typedef helps catch
148  * type errors. duplicated in libadmin/vos/afs_vosAdmin.c
149  */
150 #ifdef AFS_NT40_ENV
151 typedef HANDLE FD_t;
152 #define INVALID_FD INVALID_HANDLE_VALUE
153 #else
154 typedef int FD_t;
155 #define INVALID_FD ((FD_t)-1)
156 #endif
157
158 /* file descriptor handle */
159 typedef struct FdHandle_s {
160     int fd_status;              /* status flags */
161     int fd_refcnt;              /* refcnt */
162     FD_t fd_fd;                 /* file descriptor */
163     struct IHandle_s *fd_ih;    /* Pointer to Inode handle */
164     struct FdHandle_s *fd_next; /* LRU/Avail list pointers */
165     struct FdHandle_s *fd_prev;
166     struct FdHandle_s *fd_ihnext;       /* Inode handle's list of file descriptors */
167     struct FdHandle_s *fd_ihprev;
168 } FdHandle_t;
169
170 /* File descriptor status values */
171 #define FD_HANDLE_AVAIL         1       /* handle is not open and available */
172 #define FD_HANDLE_OPEN          2       /* handle is open and not in use */
173 #define FD_HANDLE_INUSE         3       /* handle is open and in use */
174
175 /* buffered file descriptor handle */
176 #define STREAM_HANDLE_BUFSIZE   2048    /* buffer size for STR_READ/STR_WRITE */
177 typedef struct StreamHandle_s {
178     FD_t str_fd;                /* file descriptor */
179     int str_direction;          /* current read/write direction */
180     afs_sfsize_t str_buflen;    /* bytes remaining in buffer */
181     afs_foff_t str_bufoff;      /* current offset into buffer */
182     afs_foff_t str_fdoff;       /* current offset into file */
183     int str_error;              /* error code */
184     int str_eof;                /* end of file flag */
185     struct StreamHandle_s *str_next;    /* Avail list pointers */
186     struct StreamHandle_s *str_prev;
187     char str_buffer[STREAM_HANDLE_BUFSIZE];     /* data buffer */
188 } StreamHandle_t;
189
190 #define STREAM_DIRECTION_NONE   1       /* stream is in initial mode */
191 #define STREAM_DIRECTION_READ   2       /* stream is in input mode */
192 #define STREAM_DIRECTION_WRITE  3       /* stream is in output mode */
193
194 /* number handles allocated at a shot */
195 #define I_HANDLE_MALLOCSIZE     ((size_t)((4096/sizeof(IHandle_t))))
196 #define FD_HANDLE_MALLOCSIZE    ((size_t)((4096/sizeof(FdHandle_t))))
197 #define STREAM_HANDLE_MALLOCSIZE 1
198
199
200 /* READ THIS.
201  *
202  * On modern platforms tuned for I/O intensive workloads, there may be
203  * thousands of file descriptors available (64K on 32-bit Solaris 7,
204  * for example), and threading in Solaris 9 and Linux 2.6 (NPTL) are
205  * tuned for (many) thousands of concurrent threads at peak.
206  *
207  * On these platforms, it makes sense to allow administrators to set
208  * appropriate limits for their hardware.  Clients may now set desired
209  * values in the exported vol_io_params, of type ih_init_params.
210  */
211
212 typedef struct ih_init_params
213 {
214     afs_uint32 fd_handle_setaside; /* for non-cached i/o, trad. was 128 */
215     afs_uint32 fd_initial_cachesize; /* what was 'default' */
216     afs_uint32 fd_max_cachesize; /* max open files if large-cache activated */
217 } ih_init_params;
218
219
220 /* Number of file descriptors needed for non-cached I/O */
221 #define FD_HANDLE_SETASIDE      128 /* Match to MAX_FILESERVER_THREAD */
222
223 /* Which systems have 8-bit fileno?  On GNU/Linux systems, the
224  * fileno member of FILE is an int.  On NetBSD 5, it's a short.
225  * Ditto for OpenBSD 4.5. Through Solaris 10 8/07 it's unsigned char.
226  */
227
228 /* Don't try to have more than 256 files open at once if you are planning
229  * to use fopen or fdopen. The FILE structure has an eight bit field for
230  * the file descriptor.  */
231 #define FD_DEFAULT_CACHESIZE (255-FD_HANDLE_SETASIDE)
232
233 /* We need some limit on the number of files open at once. Some systems
234  * say we can open lots of files, but when we do they run out of slots
235  * in the file table.
236  */
237 #define FD_MAX_CACHESIZE (2000 - FD_HANDLE_SETASIDE)
238
239 /* On modern platforms, this is sized higher than the note implies.
240  * For HP, see http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1242508538748+28353475&threadId=302950
241  * On AIX, it's said to be self-tuning (sar -v)
242  * On Solaris, http://www.princeton.edu/~unix/Solaris/troubleshoot/kerntune.html
243  * says stdio limit (FILE) may exist, but then backtracks and says the 64bit
244  * solaris and POLL (rather than select) io avoid the issue.  Solaris Internals
245  * states that Solaris 7 and above deal with up to 64K on 32bit.
246  * However, extended FILE must be enabled to use this. See
247  * enable_extended_FILE_stdio(3C)
248  */
249
250 /* Inode handle */
251 typedef struct IHandle_s {
252     afs_uint32 ih_vid;          /* Parent volume id. */
253     int ih_dev;                 /* device id. */
254     int ih_flags;               /* Flags */
255     int ih_synced;              /* should be synced next time */
256     Inode ih_ino;               /* Inode number */
257     int ih_refcnt;              /* reference count */
258     struct FdHandle_s *ih_fdhead;       /* List of open file desciptors */
259     struct FdHandle_s *ih_fdtail;
260     struct IHandle_s *ih_next;  /* Links for avail list/hash chains */
261     struct IHandle_s *ih_prev;
262 } IHandle_t;
263
264 /* Flags for the Inode handle */
265 #define IH_REALLY_CLOSED                1
266
267 /* Hash function for inode handles */
268 #define I_HANDLE_HASH_SIZE      2048    /* power of 2 */
269
270 /* The casts to int's ensure NT gets the xor operation correct. */
271 #define IH_HASH(D, V, I) ((int)(((D)^(V)^((int)(I)))&(I_HANDLE_HASH_SIZE-1)))
272
273 /*
274  * Hash buckets for inode handles
275  */
276 typedef struct IHashBucket_s {
277     IHandle_t *ihash_head;
278     IHandle_t *ihash_tail;
279 } IHashBucket_t;
280
281 /* Prototypes for handle support routines. */
282 #ifdef AFS_NAMEI_ENV
283 #ifdef AFS_NT40_ENV
284 #include "ntops.h"
285 #endif
286 #include "namei_ops.h"
287
288 extern void ih_clear(IHandle_t * h);
289 extern Inode ih_create(IHandle_t * h, int dev, char *part, Inode nI, int p1,
290                        int p2, int p3, int p4);
291 extern FILE *ih_fdopen(FdHandle_t * h, char *fdperms);
292 #endif /* AFS_NAMEI_ENV */
293
294 /*
295  * Prototypes for file descriptor cache routines
296  */
297 extern void ih_PkgDefaults(void);
298 extern void ih_Initialize(void);
299 extern void ih_UseLargeCache(void);
300 extern IHandle_t *ih_init(int /*@alt Device@ */ dev, int /*@alt VolId@ */ vid,
301                           Inode ino);
302 extern IHandle_t *ih_copy(IHandle_t * ihP);
303 extern FdHandle_t *ih_open(IHandle_t * ihP);
304 extern int fd_close(FdHandle_t * fdP);
305 extern int fd_reallyclose(FdHandle_t * fdP);
306 extern StreamHandle_t *stream_fdopen(FD_t fd);
307 extern StreamHandle_t *stream_open(const char *file, const char *mode);
308 extern afs_sfsize_t stream_read(void *ptr, afs_fsize_t size,
309                                 afs_fsize_t nitems, StreamHandle_t * streamP);
310 extern afs_sfsize_t stream_write(void *ptr, afs_fsize_t size,
311                                  afs_fsize_t nitems,
312                                  StreamHandle_t * streamP);
313 extern int stream_aseek(StreamHandle_t * streamP, afs_foff_t offset);
314 extern int stream_flush(StreamHandle_t * streamP);
315 extern int stream_close(StreamHandle_t * streamP, int reallyClose);
316 extern int ih_reallyclose(IHandle_t * ihP);
317 extern int ih_release(IHandle_t * ihP);
318 extern int ih_condsync(IHandle_t * ihP);
319
320 /* Macros common to user space and inode API's. */
321 #define IH_INIT(H, D, V, I) ((H) = ih_init((D), (V), (I)))
322
323 #define IH_COPY(D, S) ((D) = ih_copy(S))
324
325 #define IH_NLINK(H) ih_nlink(H)
326
327 #define IH_OPEN(H) ih_open(H)
328
329 #define FDH_CLOSE(H) (fd_close(H), (H)=NULL, 0)
330
331 #define FDH_REALLYCLOSE(H) (fd_reallyclose(H), (H)=NULL, 0)
332
333 #define FDH_FDOPEN(H, A) stream_fdopen((H)->fd_fd)
334
335 #define STREAM_FDOPEN(A, B) stream_fdopen(A)
336
337 #define STREAM_OPEN(A, B) stream_open(A, B)
338
339 #define STREAM_READ(A, B, C, H) stream_read(A, B, C, H)
340
341 #define STREAM_WRITE(A, B, C, H) stream_write(A, B, C, H)
342
343 #define STREAM_ASEEK(H, A) stream_aseek(H, A)
344
345 #define STREAM_FLUSH(H) stream_flush(H)
346
347 #define STREAM_ERROR(H) ((H)->str_error)
348
349 #define STREAM_EOF(H) ((H)->str_eof)
350
351 #define STREAM_CLOSE(H) stream_close(H, 0)
352
353 #define STREAM_REALLYCLOSE(H) stream_close(H, 1)
354
355 #define IH_RELEASE(H) (ih_release(H), (H)=NULL, 0)
356
357 #define IH_REALLYCLOSE(H) ih_reallyclose(H)
358
359 #define IH_CONDSYNC(H) ih_condsync(H)
360
361 #ifdef HAVE_PIO
362 #ifdef AFS_NT40_ENV
363 #define OS_PREAD(FD, B, S, O) nt_pread(FD, B, S, O)
364 #define OS_PWRITE(FD, B, S, O) nt_pwrite(FD, B, S, O)
365 #else
366 #ifdef O_LARGEFILE
367 #define OS_PREAD(FD, B, S, O) pread64(FD, B, S, O)
368 #define OS_PWRITE(FD, B, S, O) pwrite64(FD, B, S, O)
369 #else /* !O_LARGEFILE */
370 #define OS_PREAD(FD, B, S, O) pread(FD, B, S, O)
371 #define OS_PWRITE(FD, B, S, O) pwrite(FD, B, S, O)
372 #endif /* !O_LARGEFILE */
373 #endif /* AFS_NT40_ENV */
374 #else /* !HAVE_PIO */
375 extern ssize_t ih_pread(int fd, void * buf, size_t count, afs_foff_t offset);
376 extern ssize_t ih_pwrite(int fd, const void * buf, size_t count, afs_foff_t offset);
377 #define OS_PREAD(FD, B, S, O) ih_pread(FD, B, S, O)
378 #define OS_PWRITE(FD, B, S, O) ih_pwrite(FD, B, S, O)
379 #endif /* !HAVE_PIO */
380 #ifdef AFS_NT40_ENV
381 #define OS_LOCKFILE(FD, O) (!LockFile(FD, (DWORD)((O) & 0xFFFFFFFF), (DWORD)((O) >> 32), 2, 0))
382 #define OS_UNLOCKFILE(FD, O) (!UnlockFile(FD, (DWORD)((O) & 0xFFFFFFFF), (DWORD)((O) >> 32), 2, 0))
383 #define OS_ERROR(X) nterr_nt2unix(GetLastError(), X)
384 #define OS_UNLINK(X) nt_unlink(X)
385 #define OS_DIRSEP "\\"
386 #define OS_DIRSEPC '\\'
387 #else
388 #define OS_LOCKFILE(FD, O) flock(FD, LOCK_EX)
389 #define OS_UNLOCKFILE(FD, O) flock(FD, LOCK_UN)
390 #define OS_ERROR(X) X
391 #define OS_UNLINK(X) unlink(X)
392 #define OS_DIRSEP "/"
393 #define OS_DIRSEPC '/'
394 #endif
395
396
397
398 #ifdef AFS_NAMEI_ENV
399
400 #ifdef AFS_NT40_ENV
401 #define OS_OPEN(F, M, P) nt_open(F, M, P)
402 #define OS_CLOSE(FD) nt_close(FD)
403
404 #define OS_READ(FD, B, S) nt_read(FD, B, S)
405 #define OS_WRITE(FD, B, S) nt_write(FD, B, S)
406 #define OS_SEEK(FD, O, F) nt_seek(FD, O, F)
407
408 #define OS_SYNC(FD) nt_fsync(FD)
409 #define OS_TRUNC(FD, L) nt_ftruncate(FD, L)
410
411 #else /* AFS_NT40_ENV */
412
413 /*@+fcnmacros +macrofcndecl@*/
414 #ifdef S_SPLINT_S
415 extern Inode IH_CREATE(IHandle_t * H, int /*@alt Device @ */ D,
416                        char *P, Inode N, int /*@alt VolumeId @ */ P1,
417                        int /*@alt VnodeId @ */ P2,
418                        int /*@alt Unique @ */ P3,
419                        int /*@alt unsigned @ */ P4);
420 extern FD_t OS_IOPEN(IHandle_t * H);
421 extern int OS_OPEN(const char *F, int M, mode_t P);
422 extern int OS_CLOSE(int FD);
423 extern ssize_t OS_READ(int FD, void *B, size_t S);
424 extern ssize_t OS_WRITE(int FD, void *B, size_t S);
425 extern ssize_t OS_PREAD(int FD, void *B, size_t S, afs_foff_t O);
426 extern ssize_t OS_PWRITE(int FD, void *B, size_t S, afs_foff_t O);
427 extern int OS_SYNC(int FD);
428 extern afs_sfsize_t OS_SIZE(int FD);
429 extern int IH_INC(IHandle_t * H, Inode I, int /*@alt VolId, VolumeId @ */ P);
430 extern int IH_DEC(IHandle_t * H, Inode I, int /*@alt VolId, VolumeId @ */ P);
431 extern afs_sfsize_t IH_IREAD(IHandle_t * H, afs_foff_t O, void *B,
432                              afs_fsize_t S);
433 extern afs_sfsize_t IH_IWRITE(IHandle_t * H, afs_foff_t O, void *B,
434                               afs_fsize_t S);
435 #ifdef O_LARGEFILE
436 #define OFFT off64_t
437 #else
438 #define OFFT off_t
439 #endif
440
441 extern OFFT OS_SEEK(int FD, OFFT O, int F);
442 extern int OS_TRUNC(int FD, OFFT L);
443 #endif /*S_SPLINT_S */
444
445 #ifdef O_LARGEFILE
446 #define OS_OPEN(F, M, P) open64(F, M, P)
447 #else /* !O_LARGEFILE */
448 #define OS_OPEN(F, M, P) open(F, M, P)
449 #endif /* !O_LARGEFILE */
450 #define OS_CLOSE(FD) close(FD)
451
452 #define OS_READ(FD, B, S) read(FD, B, S)
453 #define OS_WRITE(FD, B, S) write(FD, B, S)
454 #ifdef O_LARGEFILE
455 #define OS_SEEK(FD, O, F) lseek64(FD, (off64_t) (O), F)
456 #define OS_TRUNC(FD, L) ftruncate64(FD, (off64_t) (L))
457 #else /* !O_LARGEFILE */
458 #define OS_SEEK(FD, O, F) lseek(FD, (off_t) (O), F)
459 #define OS_TRUNC(FD, L) ftruncate(FD, (off_t) (L))
460 #endif /* !O_LARGEFILE */
461
462 #define OS_SYNC(FD) fsync(FD)
463
464 /*@=fcnmacros =macrofcndecl@*/
465 #endif /* AFS_NT40_ENV */
466 #define IH_INC(H, I, P) namei_inc(H, I, P)
467 #define IH_DEC(H, I, P) namei_dec(H, I, P)
468 #define IH_IREAD(H, O, B, S) namei_iread(H, O, B, S)
469 #define IH_IWRITE(H, O, B, S) namei_iwrite(H, O, B, S)
470 #define IH_CREATE(H, D, P, N, P1, P2, P3, P4) \
471         namei_icreate(H, P, P1, P2, P3, P4)
472 #define OS_IOPEN(H) namei_iopen(H)
473
474
475 #else /* AFS_NAMEI_ENV */
476 extern Inode ih_icreate(IHandle_t * ih, int dev, char *part, Inode nI, int p1,
477                         int p2, int p3, int p4);
478
479 #define IH_CREATE(H, D, P, N, P1, P2, P3, P4) \
480         ih_icreate(H, D, P, N, P1, P2, P3, P4)
481
482 #ifdef AFS_LINUX22_ENV
483 #define OS_IOPEN(H) -1
484 #else
485 #ifdef O_LARGEFILE
486 #define OS_IOPEN(H) (IOPEN((H)->ih_dev, (H)->ih_ino, O_RDWR|O_LARGEFILE))
487 #else
488 #define OS_IOPEN(H) (IOPEN((H)->ih_dev, (H)->ih_ino, O_RDWR))
489 #endif
490 #endif
491 #define OS_OPEN(F, M, P) open(F, M, P)
492 #define OS_CLOSE(FD) close(FD)
493
494 #define OS_READ(FD, B, S) read(FD, B, S)
495 #define OS_WRITE(FD, B, S) write(FD, B, S)
496 #ifdef O_LARGEFILE
497 #define OS_SEEK(FD, O, F) lseek64(FD, (off64_t) (O), F)
498 #define OS_TRUNC(FD, L) ftruncate64(FD, (off64_t) (L))
499 #else /* !O_LARGEFILE */
500 #define OS_SEEK(FD, O, F) lseek(FD, (off_t) (O), F)
501 #define OS_TRUNC(FD, L) ftruncate(FD, (off_t) (L))
502 #endif /* !O_LARGEFILE */
503
504 #define OS_SYNC(FD) fsync(FD)
505
506 #ifdef AFS_LINUX22_ENV
507 #define IH_INC(H, I, P) -1
508 #define IH_DEC(H, I, P) -1
509 #define IH_IREAD(H, O, B, S) -1
510 #define IH_IWRITE(H, O, B, S) -1
511 #else
512 #define IH_INC(H, I, P) IINC((H)->ih_dev, I, P)
513 #define IH_DEC(H, I, P) IDEC((H)->ih_dev, I, P)
514 #define IH_IREAD(H, O, B, S) inode_read((H)->ih_dev, (H)->ih_ino, (H)->ih_vid,\
515                                         O, B, S)
516 #define IH_IWRITE(H, O, B, S) \
517         inode_write((H)->ih_dev, (H)->ih_ino, (H)->ih_vid, O, B, S)
518 #endif /* AFS_LINUX22_ENV */
519
520
521 #endif /* AFS_NAMEI_ENV */
522 #define OS_SIZE(FD) ih_size(FD)
523 extern afs_sfsize_t ih_size(FD_t);
524
525 #ifndef AFS_NT40_ENV
526 #define FDH_READV(H, I, N) readv((H)->fd_fd, I, N)
527 #define FDH_WRITEV(H, I, N) writev((H)->fd_fd, I, N)
528 #endif
529
530 #ifdef HAVE_PIOV
531 #define FDH_PREADV(H, I, N, O) preadv((H)->fd_fd, I, N, O)
532 #define FDH_PWRITEV(H, I, N, O) pwritev((H)->fd_fd, I, N, O)
533 #endif
534
535 #define FDH_PREAD(H, B, S, O) OS_PREAD((H)->fd_fd, B, S, O)
536 #define FDH_PWRITE(H, B, S, O) OS_PWRITE((H)->fd_fd, B, S, O)
537 #define FDH_READ(H, B, S) OS_READ((H)->fd_fd, B, S)
538 #define FDH_WRITE(H, B, S) OS_WRITE((H)->fd_fd, B, S)
539 #define FDH_SEEK(H, O, F) OS_SEEK((H)->fd_fd, O, F)
540
541 #define FDH_SYNC(H) ((H->fd_ih!=NULL) ? ( H->fd_ih->ih_synced = 1) - 1 : 1)
542 #define FDH_TRUNC(H, L) OS_TRUNC((H)->fd_fd, L)
543 #define FDH_SIZE(H) OS_SIZE((H)->fd_fd)
544 #define FDH_LOCKFILE(H, O) OS_LOCKFILE((H)->fd_fd, O)
545 #define FDH_UNLOCKFILE(H, O) OS_UNLOCKFILE((H)->fd_fd, O)
546
547 #endif /* _IHANDLE_H_ */