Fork me on GitHub

root/kernel/syscalls/ioctl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sys_ioctl

   1 /*
   2  * fiwix/kernel/syscalls/ioctl.c
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/process.h>
   9 #include <fiwix/errno.h>
  10 
  11 #ifdef __DEBUG__
  12 #include <fiwix/stdio.h>
  13 #endif /*__DEBUG__ */
  14 
  15 int sys_ioctl(unsigned int fd, int cmd, unsigned long int arg)
  16 {
  17         int errno;
  18         struct inode *i;
  19 
  20 #ifdef __DEBUG__
  21         printk("(pid %d) sys_ioctl(%d, 0x%x, 0x%08x) -> ", current->pid, fd, cmd, arg);
  22 #endif /*__DEBUG__ */
  23 
  24         CHECK_UFD(fd);
  25         i = fd_table[current->fd[fd]].inode;
  26         if(i->fsop && i->fsop->ioctl) {
  27                 errno = i->fsop->ioctl(i, cmd, arg);
  28 
  29 #ifdef __DEBUG__
  30                 printk("%d\n", errno);
  31 #endif /*__DEBUG__ */
  32 
  33                 return errno;
  34         }
  35 
  36 #ifdef __DEBUG__
  37         printk("%d\n", -ENOTTY);
  38 #endif /*__DEBUG__ */
  39 
  40         return -ENOTTY;
  41 }

/* [previous][next][first][last][top][bottom][index][help] */