kernel/fs/mount.c
/*
 * Special case of mounting root IFS file system.
 */
Special case of mounting root IFS file system.
Special case of mounting root IFS file system .
int MountRoot(uint32_t flags, struct stat *stat) {
  struct Process *current;
  int fd = -1;
  int error;
  struct VNode *server_vnode = NULL;
  struct VNode *client_vnode = NULL;
  struct Filp *filp = NULL;
  struct SuperBlock *sb = NULL;
  Info("MountRoot");
  current = GetCurrentProcess();
  sb = AllocSuperBlock();
  if (sb == NULL) {
    error = -ENOMEM;
    goto exit;
  }
  server_vnode = VNodeNew(sb, -1);
  if (server_vnode == NULL) {
    error = -ENOMEM;
    goto exit;
  }
  client_vnode = VNodeNew(sb, 0);
  if (client_vnode == NULL) {
    error = -ENOMEM;
    goto exit;
  }
  InitRendez(&sb->rendez);
  InitMsgPort(&sb->msgport, server_vnode);
  sb->server_vnode = server_vnode; 
  sb->root = client_vnode;         
  sb->flags = flags;
  sb->reference_cnt = 2;
  sb->busy = FALSE;
  server_vnode->flags = V_VALID;
  server_vnode->reference_cnt = 1;
  server_vnode->uid = current->uid;
  server_vnode->gid = current->gid;
  server_vnode->mode = 0777 | _IFPORT;
  server_vnode->size = 0;
  client_vnode->flags = V_VALID | V_ROOT;
  client_vnode->reference_cnt = 1;
  client_vnode->uid = stat->st_uid;
  client_vnode->gid = stat->st_gid;
  client_vnode->mode = stat->st_mode;
  client_vnode->size = stat->st_size;
  fd = AllocHandle();
  if (fd == -1) {
    error = -ENOMEM;
    goto exit;
  }
  client_vnode->vnode_covered = NULL;
  root_vnode = client_vnode;
  filp = GetFilp(fd);
  filp->vnode = server_vnode;
  filp->offset = 0;
  VNodeUnlock(server_vnode);
  VNodeUnlock(client_vnode);
  if (root_vnode != NULL) {
    TaskWakeup(&root_rendez);
  }
  TaskWakeup(&root_rendez);
  return fd;
exit:
  Info ("MountRoot FAILED!!!!!!!!!!!!!!!1");
  return error;
}
int MountRoot ( uint32_t flags , struct stat * stat ) { struct Process * current ; int fd = -1 ; int error ; struct VNode * server_vnode = NULL ; struct VNode * client_vnode = NULL ; struct Filp * filp = NULL ; struct SuperBlock * sb = NULL ; Info ( " " ) ; current = GetCurrentProcess ( ) ; sb = AllocSuperBlock ( ) ; if ( sb == NULL ) { error = - ENOMEM ; goto exit ; } server_vnode = VNodeNew ( sb , -1 ) ; if ( server_vnode == NULL ) { error = - ENOMEM ; goto exit ; } client_vnode = VNodeNew ( sb , 0 ) ; if ( client_vnode == NULL ) { error = - ENOMEM ; goto exit ; } InitRendez ( & sb -> rendez ) ; InitMsgPort ( & sb -> msgport , server_vnode ) ; sb -> server_vnode = server_vnode ; sb -> root = client_vnode ; sb -> flags = flags ; sb -> reference_cnt = 2 ; sb -> busy = FALSE ; server_vnode -> flags = V_VALID ; server_vnode -> reference_cnt = 1 ; server_vnode -> uid = current -> uid ; server_vnode -> gid = current -> gid ; server_vnode -> mode = 0777 | _IFPORT ; server_vnode -> size = 0 ; client_vnode -> flags = V_VALID | V_ROOT ; client_vnode -> reference_cnt = 1 ; client_vnode -> uid = stat -> st_uid ; client_vnode -> gid = stat -> st_gid ; client_vnode -> mode = stat -> st_mode ; client_vnode -> size = stat -> st_size ; fd = AllocHandle ( ) ; if ( fd == -1 ) { error = - ENOMEM ; goto exit ; } client_vnode -> vnode_covered = NULL ; root_vnode = client_vnode ; filp = GetFilp ( fd ) ; filp -> vnode = server_vnode ; filp -> offset = 0 ; VNodeUnlock ( server_vnode ) ; VNodeUnlock ( client_vnode ) ; if ( root_vnode != NULL ) { TaskWakeup ( & root_rendez ) ; } TaskWakeup ( & root_rendez ) ; return fd ; exit : Info ( " " ) ; return error ; }
Special case of mounting root IFS file system.
Special case of mounting root IFS file system .
// Server vnode set to -1. // TODO: Set Client VNODE to some parameter of stat // FIXME: Needed? // FIXME: Needed? // TODO: initialize rest of fields