PostgreSQL Source Code  git master
file_utils.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * Assorted utility functions to work on files.
4  *
5  *
6  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/common/file_utils.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef FILE_UTILS_H
14 #define FILE_UTILS_H
15 
16 #include <dirent.h>
17 
18 typedef enum PGFileType
19 {
26 
27 struct iovec; /* avoid including port/pg_iovec.h here */
28 
29 #ifdef FRONTEND
30 extern int fsync_fname(const char *fname, bool isdir);
31 extern void fsync_pgdata(const char *pg_data, int serverVersion);
32 extern void fsync_dir_recurse(const char *dir);
33 extern int durable_rename(const char *oldfile, const char *newfile);
34 extern int fsync_parent_path(const char *fname);
35 #endif
36 
37 extern PGFileType get_dirent_type(const char *path,
38  const struct dirent *de,
39  bool look_through_symlinks,
40  int elevel);
41 
42 extern ssize_t pg_pwritev_with_retry(int fd,
43  const struct iovec *iov,
44  int iovcnt,
45  off_t offset);
46 
47 extern ssize_t pg_pwrite_zeros(int fd, size_t size, off_t offset);
48 
49 #endif /* FILE_UTILS_H */
int durable_rename(const char *oldfile, const char *newfile, int elevel)
Definition: fd.c:693
void fsync_fname(const char *fname, bool isdir)
Definition: fd.c:667
static int fsync_parent_path(const char *fname, int elevel)
Definition: fd.c:3770
PGFileType
Definition: file_utils.h:19
@ PGFILETYPE_LNK
Definition: file_utils.h:24
@ PGFILETYPE_UNKNOWN
Definition: file_utils.h:21
@ PGFILETYPE_DIR
Definition: file_utils.h:23
@ PGFILETYPE_REG
Definition: file_utils.h:22
@ PGFILETYPE_ERROR
Definition: file_utils.h:20
ssize_t pg_pwrite_zeros(int fd, size_t size, off_t offset)
Definition: file_utils.c:541
ssize_t pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset)
Definition: file_utils.c:472
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
Definition: file_utils.c:406
static char * pg_data
Definition: initdb.c:137
static int fd(const char *x, int i)
Definition: preproc-init.c:105
Definition: dirent.h:10