函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:ipc\mqueue.c Create Date:2022-07-27 18:26:20
首页 Copyright©Brick

770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
static int prepare_open(struct dentry *dentry, int oflag, int ro,
            umode_t mode, struct filename *name,
            struct mq_attr *attr)
{
    static const int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE,
                          MAY_READ | MAY_WRITE };
    int acc;
 
    if (d_really_is_negative(dentry)) {
        if (!(oflag & O_CREAT))
            return -ENOENT;
        if (ro)
            return ro;
        audit_inode_parent_hidden(name, dentry->d_parent);
        return vfs_mkobj(dentry, mode & ~current_umask(),
                  mqueue_create_attr, attr);
    }
    /* it already existed */
    audit_inode(name, dentry, 0);
    if ((oflag & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
        return -EEXIST;
    if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY))
        return -EINVAL;
    acc = oflag2acc[oflag & O_ACCMODE];
    return inode_permission(d_inode(dentry), acc);
}