1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* fd.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* Virtual file descriptor definitions.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2010-01-02 17:58:17 +01:00
|
|
|
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2010-02-26 03:01:40 +01:00
|
|
|
* $PostgreSQL: pgsql/src/include/storage/fd.h,v 1.68 2010/02/26 02:01:27 momjian Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1999-10-13 17:02:32 +02:00
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
|
|
|
* calls:
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
2004-05-31 05:48:10 +02:00
|
|
|
* File {Close, Read, Write, Seek, Tell, Sync}
|
1997-09-07 07:04:48 +02:00
|
|
|
* {File Name Open, Allocate, Free} File
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
* These are NOT JUST RENAMINGS OF THE UNIX ROUTINES.
|
1999-05-09 02:52:08 +02:00
|
|
|
* Use them for all file activity...
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* File fd;
|
2000-06-02 05:58:34 +02:00
|
|
|
* fd = FilePathOpenFile("foo", O_RDONLY, 0600);
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* AllocateFile();
|
|
|
|
* FreeFile();
|
1999-05-09 02:52:08 +02:00
|
|
|
*
|
|
|
|
* Use AllocateFile, not fopen, if you need a stdio file (FILE*); then
|
|
|
|
* use FreeFile, not fclose, to close it. AVOID using stdio for files
|
|
|
|
* that you intend to hold open for any length of time, since there is
|
|
|
|
* no way for them to share kernel file descriptors with other files.
|
2004-02-24 00:03:10 +01:00
|
|
|
*
|
|
|
|
* Likewise, use AllocateDir/FreeDir, not opendir/closedir, to allocate
|
|
|
|
* open directories (DIR*).
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef FD_H
|
1996-08-28 03:59:28 +02:00
|
|
|
#define FD_H
|
|
|
|
|
2004-02-24 00:03:10 +01:00
|
|
|
#include <dirent.h>
|
|
|
|
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
|
|
|
* FileSeek uses the standard UNIX lseek(2) flags.
|
|
|
|
*/
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
typedef char *FileName;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
typedef int File;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2001-09-30 20:57:45 +02:00
|
|
|
|
|
|
|
/* GUC parameter */
|
2001-10-25 07:50:21 +02:00
|
|
|
extern int max_files_per_process;
|
2001-09-30 20:57:45 +02:00
|
|
|
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
|
|
|
* prototypes for functions in fd.c
|
|
|
|
*/
|
1999-05-09 02:52:08 +02:00
|
|
|
|
|
|
|
/* Operations on virtual Files --- equivalent to Unix kernel file ops */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode);
|
2007-06-07 21:19:57 +02:00
|
|
|
extern File OpenTemporaryFile(bool interXact);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void FileClose(File file);
|
2009-01-12 06:10:45 +01:00
|
|
|
extern int FilePrefetch(File file, off_t offset, int amount);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int FileRead(File file, char *buffer, int amount);
|
|
|
|
extern int FileWrite(File file, char *buffer, int amount);
|
2004-05-31 05:48:10 +02:00
|
|
|
extern int FileSync(File file);
|
2008-03-10 21:06:27 +01:00
|
|
|
extern off_t FileSeek(File file, off_t offset, int whence);
|
|
|
|
extern int FileTruncate(File file, off_t offset);
|
2009-08-05 20:01:54 +02:00
|
|
|
extern char *FilePathName(File file);
|
1999-05-09 02:52:08 +02:00
|
|
|
|
|
|
|
/* Operations that allow use of regular stdio --- USE WITH CAUTION */
|
2006-03-04 22:32:47 +01:00
|
|
|
extern FILE *AllocateFile(const char *name, const char *mode);
|
2004-02-24 00:03:10 +01:00
|
|
|
extern int FreeFile(FILE *file);
|
|
|
|
|
|
|
|
/* Operations to allow use of the <dirent.h> library routines */
|
|
|
|
extern DIR *AllocateDir(const char *dirname);
|
2005-06-19 23:34:03 +02:00
|
|
|
extern struct dirent *ReadDir(DIR *dir, const char *dirname);
|
2004-02-24 00:03:10 +01:00
|
|
|
extern int FreeDir(DIR *dir);
|
1999-05-09 02:52:08 +02:00
|
|
|
|
2000-06-02 05:58:34 +02:00
|
|
|
/* If you've really really gotta have a plain kernel FD, use this */
|
|
|
|
extern int BasicOpenFile(FileName fileName, int fileFlags, int fileMode);
|
|
|
|
|
1999-05-09 02:52:08 +02:00
|
|
|
/* Miscellaneous support routines */
|
2005-08-08 05:12:16 +02:00
|
|
|
extern void InitFileAccess(void);
|
2004-02-23 21:45:59 +01:00
|
|
|
extern void set_max_safe_fds(void);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void closeAllVfds(void);
|
2007-06-07 21:19:57 +02:00
|
|
|
extern void SetTempTablespaces(Oid *tableSpaces, int numSpaces);
|
|
|
|
extern bool TempTablespacesAreSet(void);
|
|
|
|
extern Oid GetNextTempTableSpace(void);
|
1999-05-09 02:52:08 +02:00
|
|
|
extern void AtEOXact_Files(void);
|
2004-09-16 18:58:44 +02:00
|
|
|
extern void AtEOSubXact_Files(bool isCommit, SubTransactionId mySubid,
|
2005-10-15 04:49:52 +02:00
|
|
|
SubTransactionId parentSubid);
|
2001-06-11 06:12:29 +02:00
|
|
|
extern void RemovePgTempFiles(void);
|
2007-06-07 21:19:57 +02:00
|
|
|
|
2000-12-08 23:21:33 +01:00
|
|
|
extern int pg_fsync(int fd);
|
2005-05-20 16:53:26 +02:00
|
|
|
extern int pg_fsync_no_writethrough(int fd);
|
|
|
|
extern int pg_fsync_writethrough(int fd);
|
2001-02-18 05:39:42 +01:00
|
|
|
extern int pg_fdatasync(int fd);
|
2010-02-26 03:01:40 +01:00
|
|
|
extern int pg_flush_data(int fd, off_t offset, off_t amount);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2003-12-20 18:31:21 +01:00
|
|
|
/* Filename components for OpenTemporaryFile */
|
|
|
|
#define PG_TEMP_FILES_DIR "pgsql_tmp"
|
|
|
|
#define PG_TEMP_FILE_PREFIX "pgsql_tmp"
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* FD_H */
|