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. |
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? |
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); .. } |
All times are GMT -5. The time now is 08:54 AM. |