1 #include <lunaix/fs/taskfs.h>
2 #include <lunaix/process.h>
4 #define proc(map) (twimap_data(map, struct proc_info*))
7 __task_read_parent(struct twimap* map)
9 twimap_printf(map, "%d", proc(map)->parent->pid);
13 __task_read_created(struct twimap* map)
15 twimap_printf(map, "%d", proc(map)->created);
19 __task_read_pgid(struct twimap* map)
21 twimap_printf(map, "%d", proc(map)->pgid);
25 __task_read_cmdline(struct twimap* map)
27 twimap_printf(map, "%s", proc(map)->cmd);
31 __get_protection(struct mm_region* vmr, char* prot_buf)
33 prot_buf[0] = (vmr->attr & REGION_READ) ? 'r' : '-';
34 prot_buf[1] = (vmr->attr & REGION_WRITE) ? 'w' : '-';
35 prot_buf[2] = (vmr->attr & REGION_EXEC) ? 'x' : '-';
36 prot_buf[3] = shared_writable_region(vmr) ? 's' : 'p';
41 __get_vmr_name(struct mm_region* vmr, char* buf, unsigned int size)
45 region_type = (vmr->attr >> 16) & 0xf;
47 if (region_type == REGION_TYPE_STACK) {
48 strcpy(buf, "[stack]");
51 else if (region_type == REGION_TYPE_HEAP) {
52 strcpy(buf, "[heap]");
55 else if (vmr->mfile) {
56 vfs_get_path(vmr->mfile->dnode, buf, size, 0);
65 __task_read_maps(struct twimap* map)
67 struct llist_header* vmr_;
68 struct mm_region* vmr;
71 vmr_ = twimap_index(map, struct llist_header*);
72 vmr = container_of(vmr_, struct mm_region, head);
76 char prot[5], name[256];
78 __get_protection(vmr, prot);
79 __get_vmr_name(vmr, name, 256);
81 size = vmr->end - vmr->start;
83 twimap_printf(map, "%012lx-%012lx %x %s %s\n",
84 vmr->start, vmr->end, size, prot, name);
88 __task_gonext_maps(struct twimap* map)
91 struct llist_header* vmr;
93 vmr = twimap_index(map, struct llist_header*);
94 mm = vmspace(proc(map));
99 map->index = vmr->next;
100 if (map->index == &mm->regions) {
108 __task_reset_maps(struct twimap* map)
112 mm = vmspace(proc(map));
113 if (llist_empty(&mm->regions)) {
118 map->index = mm->regions.next;
124 taskfs_export_attr(parent);
125 taskfs_export_attr(created);
126 taskfs_export_attr(pgid);
127 taskfs_export_attr(cmdline);
128 taskfs_export_list_attr(maps);