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
|
|
|
*
|
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, 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
|
|
|
*
|
2001-06-11 06:12:29 +02:00
|
|
|
* $Id: fd.h,v 1.30 2001/06/11 04:12:29 tgl 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
|
|
|
*
|
2000-04-09 06:43:20 +02:00
|
|
|
* File {Close, Read, Write, Seek, Tell, MarkDirty, 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.
|
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
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 FileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
|
|
|
|
extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode);
|
1999-05-09 02:52:08 +02:00
|
|
|
extern File OpenTemporaryFile(void);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void FileClose(File file);
|
|
|
|
extern void FileUnlink(File file);
|
|
|
|
extern int FileRead(File file, char *buffer, int amount);
|
|
|
|
extern int FileWrite(File file, char *buffer, int amount);
|
|
|
|
extern long FileSeek(File file, long offset, int whence);
|
1999-10-13 17:02:32 +02:00
|
|
|
extern int FileTruncate(File file, long offset);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int FileSync(File file);
|
2000-04-09 06:43:20 +02:00
|
|
|
extern void FileMarkDirty(File file);
|
1999-05-09 02:52:08 +02:00
|
|
|
|
|
|
|
/* Operations that allow use of regular stdio --- USE WITH CAUTION */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern FILE *AllocateFile(char *name, char *mode);
|
|
|
|
extern void FreeFile(FILE *);
|
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 */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void closeAllVfds(void);
|
1999-05-09 02:52:08 +02:00
|
|
|
extern void AtEOXact_Files(void);
|
2001-06-11 06:12:29 +02:00
|
|
|
extern void RemovePgTempFiles(void);
|
2000-12-08 23:21:33 +01:00
|
|
|
extern int pg_fsync(int fd);
|
2001-02-18 05:39:42 +01:00
|
|
|
extern int pg_fdatasync(int fd);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* FD_H */
|