]> git.alsa-project.org Git - tinycompress.git/commitdiff
crec: Fix error with opening file using O_CREAT
authorAmmar Zahid Ali Syed <ammar.zhd@googlemail.com>
Mon, 18 Aug 2014 08:41:58 +0000 (09:41 +0100)
committerVinod Koul <vinod.koul@intel.com>
Fri, 17 Oct 2014 09:21:22 +0000 (14:51 +0530)
The code was not compiling when mode was not passed to open()
while using O_CREAT offset. Passed mode to the open() alongwith
O_CREAT to specify the attributes of file and fix compile issue.

Signed-off-by: Ammar Zahid Ali Syed <ammar.zhd@googlemail.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
crec.c

diff --git a/crec.c b/crec.c
index 31703c592ab6d34473b488fc94554be3afc56fd1..e3f189f41448ef36074b58d67e820a36db21b072 100644 (file)
--- a/crec.c
+++ b/crec.c
@@ -66,6 +66,8 @@
 #include <stdbool.h>
 #include <getopt.h>
 #include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #define __force
 #define __bitwise
 #define __user
@@ -256,7 +258,7 @@ void capture_samples(char *name, unsigned int card, unsigned int device,
        if (verbose)
                printf("%s: entry, reading %u bytes\n", __func__, length);
 
-       file = open(name, O_RDWR | O_CREAT);
+       file = open(name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
        if (file == -1) {
                fprintf(stderr, "Unable to open file '%s'\n", name);
                exit(EXIT_FAILURE);