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()
76 struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir, in ubifs_new_inode() argument
97 inode_init_owner(inode, dir, mode); in ubifs_new_inode()
102 err = fscrypt_prepare_new_inode(dir, inode, &encrypted); in ubifs_new_inode()
132 ui->flags = inherit_flags(dir, mode); in ubifs_new_inode()
193 static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, in ubifs_lookup() argument
200 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_lookup()
203 dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino); in ubifs_lookup()
205 err = fscrypt_prepare_lookup(dir, dentry, &nm); in ubifs_lookup()
226 dent_key_init_hash(c, &key, dir->i_ino, nm.hash); in ubifs_lookup()
229 dent_key_init(c, &key, dir->i_ino, &nm); in ubifs_lookup()
246 inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum)); in ubifs_lookup()
259 if (IS_ENCRYPTED(dir) && in ubifs_lookup()
261 !fscrypt_has_permitted_context(dir, inode)) { in ubifs_lookup()
263 dir->i_ino, inode->i_ino); in ubifs_lookup()
274 static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry, in ubifs_prepare_create() argument
280 return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm); in ubifs_prepare_create()
283 static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode, in ubifs_create() argument
287 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_create()
290 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_create()
300 dentry, mode, dir->i_ino); in ubifs_create()
306 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_create()
312 inode = ubifs_new_inode(c, dir, mode); in ubifs_create()
318 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_create()
323 dir->i_size += sz_change; in ubifs_create()
324 dir_ui->ui_size = dir->i_size; in ubifs_create()
325 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_create()
326 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_create()
338 dir->i_size -= sz_change; in ubifs_create()
339 dir_ui->ui_size = dir->i_size; in ubifs_create()
352 static int do_tmpfile(struct inode *dir, struct dentry *dentry, in do_tmpfile() argument
356 struct ubifs_info *c = dir->i_sb->s_fs_info; in do_tmpfile()
360 struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir); in do_tmpfile()
372 dentry, mode, dir->i_ino); in do_tmpfile()
374 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); in do_tmpfile()
391 inode = ubifs_new_inode(c, dir, mode); in do_tmpfile()
403 err = ubifs_init_security(dir, inode, &dentry->d_name); in do_tmpfile()
423 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0); in do_tmpfile()
450 static int ubifs_tmpfile(struct inode *dir, struct dentry *dentry, in ubifs_tmpfile() argument
453 return do_tmpfile(dir, dentry, mode, NULL); in ubifs_tmpfile()
510 struct inode *dir = file_inode(file); in ubifs_readdir() local
511 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_readdir()
512 bool encrypted = IS_ENCRYPTED(dir); in ubifs_readdir()
514 dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos); in ubifs_readdir()
524 err = fscrypt_prepare_readdir(dir); in ubifs_readdir()
563 lowest_dent_key(c, &key, dir->i_ino); in ubifs_readdir()
581 dent_key_init_hash(c, &key, dir->i_ino, ctx->pos); in ubifs_readdir()
597 ubifs_inode(dir)->creat_sqnum); in ubifs_readdir()
605 err = fscrypt_fname_disk_to_usr(dir, key_hash_flash(c, in ubifs_readdir()
662 static int ubifs_dir_release(struct inode *dir, struct file *file) in ubifs_dir_release() argument
695 static int ubifs_link(struct dentry *old_dentry, struct inode *dir, in ubifs_link() argument
698 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_link()
701 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_link()
714 inode->i_nlink, dir->i_ino); in ubifs_link()
715 ubifs_assert(c, inode_is_locked(dir)); in ubifs_link()
718 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ubifs_link()
722 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); in ubifs_link()
734 lock_2_inodes(dir, inode); in ubifs_link()
743 dir->i_size += sz_change; in ubifs_link()
744 dir_ui->ui_size = dir->i_size; in ubifs_link()
745 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_link()
746 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_link()
749 unlock_2_inodes(dir, inode); in ubifs_link()
757 dir->i_size -= sz_change; in ubifs_link()
758 dir_ui->ui_size = dir->i_size; in ubifs_link()
762 unlock_2_inodes(dir, inode); in ubifs_link()
770 static int ubifs_unlink(struct inode *dir, struct dentry *dentry) in ubifs_unlink() argument
772 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_unlink()
774 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_unlink()
789 inode->i_nlink, dir->i_ino); in ubifs_unlink()
791 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm); in ubifs_unlink()
801 ubifs_assert(c, inode_is_locked(dir)); in ubifs_unlink()
814 lock_2_inodes(dir, inode); in ubifs_unlink()
815 inode->i_ctime = current_time(dir); in ubifs_unlink()
817 dir->i_size -= sz_change; in ubifs_unlink()
818 dir_ui->ui_size = dir->i_size; in ubifs_unlink()
819 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_unlink()
820 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0); in ubifs_unlink()
823 unlock_2_inodes(dir, inode); in ubifs_unlink()
836 dir->i_size += sz_change; in ubifs_unlink()
837 dir_ui->ui_size = dir->i_size; in ubifs_unlink()
839 unlock_2_inodes(dir, inode); in ubifs_unlink()
855 int ubifs_check_dir_empty(struct inode *dir) in ubifs_check_dir_empty() argument
857 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_check_dir_empty()
863 lowest_dent_key(c, &key, dir->i_ino); in ubifs_check_dir_empty()
876 static int ubifs_rmdir(struct inode *dir, struct dentry *dentry) in ubifs_rmdir() argument
878 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_rmdir()
881 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_rmdir()
892 inode->i_ino, dir->i_ino); in ubifs_rmdir()
893 ubifs_assert(c, inode_is_locked(dir)); in ubifs_rmdir()
899 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm); in ubifs_rmdir()
916 lock_2_inodes(dir, inode); in ubifs_rmdir()
917 inode->i_ctime = current_time(dir); in ubifs_rmdir()
919 drop_nlink(dir); in ubifs_rmdir()
920 dir->i_size -= sz_change; in ubifs_rmdir()
921 dir_ui->ui_size = dir->i_size; in ubifs_rmdir()
922 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_rmdir()
923 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0); in ubifs_rmdir()
926 unlock_2_inodes(dir, inode); in ubifs_rmdir()
939 dir->i_size += sz_change; in ubifs_rmdir()
940 dir_ui->ui_size = dir->i_size; in ubifs_rmdir()
941 inc_nlink(dir); in ubifs_rmdir()
943 unlock_2_inodes(dir, inode); in ubifs_rmdir()
951 static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) in ubifs_mkdir() argument
954 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_mkdir()
955 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_mkdir()
967 dentry, mode, dir->i_ino); in ubifs_mkdir()
973 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_mkdir()
979 inode = ubifs_new_inode(c, dir, S_IFDIR | mode); in ubifs_mkdir()
985 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_mkdir()
992 inc_nlink(dir); in ubifs_mkdir()
993 dir->i_size += sz_change; in ubifs_mkdir()
994 dir_ui->ui_size = dir->i_size; in ubifs_mkdir()
995 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_mkdir()
996 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_mkdir()
1009 dir->i_size -= sz_change; in ubifs_mkdir()
1010 dir_ui->ui_size = dir->i_size; in ubifs_mkdir()
1011 drop_nlink(dir); in ubifs_mkdir()
1023 static int ubifs_mknod(struct inode *dir, struct dentry *dentry, in ubifs_mknod() argument
1028 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_mknod()
1029 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_mknod()
1042 dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino); in ubifs_mknod()
1058 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_mknod()
1066 inode = ubifs_new_inode(c, dir, mode); in ubifs_mknod()
1079 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_mknod()
1084 dir->i_size += sz_change; in ubifs_mknod()
1085 dir_ui->ui_size = dir->i_size; in ubifs_mknod()
1086 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_mknod()
1087 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_mknod()
1099 dir->i_size -= sz_change; in ubifs_mknod()
1100 dir_ui->ui_size = dir->i_size; in ubifs_mknod()
1112 static int ubifs_symlink(struct inode *dir, struct dentry *dentry, in ubifs_symlink() argument
1117 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_symlink()
1118 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_symlink()
1126 symname, dir->i_ino); in ubifs_symlink()
1128 err = fscrypt_prepare_symlink(dir, symname, len, UBIFS_MAX_INO_DATA, in ubifs_symlink()
1142 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_symlink()
1148 inode = ubifs_new_inode(c, dir, S_IFLNK | S_IRWXUGO); in ubifs_symlink()
1179 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_symlink()
1184 dir->i_size += sz_change; in ubifs_symlink()
1185 dir_ui->ui_size = dir->i_size; in ubifs_symlink()
1186 dir->i_mtime = dir->i_ctime = inode->i_ctime; in ubifs_symlink()
1187 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0); in ubifs_symlink()
1198 dir->i_size -= sz_change; in ubifs_symlink()
1199 dir_ui->ui_size = dir->i_size; in ubifs_symlink()