Lines Matching refs:dir
47 static int inherit_flags(const struct inode *dir, umode_t mode) in inherit_flags() argument
50 const struct ubifs_inode *ui = ubifs_inode(dir); in inherit_flags()
52 if (!S_ISDIR(dir->i_mode)) in inherit_flags()
77 struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir, in ubifs_new_inode() argument
98 inode_init_owner(&init_user_ns, inode, dir, mode); in ubifs_new_inode()
104 err = fscrypt_prepare_new_inode(dir, inode, &encrypted); in ubifs_new_inode()
135 ui->flags = inherit_flags(dir, mode); in ubifs_new_inode()
196 static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, in ubifs_lookup() argument
203 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_lookup()
206 dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino); in ubifs_lookup()
208 err = fscrypt_prepare_lookup(dir, dentry, &nm); in ubifs_lookup()
229 dent_key_init_hash(c, &key, dir->i_ino, nm.hash); in ubifs_lookup()
232 dent_key_init(c, &key, dir->i_ino, &nm); in ubifs_lookup()
249 inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum)); in ubifs_lookup()
262 if (IS_ENCRYPTED(dir) && in ubifs_lookup()
264 !fscrypt_has_permitted_context(dir, inode)) { in ubifs_lookup()
266 dir->i_ino, inode->i_ino); in ubifs_lookup()
277 static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry, in ubifs_prepare_create() argument
283 return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm); in ubifs_prepare_create()
286 static int ubifs_create(struct user_namespace *mnt_userns, struct inode *dir, in ubifs_create() argument
290 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_create()
293 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_create()
303 dentry, mode, dir->i_ino); in ubifs_create()
309 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_create()
315 inode = ubifs_new_inode(c, dir, mode, false); in ubifs_create()
321 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_create()
326 dir->i_size += sz_change; in ubifs_create()
327 dir_ui->ui_size = dir->i_size; in ubifs_create()
328 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_create()
329 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_create()
341 dir->i_size -= sz_change; in ubifs_create()
342 dir_ui->ui_size = dir->i_size; in ubifs_create()
355 static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry) in create_whiteout() argument
360 struct ubifs_info *c = dir->i_sb->s_fs_info; in create_whiteout()
370 dentry, mode, dir->i_ino); in create_whiteout()
372 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); in create_whiteout()
376 inode = ubifs_new_inode(c, dir, mode, false); in create_whiteout()
385 err = ubifs_init_security(dir, inode, &dentry->d_name); in create_whiteout()
429 static int ubifs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, in ubifs_tmpfile() argument
434 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_tmpfile()
450 dentry, mode, dir->i_ino); in ubifs_tmpfile()
452 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); in ubifs_tmpfile()
469 inode = ubifs_new_inode(c, dir, mode, false); in ubifs_tmpfile()
476 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_tmpfile()
488 lock_2_inodes(dir, inode); in ubifs_tmpfile()
489 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0); in ubifs_tmpfile()
492 unlock_2_inodes(dir, inode); in ubifs_tmpfile()
499 unlock_2_inodes(dir, inode); in ubifs_tmpfile()
567 struct inode *dir = file_inode(file); in ubifs_readdir() local
568 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_readdir()
569 bool encrypted = IS_ENCRYPTED(dir); in ubifs_readdir()
571 dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos); in ubifs_readdir()
581 err = fscrypt_prepare_readdir(dir); in ubifs_readdir()
620 lowest_dent_key(c, &key, dir->i_ino); in ubifs_readdir()
638 dent_key_init_hash(c, &key, dir->i_ino, ctx->pos); in ubifs_readdir()
654 ubifs_inode(dir)->creat_sqnum); in ubifs_readdir()
662 err = fscrypt_fname_disk_to_usr(dir, key_hash_flash(c, in ubifs_readdir()
719 static int ubifs_dir_release(struct inode *dir, struct file *file) in ubifs_dir_release() argument
726 static int ubifs_link(struct dentry *old_dentry, struct inode *dir, in ubifs_link() argument
729 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_link()
732 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_link()
745 inode->i_nlink, dir->i_ino); in ubifs_link()
746 ubifs_assert(c, inode_is_locked(dir)); in ubifs_link()
749 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ubifs_link()
753 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); in ubifs_link()
765 lock_2_inodes(dir, inode); in ubifs_link()
774 dir->i_size += sz_change; in ubifs_link()
775 dir_ui->ui_size = dir->i_size; in ubifs_link()
776 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_link()
777 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_link()
780 unlock_2_inodes(dir, inode); in ubifs_link()
788 dir->i_size -= sz_change; in ubifs_link()
789 dir_ui->ui_size = dir->i_size; in ubifs_link()
793 unlock_2_inodes(dir, inode); in ubifs_link()
801 static int ubifs_unlink(struct inode *dir, struct dentry *dentry) in ubifs_unlink() argument
803 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_unlink()
805 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_unlink()
820 inode->i_nlink, dir->i_ino); in ubifs_unlink()
822 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm); in ubifs_unlink()
832 ubifs_assert(c, inode_is_locked(dir)); in ubifs_unlink()
845 lock_2_inodes(dir, inode); in ubifs_unlink()
846 inode->i_ctime = current_time(dir); in ubifs_unlink()
848 dir->i_size -= sz_change; in ubifs_unlink()
849 dir_ui->ui_size = dir->i_size; in ubifs_unlink()
850 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_unlink()
851 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0); in ubifs_unlink()
854 unlock_2_inodes(dir, inode); in ubifs_unlink()
867 dir->i_size += sz_change; in ubifs_unlink()
868 dir_ui->ui_size = dir->i_size; in ubifs_unlink()
870 unlock_2_inodes(dir, inode); in ubifs_unlink()
886 int ubifs_check_dir_empty(struct inode *dir) in ubifs_check_dir_empty() argument
888 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_check_dir_empty()
894 lowest_dent_key(c, &key, dir->i_ino); in ubifs_check_dir_empty()
907 static int ubifs_rmdir(struct inode *dir, struct dentry *dentry) in ubifs_rmdir() argument
909 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_rmdir()
912 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_rmdir()
923 inode->i_ino, dir->i_ino); in ubifs_rmdir()
924 ubifs_assert(c, inode_is_locked(dir)); in ubifs_rmdir()
930 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm); in ubifs_rmdir()
947 lock_2_inodes(dir, inode); in ubifs_rmdir()
948 inode->i_ctime = current_time(dir); in ubifs_rmdir()
950 drop_nlink(dir); in ubifs_rmdir()
951 dir->i_size -= sz_change; in ubifs_rmdir()
952 dir_ui->ui_size = dir->i_size; in ubifs_rmdir()
953 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_rmdir()
954 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0); in ubifs_rmdir()
957 unlock_2_inodes(dir, inode); in ubifs_rmdir()
970 dir->i_size += sz_change; in ubifs_rmdir()
971 dir_ui->ui_size = dir->i_size; in ubifs_rmdir()
972 inc_nlink(dir); in ubifs_rmdir()
974 unlock_2_inodes(dir, inode); in ubifs_rmdir()
982 static int ubifs_mkdir(struct user_namespace *mnt_userns, struct inode *dir, in ubifs_mkdir() argument
986 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_mkdir()
987 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_mkdir()
999 dentry, mode, dir->i_ino); in ubifs_mkdir()
1005 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_mkdir()
1011 inode = ubifs_new_inode(c, dir, S_IFDIR | mode, false); in ubifs_mkdir()
1017 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_mkdir()
1024 inc_nlink(dir); in ubifs_mkdir()
1025 dir->i_size += sz_change; in ubifs_mkdir()
1026 dir_ui->ui_size = dir->i_size; in ubifs_mkdir()
1027 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_mkdir()
1028 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_mkdir()
1041 dir->i_size -= sz_change; in ubifs_mkdir()
1042 dir_ui->ui_size = dir->i_size; in ubifs_mkdir()
1043 drop_nlink(dir); in ubifs_mkdir()
1055 static int ubifs_mknod(struct user_namespace *mnt_userns, struct inode *dir, in ubifs_mknod() argument
1060 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_mknod()
1061 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_mknod()
1074 dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino); in ubifs_mknod()
1090 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_mknod()
1098 inode = ubifs_new_inode(c, dir, mode, false); in ubifs_mknod()
1111 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_mknod()
1116 dir->i_size += sz_change; in ubifs_mknod()
1117 dir_ui->ui_size = dir->i_size; in ubifs_mknod()
1118 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_mknod()
1119 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_mknod()
1131 dir->i_size -= sz_change; in ubifs_mknod()
1132 dir_ui->ui_size = dir->i_size; in ubifs_mknod()
1144 static int ubifs_symlink(struct user_namespace *mnt_userns, struct inode *dir, in ubifs_symlink() argument
1149 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_symlink()
1150 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_symlink()
1159 symname, dir->i_ino); in ubifs_symlink()
1161 err = fscrypt_prepare_symlink(dir, symname, len, UBIFS_MAX_INO_DATA, in ubifs_symlink()
1174 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_symlink()
1180 inode = ubifs_new_inode(c, dir, S_IFLNK | S_IRWXUGO, false); in ubifs_symlink()
1211 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_symlink()
1216 dir->i_size += sz_change; in ubifs_symlink()
1217 dir_ui->ui_size = dir->i_size; in ubifs_symlink()
1218 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_symlink()
1219 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_symlink()
1230 dir->i_size -= sz_change; in ubifs_symlink()
1231 dir_ui->ui_size = dir->i_size; in ubifs_symlink()