* [Xenomai] Fun with cobalt interposing fcntl
@ 2018-10-16 9:23 Lange Norbert
0 siblings, 0 replies; only message in thread
From: Lange Norbert @ 2018-10-16 9:23 UTC (permalink / raw)
To: Xenomai (xenomai@xenomai.org)
Hello,
I ran into an annoying problem with cobalt, namely that it interposes functions with varargs like fcntl,
The issue is that it won't ever be able to correctly forward the varags.
In the example, fcntl will be interpreted as having an additional int parameter, while some functionality has a pointer instead,
This yields to truncation and errors.
Unfortunatly I don't see any way of fixing this easily, but I consider this harmful (silently breaking code).
IMHO Would be better to remove the wrapping for fcntl and use an explicit cobalt function where necessary.
King regards, Norbert
----- offending code
bool lockfile(const char *fname)
{
int fd = open(fname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0)
{
perror("Opening Component Lock");
return false;
}
struct flock fl = {F_WRLCK, SEEK_SET};
int ret = fcntl(fd, F_SETLK, &fl);
if (ret != 0)
{
perror("Acquiring Component Lock");
return false;
}
return true;
}
----- wrapping in rtdm.c
COBALT_IMPL(int, fcntl, (int fd, int cmd, ...))
{
va_list ap;
int arg;
int ret;
va_start(ap, cmd);
arg = va_arg(ap, int);
va_end(ap);
ret = XENOMAI_SYSCALL3(sc_cobalt_fcntl, fd, cmd, arg);
if (ret != -EBADF && ret != -ENOSYS)
return set_errno(ret);
return __STD(fcntl(fd, cmd, arg));
}
________________________________
This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.
ANDRITZ HYDRO GmbH
Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation
Firmensitz/ Registered seat: Wien
Firmenbuchgericht/ Court of registry: Handelsgericht Wien
Firmenbuchnummer/ Company registration: FN 61833 g
DVR: 0605077
UID-Nr.: ATU14756806
Thank You
________________________________
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-10-16 9:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16 9:23 [Xenomai] Fun with cobalt interposing fcntl Lange Norbert
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.