kernel/fs/handle.c
/*
 * Allocates a handle structure.  Checks to see that free_handle_cnt is
 * non-zero should already have been performed prior to calling AllocHandle().
 */
Allocates a handle structure.  Checks to see that free_handle_cnt is
non-zero should already have been performed prior to calling AllocHandle().
Allocates a handle structure . Checks to see that free_handle_cnt is non - zero should already have been performed prior to calling AllocHandle () .
int AllocHandle(void) {
  int fd;
  struct Process *current;
  struct Filp *filp;
  current = GetCurrentProcess();
  for (fd = 0; fd < NPROC_FD; fd++) {
    if (current->fd_table[fd] == NULL) {
      filp = AllocFilp();
      if (filp == NULL) {
        return -ENOMEM;
      }
      current->fd_table[fd] = filp;      
      filp->reference_cnt++;
      return fd;
    }
  }
  return -EMFILE;
}
int AllocHandle ( void ) { int fd ; struct Process * current ; struct Filp * filp ; current = GetCurrentProcess ( ) ; for ( fd = 0 ; fd < NPROC_FD ; fd ++ ) { if ( current -> fd_table [ fd ] == NULL ) { filp = AllocFilp ( ) ; if ( filp == NULL ) { return - ENOMEM ; } current -> fd_table [ fd ] = filp ; filp -> reference_cnt ++ ; return fd ; } } return - EMFILE ; }
Allocates a handle structure.
Allocates a handle structure .