Lines Matching defs:inode
56 * With the new dcache, the pathname is stored at each inode, at least as
57 * long as the refcount of the inode is positive. As a side effect, the
58 * size of the dcache depends on the inode cache and thus is dynamic.
258 static int check_acl(struct inode *inode, int mask)
264 acl = get_cached_acl_rcu(inode, ACL_TYPE_ACCESS);
270 return posix_acl_permission(inode, acl, mask & ~MAY_NOT_BLOCK);
273 acl = get_acl(inode, ACL_TYPE_ACCESS);
277 int error = posix_acl_permission(inode, acl, mask);
289 static int acl_permission_check(struct inode *inode, int mask)
291 unsigned int mode = inode->i_mode;
293 if (likely(uid_eq(current_fsuid(), inode->i_uid)))
296 if (IS_POSIXACL(inode) && (mode & S_IRWXG)) {
297 int error = check_acl(inode, mask);
302 if (in_group_p(inode->i_gid))
316 * @inode: inode to check access rights for
328 int generic_permission(struct inode *inode, int mask)
335 ret = acl_permission_check(inode, mask);
339 if (S_ISDIR(inode->i_mode)) {
341 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
344 if (capable_wrt_inode_uidgid(inode,
354 if (!(mask & MAY_EXEC) || (inode->i_mode & S_IXUGO))
355 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
363 if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
372 * even looking at the inode->i_op values. So we keep a cache
373 * flag in inode->i_opflags, that says "this has not special
376 static inline int do_inode_permission(struct inode *inode, int mask)
378 if (unlikely(!(inode->i_opflags & IOP_FASTPERM))) {
379 if (likely(inode->i_op->permission))
380 return inode->i_op->permission(inode, mask);
382 /* This gets set once for the inode lifetime */
383 spin_lock(&inode->i_lock);
384 inode->i_opflags |= IOP_FASTPERM;
385 spin_unlock(&inode->i_lock);
387 return generic_permission(inode, mask);
391 * __inode_permission - Check for access rights to a given inode
392 * @inode: Inode to check permission on
395 * Check for read/write/execute permissions on an inode.
402 int __inode_permission(struct inode *inode, int mask)
410 if (IS_IMMUTABLE(inode))
414 retval = do_inode_permission(inode, mask);
418 retval = devcgroup_inode_permission(inode, mask);
422 return security_inode_permission(inode, mask);
428 * @sb: Superblock of inode to check permission on
429 * @inode: Inode to check permission on
432 * Separate out file-system wide checks from inode-specific permission checks.
434 static int sb_permission(struct super_block *sb, struct inode *inode, int mask)
437 umode_t mode = inode->i_mode;
448 * inode_permission - Check for access rights to a given inode
449 * @inode: Inode to check permission on
452 * Check for read/write/execute permissions on an inode. We use fs[ug]id for
458 int inode_permission(struct inode *inode, int mask)
462 retval = sb_permission(inode->i_sb, inode, mask);
465 return __inode_permission(inode, mask);
500 struct inode *inode; /* path.dentry.d_inode */
510 struct inode *inode;
595 struct inode *inode = last->inode;
596 if (last->cookie && inode->i_op->put_link) {
597 inode->i_op->put_link(inode, last->cookie);
708 BUG_ON(nd->inode != parent->d_inode);
854 nd->inode = nd->path.dentry->d_inode;
861 struct inode *inode = last->inode;
862 if (last->cookie && inode->i_op->put_link)
863 inode->i_op->put_link(inode, last->cookie);
888 const struct inode *inode;
889 const struct inode *parent;
895 inode = nd->stack[0].inode;
896 if (uid_eq(current_cred()->fsuid, inode->i_uid))
900 parent = nd->inode;
905 if (uid_eq(parent->i_uid, inode->i_uid))
917 * @inode: the source inode to hardlink from
920 * - inode is not a regular file
921 * - inode is setuid
922 * - inode is setgid and group-exec
927 static bool safe_hardlink_source(struct inode *inode)
929 umode_t mode = inode->i_mode;
944 if (inode_permission(inode, MAY_READ | MAY_WRITE))
956 * - fsuid does not match inode
958 * - not CAP_FOWNER in a namespace with the inode owner uid mapped
964 struct inode *inode;
969 inode = link->dentry->d_inode;
971 /* Source inode owner (or CAP_FOWNER) can hardlink all they like,
974 if (inode_owner_or_capable(inode) || safe_hardlink_source(inode))
986 struct inode *inode = last->inode;
993 } else if (atime_needs_update(&last->link, inode)) {
999 error = security_inode_follow_link(dentry, inode,
1005 res = inode->i_link;
1011 res = inode->i_op->follow_link(dentry, &last->cookie);
1024 nd->inode = d->d_inode;
1034 nd->inode = nd->path.dentry->d_inode;
1255 struct inode **inode, unsigned *seqp)
1284 * Update the inode too. We don't need to re-check the
1288 *inode = path->dentry->d_inode;
1296 struct inode *inode = nd->inode;
1308 inode = parent->d_inode;
1321 struct inode *inode2 = mountpoint->d_inode;
1330 inode = inode2;
1343 inode = nd->path.dentry->d_inode;
1346 nd->inode = inode;
1440 nd->inode = nd->path.dentry->d_inode;
1491 static struct dentry *lookup_real(struct inode *dir, struct dentry *dentry,
1529 struct path *path, struct inode **inode,
1551 * This sequence count validates that the inode matches
1554 *inode = d_backing_inode(dentry);
1586 if (likely(__follow_mount_rcu(nd, path, inode, seqp)))
1618 *inode = d_backing_inode(path->dentry);
1631 BUG_ON(nd->inode != parent->d_inode);
1646 int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
1652 return inode_permission(nd->inode, MAY_EXEC);
1667 struct inode *inode, unsigned seq)
1695 last->inode = inode;
1702 * to do this check without having to look at inode->i_op,
1708 struct inode *inode, unsigned seq)
1714 /* make sure that d_is_symlink above matches inode */
1719 return pick_link(nd, link, inode, seq);
1727 struct inode *inode;
1741 err = lookup_fast(nd, &path, &inode, &seq);
1754 inode = d_backing_inode(path.dentry);
1759 err = should_follow_link(nd, &path, flags & WALK_GET, inode, seq);
1763 nd->inode = inode;
2006 struct inode *inode = root->d_inode;
2010 retval = inode_permission(inode, MAY_EXEC);
2015 nd->inode = inode;
2075 nd->inode = nd->path.dentry->d_inode;
2079 nd->inode = nd->path.dentry->d_inode;
2085 nd->inode = nd->path.dentry->d_inode;
2501 * in the inode in this situation, and ESTALE errors can be a problem. We
2522 int __check_sticky(struct inode *dir, struct inode *inode)
2526 if (uid_eq(inode->i_uid, fsuid))
2530 return !capable_wrt_inode_uidgid(inode, CAP_FOWNER);
2553 static int may_delete(struct inode *dir, struct dentry *victim, bool isdir)
2555 struct inode *inode = d_backing_inode(victim);
2560 BUG_ON(!inode);
2571 if (check_sticky(dir, inode) || IS_APPEND(inode) ||
2572 IS_IMMUTABLE(inode) || IS_SWAPFILE(inode))
2596 static inline int may_create(struct inode *dir, struct dentry *child)
2650 int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2674 struct inode *inode = dentry->d_inode;
2681 if (!inode)
2684 switch (inode->i_mode & S_IFMT) {
2702 error = inode_permission(inode, acc_mode);
2709 if (IS_APPEND(inode)) {
2717 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
2726 struct inode *inode = path->dentry->d_inode;
2727 int error = get_write_access(inode);
2741 put_write_access(inode);
2784 struct inode *dir = nd->path.dentry->d_inode;
2887 * We didn't have the inode before the open, so check open permission
2944 struct inode *dir_inode = dir->d_inode;
3019 struct inode *inode;
3039 error = lookup_fast(nd, &path, &inode, &seq);
3046 BUG_ON(nd->inode != dir->d_inode);
3131 inode = d_backing_inode(path.dentry);
3136 inode, seq);
3148 nd->inode = inode;
3226 nd->inode = dir->d_inode;
3243 struct inode *dir;
3271 /* Don't check for other permissions, the inode was just created */
3283 struct inode *inode = file_inode(file);
3284 spin_lock(&inode->i_lock);
3285 inode->i_state |= I_LINKABLE;
3286 spin_unlock(&inode->i_lock);
3487 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
3579 int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
3660 int vfs_rmdir(struct inode *dir, struct dentry *dentry)
3767 * @delegated_inode: returns victim inode, if the inode is delegated.
3772 * return a reference to the inode in delegated_inode. The caller
3773 * should then break the delegation on that inode and retry. Because
3781 int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegated_inode)
3783 struct inode *target = dentry->d_inode;
3835 struct inode *inode = NULL;
3836 struct inode *delegated_inode = NULL;
3859 inode = dentry->d_inode;
3862 ihold(inode);
3871 if (inode)
3872 iput(inode); /* truncate the inode here */
3873 inode = NULL;
3885 inode = NULL;
3916 int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
3978 * @delegated_inode: returns inode needing a delegation break
3984 * inode in delegated_inode. The caller should then break the delegation
3992 int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry, struct inode **delegated_inode)
3994 struct inode *inode = old_dentry->d_inode;
3998 if (!inode)
4005 if (dir->i_sb != inode->i_sb)
4011 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4015 if (S_ISDIR(inode->i_mode))
4022 mutex_lock(&inode->i_mutex);
4024 if (inode->i_nlink == 0 && !(inode->i_state & I_LINKABLE))
4026 else if (max_links && inode->i_nlink >= max_links)
4029 error = try_break_deleg(inode, delegated_inode);
4034 if (!error && (inode->i_state & I_LINKABLE)) {
4035 spin_lock(&inode->i_lock);
4036 inode->i_state &= ~I_LINKABLE;
4037 spin_unlock(&inode->i_lock);
4039 mutex_unlock(&inode->i_mutex);
4041 fsnotify_link(dir, inode, new_dentry);
4060 struct inode *delegated_inode = NULL;
4131 * @delegated_inode: returns an inode needing a delegation break
4138 * reference to the inode in delegated_inode. The caller should then
4174 int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4175 struct inode *new_dir, struct dentry *new_dentry,
4176 struct inode **delegated_inode, unsigned int flags)
4181 struct inode *source = old_dentry->d_inode;
4182 struct inode *target = new_dentry->d_inode;
4320 struct inode *delegated_inode = NULL;
4466 int vfs_whiteout(struct inode *dir, struct dentry *dentry)
4499 * using) it for any given inode is up to filesystem.
4504 struct inode *inode = d_inode(dentry);
4505 const char *link = inode->i_link;
4509 link = inode->i_op->follow_link(dentry, &cookie);
4514 if (inode->i_op->put_link)
4515 inode->i_op->put_link(inode, cookie);
4557 void page_put_link(struct inode *unused, void *cookie)
4568 int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
4570 struct address_space *mapping = inode->i_mapping;
4596 mark_inode_dirty(inode);
4603 int page_symlink(struct inode *inode, const char *symname, int len)
4605 return __page_symlink(inode, symname, len,
4606 !mapping_gfp_constraint(inode->i_mapping, __GFP_FS));