]> granicus.if.org Git - postgresql/blob - src/include/storage/fd.h
Compile and warning cleanup
[postgresql] / src / include / storage / fd.h
1 /*-------------------------------------------------------------------------
2  *
3  * fd.h--
4  *    Virtual file descriptor definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: fd.h,v 1.5 1996/11/08 06:02:12 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 /*
14  * calls:
15  * 
16  *  File {Close, Read, Write, Seek, Tell, Sync}
17  *  {File Name Open, Allocate, Free} File
18  *
19  * These are NOT JUST RENAMINGS OF THE UNIX ROUTINES.
20  * use them for all file activity...
21  *
22  *  fd = FilePathOpenFile("foo", O_RDONLY);
23  *  File fd;
24  *
25  * use AllocateFile if you need a file descriptor in some other context.
26  * it will make sure that there is a file descriptor free
27  *
28  * use FreeFile to let the virtual file descriptor package know that 
29  * there is now a free fd (when you are done with it)
30  *
31  *  AllocateFile();
32  *  FreeFile();
33  */
34 #ifndef FD_H
35 #define FD_H
36
37 /*
38  * FileOpen uses the standard UNIX open(2) flags.
39  */
40 #ifndef O_RDONLY
41 #endif /* O_RDONLY */
42
43 /*
44  * FileSeek uses the standard UNIX lseek(2) flags.
45  */
46 #ifndef WIN32
47 #else
48 #ifndef SEEK_SET
49 #endif /* SEEK_SET */
50 #endif /* WIN32 */
51
52 typedef char   *FileName;
53
54 typedef int     File;
55
56 /* originally in libpq-fs.h */
57 struct pgstat { /* just the fields we need from stat structure */
58     int st_ino;
59     int st_mode;
60     unsigned int st_size;
61     unsigned int st_sizehigh;   /* high order bits */
62 /* 2^64 == 1.8 x 10^20 bytes */
63     int st_uid;
64     int st_atime_s;     /* just the seconds */
65     int st_mtime_s;     /* since SysV and the new BSD both have */
66     int st_ctime_s;     /* usec fields.. */
67 };
68
69 /*
70  * prototypes for functions in fd.c
71  */
72 extern void FileInvalidate(File file);
73 extern File FileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
74 extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode);
75 extern void FileClose(File file);
76 extern void FileUnlink(File file);
77 extern int FileRead(File file, char *buffer, int amount);
78 extern int FileWrite(File file, char *buffer, int amount);
79 extern long FileSeek(File file, long offset, int whence);
80 extern long FileTell(File file);
81 extern int FileTruncate(File file, int offset);
82 extern int FileSync(File file);
83 extern int FileNameUnlink(char *filename);
84 extern void AllocateFile(void);
85 extern void FreeFile(void);
86 extern void closeAllVfds(void);
87 extern void closeOneVfd(void);
88 extern int pg_fsync(int fd);
89
90 #endif  /* FD_H */