Chinaunix首页 | 论坛 | 博客
  • 博客访问: 155051
  • 博文数量: 26
  • 博客积分: 1555
  • 博客等级: 上尉
  • 技术积分: 236
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-16 17:37
个人简介

我在互联网世界等候各位。。。。。

文章分类

全部博文(26)

文章存档

2015年(1)

2011年(4)

2010年(2)

2009年(19)

我的朋友

分类:

2009-11-10 20:22:00


static void readLogLines(int logfd)
{
    char buffer[256] = {0};
    while (1) {
        unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1] __attribute__((aligned(4)));
        struct logger_entry *entry = (struct logger_entry *) buf;
        int ret;
 
        ret = read(logfd, entry, LOGGER_ENTRY_MAX_LEN);
        if (ret < 0) {
            if (errno == EINTR)
                continue;
            if (errno == EAGAIN)
                break;
            perror("logcat read");
            exit(EXIT_FAILURE);
        }
        else if (!ret) {
            fprintf(stderr, "read: Unexpected EOF!\n");
            exit(EXIT_FAILURE);
        }
 
        /* NOTE: driver guarantees we read exactly one full entry */
 
        entry->msg[entry->len] = '\0';
 
        if (g_printBinary) {
            printBinary(entry);
        } else {
            (void) processBuffer(entry);
        }
 
        /*读入内核调试信息*/
        if((ret = klogctl(9, buffer, sizeof(buffer))) > 0) {
            if((ret = klogctl(2, buffer, sizeof(buffer))) > 0) {
                entry->tid = 0;
                entry->pid = getpid();
                /*priority*/
                entry->msg[0] = ANDROID_LOG_INFO;
                /*tag*/
                strcpy(entry->msg+1, KERNEL_TAG);
                /*message*/
                strncpy(entry->msg+1+sizeof(KERNEL_TAG), buffer, ret);
                entry->len = 1 + sizeof(KERNEL_TAG) + ret + 1;
                entry->msg[entry->len] = '\0';
                if (g_printBinary) {
                    printBinary(entry);
                } else {
                    (void) processBuffer(entry);
                }
            }
        }
    }
}



阅读(2485) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~