meiyxq 发表于 2013-12-30 01:13

驱动打开文件读取文件出现如下错误!

Dec 30 01:04:56 test-virtual-machine kernel: Call Trace:
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff813133dc>] apparmor_file_alloc_security+0x2c/0x60
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff812da046>] security_file_alloc+0x16/0x20
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff8119cd28>] get_empty_filp+0x88/0x180
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff811aa168>] path_openat+0x48/0x4d0
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff811aaff2>] do_filp_open+0x42/0xa0
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff816f3a8e>] ? _raw_spin_lock+0xe/0x20
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff811b8c75>] ? __alloc_fd+0xe5/0x170
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff8119ac1a>] do_sys_open+0xfa/0x250
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff8119a2b0>] ? sys_faccessat+0x1f0/0x220
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff8119ad91>] sys_open+0x21/0x30
Dec 30 01:04:56 test-virtual-machine kernel: [<ffffffff816fc8dd>] system_call_fastpath+0x1a/0x1f
Dec 30 01:04:56 test-virtual-machine kernel: Code: 00 4d 8b 04 24 65 4c 03 04 25 08 dc 00 00 49 8b 50 08 4d 8b 28 4d 85 ed 0f 84 cf 00 00 00 49 63 44 24 20 49 8b 3c 24 48 8d 4a 01 <49> 8b 5c 05 00 4c 89 e8 65 48 0f c7 0f 0f 94 c0 84 c0 74 c2 49
Dec 30 01:04:56 test-virtual-machine kernel: RIP[<ffffffff811850ff>] kmem_cache_alloc_trace+0x5f/0x140
Dec 30 01:04:56 test-virtual-machine kernel: RSP <ffff88000b865cd8>
Dec 30 01:04:56 test-virtual-machine kernel: ---[ end trace 60d56133fa2bcb94
这个是什么错误?

wwxxxxll 发表于 2013-12-31 09:48

我以前写的内核写文件代码片段,你看看吧!读的话用filp->f_op->read()。
在x86 linux-2.6.18
arm920t linux-3.2.36运行过
static char data_write =
{
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};

static void filewrite(char* filename)
{
    struct file *filp;
    mm_segment_t fs;
    u32 index = 0;

    filp = filp_open(filename, O_RDWR| O_APPEND| O_CREAT, 0644);
    if (IS_ERR(filp))
    {
      printk("open error...\n");
      return;
    }
    fs=get_fs();

    set_fs(KERNEL_DS);

    for (index = 0; index < 10; index++)
    {
      memset(data_write, index, 10);
      filp->f_op->write(filp, data_write, sizeof(data_write),&filp->f_pos);
    }

    set_fs(fs);

    filp_close(filp,NULL);
}

meiyxq 发表于 2013-12-31 11:35

我的跟你这个差不多的!在centos系统上面运行上面没有问题。但是在ubuntu上面会出现上面说的错误!

hejianet 发表于 2014-01-02 15:18

apparmor 是一个类似selinux的东西,在ubuntu上独有,把它禁止看看
页: [1]
查看完整版本: 驱动打开文件读取文件出现如下错误!