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
________________________________

_______________________________________________
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai

Reply via email to