Ejemplo n.º 1
0
void init_dev_fs()
{
	devfs_root = (struct inode*)kmalloc(sizeof(struct inode));
	_strcpy(devfs_root->name, "dev");
	devfs_root->i_ops = &devfs_inode_ops;
	devfs_root->parent = current_task->thread->root;
	devfs_root->mode = S_IFDIR | 0x1FF;
	devfs_root->num = -1;
	rwlock_create(&devfs_root->rwl);
	/* Create device nodes */
	char tty[6] = "tty";
	int i;
	for(i=1;i<10;i++) {
		sprintf(tty, "tty%d", i);
		devfs_add(devfs_root, tty, S_IFCHR, 3, i);
	}
	devfs_add(devfs_root, "tty", S_IFCHR, 4, 0);
	devfs_add(devfs_root, "null", S_IFCHR, 0, 0);
	devfs_add(devfs_root, "zero", S_IFCHR, 1, 0);
	devfs_add(devfs_root, "com0", S_IFCHR, 5, 0);
	/* Mount the filesystem */
	add_inode(current_task->thread->root, devfs_root);
#if CONFIG_MODULES
	add_kernel_symbol(devfs_add);
	add_kernel_symbol(devfs_remove);
#endif
}
Ejemplo n.º 2
0
void fs_init(void)
#endif
{
  char *rnn;

  kprintf("FS initialization...\n");
  vfs_node_t *main;

#ifdef __HOSTED__
  main = initrd_init(p, len);
  rnn = "initrd0";
#else
  main = ata_init();
  rnn = "ata0";
#endif

  dfs = devfs_init();

  devfs_add(main);

  root = vfs_alloc_node();
  root->name[0] = '/';
  root->name[1] = 0;

  root->flags = VFS_DIRECTORY;

  vfs_node_t *t = vfs_finddir(dfs, rnn);
  vfs_mount(t, root);

  if (root->ptr != NULL)
  {
    kprintf("Root mounted successfully\n");
  }

  tty_node = tty_init(NULL);
  devfs_add(tty_node);

  fs_print_dir(dfs);
}