open

作者: grimlock44 | 来源:发表于2019-08-02 11:13 被阅读0次
long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
{
    struct open_flags op;
    int lookup = build_open_flags(flags, mode, &op);
    struct filename *tmp = getname(filename);
    int fd = PTR_ERR(tmp);

    if (!IS_ERR(tmp)) {
        fd = get_unused_fd_flags(flags);
        if (fd >= 0) {
            struct file *f = do_filp_open(dfd, tmp, &op, lookup);
            if (IS_ERR(f)) {
                put_unused_fd(fd);
                fd = PTR_ERR(f);
            } else {
                fsnotify_open(f);             fsnotify
                fd_install(fd, f);               和task关联上
            }
        }
        putname(tmp);
    }
    return fd;
}

相关文章

网友评论

      本文标题:open

      本文链接:https://www.haomeiwen.com/subject/wknkdctx.html