Commit 456268e5 authored by Norbert Lange via Xenomai's avatar Norbert Lange via Xenomai Committed by Jan Kiszka

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.
Signed-off-by: default avatarNorbert Lange <norbert.lange@andritz.com>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 1b579717
......@@ -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);
......
......@@ -44,6 +44,11 @@
#include <malloc.h>
#include <boilerplate/compiler.h>
/* support for very old c libraries not supporting O_TMPFILE */
#ifndef O_TMPFILE
#define O_TMPFILE (020000000 | 0200000)
#endif
/* sched */
__weak
int __real_pthread_setschedparam(pthread_t thread,
......@@ -174,7 +179,7 @@ int __real_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, mode_t);
va_end(ap);
......@@ -190,7 +195,7 @@ int __real_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, mode_t);
va_end(ap);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment