Blaisorblade <[EMAIL PROTECTED]> writes: > Wait - I think this specific case does not need any work with dentries, it is > different from the crash I described. I was giving generic suggestions - > afterwards I looked at sys_getdents and found that this one was easier. > Finish this patch this way and it can be (IMHO) accepted with interest > (after "impedence matching" with kernel standards - codingStyle et similar > things).
Inlined below is another patch that works much of the time. It can be fatal however so be warned. The conditions under which it is fatal are when you request a file descriptor from the fd directory of a process. Even then it is not consistent. I've no idea why of course. Maybe some testing will bear fruit. btw vfs_readdir didn't work. So I simply stole the locking code from somewhere and did my own locking. It seems to work. I'm not sure whether I have to lock the whole kernel though. Again, some more testing might help. Anyway, I thought I'd copy to the list as soon as. It's neat to be able to iterate over proc from outside the VM. --- /var/local/virtualmachine/kernels/linux-2.6.17.1/arch/um/drivers/mconsole_kern.c +++ /var/local/src/linux-2.6.17.1/arch/um/drivers/mconsole_kern.c @@ -209,13 +209,25 @@ } #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; + char *ptr = req->request.data; ptr += strlen("proc"); @@ -238,6 +250,26 @@ for (;;) { len = sys_read(fd, buf, PAGE_SIZE-1); if (len < 0) { + struct file *file; + file = filp_open(path, 0, 0); + if (*file->f_op->readdir != NULL) { + struct inode *inode = file->f_dentry->d_inode; + int res = -ENOTDIR; + int dir_result; + + mutex_lock(&inode->i_mutex); + res = -ENOENT; + if (!IS_DEADDIR(inode)) { + lock_kernel(); + mconsole_reply(req, "\n", 0, 1); + dir_result = file->f_op->readdir(file, req, mconsole_proc_filldir); + unlock_kernel(); + } + mutex_unlock(&inode->i_mutex); + mconsole_reply(req, "", 0, 0); + goto out; + } + mconsole_reply(req, "Read of file failed", 1, 0); goto out_free; } @@ -257,11 +289,12 @@ } out_free: - kfree(buf); + kfree(buf); out_close: sys_close(fd); out: - /* nothing */; + ; + //filp_close(file, NULL); } #define UML_MCONSOLE_HELPTEXT \ Diff finished. Sun Oct 8 23:48:46 2006 ------------------------------------------------------------------------- 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