Lines Matching defs:dir

577 static noinline int create_subvol(struct inode *dir,
582 struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
588 struct btrfs_root *root = BTRFS_I(dir)->root;
591 struct timespec64 cur_time = current_time(dir);
734 ret = btrfs_set_inode_index(BTRFS_I(dir), &index);
740 ret = btrfs_insert_dir_item(trans, name, namelen, BTRFS_I(dir), &key,
747 btrfs_i_size_write(BTRFS_I(dir), dir->i_size + namelen * 2);
748 ret = btrfs_update_inode(trans, root, dir);
755 btrfs_ino(BTRFS_I(dir)), index, name, namelen);
777 inode = btrfs_lookup_dentry(dir, dentry);
791 static int create_snapshot(struct btrfs_root *root, struct inode *dir,
795 struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
831 * 1 - parent dir inode
832 * 2 - dir entries
838 ret = btrfs_subvolume_reserve_metadata(BTRFS_I(dir)->root,
847 pending_snapshot->dir = dir;
899 * Check whether we can remove a link victim from directory dir, check
901 * 1. We can't do it if dir is read-only (done in permission())
902 * 2. We should have write and exec permissions on dir
903 * 3. We can't remove anything from append-only dir
904 * 4. We can't do anything with immutable dir (done in permission())
905 * 5. If the sticky bit on dir is set we should either
906 * a. be owner of dir, or
918 static int btrfs_may_delete(struct inode *dir, struct dentry *victim, int isdir)
925 BUG_ON(d_inode(victim->d_parent) != dir);
926 audit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE);
928 error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
931 if (IS_APPEND(dir))
933 if (check_sticky(dir, d_inode(victim)) || IS_APPEND(d_inode(victim)) ||
943 if (IS_DEADDIR(dir))
951 static inline int btrfs_may_create(struct inode *dir, struct dentry *child)
955 if (IS_DEADDIR(dir))
957 return inode_permission(dir, MAY_WRITE | MAY_EXEC);
971 struct inode *dir = d_inode(parent->dentry);
972 struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
976 error = down_write_killable_nested(&dir->i_rwsem, I_MUTEX_PARENT);
985 error = btrfs_may_create(dir, dentry);
993 error = btrfs_check_dir_item_collision(BTRFS_I(dir)->root,
994 dir->i_ino, name,
1001 if (btrfs_root_refs(&BTRFS_I(dir)->root->root_item) == 0)
1005 error = create_snapshot(snap_src, dir, dentry, readonly, inherit);
1007 error = create_subvol(dir, dentry, name, namelen, inherit);
1010 fsnotify_mkdir(dir, dentry);
1016 inode_unlock(dir);
2950 struct inode *dir = d_inode(parent);
2952 struct btrfs_root *root = BTRFS_I(dir)->root;
3019 dir = d_inode(parent);
3059 if (!S_ISDIR(dir->i_mode)) {
3064 err = down_write_killable_nested(&dir->i_rwsem, I_MUTEX_PARENT);
3099 * Do not allow deletion if the parent dir is the same
3100 * as the dir to be deleted. That means the ioctl
3115 err = btrfs_may_delete(dir, dentry, 1);
3125 err = btrfs_delete_subvolume(dir, dentry);
3128 d_delete_notify(dir, dentry);
3133 inode_unlock(dir);