星闪夜空 发表于 2012-10-24 14:13

LDD3中调试技术使用/proc实现文件的问题

   关于LDD3中第四章调试技术中使用/proc实现文件中的源码如下:
   int scull_read_procmem(char *buf, char **start, off_t offset,
                   int count, int *eof, void *data)
    {
      int i, j, len = 0;
      int limit = count - 80; /* Don't print more than this */

      for (i = 0; i < scull_nr_devs && len <= limit; i++) {
                struct scull_dev *d = &scull_devices;
                struct scull_qset *qs = d->data;
                if (down_interruptible(&d->sem))
                        return -ERESTARTSYS;
                len += sprintf(buf+len,"\nDevice %i: qset %i, q %i, sz %li\n",
                              i, d->qset, d->quantum, d->size);
                for (; qs && len <= limit; qs = qs->next) { /* scan the list */
                        len += sprintf(buf + len, "item at %p, qset at %p\n",
                                        qs, qs->data);
                        if (qs->data && !qs->next) /* dump only the last item */
                              for (j = 0; j < d->qset; j++) {
                                        if (qs->data)
                                                len += sprintf(buf + len,
                                                                "    % 4i: %8p\n",
                                                                j, qs->data);
                              }
                }
                up(&scull_devices.sem);
      }
      *eof = 1;
      return len;
      }
      
      为什么int limit = count - 80; 不要打印超过这个值的数据?

星闪夜空 发表于 2012-10-25 18:08

怎么木有人来解决这个问题啊?求大神,求指导!!!
页: [1]
查看完整版本: LDD3中调试技术使用/proc实现文件的问题