All of lore.kernel.org
 help / color / mirror / Atom feed
* (no subject)
@ 2019-04-10 14:25 Norbert Lange
  2019-04-10 14:25 ` [PATCH v2 1/1] cobalt: mode argument from open forwarded for O_TMPFILE Norbert Lange
  0 siblings, 1 reply; 3+ messages in thread
From: Norbert Lange @ 2019-04-10 14:25 UTC (permalink / raw)
  To: xenomai

V2 now also fixes the wrappers.

Btw. wouldnt it be possible to just do away with the ugly vaargs?
I tested a few architectures (x86, arm mips, both 32 and 64 bit)
and the function call singature stays the same whether a
function has varagrs or a fixed amount of arguments.

The wrappers could then be oblivous to such wacky special cases.

Torvalds seems to have that opinion aswell:
https://lkml.org/lkml/2014/10/30/812




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/1] cobalt: mode argument from open forwarded for O_TMPFILE
  2019-04-10 14:25 Norbert Lange
@ 2019-04-10 14:25 ` Norbert Lange
  2019-04-10 14:32   ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Norbert Lange @ 2019-04-10 14:25 UTC (permalink / raw)
  To: 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.

Signed-off-by: Norbert Lange <norbert.lange@andritz.com>
---
 lib/cobalt/rtdm.c     | 10 ++++++++--
 lib/cobalt/wrappers.c |  9 +++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c
index 6b8898e70..176210ddc 100644
--- a/lib/cobalt/rtdm.c
+++ b/lib/cobalt/rtdm.c
@@ -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);
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 20ad63a61..323f60b92 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -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);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/1] cobalt: mode argument from open forwarded for O_TMPFILE
  2019-04-10 14:25 ` [PATCH v2 1/1] cobalt: mode argument from open forwarded for O_TMPFILE Norbert Lange
@ 2019-04-10 14:32   ` Jan Kiszka
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2019-04-10 14:32 UTC (permalink / raw)
  To: Norbert Lange, xenomai

On 10.04.19 16:25, Norbert Lange via Xenomai wrote:
> 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: Norbert Lange <norbert.lange@andritz.com>
> ---
>   lib/cobalt/rtdm.c     | 10 ++++++++--
>   lib/cobalt/wrappers.c |  9 +++++++--
>   2 files changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/cobalt/rtdm.c b/lib/cobalt/rtdm.c
> index 6b8898e70..176210ddc 100644
> --- a/lib/cobalt/rtdm.c
> +++ b/lib/cobalt/rtdm.c
> @@ -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);
> diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
> index 20ad63a61..323f60b92 100644
> --- a/lib/cobalt/wrappers.c
> +++ b/lib/cobalt/wrappers.c
> @@ -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);
> 

OK, taken this one now, instead of v1.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-10 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-10 14:25 Norbert Lange
2019-04-10 14:25 ` [PATCH v2 1/1] cobalt: mode argument from open forwarded for O_TMPFILE Norbert Lange
2019-04-10 14:32   ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.