Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619AbXL0BiF (ORCPT ); Wed, 26 Dec 2007 20:38:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751710AbXL0Bhy (ORCPT ); Wed, 26 Dec 2007 20:37:54 -0500 Received: from nofear-snat.bivio.net ([216.142.75.231]:33791 "EHLO corpexc01.corp.networkrobots.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751701AbXL0Bhx (ORCPT ); Wed, 26 Dec 2007 20:37:53 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C84828.90BE9A34" Subject: Device node - How does kernel know about it Date: Wed, 26 Dec 2007 17:34:04 -0800 Message-ID: X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: Device node - How does kernel know about it Thread-Index: AchIKDAFATx33+nNRhyrqi8pP6Al/wAAAZyA From: "Siva Prasad" To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9995 Lines: 169 This is a multi-part message in MIME format. ------_=_NextPart_001_01C84828.90BE9A34 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, How do the device nodes work as an interface between user and kernel programs, and how to go debugging it?=20 This is as part of my debugging effort on an embedded board. * It all started with the problem of "not printing" any thing that comes from ramdisk (echo and printf statements), while kernel printk's work perfectly fine. * Ramdisk is also executing fine, just that prints are not coming out of serial. I can see the execution of various user programs with a printk in sys_execve() routine. Ramdisk has all the required files like /dev/console, /dev/ttyS0, etc. * Looking further into tty driver, I noticed that call to tty_write() or do_tty_write() is not happening at all. So, somewhere the interface between kernel and user program is lost. * Just to check it out, I tried to write a small kernel module and a test program. - Attached memtest.c module (not really testing memory there. :-)) - Attached testmemtest.c user program, that just open's it and reads the information - Created a device node using "mknod /dev/memtest c 168 0" - When I do "insmod memtest.ko" inside the ramdisk bootup scripts, I could see all the printk's on the console - When I execute "testmemtest" next in the same script, it does not display the printk inside of memtest.c module. This only indicates that read call did not really go to the kernel side. - Just to check my program's validity, I checked on a similar machine and all the code works fine.=20 - "uname -r" also matches with what I built. So, chances of exiting from open call because of mismatch is remote. Since userland cannot print, I have no idea what exactly is happening there. Now going back to the original question... How does a kernel know about device nodes and how to link with it. Basically I believe interface between user programs and kernel is lost at device nodes. Appreciate any help in continuing my debugging efforts. Thanks Siva ------_=_NextPart_001_01C84828.90BE9A34 Content-Type: application/octet-stream; name="memtest.c" Content-Transfer-Encoding: base64 Content-Description: memtest.c Content-Disposition: attachment; filename="memtest.c" Ci8qIEFwcHJvcHJpYXRlIEtlcm5lbCBoZWFkZXIgZmlsZXMgKi8KI2luY2x1ZGUgPGxpbnV4L2lu aXQuaD4KI2luY2x1ZGUgPGxpbnV4L21vZHVsZS5oPgojaW5jbHVkZSA8bGludXgva2VybmVsLmg+ CiNpbmNsdWRlIDxsaW51eC9zY2hlZC5oPgojaW5jbHVkZSA8bGludXgvcG9sbC5oPgojaW5jbHVk ZSA8bGludXgvZnMuaD4KI2luY2x1ZGUgPGxpbnV4L2NkZXYuaD4KI2luY2x1ZGUgPGxpbnV4L21t Lmg+CiNpbmNsdWRlIDxsaW51eC9kZWxheS5oPgojaW5jbHVkZSA8bGludXgvcmFuZG9tLmg+CiNp bmNsdWRlIDxhc20vaW8uaD4KCi8qIERlZmF1bHRzICovCiNkZWZpbmUgREVGQVVMVF9NQUpPUgkx NjgKI2RlZmluZSBERUZBVUxUX05BTUUJIm1lbXRlc3QiCgovKiBQYXJhbWV0ZXJzIHRoYXQgY2Fu IGJlIHNldCBieSBpbnNtb2QgKi8Kc3RhdGljIGludCBtYWpvciA9IAlERUZBVUxUX01BSk9SOwpz dGF0aWMgY2hhciogbmFtZSA9IAlERUZBVUxUX05BTUU7CQoKI2RlZmluZSB1aW50IHVuc2lnbmVk IGludAoKLyogRnVuY3Rpb24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nsKCXByaW50ayhLRVJOX0VNRVJHICJt ZW10ZXN0IFJFTEVBU0VEOlxuIik7CgoJLy8gSnVzdCByZXR1cm4sIGFzIHRoZXJlIGlzIG5vdGhp bmcgdG8gZG8gaW4gcmVsZWFzZS4KCXJldHVybiAwOwp9CgoKbW9kdWxlX2luaXQobXlfaW5pdF9t b2R1bGUpOwptb2R1bGVfZXhpdChteV9jbGVhbnVwX21vZHVsZSk7Cgo= ------_=_NextPart_001_01C84828.90BE9A34 Content-Type: application/octet-stream; name="testmemtest.c" Content-Transfer-Encoding: base64 Content-Description: testmemtest.c Content-Disposition: attachment; filename="testmemtest.c" CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDxmY250bC5o PgoKI2RlZmluZSBERVZJQ0UgIi9kZXYvbWVtdGVzdCIKI2RlZmluZSBCVUZGRVJfU0laRSAgICAg NTAKCmludCBtYWluKHZvaWQpCnsKCWludCBmZCwgcmV0dmFsLCBpOwoJY2hhciBidWZmZXJbQlVG RkVSX1NJWkUqODBdOwoJdW5zaWduZWQgbG9uZyBidWZsZW5ndGggPSAwOwoKCglmZCA9IG9wZW4o REVWSUNFLCBPX1JET05MWSk7CglwcmludGYoInRlc3RtZW10ZXN0OiBvcGVuIHJldHVybmVkIGZk PSVkLlxuIiwgZmQpOwoJaWYgKGZkIDwgMCkKCXsKCQlwcmludGYoIkNvdWxkIG5vdCBvcGVuIHRo ZSBkZXZpY2UgYCVzJy5cbiIsIERFVklDRSk7CgkJcmV0dXJuIC0xOwoJfQoKCXJldHZhbCA9IHJl YWQoZmQsIGJ1ZmZlciwgQlVGRkVSX1NJWkUqODApOwoJaWYgKHJldHZhbCA8IDEpCgkJcHJpbnRm KCJFcnJvciByZWFkaW5nIGluZm9ybWF0aW9uIGZyb20gJXMuXG4iLCBERVZJQ0UpOwoKCWZvciAo aT0wOyBpPHJldHZhbDsgaSsrKSBwcmludGYoIiVjIiwgYnVmZmVyW2ldKTsKCgljbG9zZShmZCk7 Cgp9Cg== ------_=_NextPart_001_01C84828.90BE9A34-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/