|
19 | 19 | * |
20 | 20 | * Copyright (c) 2001, PostgreSQL Global Development Group |
21 | 21 | * |
22 | | - * $Id: pgstat.c,v 1.2 2001/06/29 16:29:37 wieck Exp $ |
| 22 | + * $Id: pgstat.c,v 1.3 2001/06/30 19:01:27 petere Exp $ |
23 | 23 | * ---------- |
24 | 24 | */ |
25 | | -#include <stdio.h> |
26 | | -#include <stdlib.h> |
| 25 | +#include "postgres.h" |
| 26 | + |
27 | 27 | #include <unistd.h> |
28 | 28 | #include <fcntl.h> |
29 | 29 |
|
|
37 | 37 | #include <errno.h> |
38 | 38 | #include <signal.h> |
39 | 39 |
|
40 | | -#include "postgres.h" |
41 | | - |
42 | 40 | #include "miscadmin.h" |
43 | 41 | #include "utils/memutils.h" |
44 | 42 | #include "storage/backendid.h" |
@@ -88,8 +86,8 @@ static HTAB *pgStatBeDead = NULL; |
88 | 86 | static PgStat_StatBeEntry *pgStatBeTable = NULL; |
89 | 87 | static int pgStatNumBackends = 0; |
90 | 88 |
|
91 | | -static char pgStat_tmpfname[PATH_MAX]; |
92 | | -static char pgStat_fname[PATH_MAX]; |
| 89 | +static char pgStat_tmpfname[MAXPGPATH]; |
| 90 | +static char pgStat_fname[MAXPGPATH]; |
93 | 91 |
|
94 | 92 |
|
95 | 93 | /* ---------- |
@@ -140,9 +138,9 @@ pgstat_init(void) |
140 | 138 | /* |
141 | 139 | * Initialize the filenames for the status reports. |
142 | 140 | */ |
143 | | - snprintf(pgStat_tmpfname, PATH_MAX - 1, |
| 141 | + snprintf(pgStat_tmpfname, MAXPGPATH, |
144 | 142 | PGSTAT_STAT_TMPFILE, DataDir, getpid()); |
145 | | - snprintf(pgStat_fname, PATH_MAX - 1, |
| 143 | + snprintf(pgStat_fname, MAXPGPATH, |
146 | 144 | PGSTAT_STAT_FILENAME, DataDir); |
147 | 145 |
|
148 | 146 | /* |
@@ -1696,7 +1694,7 @@ pgstat_write_statsfile(void) |
1696 | 1694 | * Open the statistics temp file to write out |
1697 | 1695 | * the current values. |
1698 | 1696 | */ |
1699 | | - fpout = fopen(pgStat_tmpfname, "w"); |
| 1697 | + fpout = fopen(pgStat_tmpfname, PG_BINARY_W); |
1700 | 1698 | if (fpout == NULL) |
1701 | 1699 | { |
1702 | 1700 | fprintf(stderr, "PGSTAT: cannot open temp stats file\nPGSTAT: "); |
@@ -1954,7 +1952,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, |
1954 | 1952 | * simply return zero for anything and the collector simply |
1955 | 1953 | * starts from scratch with empty counters. |
1956 | 1954 | */ |
1957 | | - if ((fpin = fopen(pgStat_fname, "r")) == NULL) |
| 1955 | + if ((fpin = fopen(pgStat_fname, PG_BINARY_R)) == NULL) |
1958 | 1956 | return; |
1959 | 1957 |
|
1960 | 1958 | /* |
|
0 commit comments