/* this function will perform a io control on a file descriptor. */
int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
/* this function will perform a io control on a file descriptor. */
int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
{
    if (fd == NULL)
        return -EINVAL;
    if (fd->type == FT_REGULAR)
    {
        switch (cmd)
        {
        case F_GETFL:
            return fd->flags;
        case F_SETFL:
            {
                int flags = (int)(rt_base_t)args;
                int mask  = O_NONBLOCK | O_APPEND;
                flags &= mask;
                fd->flags &= ~mask;
                fd->flags |= flags;
            }
            return 0;
        }
    }
    if (fd->fops->ioctl != NULL)
        return fd->fops->ioctl(fd, cmd, args);
    return -ENOSYS;
}