~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/include/storage/fd.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * fd.h
 
4
 *        Virtual file descriptor definitions.
 
5
 *
 
6
 *
 
7
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 
8
 * Portions Copyright (c) 1994, Regents of the University of California
 
9
 *
 
10
 * $PostgreSQL$
 
11
 *
 
12
 *-------------------------------------------------------------------------
 
13
 */
 
14
 
 
15
/*
 
16
 * calls:
 
17
 *
 
18
 *      File {Close, Read, Write, Seek, Tell, Sync}
 
19
 *      {File Name Open, Allocate, Free} File
 
20
 *
 
21
 * These are NOT JUST RENAMINGS OF THE UNIX ROUTINES.
 
22
 * Use them for all file activity...
 
23
 *
 
24
 *      File fd;
 
25
 *      fd = FilePathOpenFile("foo", O_RDONLY, 0600);
 
26
 *
 
27
 *      AllocateFile();
 
28
 *      FreeFile();
 
29
 *
 
30
 * Use AllocateFile, not fopen, if you need a stdio file (FILE*); then
 
31
 * use FreeFile, not fclose, to close it.  AVOID using stdio for files
 
32
 * that you intend to hold open for any length of time, since there is
 
33
 * no way for them to share kernel file descriptors with other files.
 
34
 *
 
35
 * Likewise, use AllocateDir/FreeDir, not opendir/closedir, to allocate
 
36
 * open directories (DIR*).
 
37
 */
 
38
#ifndef FD_H
 
39
#define FD_H
 
40
 
 
41
#include <dirent.h>
 
42
 
 
43
 
 
44
/*
 
45
 * FileSeek uses the standard UNIX lseek(2) flags.
 
46
 */
 
47
 
 
48
typedef char *FileName;
 
49
 
 
50
typedef int File;
 
51
 
 
52
 
 
53
/* GUC parameter */
 
54
extern int      max_files_per_process;
 
55
 
 
56
 
 
57
/*
 
58
 * prototypes for functions in fd.c
 
59
 */
 
60
 
 
61
/* Operations on virtual Files --- equivalent to Unix kernel file ops */
 
62
extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode);
 
63
extern File OpenTemporaryFile(bool interXact);
 
64
extern void FileClose(File file);
 
65
extern int      FilePrefetch(File file, off_t offset, int amount);
 
66
extern int      FileRead(File file, char *buffer, int amount);
 
67
extern int      FileWrite(File file, char *buffer, int amount);
 
68
extern int      FileSync(File file);
 
69
extern off_t FileSeek(File file, off_t offset, int whence);
 
70
extern int      FileTruncate(File file, off_t offset);
 
71
 
 
72
/* Operations that allow use of regular stdio --- USE WITH CAUTION */
 
73
extern FILE *AllocateFile(const char *name, const char *mode);
 
74
extern int      FreeFile(FILE *file);
 
75
 
 
76
/* Operations to allow use of the <dirent.h> library routines */
 
77
extern DIR *AllocateDir(const char *dirname);
 
78
extern struct dirent *ReadDir(DIR *dir, const char *dirname);
 
79
extern int      FreeDir(DIR *dir);
 
80
 
 
81
/* If you've really really gotta have a plain kernel FD, use this */
 
82
extern int      BasicOpenFile(FileName fileName, int fileFlags, int fileMode);
 
83
 
 
84
/* Miscellaneous support routines */
 
85
extern void InitFileAccess(void);
 
86
extern void set_max_safe_fds(void);
 
87
extern void closeAllVfds(void);
 
88
extern void SetTempTablespaces(Oid *tableSpaces, int numSpaces);
 
89
extern bool TempTablespacesAreSet(void);
 
90
extern Oid      GetNextTempTableSpace(void);
 
91
extern void AtEOXact_Files(void);
 
92
extern void AtEOSubXact_Files(bool isCommit, SubTransactionId mySubid,
 
93
                                  SubTransactionId parentSubid);
 
94
extern void RemovePgTempFiles(void);
 
95
 
 
96
extern int      pg_fsync(int fd);
 
97
extern int      pg_fsync_no_writethrough(int fd);
 
98
extern int      pg_fsync_writethrough(int fd);
 
99
extern int      pg_fdatasync(int fd);
 
100
 
 
101
/* Filename components for OpenTemporaryFile */
 
102
#define PG_TEMP_FILES_DIR "pgsql_tmp"
 
103
#define PG_TEMP_FILE_PREFIX "pgsql_tmp"
 
104
 
 
105
#endif   /* FD_H */