内核扩展模块的读取函数出现“资源暂时不可用”错误。

huangapple go评论161阅读模式
英文:

Read function of kernel extension module is giving Resource temporarily unavailable

问题

I see that you've provided code and descriptions related to a kernel module and user programs for reading and writing messages to a character device. It seems like you're encountering issues with the reader function. The code appears to be in C, and it's related to Linux kernel programming.

Here's a translation of the code-related content:

  1. 我遇到了构建内核模块的问题。这是一个名为message_slot的字符设备模块。根据说明,它应该支持多达256个次设备(所有次设备都具有相同的主设备号-235)。每个次设备代表一个不同的设备文件,并且可以有多达2^20个通道。为了实现这一点,我使用了一个二叉树列表,每个条目表示一个不同的设备文件。
  2. 我有两个用户程序:message_writer.cmessage_reader.c,它们分别成功编译为-o sender和-o reader
  3. 我的问题与reader函数有关。
  4. 在执行整个过程(makeinsmodmknod /dev/slot1 c 235 1sudo chmod o+rw /dev/slot1)并最后执行./sender /dev/slot1 1 message1之后,我得到了以下指示,即“message”实际上被写入了通道1message槽中(使用printk打印):
  5. Write Done. curr_channel->bytes = 8
  6. 然而,当我发出'./reader /dev/slot1 1'时,我得到以下消息:
  7. Resource temporarily unavailable
  8. 在我的read函数中使用printk,并分配'msg_len = curr_channel->bytes'(这是刚刚在sender函数中写入的相同通道),我发现msg_len实际上为0(预期值为8)。
  9. 附上了message_slot.cmessage_slot.hmessage_reader.c的代码:
  10. **message_slot.c**
  11. ...
  12. **message_slot.h**
  13. ...
  14. **message_reader.c**
  15. ...
  16. 运行'strace ./reader /dev/slot1 1'后的消息如下:
  17. ...

Please note that I've provided a translation of the code and descriptions. If you have specific questions or need assistance with a particular issue, please feel free to ask.

英文:

I'm having trouble trying to build a kernel module. It's a character device module named message_slot. According to the instructions, it should support up to 256 minors (all have the same major- 235). Each minor represents a different device file and can have up to 2^20 channels. In order to do so I used a list of binary trees, such that each entry represents a different device file.

I have two user programs: message_writer.c and message_reader.c which were successfully compiled with -o sender and -o reader respectivly.

My problem is related to the reader fuction.
After doing the whole process of make, insmod, mknod /dev/slot1 c 235 1, sudo chmod o+rw /dev/slot1 and finally ./sender /dev/slot1 1 message1 - I got the following indication that "message" was actually writen to the slot1 message slot in channel 1 (printed using printk):
Write Done. curr_channel->bytes = 8

However, when issuing ./reader /dev/slot1 1 I get the following message:
Resource temporarily unavailable
using printk in my read function, and assigning msg_len = curr_channel->bytes (which is the same channel that was just writen in the sender function), I find that msg_len is actually 0 (expected to be 8).

Attached is message_slot.c, message_slot.h and message_reader.c:

message_slot.c

  1. #undef __KERNEL__
  2. #define __KERNEL__
  3. #undef MODULE
  4. #define MODULE
  5. #include <linux/kernel.h>
  6. #include <linux/module.h>
  7. #include <linux/fs.h>
  8. #include <linux/init.h>
  9. #include <linux/uaccess.h>
  10. #include <linux/string.h>
  11. #include <linux/slab.h>
  12. #include "message_slot.h"
  13. MODULE_LICENSE("GPL");
  14. struct channel* search_channel(struct channel*, int);
  15. void insert_channel(struct channel*, struct channel*);
  16. void cleanup_trees(struct channel*);
  17. // We will hold a list containing all the minors
  18. // Each minor is an entry in the minors list
  19. // Actually, each entry will hold the root of a binary tree
  20. // Each node in each binary tree is a channel
  21. // Therefore, our minors list is a list of (root) channels
  22. static struct channel *minors[257]; // 256 (non zero) message slots at most
  23. // Implementation of binary tree functions: search, insert
  24. struct channel* search_channel(struct channel* root, int x) {
  25. struct channel* curr = root;
  26. while (curr != NULL) {
  27. if (curr->channel_number == x) {
  28. return curr; // Found the channel with the given channel_number
  29. } else if (x < curr->channel_number) {
  30. curr = curr->left; // Go to the left subtree
  31. } else {
  32. curr = curr->right; // Go to the right subtree
  33. }
  34. }
  35. return NULL; // Channel with the given channel_number (x) not found
  36. }
  37. void insert_channel(struct channel* root, struct channel* node) {
  38. struct channel* curr;
  39. if (root == NULL) {
  40. // The tree is empty, make the node as the root
  41. root = node;
  42. }
  43. else {
  44. curr = root;
  45. while (1) {
  46. if ((node->channel_number) < (curr->channel_number)) {
  47. if (curr->left == NULL) {
  48. curr->left = node; // Insert node as the left child
  49. break;
  50. }
  51. else {
  52. curr = curr->left; // Move to the left subtree
  53. }
  54. }
  55. else {
  56. if (curr->right == NULL) {
  57. curr->right = node; // Insert node as the right child
  58. break;
  59. }
  60. else {
  61. curr = curr->right; // Move to the right subtree
  62. }
  63. }
  64. }
  65. }
  66. }
  67. // A clean up function, which will be called for each entry in minors when we exit the module
  68. void cleanup_trees(struct channel* root) {
  69. if (root == NULL) {
  70. return; // Base case: empty tree or leaf node
  71. }
  72. // Post-order traversal to delete nodes recursively
  73. cleanup_trees(root->left);
  74. cleanup_trees(root->right);
  75. // Delete the current node
  76. kfree(root);
  77. }
  78. // Device Functions
  79. // device_open: assigning privat data to Null. nothing else required.
  80. static int device_open(struct inode* inode, struct file* file) {
  81. file->private_data = NULL;
  82. printk("End of device open\n");
  83. return SUCCESS;
  84. }
  85. static long device_ioctl(struct file* file, unsigned int ioctl_command_id, unsigned long ioctl_param){
  86. struct channel *curr;
  87. struct channel *root;
  88. int minor;
  89. printk("in ioctl\n");
  90. if (ioctl_command_id != MSG_SLOT_CHANNEL || ioctl_param == 0){
  91. printk("Channel/ Command error\n");
  92. return -EINVAL;
  93. }
  94. minor = iminor(file->f_inode);
  95. root = minors[minor];
  96. curr = search_channel(root, ioctl_param);
  97. if(curr == NULL){
  98. curr = kmalloc(sizeof(struct channel), GFP_KERNEL);
  99. curr->channel_number = ioctl_param;
  100. curr->left = NULL;
  101. curr->right = NULL;
  102. curr->bytes = 0;
  103. insert_channel(root, curr);
  104. }
  105. file->private_data = curr;
  106. printk("number of bits in file->private_data->bytes = %d\n", curr->bytes);
  107. return SUCCESS;
  108. }
  109. static ssize_t device_read(struct file* file, char __user* buffer, size_t length, loff_t* offset){
  110. struct channel *curr_channel;
  111. int msg_len;
  112. int i;
  113. curr_channel = (struct channel *)(file->private_data);
  114. if (curr_channel == NULL){
  115. printk("No channel has been set\n");
  116. return -EINVAL;
  117. }
  118. msg_len = curr_channel->bytes;
  119. printk("msg_len is %d\n", msg_len);
  120. if (length < msg_len || buffer == NULL){
  121. printk("Buffer length is too short to hold the message\n");
  122. return -ENOSPC;
  123. }
  124. if (msg_len == 0){
  125. printk("No message in this channel\n");
  126. return -EWOULDBLOCK;
  127. }
  128. for (i=0 ; i < msg_len; i++){
  129. put_user(curr_channel->message[i],&buffer[i]);
  130. }
  131. return msg_len;
  132. }
  133. static ssize_t device_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset){
  134. struct channel *curr_channel;
  135. char *msg;
  136. int i;
  137. curr_channel = (struct channel *)(file->private_data);
  138. if (curr_channel == NULL){
  139. printk("No channel has been set for this file\n");
  140. return -EINVAL;
  141. }
  142. if (length == 0 || length > MAX_BUF_LEN){
  143. printk("Invalid message length\n");
  144. return -EMSGSIZE;
  145. }
  146. if (buffer == NULL){
  147. printk("Null buffer\n");
  148. return -EINVAL;
  149. }
  150. msg = curr_channel->message;
  151. for (i=0; i< length; i++){
  152. get_user(msg[i],&buffer[i]);
  153. }
  154. curr_channel->bytes = (int)length;
  155. for (i=0 ; i < curr_channel->bytes ; i++){
  156. curr_channel->message[i] = msg[i];
  157. }
  158. printk ("Write Done. curr_channel->bytes = %d\n", curr_channel->bytes);
  159. return length;
  160. }
  161. static int device_release(struct inode* inode, struct file* file){
  162. return SUCCESS;
  163. }
  164. struct file_operations Fops =
  165. {
  166. .owner = THIS_MODULE,
  167. .read = device_read,
  168. .write = device_write,
  169. .open = device_open,
  170. .unlocked_ioctl = device_ioctl,
  171. .release = device_release,
  172. };
  173. static int __init ms_init(void){
  174. int rc;
  175. int i;
  176. if ((rc = register_chrdev(MAJOR_NUM,DEVICE_NAME,&Fops)) < 0){
  177. printk("Registration failed\n");
  178. return FAIL;
  179. }
  180. for (i=0 ; i < 257 ; i ++){
  181. minors[i] = NULL;
  182. }
  183. printk("Registration Successed\n");
  184. return SUCCESS;
  185. }
  186. static void __exit ms_cleanup(void){ // should make sure to clean each and every channel with the cleanup_trees function
  187. struct channel *cur_root;
  188. int i;
  189. for (i=0 ; i < 257; i++){
  190. cur_root = minors[i];
  191. if (cur_root != NULL){
  192. cleanup_trees(minors[i]);
  193. }
  194. }
  195. unregister_chrdev(MAJOR_NUM, DEVICE_NAME);
  196. printk("Seccussfuly unregistered\n");
  197. }
  198. module_init(ms_init);
  199. module_exit(ms_cleanup);

message_slot.h

  1. #ifndef MESSAGE_SLOT_H
  2. #define MESSAGE_SLOT_H
  3. #include <linux/ioctl.h>
  4. #define MAJOR_NUM 235
  5. #define MSG_SLOT_CHANNEL _IOW(MAJOR_NUM, 0, unsigned int)
  6. #define DEVICE_NAME "message_slot"
  7. #define MAX_BUF_LEN 128
  8. #define SUCCESS 0
  9. #define FAIL -1
  10. // We will define the struct channel
  11. // Considering the fact that we keep all channels in a binary tree
  12. // Also required: channel number, the current message
  13. struct channel {
  14. int channel_number;
  15. char message[128];
  16. int bytes;
  17. struct channel *right;
  18. struct channel *left;
  19. };
  20. #endif

message_reader.c

  1. #include <fcntl.h>
  2. #include <unistd.h>
  3. #include <sys/ioctl.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "message_slot.h"
  8. int main(int argc, char** argv){
  9. int fd;
  10. char temp[MAX_BUF_LEN];
  11. unsigned int channel_number;
  12. int msg_len;
  13. if (argc != 3){
  14. perror("Wrong number of arguments");
  15. exit(1);
  16. }
  17. if ((fd = open(argv[1],O_RDWR )) < 0){
  18. perror("Could not open the specified file");
  19. exit(1);
  20. }
  21. channel_number = atoi(argv[2]);
  22. if (ioctl(fd, MSG_SLOT_CHANNEL,channel_number) < 0){
  23. perror("Error issuing ioctl");
  24. exit(1);
  25. }
  26. msg_len = read(fd,temp,MAX_BUF_LEN);
  27. printf("message_len is %d\n", msg_len);
  28. if (msg_len < 0){
  29. perror("Error reading the message");
  30. exit(1);
  31. }
  32. close(fd);
  33. if (write(1,temp,msg_len) < 0){
  34. perror("Fail to write to standrad output");
  35. exit(1);
  36. }
  37. exit(0);
  38. }

And the message after running strace ./reader /dev/slot1 1 :

  1. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  2. brk(NULL) = 0x564947f72000
  3. access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
  4. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  5. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  6. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  7. close(3) = 0
  8. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  9. read(3, "7ELF
    execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  10. brk(NULL)                               = 0x564947f72000
  11. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  12. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  13. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  14. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  15. close(3)                                = 0
  16. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  17. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  18. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  19. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  20. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  21. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  22. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  23. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  24. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  25. close(3)                                = 0
  26. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  27. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  28. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  29. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  30. munmap(0x7f5640f07000, 75005)           = 0
  31. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  32. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  33. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  34. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  35. brk(NULL)                               = 0x564947f72000
  36. brk(0x564947f93000)                     = 0x564947f93000
  37. dup(2)                                  = 4
  38. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  39. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  40. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  41. ) = 60
  42. close(4)                                = 0
  43. write(1, "message_len is -1", 17message_len is -1)       = 17
  44. exit_group(1)                           = ?
  45. +++ exited with 1 +++
  46. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  47. brk(NULL)                               = 0x564947f72000
  48. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  49. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  50. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  51. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  52. close(3)                                = 0
  53. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  54. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  55. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  56. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  57. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  58. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  59. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  60. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  61. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  62. close(3)                                = 0
  63. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  64. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  65. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  66. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  67. munmap(0x7f5640f07000, 75005)           = 0
  68. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  69. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  70. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  71. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  72. brk(NULL)                               = 0x564947f72000
  73. brk(0x564947f93000)                     = 0x564947f93000
  74. dup(2)                                  = 4
  75. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  76. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  77. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  78. ) = 60
  79. close(4)                                = 0
  80. write(1, "message_len is -1", 17message_len is -1)       = 17
  81. exit_group(1)                           = ?
  82. +++ exited with 1 +++
  83. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  84. brk(NULL)                               = 0x564947f72000
  85. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  86. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  87. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  88. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  89. close(3)                                = 0
  90. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  91. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  92. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  93. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  94. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  95. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  96. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  97. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  98. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  99. close(3)                                = 0
  100. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  101. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  102. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  103. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  104. munmap(0x7f5640f07000, 75005)           = 0
  105. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  106. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  107. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  108. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  109. brk(NULL)                               = 0x564947f72000
  110. brk(0x564947f93000)                     = 0x564947f93000
  111. dup(2)                                  = 4
  112. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  113. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  114. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  115. ) = 60
  116. close(4)                                = 0
  117. write(1, "message_len is -1", 17message_len is -1)       = 17
  118. exit_group(1)                           = ?
  119. +++ exited with 1 +++
  120. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  121. brk(NULL)                               = 0x564947f72000
  122. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  123. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  124. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  125. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  126. close(3)                                = 0
  127. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  128. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  129. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  130. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  131. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  132. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  133. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  134. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  135. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  136. close(3)                                = 0
  137. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  138. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  139. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  140. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  141. munmap(0x7f5640f07000, 75005)           = 0
  142. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  143. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  144. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  145. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  146. brk(NULL)                               = 0x564947f72000
  147. brk(0x564947f93000)                     = 0x564947f93000
  148. dup(2)                                  = 4
  149. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  150. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  151. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  152. ) = 60
  153. close(4)                                = 0
  154. write(1, "message_len is -1", 17message_len is -1)       = 17
  155. exit_group(1)                           = ?
  156. +++ exited with 1 +++
  157. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  158. brk(NULL)                               = 0x564947f72000
  159. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  160. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  161. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  162. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  163. close(3)                                = 0
  164. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  165. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  166. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  167. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  168. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  169. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  170. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  171. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  172. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  173. close(3)                                = 0
  174. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  175. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  176. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  177. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  178. munmap(0x7f5640f07000, 75005)           = 0
  179. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  180. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  181. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  182. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  183. brk(NULL)                               = 0x564947f72000
  184. brk(0x564947f93000)                     = 0x564947f93000
  185. dup(2)                                  = 4
  186. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  187. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  188. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  189. ) = 60
  190. close(4)                                = 0
  191. write(1, "message_len is -1", 17message_len is -1)       = 17
  192. exit_group(1)                           = ?
  193. +++ exited with 1 +++
  194. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  195. brk(NULL)                               = 0x564947f72000
  196. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  197. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  198. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  199. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  200. close(3)                                = 0
  201. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  202. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  203. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  204. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  205. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  206. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  207. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  208. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  209. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  210. close(3)                                = 0
  211. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  212. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  213. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  214. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  215. munmap(0x7f5640f07000, 75005)           = 0
  216. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  217. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  218. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  219. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  220. brk(NULL)                               = 0x564947f72000
  221. brk(0x564947f93000)                     = 0x564947f93000
  222. dup(2)                                  = 4
  223. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  224. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  225. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  226. ) = 60
  227. close(4)                                = 0
  228. write(1, "message_len is -1", 17message_len is -1)       = 17
  229. exit_group(1)                           = ?
  230. +++ exited with 1 +++
  231. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  232. brk(NULL)                               = 0x564947f72000
  233. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  234. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  235. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  236. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  237. close(3)                                = 0
  238. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  239. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  240. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  241. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  242. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  243. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  244. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  245. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  246. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  247. close(3)                                = 0
  248. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  249. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  250. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  251. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  252. munmap(0x7f5640f07000, 75005)           = 0
  253. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  254. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  255. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  256. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  257. brk(NULL)                               = 0x564947f72000
  258. brk(0x564947f93000)                     = 0x564947f93000
  259. dup(2)                                  = 4
  260. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  261. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  262. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  263. ) = 60
  264. close(4)                                = 0
  265. write(1, "message_len is -1", 17message_len is -1)       = 17
  266. exit_group(1)                           = ?
  267. +++ exited with 1 +++
  268. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  269. brk(NULL)                               = 0x564947f72000
  270. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  271. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  272. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  273. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  274. close(3)                                = 0
  275. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  276. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  277. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  278. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  279. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  280. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  281. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  282. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  283. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  284. close(3)                                = 0
  285. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  286. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  287. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  288. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  289. munmap(0x7f5640f07000, 75005)           = 0
  290. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  291. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  292. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  293. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  294. brk(NULL)                               = 0x564947f72000
  295. brk(0x564947f93000)                     = 0x564947f93000
  296. dup(2)                                  = 4
  297. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  298. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  299. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  300. ) = 60
  301. close(4)                                = 0
  302. write(1, "message_len is -1", 17message_len is -1)       = 17
  303. exit_group(1)                           = ?
  304. +++ exited with 1 +++
  305. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  306. brk(NULL)                               = 0x564947f72000
  307. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  308. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  309. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  310. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  311. close(3)                                = 0
  312. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  313. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  314. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  315. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  316. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  317. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  318. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  319. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  320. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  321. close(3)                                = 0
  322. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  323. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  324. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  325. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  326. munmap(0x7f5640f07000, 75005)           = 0
  327. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  328. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  329. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  330. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  331. brk(NULL)                               = 0x564947f72000
  332. brk(0x564947f93000)                     = 0x564947f93000
  333. dup(2)                                  = 4
  334. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  335. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  336. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  337. ) = 60
  338. close(4)                                = 0
  339. write(1, "message_len is -1", 17message_len is -1)       = 17
  340. exit_group(1)                           = ?
  341. +++ exited with 1 +++
  342. >
    execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  343. brk(NULL)                               = 0x564947f72000
  344. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  345. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  346. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  347. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  348. close(3)                                = 0
  349. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  350. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  351. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  352. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  353. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  354. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  355. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  356. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  357. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  358. close(3)                                = 0
  359. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  360. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  361. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  362. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  363. munmap(0x7f5640f07000, 75005)           = 0
  364. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  365. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  366. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  367. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  368. brk(NULL)                               = 0x564947f72000
  369. brk(0x564947f93000)                     = 0x564947f93000
  370. dup(2)                                  = 4
  371. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  372. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  373. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  374. ) = 60
  375. close(4)                                = 0
  376. write(1, "message_len is -1", 17message_len is -1)       = 17
  377. exit_group(1)                           = ?
  378. +++ exited with 1 +++
  379. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  380. brk(NULL)                               = 0x564947f72000
  381. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  382. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  383. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  384. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  385. close(3)                                = 0
  386. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  387. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  388. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  389. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  390. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  391. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  392. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  393. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  394. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  395. close(3)                                = 0
  396. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  397. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  398. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  399. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  400. munmap(0x7f5640f07000, 75005)           = 0
  401. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  402. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  403. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  404. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  405. brk(NULL)                               = 0x564947f72000
  406. brk(0x564947f93000)                     = 0x564947f93000
  407. dup(2)                                  = 4
  408. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  409. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  410. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  411. ) = 60
  412. close(4)                                = 0
  413. write(1, "message_len is -1", 17message_len is -1)       = 17
  414. exit_group(1)                           = ?
  415. +++ exited with 1 +++
  416. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  417. brk(NULL)                               = 0x564947f72000
  418. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  419. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  420. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  421. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  422. close(3)                                = 0
  423. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  424. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  425. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  426. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  427. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  428. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  429. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  430. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  431. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  432. close(3)                                = 0
  433. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  434. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  435. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  436. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  437. munmap(0x7f5640f07000, 75005)           = 0
  438. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  439. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  440. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  441. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  442. brk(NULL)                               = 0x564947f72000
  443. brk(0x564947f93000)                     = 0x564947f93000
  444. dup(2)                                  = 4
  445. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  446. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  447. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  448. ) = 60
  449. close(4)                                = 0
  450. write(1, "message_len is -1", 17message_len is -1)       = 17
  451. exit_group(1)                           = ?
  452. +++ exited with 1 +++
  453. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  454. brk(NULL)                               = 0x564947f72000
  455. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  456. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  457. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  458. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  459. close(3)                                = 0
  460. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  461. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  462. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  463. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  464. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  465. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  466. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  467. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  468. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  469. close(3)                                = 0
  470. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  471. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  472. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  473. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  474. munmap(0x7f5640f07000, 75005)           = 0
  475. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  476. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  477. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  478. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  479. brk(NULL)                               = 0x564947f72000
  480. brk(0x564947f93000)                     = 0x564947f93000
  481. dup(2)                                  = 4
  482. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  483. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  484. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  485. ) = 60
  486. close(4)                                = 0
  487. write(1, "message_len is -1", 17message_len is -1)       = 17
  488. exit_group(1)                           = ?
  489. +++ exited with 1 +++
  490. @>
    execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  491. brk(NULL)                               = 0x564947f72000
  492. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  493. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  494. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  495. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  496. close(3)                                = 0
  497. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  498. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  499. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  500. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  501. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  502. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  503. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  504. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  505. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  506. close(3)                                = 0
  507. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  508. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  509. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  510. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  511. munmap(0x7f5640f07000, 75005)           = 0
  512. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  513. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  514. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  515. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  516. brk(NULL)                               = 0x564947f72000
  517. brk(0x564947f93000)                     = 0x564947f93000
  518. dup(2)                                  = 4
  519. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  520. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  521. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  522. ) = 60
  523. close(4)                                = 0
  524. write(1, "message_len is -1", 17message_len is -1)       = 17
  525. exit_group(1)                           = ?
  526. +++ exited with 1 +++
  527. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  528. brk(NULL)                               = 0x564947f72000
  529. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  530. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  531. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  532. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  533. close(3)                                = 0
  534. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  535. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  536. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  537. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  538. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  539. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  540. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  541. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  542. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  543. close(3)                                = 0
  544. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  545. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  546. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  547. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  548. munmap(0x7f5640f07000, 75005)           = 0
  549. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  550. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  551. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  552. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  553. brk(NULL)                               = 0x564947f72000
  554. brk(0x564947f93000)                     = 0x564947f93000
  555. dup(2)                                  = 4
  556. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  557. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  558. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  559. ) = 60
  560. close(4)                                = 0
  561. write(1, "message_len is -1", 17message_len is -1)       = 17
  562. exit_group(1)                           = ?
  563. +++ exited with 1 +++
  564. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  565. brk(NULL)                               = 0x564947f72000
  566. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  567. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  568. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  569. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  570. close(3)                                = 0
  571. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  572. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  573. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  574. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  575. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  576. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  577. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  578. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  579. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  580. close(3)                                = 0
  581. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  582. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  583. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  584. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  585. munmap(0x7f5640f07000, 75005)           = 0
  586. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  587. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  588. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  589. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  590. brk(NULL)                               = 0x564947f72000
  591. brk(0x564947f93000)                     = 0x564947f93000
  592. dup(2)                                  = 4
  593. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  594. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  595. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  596. ) = 60
  597. close(4)                                = 0
  598. write(1, "message_len is -1", 17message_len is -1)       = 17
  599. exit_group(1)                           = ?
  600. +++ exited with 1 +++
  601. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  602. brk(NULL)                               = 0x564947f72000
  603. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  604. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  605. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  606. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  607. close(3)                                = 0
  608. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  609. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  610. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  611. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  612. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  613. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  614. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  615. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  616. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  617. close(3)                                = 0
  618. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  619. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  620. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  621. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  622. munmap(0x7f5640f07000, 75005)           = 0
  623. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  624. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  625. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  626. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  627. brk(NULL)                               = 0x564947f72000
  628. brk(0x564947f93000)                     = 0x564947f93000
  629. dup(2)                                  = 4
  630. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  631. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  632. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  633. ) = 60
  634. close(4)                                = 0
  635. write(1, "message_len is -1", 17message_len is -1)       = 17
  636. exit_group(1)                           = ?
  637. +++ exited with 1 +++
  638. execve("./reader", ["./reader", "/dev/slot1", "1"], 0x7ffcf0397a20 /* 22 vars */) = 0
  639. brk(NULL)                               = 0x564947f72000
  640. access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  641. openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
  642. fstat(3, {st_mode=S_IFREG|0644, st_size=75005, ...}) = 0
  643. mmap(NULL, 75005, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5640f07000
  644. close(3)                                = 0
  645. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
  646. read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
  647. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  648. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  649. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  650. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  651. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  652. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  653. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  654. close(3)                                = 0
  655. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  656. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  657. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  658. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  659. munmap(0x7f5640f07000, 75005)           = 0
  660. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  661. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  662. read(3, 0x7ffc2388cc20, 128)            = -1 EAGAIN (Resource temporarily unavailable)
  663. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  664. brk(NULL)                               = 0x564947f72000
  665. brk(0x564947f93000)                     = 0x564947f93000
  666. dup(2)                                  = 4
  667. fcntl(4, F_GETFL)                       = 0x402 (flags O_RDWR|O_APPEND)
  668. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  669. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  670. ) = 60
  671. close(4)                                = 0
  672. write(1, "message_len is -1", 17message_len is -1)       = 17
  673. exit_group(1)                           = ?
  674. +++ exited with 1 +++
  675. "..., 832) = 832
  676. fstat(3, {st_mode=S_IFREG|0755, st_size=1905632, ...}) = 0
  677. mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5640f05000
  678. mmap(NULL, 1918592, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5640d30000
  679. mmap(0x7f5640d52000, 1417216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f5640d52000
  680. mmap(0x7f5640eac000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17c000) = 0x7f5640eac000
  681. mmap(0x7f5640efb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ca000) = 0x7f5640efb000
  682. mmap(0x7f5640f01000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5640f01000
  683. close(3) = 0
  684. arch_prctl(ARCH_SET_FS, 0x7f5640f06540) = 0
  685. mprotect(0x7f5640efb000, 16384, PROT_READ) = 0
  686. mprotect(0x564946a5f000, 4096, PROT_READ) = 0
  687. mprotect(0x7f5640f44000, 4096, PROT_READ) = 0
  688. munmap(0x7f5640f07000, 75005) = 0
  689. openat(AT_FDCWD, "/dev/slot1", O_RDONLY) = 3
  690. ioctl(3, _IOC(_IOC_WRITE, 0xeb, 0, 0x4), 0x1) = 0
  691. read(3, 0x7ffc2388cc20, 128) = -1 EAGAIN (Resource temporarily unavailable)
  692. fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  693. brk(NULL) = 0x564947f72000
  694. brk(0x564947f93000) = 0x564947f93000
  695. dup(2) = 4
  696. fcntl(4, F_GETFL) = 0x402 (flags O_RDWR|O_APPEND)
  697. fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
  698. write(4, "Error reading the message: Resou"..., 60Error reading the message: Resource temporarily unavailable
  699. ) = 60
  700. close(4) = 0
  701. write(1, "message_len is -1", 17message_len is -1) = 17
  702. exit_group(1) = ?
  703. +++ exited with 1 +++

Any help will be appreciated!

答案1

得分: 1

以下是您提供的代码段的翻译:

  1. `device_open` 执行了一个无条件的操作:
  2. ```c
  3. file->private_data = NULL;

这在写操作被调用时被正确地设置。

但是,在读操作被调用时,之前由写操作设置的值丢失了(即内存泄漏),因为它被无条件地设置为 NULL

由于这是在读操作中获取数据的地方,您必须确保保留/使用先前的值。


此外,读/写操作可能会收到合法的 EAGAINEWOULDBLOCK 错误。在您的读写操作中,您必须检测并循环处理这种情况。


更新:

在读取程序中,它发出了一个 ioctl 调用。

这会初始化驱动程序中的 private_data。但是,senderreader 的地址现在是不同的。

也就是说,驱动程序读操作不会采用空指针返回(例如 EINVAL),而会采用 EWOULDBLOCK 返回,因为这是第二个实例是空的原因。

因此,解决方法与我最初提到的相同。

驱动程序必须保留 private_data,以便 senderreader 使用相同的指针值(例如用于 struct channel 实例)。


更新 #2:

下载、构建和运行后...

主要问题在于 insert_channel 中,如果 rootNULL,它将 root 设置为 curr

但是,这只适用于该函数的局部范围。

它没有设置全局 minors 数组的正确元素。

目前,只有 insert_channel 的调用者知道要与该数组一起使用的正确索引(例如 minor)。

因此,最简单的解决方法是由调用者(例如 device_ioctl)设置它。

以下是更改后的文件。它们使用了 cpp 条件来表示旧代码与新代码:

  1. #if 0
  2. // 旧代码
  3. #else
  4. // 新代码
  5. #endif
  6. #if 1
  7. // 新代码
  8. #endif

注意:可以通过运行文件通过 unifdef -k 进行清理。


文件:message_slot.c

  1. #undef __KERNEL__
  2. #define __KERNEL__
  3. #undef MODULE
  4. #define MODULE
  5. #include <linux/kernel.h>
  6. #include <linux/module.h>
  7. #include <linux/fs.h>
  8. #include <linux/init.h>
  9. #include <linux/uaccess.h>
  10. #include <linux/string.h>
  11. #include <linux/slab.h>
  12. #include "message_slot.h"
  13. MODULE_LICENSE("GPL");
  14. struct channel *search_channel(struct channel *, int);
  15. void insert_channel(struct channel *, struct channel *);
  16. void cleanup_trees(struct channel *);
  17. // 我们将持有一个包含所有次设备号的列表
  18. // 每个次设备号都是列表中的一个条目
  19. // 实际上,每个条目将包含二叉树的根
  20. // 每个二叉树中的每个节点都是一个通道
  21. // 因此,我们的次设备号列表是(根)通道的列表
  22. // 最多 256 个(非零)消息槽
  23. static struct channel *minors[257];
  24. #define printk(_fmt...) \
  25. printk("GURGLE " _fmt)
  26. // 二叉树函数的实现:搜索、插入
  27. struct channel *
  28. search_channel(struct channel *root, int x)
  29. {
  30. struct channel *curr = root;
  31. printk("search_channel: ENTER root=%p x=%d\n", root, x);
  32. while (curr != NULL) {
  33. printk("search_channel: curr=%p channel_number=%d\n",
  34. curr, curr->channel_number);
  35. if (curr->channel_number == x) {
  36. // 找到具有给定 channel_number 的通道
  37. #if 0
  38. return curr;
  39. #else
  40. break;
  41. #endif
  42. }
  43. else if (x < curr->channel_number) {
  44. // 转到左子树
  45. curr = curr->left;
  46. }
  47. else {
  48. // 转到右子树
  49. curr = curr->right;
  50. }
  51. }
  52. // 没有找到具有给定 channel_number(x)的通道
  53. #if 0
  54. return NULL;
  55. #else
  56. printk("search_channel: EXIT curr=%p\n", curr);
  57. return curr;
  58. #endif
  59. }
  60. void
  61. insert_channel(struct channel *root, struct channel *node)
  62. {
  63. struct channel *curr;
  64. printk("insert_channel: ENTER root=%p node=%p\n", root, node);
  65. // 注意/错误:调用者必须在全局次设备号中设置这个值
  66. // 树为空,将节点设置为根
  67. if (root == NULL) {
  68. root = node;
  69. }
  70. else {
  71. curr = root;
  72. while (1) {
  73. if (node->channel_number < curr->channel_number) {
  74. // 将节点作为左子节点插入
  75. if (curr->left == NULL) {
  76. curr->left = node;
  77. break;
  78. }
  79. // 转到左子树
  80. curr = curr->left;
  81. }
  82. else {
  83. // 将节点作为右子节点插入
  84. if (curr->right == NULL) {
  85. curr->right = node;
  86. break;
  87. }
  88. // 转到右子树
  89. curr = curr->right;
  90. }
  91. }
  92. }
  93. }
  94. // 一个清理函数,在模块退出时将为每个条目调用它
  95. void
  96. cleanup_trees(struct channel *root)
  97. {
  98. if (root == NULL) {
  99. // 基本情况:空树或叶子节点
  100. return;
  101. }
  102. // 后序遍历递归地删除节点
  103. cleanup_trees(root->left);
  104. cleanup_trees(root->right);
  105. // 删除当前节点
  106. kfree(root);
  107. }
  108. // 设备函数
  109. // device_open: 将私有数据分配为 Null。不需要其他操作。
  110. static int
  111. device_open(struct inode *inode, struct file *file)
  112. {
  113. file->private_data = NULL;
  114. printk("device_open: End of device open\n");
  115. return SUCCESS;
  116. }
  117. static long
  118. device_ioctl(struct file *file, unsigned int ioctl_command_id,
  119. unsigned long ioctl_param)
  120. {
  121. struct channel *curr;
  122. struct channel *root;
  123. int minor;
  124. <details>
  125. <summary>英文:</summary>
  126. A few issues ...
  127. ----------
  128. `device_open` does an _unconditional_:

file->private_data = NULL;

  1. This [subsequently] gets _set_ correctly when the writer is invoked.
  2. But, when the reader is invoked, the previous value (set by the writer) is lost (i.e. the memory is leaked) because of the unconditional setting to `NULL`.
  3. Since this is where you get the data from on a read, you have to ensure that you preserve/use the prior value.
  4. ----------
  5. Also, it _is_ possible for a read/write operation to get a _legitimate_ `EAGAIN` [`EWOULDBLOCK`] error. In your reader/writer, you have to detect this and loop.
  6. ----------
  7. **UPDATE:**
  8. In the reader program, it issues an `ioctl` call.
  9. This initializes `private_data` in the driver. But, the address for `sender` and `reader` are now _different_.
  10. That is, the driver read operation does _not_ take the null pointer return (e.g. `EINVAL`) but the `EWOULDBLOCK` return because this _second_ instance is empty.
  11. So, the remedy is the same [as I originally mentioned].
  12. The driver _must_ preserve `private_data` so that _both_ sender and reader use the same pointer value (e.g.) for the `struct channel` instance.
  13. ----------
  14. **UPDATE #2:**
  15. After downloading, building, and running ...
  16. The primary issue is that in `insert_channel`, _if_ `root` is `NULL`, it sets `root` to `curr`.
  17. But, this is [only] _local_ to the function.
  18. It does _not_ set the correct element of the global `minors` array.
  19. At present, only the _caller_ of `insert_channel` knows the correct _index_ to use with that array (e.g. `minor`).
  20. So, the simplest solution is to have caller (e.g. `device_ioctl`) set this.
  21. Below are the changed files. They are annotated with the bugs and fixes.
  22. Note that I had to synthesize an appropriate `Makefile` and a script to show the system log.
  23. In the code below, I&#39;ve used `cpp` conditionals to denote old vs. new code:

#if 0
// old code
#else
// new code
#endif

#if 1
// new code
#endif

  1. Note: this can be cleaned up by running the file through `unifdef -k`
  2. ----------
  3. FILE: message_slot.c

#undef KERNEL
#define KERNEL
#undef MODULE
#define MODULE

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/uaccess.h>
#include <linux/string.h>
#include <linux/slab.h>
#include "message_slot.h"
MODULE_LICENSE("GPL");

struct channel *search_channel(struct channel *, int);
void insert_channel(struct channel *, struct channel *);
void cleanup_trees(struct channel *);

// We will hold a list containing all the minors
// Each minor is an entry in the minors list
// Actually, each entry will hold the root of a binary tree
// Each node in each binary tree is a channel
// Therefore, our minors list is a list of (root) channels
// 256 (non zero) message slots at most
static struct channel *minors[257];

#define printk(_fmt...)
printk("GURGLE " _fmt)

// Implementation of binary tree functions: search, insert

struct channel *
search_channel(struct channel *root, int x)
{
struct channel *curr = root;

  1. printk(&quot;search_channel: ENTER root=%p x=%d\n&quot;,root,x);
  2. while (curr != NULL) {
  3. printk(&quot;search_channel: curr=%p channel_number=%d\n&quot;,
  4. curr,curr-&gt;channel_number);
  5. if (curr-&gt;channel_number == x) {
  6. // Found the channel with the given channel_number

#if 0
return curr;
#else
break;
#endif
}
else if (x < curr->channel_number) {
// Go to the left subtree
curr = curr->left;
}
else {
// Go to the right subtree
curr = curr->right;
}
}

  1. // Channel with the given channel_number (x) not found

#if 0
return NULL;
#else
printk("search_channel: EXIT curr=%p\n",curr);
return curr;
#endif
}

void
insert_channel(struct channel *root, struct channel *node)
{
struct channel *curr;

  1. printk(&quot;insert_channel: ENTER root=%p node=%p\n&quot;,root,node);

// NOTE/BUG: caller must set this value in the global minors
// The tree is empty, make the node as the root
if (root == NULL) {
root = node;
}
else {
curr = root;
while (1) {
if (node->channel_number < curr->channel_number) {
// Insert node as the left child
if (curr->left == NULL) {
curr->left = node;
break;
}

  1. // Move to the left subtree
  2. curr = curr-&gt;left;
  3. }
  4. else {
  5. // Insert node as the right child
  6. if (curr-&gt;right == NULL) {
  7. curr-&gt;right = node;
  8. break;
  9. }
  10. // Move to the right subtree
  11. curr = curr-&gt;right;
  12. }
  13. }
  14. }

}

// A clean up function, which will be called for each entry in minors when we
// exit the module
void
cleanup_trees(struct channel *root)
{
if (root == NULL) {
// Base case: empty tree or leaf node
return;
}

  1. // Post-order traversal to delete nodes recursively
  2. cleanup_trees(root-&gt;left);
  3. cleanup_trees(root-&gt;right);
  4. // Delete the current node
  5. kfree(root);

}

// Device Functions

// device_open: assigning privat data to Null. nothing else required.
static int
device_open(struct inode *inode, struct file *file)
{
file->private_data = NULL;
printk("device_open: End of device open\n");
return SUCCESS;
}

static long
device_ioctl(struct file *file, unsigned int ioctl_command_id,
unsigned long ioctl_param)
{
struct channel *curr;
struct channel *root;
int minor;

  1. printk(&quot;device_ioctl: ENTER\n&quot;);
  2. if (ioctl_command_id != MSG_SLOT_CHANNEL || ioctl_param == 0) {
  3. printk(&quot;device_ioctl: Channel/ Command error\n&quot;);
  4. return -EINVAL;
  5. }
  6. minor = iminor(file-&gt;f_inode);
  7. root = minors[minor];
  8. curr = search_channel(root, ioctl_param);
  9. if (curr == NULL) {
  10. curr = kmalloc(sizeof(struct channel), GFP_KERNEL);
  11. curr-&gt;channel_number = ioctl_param;
  12. curr-&gt;left = NULL;
  13. curr-&gt;right = NULL;
  14. curr-&gt;bytes = 0;
  15. printk(&quot;device_ioctl: NEW curr=%p channel_number=%d\n&quot;,
  16. curr,curr-&gt;channel_number);

#if 0
// NOTE/BUG: setting a new root in insert_channel does not set minors
insert_channel(root, curr);
#else
// NOTE/FIX: we should do it here as [only] we know the array index
if (root == NULL)
minors[minor] = curr;
else
insert_channel(root, curr);
#endif
}

  1. file-&gt;private_data = curr;
  2. printk(&quot;device_ioctl: EXIT curr=%p\n&quot;,curr);
  3. return SUCCESS;

}

static ssize_t
device_read(struct file *file, char __user *buffer, size_t length,
loff_t *offset)
{
struct channel *curr_channel;
int msg_len;
int i;

  1. curr_channel = file-&gt;private_data;
  2. printk(&quot;device_read: curr_channel=%p\n&quot;,curr_channel);
  3. if (curr_channel == NULL) {
  4. printk(&quot;device_read: No channel has been set\n&quot;);
  5. return -EINVAL;
  6. }
  7. msg_len = curr_channel-&gt;bytes;
  8. printk(&quot;device_read: msg_len is %d\n&quot;, msg_len);
  9. if (length &lt; msg_len || buffer == NULL) {
  10. printk(&quot;device_read: Buffer length is too short to hold the message\n&quot;);
  11. return -ENOSPC;
  12. }
  13. if (msg_len == 0) {
  14. printk(&quot;device_read: No message in this channel\n&quot;);
  15. return -EWOULDBLOCK;
  16. }
  17. for (i = 0; i &lt; msg_len; i++) {
  18. put_user(curr_channel-&gt;message[i], &amp;buffer[i]);
  19. }
  20. return msg_len;

}

static ssize_t
device_write(struct file *file, const char __user *buffer, size_t length,
loff_t *offset)
{
struct channel *curr_channel;
char *msg;
int i;

  1. curr_channel = (struct channel *) (file-&gt;private_data);
  2. printk(&quot;device_write: curr_channel=%p\n&quot;,curr_channel);
  3. if (curr_channel == NULL) {
  4. printk(&quot;device_write: No channel has been set for this file\n&quot;);
  5. return -EINVAL;
  6. }
  7. if (length == 0 || length &gt; MAX_BUF_LEN) {
  8. printk(&quot;device_write: Invalid message length\n&quot;);
  9. return -EMSGSIZE;
  10. }
  11. if (buffer == NULL) {
  12. printk(&quot;device_write: Null buffer\n&quot;);
  13. return -EINVAL;
  14. }
  15. msg = curr_channel-&gt;message;
  16. printk(&quot;device_write: msg=%p\n&quot;,msg);
  17. for (i = 0; i &lt; length; i++) {
  18. get_user(msg[i], &amp;buffer[i]);
  19. printk(&quot;device_write: msg[%d]=%2.2X\n&quot;,i,msg[i]);
  20. }
  21. curr_channel-&gt;bytes = (int) length;
  22. printk(&quot;Write Done. curr_channel-&gt;bytes = %d\n&quot;, curr_channel-&gt;bytes);
  23. return length;

}

static int
device_release(struct inode *inode, struct file *file)
{
return SUCCESS;
}

struct file_operations Fops = {
.owner = THIS_MODULE,
.read = device_read,
.write = device_write,
.open = device_open,
.unlocked_ioctl = device_ioctl,
.release = device_release,
};

static int __init
ms_init(void)
{
int rc;
int i;

  1. if ((rc = register_chrdev(MAJOR_NUM, DEVICE_NAME, &amp;Fops)) &lt; 0) {
  2. printk(&quot;Registration failed\n&quot;);
  3. return FAIL;
  4. }
  5. for (i = 0; i &lt; 257; i++) {
  6. minors[i] = NULL;
  7. }
  8. printk(&quot;Registration Successed\n&quot;);
  9. return SUCCESS;

}

// should make sure to clean each and every channel with the cleanup_trees
// function
static void __exit
ms_cleanup(void)
{
struct channel *cur_root;
int i;

  1. for (i = 0; i &lt; 257; i++) {
  2. cur_root = minors[i];
  3. if (cur_root != NULL)
  4. cleanup_trees(cur_root);
  5. }
  6. unregister_chrdev(MAJOR_NUM, DEVICE_NAME);
  7. printk(&quot;Successfuly unregistered\n&quot;);

}

module_init(ms_init);
module_exit(ms_cleanup);

  1. ----------
  2. FILE: message_reader.c

#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "message_slot.h"

int
main(int argc, char **argv)
{
int fd;
char temp[MAX_BUF_LEN];
unsigned int channel_number;
int msg_len;

  1. if (argc != 3) {
  2. perror(&quot;Wrong number of arguments&quot;);
  3. exit(1);
  4. }
  5. if ((fd = open(argv[1], O_RDWR)) &lt; 0) {
  6. perror(&quot;Could not open the specified file&quot;);
  7. exit(1);
  8. }
  9. channel_number = atoi(argv[2]);
  10. if (ioctl(fd, MSG_SLOT_CHANNEL, channel_number) &lt; 0) {
  11. perror(&quot;Error issuing ioctl&quot;);
  12. exit(1);
  13. }
  14. msg_len = read(fd, temp, MAX_BUF_LEN);
  15. printf(&quot;reader: message_len is %d\n&quot;, msg_len);
  16. if (msg_len &lt; 0) {
  17. perror(&quot;Error reading the message&quot;);
  18. exit(1);
  19. }
  20. close(fd);

#if 0
if (write(1, temp, msg_len) < 0) {
perror("Fail to write to standrad output");
exit(1);
}
#else
fwrite(temp,1,msg_len,stdout);
printf("\n");
#endif

  1. return 0;

}

  1. ----------
  2. FILE: Makefile

devtree/Makefile -- make file for devtree

SO: read function of kernel extension module is giving resource temporarily

SO: unavaila

SITE: stackoverflow.com

SO: 76408531

MOD = message_slot

MAJOR_NUM := 235
DEVFILE := /dev/slot1

KPATH := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m = $(MOD).o

ifeq ($(SUDO),"")
SUDO := sudo
endif

###LOGMSG := grep GURGLE /var/log/messages ; true
LOGMSG := $(SUDO) perl ./showlog

all: reader sender
$(MAKE) -C $(KPATH) M=$(PWD) modules

clean:
$(MAKE) -C $(KPATH) M=$(PWD) clean
rm -f reader sender
$(SUDO) rmmod $(MOD).ko; true
$(SUDO) rm -f $(DEVFILE)

insmod: all
sync
$(SUDO) rmmod $(MOD).ko; true
$(SUDO) insmod $(MOD).ko

log:
$(LOGMSG)

devices:
$(SUDO) rm -f $(DEVFILE)
$(SUDO) mknod $(DEVFILE) c $(MAJOR_NUM) 1
$(SUDO) chmod o+rw $(DEVFILE)

install: insmod devices

test_sender: sender
$(GDB) ./sender $(DEVFILE) 1 message1
$(LOGMSG)

test_reader: reader
$(GDB) ./reader $(DEVFILE) 1
$(LOGMSG)

reader: message_reader.c
gcc -o reader message_reader.c

sender: message_sender.c
gcc -o sender message_sender.c

  1. ----------
  2. FILE: showlog

#!/usr/bin/perl

showlog -- show kernel logfile

master(@ARGV);
exit(0);

sub master
{
my(@argv) = @_;

  1. foreach $arg (@argv) {
  2. next unless ($arg =~ s/^-//);
  3. $sym = &quot;opt_&quot; . $arg;
  4. $$sym = 1;
  5. }
  6. ###@body = (`journalctl --lines=10000`);
  7. @body = (`dmesg`);
  8. printf(&quot;showlog: BODY %d\n&quot;,scalar(@body));
  9. foreach $buf (@body) {
  10. chomp($buf);
  11. ###printf(&quot;TRACE buf=&#39;%s&#39;\n&quot;,$buf);
  12. next unless ($buf =~ /GURGLE/);
  13. if ($buf =~ /Registration.Success/) {
  14. undef(@out)
  15. unless ($opt_a);
  16. $hit = 1;
  17. }
  18. push(@out,$buf)
  19. if ($hit);
  20. }
  21. foreach $buf (@out) {
  22. print($buf,&quot;\n&quot;);
  23. }

}

  1. ----------
  2. Here is the full test output:

18:50:03.673318386 NEWDAY 06/05/23
18:50:03.673318386 ph: starting 716334 ...
18:50:03.674014091 ph: ARGV make SUDO=shazam clean install test_sender test_reader ...

make -C /lib/modules/5.3.11-100.fc29.x86_64/build M=/home/cae/tmp/devtree clean
make[1]: Entering directory '/usr/src/kernels/5.3.11-100.fc29.x86_64'
CLEAN /home/cae/tmp/devtree/Module.symvers
make[1]: Leaving directory '/usr/src/kernels/5.3.11-100.fc29.x86_64'
rm -f reader sender
shazam rmmod message_slot.ko; true
shazam rm -f /dev/slot1
gcc -o reader message_reader.c
gcc -o sender message_sender.c
make -C /lib/modules/5.3.11-100.fc29.x86_64/build M=/home/cae/tmp/devtree modules
make[1]: Entering directory '/usr/src/kernels/5.3.11-100.fc29.x86_64'
CC [M] /home/cae/tmp/devtree/message_slot.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/cae/tmp/devtree/message_slot.mod.o
LD [M] /home/cae/tmp/devtree/message_slot.ko
make[1]: Leaving directory '/usr/src/kernels/5.3.11-100.fc29.x86_64'
sync
shazam rmmod message_slot.ko; true
rmmod: ERROR: Module message_slot is not currently loaded
shazam insmod message_slot.ko
shazam rm -f /dev/slot1
shazam mknod /dev/slot1 c 235 1
shazam chmod o+rw /dev/slot1
./sender /dev/slot1 1 message1
shazam perl ./showlog
showlog: BODY 1272
[6713278.237239] GURGLE Registration Successed
[6713278.264249] GURGLE device_open: End of device open
[6713278.264258] GURGLE device_ioctl: ENTER
[6713278.264260] GURGLE search_channel: ENTER root=000000009a5e2b86 x=1
[6713278.264261] GURGLE search_channel: EXIT curr=000000009a5e2b86
[6713278.264262] GURGLE device_ioctl: NEW curr=000000000fd62f73 channel_number=1
[6713278.264263] GURGLE device_ioctl: EXIT curr=000000000fd62f73
[6713278.264266] GURGLE device_write: curr_channel=000000000fd62f73
[6713278.264266] GURGLE device_write: msg=0000000096063cbd
[6713278.264267] GURGLE device_write: msg[0]=6D
[6713278.264268] GURGLE device_write: msg[1]=65
[6713278.264269] GURGLE device_write: msg[2]=73
[6713278.264270] GURGLE device_write: msg[3]=73
[6713278.264271] GURGLE device_write: msg[4]=61
[6713278.264271] GURGLE device_write: msg[5]=67
[6713278.264272] GURGLE device_write: msg[6]=65
[6713278.264273] GURGLE device_write: msg[7]=31
[6713278.264274] GURGLE Write Done. curr_channel->bytes = 8
./reader /dev/slot1 1
reader: message_len is 8
message1
shazam perl ./showlog
showlog: BODY 1278
[6713278.237239] GURGLE Registration Successed
[6713278.264249] GURGLE device_open: End of device open
[6713278.264258] GURGLE device_ioctl: ENTER
[6713278.264260] GURGLE search_channel: ENTER root=000000009a5e2b86 x=1
[6713278.264261] GURGLE search_channel: EXIT curr=000000009a5e2b86
[6713278.264262] GURGLE device_ioctl: NEW curr=000000000fd62f73 channel_number=1
[6713278.264263] GURGLE device_ioctl: EXIT curr=000000000fd62f73
[6713278.264266] GURGLE device_write: curr_channel=000000000fd62f73
[6713278.264266] GURGLE device_write: msg=0000000096063cbd
[6713278.264267] GURGLE device_write: msg[0]=6D
[6713278.264268] GURGLE device_write: msg[1]=65
[6713278.264269] GURGLE device_write: msg[2]=73
[6713278.264270] GURGLE device_write: msg[3]=73
[6713278.264271] GURGLE device_write: msg[4]=61
[6713278.264271] GURGLE device_write: msg[5]=67
[6713278.264272] GURGLE device_write: msg[6]=65
[6713278.264273] GURGLE device_write: msg[7]=31
[6713278.264274] GURGLE Write Done. curr_channel->bytes = 8
[6713278.298388] GURGLE device_open: End of device open
[6713278.298399] GURGLE device_ioctl: ENTER
[6713278.298402] GURGLE search_channel: ENTER root=000000000fd62f73 x=1
[6713278.298403] GURGLE search_channel: curr=000000000fd62f73 channel_number=1
[6713278.298404] GURGLE search_channel: EXIT curr=000000000fd62f73
[6713278.298405] GURGLE device_ioctl: EXIT curr=000000000fd62f73
[6713278.298408] GURGLE device_read: curr_channel=000000000fd62f73
[6713278.298410] GURGLE device_read: msg_len is 8

18:50:07.223792314 ph: complete (ELAPSED: 00:00:03.548927068)

  1. </details>

huangapple
  • 本文由 发表于 2023年6月6日 00:55:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76408531.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定