aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fd_util.c22
-rw-r--r--src/fd_util.h9
-rw-r--r--src/input/file_input_plugin.c2
-rw-r--r--src/log.c2
-rw-r--r--src/mixer/oss_mixer_plugin.c2
-rw-r--r--src/output/fifo_output_plugin.c4
-rw-r--r--src/output/mvp_plugin.c4
-rw-r--r--src/output/oss_plugin.c4
-rw-r--r--src/output/recorder_output_plugin.c3
9 files changed, 13 insertions, 39 deletions
diff --git a/src/fd_util.c b/src/fd_util.c
index f296aab97..f78b8ed8b 100644
--- a/src/fd_util.c
+++ b/src/fd_util.c
@@ -101,7 +101,7 @@ fd_set_nonblock(int fd)
}
int
-open_cloexec(const char *path_fs, int flags)
+open_cloexec(const char *path_fs, int flags, int mode)
{
int fd;
@@ -113,26 +113,6 @@ open_cloexec(const char *path_fs, int flags)
flags |= O_NOCTTY;
#endif
- fd = open(path_fs, flags, 0666);
- fd_set_cloexec(fd, true);
-
- return fd;
-}
-
-int
-creat_cloexec(const char *path_fs, int mode)
-{
- int flags = O_CREAT|O_WRONLY|O_TRUNC;
- int fd;
-
-#ifdef O_CLOEXEC
- flags |= O_CLOEXEC;
-#endif
-
-#ifdef O_NOCTTY
- flags |= O_NOCTTY;
-#endif
-
fd = open(path_fs, flags, mode);
fd_set_cloexec(fd, true);
diff --git a/src/fd_util.h b/src/fd_util.h
index 8b94a3a27..57ad63288 100644
--- a/src/fd_util.h
+++ b/src/fd_util.h
@@ -46,14 +46,7 @@ struct sockaddr;
* supported by the OS).
*/
int
-open_cloexec(const char *path_fs, int flags);
-
-/**
- * Wrapper for creat(), which sets the CLOEXEC flag (atomically if
- * supported by the OS).
- */
-int
-creat_cloexec(const char *path_fs, int mode);
+open_cloexec(const char *path_fs, int flags, int mode);
/**
* Wrapper for pipe(), which sets the CLOEXEC flag (atomically if
diff --git a/src/input/file_input_plugin.c b/src/input/file_input_plugin.c
index 55b495f38..8561d04e7 100644
--- a/src/input/file_input_plugin.c
+++ b/src/input/file_input_plugin.c
@@ -51,7 +51,7 @@ input_file_open(struct input_stream *is, const char *filename)
*slash = '\0';
}
- fd = open_cloexec(pathname, O_RDONLY);
+ fd = open_cloexec(pathname, O_RDONLY, 0);
if (fd < 0) {
is->error = errno;
g_debug("Failed to open \"%s\": %s",
diff --git a/src/log.c b/src/log.c
index b2de391bd..bb1f1f112 100644
--- a/src/log.c
+++ b/src/log.c
@@ -129,7 +129,7 @@ open_log_file(void)
{
assert(out_filename != NULL);
- return open_cloexec(out_filename, O_CREAT | O_WRONLY | O_APPEND);
+ return open_cloexec(out_filename, O_CREAT | O_WRONLY | O_APPEND, 0666);
}
static void
diff --git a/src/mixer/oss_mixer_plugin.c b/src/mixer/oss_mixer_plugin.c
index 028786ae9..631107b70 100644
--- a/src/mixer/oss_mixer_plugin.c
+++ b/src/mixer/oss_mixer_plugin.c
@@ -123,7 +123,7 @@ oss_mixer_open(struct mixer *data, GError **error_r)
{
struct oss_mixer *om = (struct oss_mixer *) data;
- om->device_fd = open_cloexec(om->device, O_RDONLY);
+ om->device_fd = open_cloexec(om->device, O_RDONLY, 0);
if (om->device_fd < 0) {
g_set_error(error_r, oss_mixer_quark(), errno,
"failed to open %s: %s",
diff --git a/src/output/fifo_output_plugin.c b/src/output/fifo_output_plugin.c
index 0217c2675..b5e6f5314 100644
--- a/src/output/fifo_output_plugin.c
+++ b/src/output/fifo_output_plugin.c
@@ -153,7 +153,7 @@ fifo_open(struct fifo_data *fd, GError **error)
if (!fifo_check(fd, error))
return false;
- fd->input = open_cloexec(fd->path, O_RDONLY|O_NONBLOCK);
+ fd->input = open_cloexec(fd->path, O_RDONLY|O_NONBLOCK, 0);
if (fd->input < 0) {
g_set_error(error, fifo_output_quark(), errno,
"Could not open FIFO \"%s\" for reading: %s",
@@ -162,7 +162,7 @@ fifo_open(struct fifo_data *fd, GError **error)
return false;
}
- fd->output = open_cloexec(fd->path, O_WRONLY|O_NONBLOCK);
+ fd->output = open_cloexec(fd->path, O_WRONLY|O_NONBLOCK, 0);
if (fd->output < 0) {
g_set_error(error, fifo_output_quark(), errno,
"Could not open FIFO \"%s\" for writing: %s",
diff --git a/src/output/mvp_plugin.c b/src/output/mvp_plugin.c
index f5fbadbee..7e6dd6d31 100644
--- a/src/output/mvp_plugin.c
+++ b/src/output/mvp_plugin.c
@@ -116,7 +116,7 @@ mvp_output_test_default_device(void)
{
int fd;
- fd = open_cloexec("/dev/adec_pcm", O_WRONLY);
+ fd = open_cloexec("/dev/adec_pcm", O_WRONLY, 0);
if (fd >= 0) {
close(fd);
@@ -231,7 +231,7 @@ mvp_output_open(void *data, struct audio_format *audio_format, GError **error)
int mix[5] = { 0, 2, 7, 1, 0 };
bool success;
- md->fd = open_cloexec("/dev/adec_pcm", O_RDWR | O_NONBLOCK);
+ md->fd = open_cloexec("/dev/adec_pcm", O_RDWR | O_NONBLOCK, 0);
if (md->fd < 0) {
g_set_error(error, mvp_output_quark(), errno,
"Error opening /dev/adec_pcm: %s",
diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c
index f308c293e..6518c3f49 100644
--- a/src/output/oss_plugin.c
+++ b/src/output/oss_plugin.c
@@ -344,7 +344,7 @@ oss_output_test_default_device(void)
int fd, i;
for (i = G_N_ELEMENTS(default_devices); --i >= 0; ) {
- fd = open_cloexec(default_devices[i], O_WRONLY);
+ fd = open_cloexec(default_devices[i], O_WRONLY, 0);
if (fd >= 0) {
close(fd);
@@ -519,7 +519,7 @@ oss_open(struct oss_data *od, GError **error)
{
bool success;
- od->fd = open_cloexec(od->device, O_WRONLY);
+ od->fd = open_cloexec(od->device, O_WRONLY, 0);
if (od->fd < 0) {
g_set_error(error, oss_output_quark(), errno,
"Error opening OSS device \"%s\": %s",
diff --git a/src/output/recorder_output_plugin.c b/src/output/recorder_output_plugin.c
index 202b56073..11dd6c041 100644
--- a/src/output/recorder_output_plugin.c
+++ b/src/output/recorder_output_plugin.c
@@ -157,7 +157,8 @@ recorder_output_open(void *data, struct audio_format *audio_format,
/* create the output file */
- recorder->fd = creat_cloexec(recorder->path, 0666);
+ recorder->fd = open_cloexec(recorder->path, O_CREAT|O_WRONLY|O_TRUNC,
+ 0666);
if (recorder->fd < 0) {
g_set_error(error_r, recorder_output_quark(), 0,
"Failed to create '%s': %s",