ENFILE, File table overflow, when using kernel iterate_dir

 ̄綄美尐妖づ 提交于 2020-01-05 04:39:08

问题


I recently started with system programming and was wondering how iterate_dir works.

I have written something and I can't figure out why I get errors. My code starts to fail at about 190k-210k iterations.

struct dir_context context2 = { actor2, 0 };

for (i = 0; i < 1000000; i++)
{
    file = filp_open("/", O_RDONLY, 0);
    if (IS_ERR(file))
    {
        printk(KERN_ALERT "ERR: %d", file);
        break;
    }
    if (iterate_dir(file, &context2))
    {
        printk(KERN_ALERT "iterate_dir failed");
        break;
    }
    filp_close(file, 0);
}

The error is always the same 23 (ENFILE, File table overflow), but I opened and closed the file and actor2 is doing nothing. Sometimes vfs file-max limit xxx reached is printed.

static int actor2(struct dir_context *ctx, const char *name, int namlen, loff_t offset, u64 ino, unsigned int d_type)
{
    return 0;
}

Or maybe I have to close the files inside of actor2 (but there is no filep?!).

来源:https://stackoverflow.com/questions/44576890/enfile-file-table-overflow-when-using-kernel-iterate-dir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!