errata
上传用户:wudi5211
上传日期:2010-01-21
资源大小:607k
文件大小:3k
- While most of the source code printed in the book is part of real
- program files, a few of the examples are standalone excerpts I wrote
- out of my mind. Unfortunately, I managed to fit a pair of errors in
- these code lines.
- Page XXX
- ========
- In chapter 9 ("Interrupt Handling"), in the section called "Going to
- Sleep 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 signal
- decoding must be performed *after* calling remove_wait_queue().
- Page YYY
- ========
- In chapter 17, in the section called "Using the New Interface", the
- ioctl() implementation shown includes a stupid mistake: "retval" is
- not 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 code
- as 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 sample
- files as you find them on the ftp site.
- Allocating DMA memory
- =====================
- In the section called "Allocating the DMA buffer", in chapter 13, I
- refer to an "allocator.c" module, which performs aggressive
- allocation. After using such a module in practice, I found that it
- didn't get reliable results, so I dropped it altogether. The
- implementation you find in the sample files (misc-modules/allocator.c)
- uses high memory to allocate the DMA buffer, in the way explained in
- the same section of chapter 13. misc-modules/README.allocator explains
- the issue to a finer detail.
- Decoding Oops messages
- ======================
- The version of "oops" you find on the ftp site only decodes messages
- generated on the Intel platform. I didn't manage to find the time to
- implement it on the Alpha and the Sparc, as I intended to. As a matter
- of fact, Oops messages on RISC platforms include less information than
- Intel ones, and they are harder to use.