Blaisorblade <[EMAIL PROTECTED]> writes: >> Is there a reason that can't be done? > No, it can be done. Produce a working patch and then that will be ok, and I > guess it will be appreciated (at least by me). It isn't IMHO that much > trivial however - the code will be probably be similar but not identical to > the userspace equivalent (using getdents()).
Here's my current attempt. It doesn't work reliably yet and I'm not sure why: @@ -209,19 +209,49 @@ } #endif +int mconsole_proc_filldir(void * __buf, const char * name, int namlen, loff_t offset, + ino_t ino, unsigned int d_type) +{ + struct mc_request *req = (struct mc_request *) __buf; + char buf[namlen+1]; + memcpy(buf, name, namlen); + buf[namlen] = '\n'; + mconsole_reply_len(req, buf, namlen +1, 0, 1); + return 0; +} + void mconsole_proc(struct mc_request *req) { char path[64]; - char *buf; + char *buf = NULL; int len; int fd; int first_chunk = 1; + struct file *file; char *ptr = req->request.data; ptr += strlen("proc"); while(isspace(*ptr)) ptr++; snprintf(path, sizeof(path), "/proc/%s", ptr); + printk("path: %s\n", path); + + file = filp_open(path, 0, 0); + + if (*file->f_op->readdir != NULL) { + int dir_result; + mconsole_reply(req, "\n", 0, 1); + + do { + dir_result = (*file->f_op->readdir)(file, req, mconsole_proc_filldir); + } + while(dir_result > 0); + printk("dir_result: %d\n", dir_result); + + mconsole_reply(req, "", 0, 0); + goto out; + } + fd = sys_open(path, 0, 0); if (fd < 0) { mconsole_reply(req, "Failed to open file", 1, 0); @@ -257,11 +287,12 @@ } out_free: - kfree(buf); + kfree(buf); out_close: sys_close(fd); out: - /* nothing */; + ; + //filp_close(file, NULL); } I have yet to establish wny it doesn't work reliably. -- Nic Ferrier http://www.tapsellferrier.co.uk for all your tapsell ferrier needs ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ User-mode-linux-user mailing list User-mode-linux-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user