Skip to contentSkip to conversation

crec: Fix error with opening file using O_CREAT

PATCH Applied Richard Fitzgerald 2 participants 2 messages Aug 18, 2014 – Oct 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crec: Fix error with opening file using O_CREAT

From: Ammar Zahid Ali Syed <[email protected]>

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.

---
 crec.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
crec.c +3 -1
index 31703c5..e3f189f 100644
@@ -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);
Signature · 1 line
1.7.2.5
Applied
#1 lore raw
Quoted 6 lines · Richard Fitzgerald

From: Ammar Zahid Ali Syed <[email protected]>

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.

Sorry this slipped thru earlier.

Applied, now

Thanks

Signature · 1 line
~Vinod
Quoted 30 lines
---
 crec.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
crec.c +3 -1
index 31703c5..e3f189f 100644
@@ -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);
Signature · 1 line
1.7.2.5