📄 errata.txt
字号:
While most of the source code printed in the book is part of realprogram files, a few of the examples are standalone excerpts I wroteout of my mind. Unfortunately, I managed to fit a pair of errors inthese code lines.Page XXX========In chapter 9 ("Interrupt Handling"), in the section called "Going toSleep Without Races", the code shown has a subtle bug.The correct implementation of the trick looks like the following: add_wait_queue(&short_queue, &wait); do { current->state = TASK_INTERRUPTIBLE; schedule(); } while ((short_head == short_tail) && !(current->signal & ~current->blocked) ); remove_wait_queue(&short_queue, &wait); if (current->signal & ~current->blocked) /* a signal arrived */ return -ERESTARTSYS;This is different from the version shown in the printed text as signaldecoding must be performed *after* calling remove_wait_queue().Page YYY========In chapter 17, in the section called "Using the New Interface", theioctl() implementation shown includes a stupid mistake: "retval" isnot initilized. A correct implementation is: int another_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); { int retval = -EINVAL, size = _IOC_SIZE(cmd); if (_IOC_DIR(cmd) & _IOC_READ) { if (!access_ok(VERIFY_WRITE, (void *)arg, size)) retturn -EFAULT; } else if (_IOC_DIR(cmd) & _IOC_WRITE) { if (!access_ok(VERIFY_READ, (void *)arg, size)) return -EFAULT switch(cmd) { case NEW_GETVALUE: retval = __put_user(another_value,arg); break; case NEW_SETVALUE: retval = __get_user(another_value,arg); break; } return retval; }Another possibility is just stating "retval = 1" and leaving the codeas shown, but I don't like the unadorned boolean value. Naturally,there are a lot of alternatives to this setup of ioctl().----------------------------------------------------------------------The following notes are about two differences between my intentions,as stated in the printed book, and the actual outcome of the samplefiles as you find them on the ftp site.Allocating DMA memory=====================In the section called "Allocating the DMA buffer", in chapter 13, Irefer to an "allocator.c" module, which performs aggressiveallocation. After using such a module in practice, I found that itdidn't get reliable results, so I dropped it altogether. Theimplementation you find in the sample files (misc-modules/allocator.c)uses high memory to allocate the DMA buffer, in the way explained inthe same section of chapter 13. misc-modules/README.allocator explainsthe issue to a finer detail.Decoding Oops messages======================The version of "oops" you find on the ftp site only decodes messagesgenerated on the Intel platform. I didn't manage to find the time toimplement it on the Alpha and the Sparc, as I intended to. As a matterof fact, Oops messages on RISC platforms include less information thanIntel ones, and they are harder to use.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -