2009/12/8 Report 報告學生 : 黃健瑋 指導教授 : 李正帆 1
Content seq_file structure proc file Data structure(not completed) 2
seq_file 1/4 static void *my_seq_start(struct seq_file *s, loff_t *pos) { if (*pos >= CLIENT_SIZE) { …… return NULL; } …… return (void *)((unsigned long) *pos); } 3
seq_file 2/4 static void *my_seq_next(struct seq_file *s, void *v, loff_t *pos) { ++(*pos); if(*pos >= CLIENT_SIZE) { return NULL; } return (void *)((unsigned long)*pos); } 4
seq_file 3/4 static void my_seq_stop(struct seq_file *s, void *v) { /* nothing to do, we use a static value in start() */ …… } 5
seq_file 4/4 static int my_seq_show(struct seq_file *s, void *v) { …… n = (int)v; if(proc[n].dstIP == 0) return 0; IpAddressToString(proc[n].dstIP, temp); seq_printf(s, "%s %d\n", temp, proc[n].dstPort); seq_printf(s, "%s\n", proc[n].chnName); seq_printf(s, "%d\n", (int)proc[n].tStamp); seq_printf(s, "%d\n", proc[n].num); for(i = 0; i < proc[n].num; i++) { IpAddressToString(proc[n].peer[i].peerIP, temp); seq_printf(s, "%s %d\n", temp, proc[n].peer[i].peerPort); } return 0; } 6
7
proc file proc file added: deleteClient Delete client –echo IP >> /proc/deleteClient 8
Date structure 1/3 struct _proc { unsigned short num; struct _client client[CLIENT_SIZE] char chnName[100]; struct _peer peer[PEER_LIST_SIZE]; }; 9
Data structure 2/3 4kb problem –One channel data too big 10
Data structure 3/3 Solution: 11
Reference