LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 04-16-2010, 02:15 AM   #1
sujababuraj
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Rep: Reputation: 0
Message Q(sys_msgsnd) in Kernel


Hi,
I was trying to use Message Queues for sending message from an
inserted kernel module to user space. The function sys_msgsnd failed
giving the obvious error -EFAULT.
However, I was able to send the message from kernel to user space when I had made the same driver part of kernel (and not inserting it).
How is that possible?
I am using linux.2.6.19.x (arch=ppc)

I now use Netlink socket to communicate from kernel to user, but the above
problem seemed strange to me. Pls help resolve.
Thanks.
 
Old 04-17-2010, 07:02 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
Moved: This thread is more suitable in Linux-Kernel and has been moved accordingly to help your thread/question get the exposure it deserves.

I guess it has more to do with the method you allocate memory for the message. Could you eleborate on this subject?
 
Old 04-19-2010, 01:43 AM   #3
sujababuraj
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Message Q (sys_msgsnd) in Kernel

I have tried obtaining the memory using kmalloc as well as declaring it as a local variable. Result is the same in either case. My msgbuf structure is:
struct MsgQ_Packet
{
long mtype;
unsigned short length;
unsigned short opcode;
unsigned short subfield;
unsigned short debug;
unsigned char msg[2];
};

case 1:
/* Global */
struct MsgQ_Packet *my_tx_msg = NULL;
void init(void) {
..
my_tx_msg = kmalloc(sizeof(struct MsgQ_Packet),GFP_KERNEL);
..
}

void sendmessage(u16 opcode, u16 subfield) {
..
ret = sys_msgsnd(drv_qid, (struct msgbuf *)my_tx_msg, sizeof(struct MsgQ_Packet) - sizeof(long), IPC_NOWAIT);
..
}

case 2:
void sendmessage(u16 opcode, u16 subfield) {
struct MsgQ_Packet my_tx_msg ;
..
ret = sys_msgsnd(drv_qid, (struct msgbuf *)&my_tx_msg, sizeof(struct MsgQ_Packet) - sizeof(long), IPC_NOWAIT);
..
}
 
  


Reply

Tags
kernel, message, queue


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
no /boot/loader and no /boot/kernel/kernel error message on a free bsd install chownuseradd Linux - Newbie 1 02-09-2008 09:05 PM
msgsnd (sys_msgsnd) symbol unresolved yhus Programming 0 09-06-2005 02:49 AM
Message with kernel No module aic7xxx found for kernel 2.4.28 abefroman Red Hat 1 01-31-2005 07:41 AM
Kernel message rlculver Linux - Hardware 1 06-01-2003 09:28 AM
Kernel Message:unable to handle kernel NULL pointer dereference at virtual address... dave_d Linux - General 0 02-14-2001 06:01 PM


All times are GMT -5. The time now is 03:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration