-#endif
-
-void mconsole_proc(struct mc_request *req)
-{
- char path[64];
- char *buf;
- int len;
- int fd;
- int first_chunk = 1;
- char *ptr = req->request.data;
-
- ptr += strlen("proc");
- while(isspace(*ptr)) ptr++;
- snprintf(path, sizeof(path), "/proc/%s", ptr);
-
- fd = sys_open(path, 0, 0);
- if (fd < 0) {
- mconsole_reply(req, "Failed to open file", 1, 0);
- printk("open %s: %d\n",path,fd);
- goto out;
- }
-
- buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- if(buf == NULL){
- mconsole_reply(req, "Failed to allocate buffer", 1, 0);
- goto out_close;
- }
-
- for (;;) {
- len = sys_read(fd, buf, PAGE_SIZE-1);
- if (len < 0) {
- mconsole_reply(req, "Read of file failed", 1, 0);
- goto out_free;
- }
- /*Begin the file content on his own line.*/
- if (first_chunk) {
- mconsole_reply(req, "\n", 0, 1);
- first_chunk = 0;
- }
- if (len == PAGE_SIZE-1) {
- buf[len] = '\0';
- mconsole_reply(req, buf, 0, 1);
- } else {
- buf[len] = '\0';
- mconsole_reply(req, buf, 0, 0);
- break;
- }
- }
-
- out_free:
- kfree(buf);
- out_close:
- sys_close(fd);
- out:
- /* nothing */;
-}