/* this function is a POSIX compliant version, which shall perform a variety of control functions on devices. */
int fcntl(int fildes, int cmd,...)
/* this function is a POSIX compliant version, which shall perform a variety of control functions on devices. */
int fcntl(int fildes, int cmd,...)
{
    int ret = -1;
    struct dfs_fd *d;
    d = fd_get(fildes);
    if (d)
    {
        void *arg;
        va_list ap;
        va_start(ap, cmd);
        arg = va_arg(ap, void *);
        va_end(ap);
        ret = dfs_file_ioctl(d, cmd, arg);
        fd_put(d);
    }
    else ret = -EBADF;
    if (ret < 0)
    {
        rt_set_errno(ret);
        ret = -1;
    }
    return ret;
}