kernel/sysfile.c
static int
argfd(int n, int *pfd, struct file **pf)
{
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == NULL)
    return -1;
  if(pfd)
    *pfd = fd;
  if(pf)
    *pf = f;
  return 0;
}
// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
Fetch the nth word-sized system call argument as a file descriptor
and return both the descriptor and the corresponding struct file.
Fetch the nth word - sized system call argument as a file descriptor and return both the descriptor and the corresponding struct file .
static int
argfd(int n, int *pfd, struct file **pf)
{
  int fd;
  struct file *f;
  if(argint(n, &fd) < 0)
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == NULL)
    return -1;
  if(pfd)
    *pfd = fd;
  if(pf)
    *pf = f;
  return 0;
}
static int argfd ( int n , int * pfd , struct file * * pf ) { int fd ; struct file * f ; if ( argint ( n , & fd ) < 0 ) return -1 ; if ( fd < 0 || fd >= NOFILE || ( f = myproc ( ) -> ofile [ fd ] ) == NULL ) return -1 ; if ( pfd ) * pfd = fd ; if ( pf ) * pf = f ; return 0 ; }
Fetch the nth word-sized system call argument as a file descriptor
and return both the descriptor and the corresponding struct file.
Fetch the nth word - sized system call argument as a file descriptor and return both the descriptor and the corresponding struct file .