Lines Matching full:dir
35 * @dir: parent inode
39 * parent directory inode @dir. UBIFS inodes inherit the following flags:
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()
69 * @dir: parent directory inode
82 struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir, in ubifs_new_inode() argument
103 inode_init_owner(&nop_mnt_idmap, inode, dir, mode); in ubifs_new_inode()
108 err = fscrypt_prepare_new_inode(dir, inode, &encrypted); in ubifs_new_inode()
139 ui->flags = inherit_flags(dir, mode); in ubifs_new_inode()
216 static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, in ubifs_lookup() argument
223 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_lookup()
226 dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino); in ubifs_lookup()
228 err = fscrypt_prepare_lookup(dir, dentry, &nm); in ubifs_lookup()
248 dent_key_init_hash(c, &key, dir->i_ino, nm.hash); in ubifs_lookup()
251 dent_key_init(c, &key, dir->i_ino, &nm); in ubifs_lookup()
268 inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum)); in ubifs_lookup()
281 if (IS_ENCRYPTED(dir) && in ubifs_lookup()
283 !fscrypt_has_permitted_context(dir, inode)) { in ubifs_lookup()
285 dir->i_ino, inode->i_ino); in ubifs_lookup()
296 static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry, in ubifs_prepare_create() argument
302 return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm); in ubifs_prepare_create()
305 static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir, in ubifs_create() argument
309 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_create()
312 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_create()
321 dbg_gen("dent '%pd', mode %#hx in dir ino %lu", in ubifs_create()
322 dentry, mode, dir->i_ino); in ubifs_create()
328 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_create()
334 inode = ubifs_new_inode(c, dir, mode, false); in ubifs_create()
340 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_create()
346 dir->i_size += sz_change; in ubifs_create()
347 dir_ui->ui_size = dir->i_size; in ubifs_create()
348 inode_set_mtime_to_ts(dir, in ubifs_create()
349 inode_set_ctime_to_ts(dir, inode_get_ctime(inode))); in ubifs_create()
350 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0, 1); in ubifs_create()
362 dir->i_size -= sz_change; in ubifs_create()
363 dir_ui->ui_size = dir->i_size; in ubifs_create()
376 static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry) in create_whiteout() argument
381 struct ubifs_info *c = dir->i_sb->s_fs_info; in create_whiteout()
389 dbg_gen("dent '%pd', mode %#hx in dir ino %lu", in create_whiteout()
390 dentry, mode, dir->i_ino); in create_whiteout()
392 inode = ubifs_new_inode(c, dir, mode, false); in create_whiteout()
401 err = ubifs_init_security(dir, inode, &dentry->d_name); in create_whiteout()
405 /* The dir size is updated by do_rename. */ in create_whiteout()
443 static int ubifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir, in ubifs_tmpfile() argument
448 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_tmpfile()
463 dbg_gen("dent '%pd', mode %#hx in dir ino %lu", in ubifs_tmpfile()
464 dentry, mode, dir->i_ino); in ubifs_tmpfile()
466 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); in ubifs_tmpfile()
483 inode = ubifs_new_inode(c, dir, mode, false); in ubifs_tmpfile()
490 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_tmpfile()
503 lock_2_inodes(dir, inode); in ubifs_tmpfile()
504 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0, 1); in ubifs_tmpfile()
507 unlock_2_inodes(dir, inode); in ubifs_tmpfile()
515 unlock_2_inodes(dir, inode); in ubifs_tmpfile()
587 struct inode *dir = file_inode(file); in ubifs_readdir() local
588 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_readdir()
589 bool encrypted = IS_ENCRYPTED(dir); in ubifs_readdir()
592 dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos); in ubifs_readdir()
602 err = fscrypt_prepare_readdir(dir); in ubifs_readdir()
641 lowest_dent_key(c, &key, dir->i_ino); in ubifs_readdir()
659 dent_key_init_hash(c, &key, dir->i_ino, ctx->pos); in ubifs_readdir()
675 ubifs_inode(dir)->creat_sqnum); in ubifs_readdir()
683 err = fscrypt_fname_disk_to_usr(dir, key_hash_flash(c, in ubifs_readdir()
740 static int ubifs_dir_release(struct inode *dir, struct file *file) in ubifs_dir_release() argument
750 static int ubifs_link(struct dentry *old_dentry, struct inode *dir, in ubifs_link() argument
753 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_link()
756 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_link()
767 dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu", in ubifs_link()
769 inode->i_nlink, dir->i_ino); in ubifs_link()
770 ubifs_assert(c, inode_is_locked(dir)); in ubifs_link()
773 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ubifs_link()
777 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); in ubifs_link()
791 lock_2_inodes(dir, inode); in ubifs_link()
796 dir->i_size += sz_change; in ubifs_link()
797 dir_ui->ui_size = dir->i_size; in ubifs_link()
798 inode_set_mtime_to_ts(dir, in ubifs_link()
799 inode_set_ctime_to_ts(dir, inode_get_ctime(inode))); in ubifs_link()
800 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0, inode->i_nlink == 1); in ubifs_link()
803 unlock_2_inodes(dir, inode); in ubifs_link()
811 dir->i_size -= sz_change; in ubifs_link()
812 dir_ui->ui_size = dir->i_size; in ubifs_link()
814 unlock_2_inodes(dir, inode); in ubifs_link()
822 static int ubifs_unlink(struct inode *dir, struct dentry *dentry) in ubifs_unlink() argument
824 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_unlink()
826 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_unlink()
839 dbg_gen("dent '%pd' from ino %lu (nlink %d) in dir ino %lu", in ubifs_unlink()
841 inode->i_nlink, dir->i_ino); in ubifs_unlink()
843 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm); in ubifs_unlink()
853 ubifs_assert(c, inode_is_locked(dir)); in ubifs_unlink()
866 lock_2_inodes(dir, inode); in ubifs_unlink()
869 dir->i_size -= sz_change; in ubifs_unlink()
870 dir_ui->ui_size = dir->i_size; in ubifs_unlink()
871 inode_set_mtime_to_ts(dir, in ubifs_unlink()
872 inode_set_ctime_to_ts(dir, inode_get_ctime(inode))); in ubifs_unlink()
873 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0, 0); in ubifs_unlink()
876 unlock_2_inodes(dir, inode); in ubifs_unlink()
889 dir->i_size += sz_change; in ubifs_unlink()
890 dir_ui->ui_size = dir->i_size; in ubifs_unlink()
892 unlock_2_inodes(dir, inode); in ubifs_unlink()
902 * @dir: VFS inode object of the directory to check
904 * This function checks if directory @dir is empty. Returns zero if the
908 int ubifs_check_dir_empty(struct inode *dir) in ubifs_check_dir_empty() argument
910 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_check_dir_empty()
916 lowest_dent_key(c, &key, dir->i_ino); in ubifs_check_dir_empty()
929 static int ubifs_rmdir(struct inode *dir, struct dentry *dentry) in ubifs_rmdir() argument
931 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_rmdir()
934 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_rmdir()
944 dbg_gen("directory '%pd', ino %lu in dir ino %lu", dentry, in ubifs_rmdir()
945 inode->i_ino, dir->i_ino); in ubifs_rmdir()
946 ubifs_assert(c, inode_is_locked(dir)); in ubifs_rmdir()
952 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm); in ubifs_rmdir()
969 lock_2_inodes(dir, inode); in ubifs_rmdir()
972 drop_nlink(dir); in ubifs_rmdir()
973 dir->i_size -= sz_change; in ubifs_rmdir()
974 dir_ui->ui_size = dir->i_size; in ubifs_rmdir()
975 inode_set_mtime_to_ts(dir, in ubifs_rmdir()
976 inode_set_ctime_to_ts(dir, inode_get_ctime(inode))); in ubifs_rmdir()
977 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0, 0); in ubifs_rmdir()
980 unlock_2_inodes(dir, inode); in ubifs_rmdir()
993 dir->i_size += sz_change; in ubifs_rmdir()
994 dir_ui->ui_size = dir->i_size; in ubifs_rmdir()
995 inc_nlink(dir); in ubifs_rmdir()
997 unlock_2_inodes(dir, inode); in ubifs_rmdir()
1005 static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir, in ubifs_mkdir() argument
1009 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_mkdir()
1010 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_mkdir()
1021 dbg_gen("dent '%pd', mode %#hx in dir ino %lu", in ubifs_mkdir()
1022 dentry, mode, dir->i_ino); in ubifs_mkdir()
1028 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_mkdir()
1034 inode = ubifs_new_inode(c, dir, S_IFDIR | mode, false); in ubifs_mkdir()
1040 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_mkdir()
1048 inc_nlink(dir); in ubifs_mkdir()
1049 dir->i_size += sz_change; in ubifs_mkdir()
1050 dir_ui->ui_size = dir->i_size; in ubifs_mkdir()
1051 inode_set_mtime_to_ts(dir, in ubifs_mkdir()
1052 inode_set_ctime_to_ts(dir, inode_get_ctime(inode))); in ubifs_mkdir()
1053 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0, 1); in ubifs_mkdir()
1066 dir->i_size -= sz_change; in ubifs_mkdir()
1067 dir_ui->ui_size = dir->i_size; in ubifs_mkdir()
1068 drop_nlink(dir); in ubifs_mkdir()
1080 static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir, in ubifs_mknod() argument
1085 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_mknod()
1086 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_mknod()
1099 dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino); in ubifs_mknod()
1115 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_mknod()
1123 inode = ubifs_new_inode(c, dir, mode, false); in ubifs_mknod()
1130 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_mknod()
1144 dir->i_size += sz_change; in ubifs_mknod()
1145 dir_ui->ui_size = dir->i_size; in ubifs_mknod()
1146 inode_set_mtime_to_ts(dir, in ubifs_mknod()
1147 inode_set_ctime_to_ts(dir, inode_get_ctime(inode))); in ubifs_mknod()
1148 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0, 1); in ubifs_mknod()
1160 dir->i_size -= sz_change; in ubifs_mknod()
1161 dir_ui->ui_size = dir->i_size; in ubifs_mknod()
1173 static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir, in ubifs_symlink() argument
1178 struct ubifs_inode *dir_ui = ubifs_inode(dir); in ubifs_symlink()
1179 struct ubifs_info *c = dir->i_sb->s_fs_info; in ubifs_symlink()
1186 dbg_gen("dent '%pd', target '%s' in dir ino %lu", dentry, in ubifs_symlink()
1187 symname, dir->i_ino); in ubifs_symlink()
1189 err = fscrypt_prepare_symlink(dir, symname, len, UBIFS_MAX_INO_DATA, in ubifs_symlink()
1203 err = ubifs_prepare_create(dir, dentry, &nm); in ubifs_symlink()
1209 inode = ubifs_new_inode(c, dir, S_IFLNK | S_IRWXUGO, false); in ubifs_symlink()
1215 err = ubifs_init_security(dir, inode, &dentry->d_name); in ubifs_symlink()
1246 dir->i_size += sz_change; in ubifs_symlink()
1247 dir_ui->ui_size = dir->i_size; in ubifs_symlink()
1248 inode_set_mtime_to_ts(dir, in ubifs_symlink()
1249 inode_set_ctime_to_ts(dir, inode_get_ctime(inode))); in ubifs_symlink()
1250 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0, 1); in ubifs_symlink()
1261 dir->i_size -= sz_change; in ubifs_symlink()
1262 dir_ui->ui_size = dir->i_size; in ubifs_symlink()
1352 dbg_gen("dent '%pd' ino %lu in dir ino %lu to dent '%pd' in dir ino %lu flags 0x%x", in do_rename()
1511 * have already checked the old dir inode. So there is no need in do_rename()
1600 dbg_gen("dent '%pd' ino %lu in dir ino %lu exchange dent '%pd' ino %lu in dir ino %lu", in ubifs_xrename()