Skip to contentSkip to conversation

cobalt: mode argument from open forwarded for O_TMPFILE

PATCH Applied Norbert Lange 2 participants 2 messages Apr 10, 2019

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cobalt: mode argument from open forwarded for O_TMPFILE

The optional mode argument (open is a vararg function), was only be read and forwarded if the O_CREAT flag is set.

That is not complete, as O_TMPFILE will require this argument aswell. Fixed in this commit, and a fallback definition of O_TMPFILE is added, incase libcobalt is built against an library lacking this macro.

---
 lib/cobalt/rtdm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
lib/cobalt/rtdm.c +8 -2
index 6b8898e70..176210ddc 100644
@@ -30,6 +30,12 @@
 #include <asm/xenomai/syscall.h>
 #include "internal.h"
 
+/* support for very old c libraries not supporting O_TMPFILE */
+#ifndef O_TMPFILE
+#define O_TMPFILE (020000000 | 0200000)
+#endif
+
+
 static inline int set_errno(int ret)
 {
 	if (ret >= 0)
@@ -65,7 +71,7 @@ COBALT_IMPL(int, open, (const char *path, int oflag, ...))
 	mode_t mode = 0;
 	va_list ap;
 
-	if (oflag & O_CREAT) {
+	if ((oflag & O_CREAT)  || (oflag & O_TMPFILE) == O_TMPFILE) {
 		va_start(ap, oflag);
 		mode = va_arg(ap, int);
 		va_end(ap);
@@ -79,7 +85,7 @@ COBALT_IMPL(int, open64, (const char *path, int oflag, ...))
 	mode_t mode = 0;
 	va_list ap;
 
-	if (oflag & O_CREAT) {
+	if ((oflag & O_CREAT)  || (oflag & O_TMPFILE) == O_TMPFILE) {
 		va_start(ap, oflag);
 		mode = va_arg(ap, int);
 		va_end(ap);
Signature · 1 line
2.20.1
Applied
#1 lore raw
Quoted 41 lines · Norbert Lange via Xenomai

The optional mode argument (open is a vararg function), was only be read and forwarded if the O_CREAT flag is set.

That is not complete, as O_TMPFILE will require this argument aswell. Fixed in this commit, and a fallback definition of O_TMPFILE is added, incase libcobalt is built against an library lacking this macro.

---
  lib/cobalt/rtdm.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
lib/cobalt/rtdm.c +7 -1
index 6b8898e70..176210ddc 100644
@@ -30,6 +30,12 @@
  #include <asm/xenomai/syscall.h>
  #include "internal.h"
 
+/* support for very old c libraries not supporting O_TMPFILE */
+#ifndef O_TMPFILE
+#define O_TMPFILE (020000000 | 0200000)
+#endif
+
+
  static inline int set_errno(int ret)
  {
  	if (ret >= 0)
@@ -65,7 +71,7 @@ COBALT_IMPL(int, open, (const char *path, int oflag, ...))
  	mode_t mode = 0;
  	va_list ap;
 
-	if (oflag & O_CREAT) {
+	if ((oflag & O_CREAT)  || (oflag & O_TMPFILE) == O_TMPFILE) {
  		va_start(ap, oflag);
  		mode = va_arg(ap, int);
  		va_end(ap);

lib/cobalt/rtdm.c COBALT_IMPL(int, open64, (const char *path, int oflag, ...)) · line 91

Quoted 8 lines
lib/cobalt/rtdm.c +1 -1
@@ -79,7 +85,7 @@ COBALT_IMPL(int, open64, (const char *path, int oflag, ...))
  	mode_t mode = 0;
  	va_list ap;
 
-	if (oflag & O_CREAT) {
+	if ((oflag & O_CREAT)  || (oflag & O_TMPFILE) == O_TMPFILE) {
  		va_start(ap, oflag);
  		mode = va_arg(ap, int);
  		va_end(ap);

Thanks, applied.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux