summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorDaniel Black <daniel@linux.vnet.ibm.com>2018-03-14 13:31:28 +1100
committerJan Lindström <jan.lindstrom@mariadb.com>2018-03-15 12:07:43 +0200
commit8b54c314863e7e9861470844e09c0453800748ae (patch)
tree1178e5c268336239fb8ef0ef81c5e998797e8d5b /storage
parent930682c4877b66417184c1787fab7941c9331c34 (diff)
downloadmariadb-git-8b54c314863e7e9861470844e09c0453800748ae.tar.gz
MDEV-8743: where O_CLOEXEC is available, use for innodb buf_dump
As this is the only moderately critical fopened for writing file, create an alternate path to use open and fdopen for non-glibc platforms that support O_CLOEXEC (BSDs). Tested on Linux (by modifing the GLIBC defination) to take this alternate path: $ cd /proc/23874 $ more fdinfo/71 pos: 0 flags: 02100001 mnt_id: 24 $ ls -la fd/71 l-wx------. 1 dan dan 64 Mar 14 13:30 fd/71 -> /dev/shm/var_auto_i7rl/mysqld.1/data/ib_buffer_pool.incomplete
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/buf/buf0dump.cc15
-rw-r--r--storage/xtradb/buf/buf0dump.cc15
2 files changed, 28 insertions, 2 deletions
diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc
index 5d5be0505f6..306dcc2ec18 100644
--- a/storage/innobase/buf/buf0dump.cc
+++ b/storage/innobase/buf/buf0dump.cc
@@ -220,7 +220,20 @@ buf_dump(
buf_dump_status(STATUS_NOTICE, "Dumping buffer pool(s) to %s",
full_filename);
- f = fopen(tmp_filename, "w");
+#if defined(__GLIBC__) || defined(__WIN__) || O_CLOEXEC == 0
+ f = fopen(tmp_filename, "w" STR_O_CLOEXEC);
+#else
+ {
+ int fd;
+ fd = open(tmp_filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, 0640);
+ if (fd >= 0) {
+ f = fdopen(fd, "w");
+ }
+ else {
+ f = NULL;
+ }
+ }
+#endif
if (f == NULL) {
buf_dump_status(STATUS_ERR,
"Cannot open '%s' for writing: %s",
diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc
index 09ac460f865..0bc222d2cc2 100644
--- a/storage/xtradb/buf/buf0dump.cc
+++ b/storage/xtradb/buf/buf0dump.cc
@@ -220,7 +220,20 @@ buf_dump(
buf_dump_status(STATUS_NOTICE, "Dumping buffer pool(s) to %s",
full_filename);
- f = fopen(tmp_filename, "w");
+#if defined(__GLIBC__) || defined(__WIN__) || O_CLOEXEC == 0
+ f = fopen(tmp_filename, "w" STR_O_CLOEXEC);
+#else
+ {
+ int fd;
+ fd = open(tmp_filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, 0640);
+ if (fd >= 0) {
+ f = fdopen(fd, "w");
+ }
+ else {
+ f = NULL;
+ }
+ }
+#endif
if (f == NULL) {
buf_dump_status(STATUS_ERR,
"Cannot open '%s' for writing: %s",