static void *run(void *data) { int fd; const struct shell *sh; struct fbcon *fbcon = (struct fbcon *) data; sh = shell_lookup("tish"); if (!sh) { return NULL; } close(0); close(1); close(2); idesc_init(&fbcon->idesc, &fbcon_idesc_ops, FS_MAY_READ | FS_MAY_WRITE); fd = index_descriptor_add(&fbcon->idesc); fbcon->vterm.tty.idesc = &fbcon->idesc; assert(fd == 0); dup2(fd, 1); dup2(fd, 2); shell_exec(sh, "login"); return NULL; }
static void sock_init(struct sock *sk, int family, int type, int protocol, const struct sock_family_ops *f_ops, const struct sock_proto_ops *p_ops, const struct net_pack_out_ops *o_ops) { assert(sk != NULL); assert(f_ops != NULL); assert(p_ops != NULL); dlist_head_init(&sk->lnk); sock_opt_init(&sk->opt, family, type, protocol); skb_queue_init(&sk->rx_queue); skb_queue_init(&sk->tx_queue); sk->rx_data_len = 0; sock_set_state(sk, SS_UNKNOWN); sk->shutdown_flag = 0; sk->p_sk = sk->p_sk; /* setup in sock_alloc() */ sk->f_ops = f_ops; sk->p_ops = p_ops; sk->o_ops = o_ops; sk->src_addr = sk->dst_addr = NULL; sk->addr_len = 0; sk->err = 0; idesc_init(&sk->idesc, &task_idx_ops_socket, FS_MAY_READ | FS_MAY_WRITE); sock_xattr_init(sk); security_sock_create(sk); }
static int idesc_pipe_init(struct idesc_pipe *pdesc, struct pipe *pipe, idesc_access_mode_t amode) { idesc_init(&pdesc->idesc, &idesc_pipe_ops, amode); pdesc->pipe = pipe; return 0; }
int diag_fd(void) { struct idesc_table *idesc_table; idesc_table = task_resource_idesc_table(task_self()); if (!idesc_table) { return -ENOSYS; } idesc_init(&diag_idesc, &diag_idx_ops, FS_MAY_READ | FS_MAY_WRITE); return idesc_table_add(idesc_table, &diag_idesc, 0); }
int diag_fd(void) { struct idesc_table *idesc_table; idesc_table = task_resource_idesc_table(task_self()); if (!idesc_table) { return -ENOSYS; } idesc_init(&diag_idesc, &diag_idx_ops, S_IROTH | S_IWOTH); return idesc_table_add(idesc_table, &diag_idesc, 0); }
/* * file_operations */ static int vc_open(struct node *node, struct file_desc *desc, int flags) { struct vterm_video *vc_vga; vc_vga = vc_vga_init(); vterm_init(&vc_vterm, vc_vga, NULL); vterm_open_indev(&vc_vterm, "keyboard"); assert(desc); idesc_init(&desc->idesc, &idesc_vc_ops, S_IROTH | S_IWOTH); vc_vterm.tty.idesc = &desc->idesc; return 0; }