1 /* * This file is part of UBIFS.
3 * Copyright (C) 2006-2008 Nokia Corporation.
4 * Copyright (C) 2006, 2007 University of Szeged, Hungary
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Artem Bityutskiy (Битюцкий Артём)
25 * This file implements directory operations.
27 * All FS operations in this file allocate budget before writing anything to the
28 * media. If they fail to allocate it, the error is returned. The only
29 * exceptions are 'ubifs_unlink()' and 'ubifs_rmdir()' which keep working even
30 * if they unable to allocate the budget, because deletion %-ENOSPC failure is
31 * not what users are usually ready to get. UBIFS budgeting subsystem has some
32 * space reserved for these purposes.
34 * All operations in this file write all inodes which they change straight
35 * away, instead of marking them dirty. For example, 'ubifs_link()' changes
36 * @i_size of the parent inode and writes the parent inode together with the
37 * target inode. This was done to simplify file-system recovery which would
38 * otherwise be very difficult to do. The only exception is rename which marks
39 * the re-named inode dirty (because its @i_ctime is updated) but does not
40 * write it, but just marks it as dirty.
46 * inherit_flags - inherit flags of the parent inode.
48 * @mode: new inode mode flags
50 * This is a helper function for 'ubifs_new_inode()' which inherits flag of the
51 * parent directory inode @dir. UBIFS inodes inherit the following flags:
52 * o %UBIFS_COMPR_FL, which is useful to switch compression on/of on
53 * sub-directory basis;
54 * o %UBIFS_SYNC_FL - useful for the same reasons;
55 * o %UBIFS_DIRSYNC_FL - similar, but relevant only to directories.
57 * This function returns the inherited flags.
59 static int inherit_flags(const struct inode *dir, umode_t mode)
62 const struct ubifs_inode *ui = ubifs_inode(dir);
64 if (!S_ISDIR(dir->i_mode))
66 * The parent is not a directory, which means that an extended
67 * attribute inode is being created. No flags.
71 flags = ui->flags & (UBIFS_COMPR_FL | UBIFS_SYNC_FL | UBIFS_DIRSYNC_FL);
73 /* The "DIRSYNC" flag only applies to directories */
74 flags &= ~UBIFS_DIRSYNC_FL;
79 * ubifs_new_inode - allocate new UBIFS inode object.
80 * @c: UBIFS file-system description object
81 * @dir: parent directory inode
82 * @mode: inode mode flags
84 * This function finds an unused inode number, allocates new inode and
85 * initializes it. Returns new inode in case of success and an error code in
88 struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
93 struct ubifs_inode *ui;
94 bool encrypted = false;
96 if (ubifs_crypt_is_encrypted(dir)) {
97 err = fscrypt_get_encryption_info(dir);
99 ubifs_err(c, "fscrypt_get_encryption_info failed: %i", err);
103 if (!fscrypt_has_encryption_key(dir))
104 return ERR_PTR(-EPERM);
109 inode = new_inode(c->vfs_sb);
110 ui = ubifs_inode(inode);
112 return ERR_PTR(-ENOMEM);
115 * Set 'S_NOCMTIME' to prevent VFS form updating [mc]time of inodes and
116 * marking them dirty in file write path (see 'file_update_time()').
117 * UBIFS has to fully control "clean <-> dirty" transitions of inodes
118 * to make budgeting work.
120 inode->i_flags |= S_NOCMTIME;
122 inode_init_owner(inode, dir, mode);
123 inode->i_mtime = inode->i_atime = inode->i_ctime =
124 ubifs_current_time(inode);
125 inode->i_mapping->nrpages = 0;
127 switch (mode & S_IFMT) {
129 inode->i_mapping->a_ops = &ubifs_file_address_operations;
130 inode->i_op = &ubifs_file_inode_operations;
131 inode->i_fop = &ubifs_file_operations;
134 inode->i_op = &ubifs_dir_inode_operations;
135 inode->i_fop = &ubifs_dir_operations;
136 inode->i_size = ui->ui_size = UBIFS_INO_NODE_SZ;
139 inode->i_op = &ubifs_symlink_inode_operations;
145 inode->i_op = &ubifs_file_inode_operations;
151 ui->flags = inherit_flags(dir, mode);
152 ubifs_set_inode_flags(inode);
154 ui->compr_type = c->default_compr;
156 ui->compr_type = UBIFS_COMPR_NONE;
157 ui->synced_i_size = 0;
159 spin_lock(&c->cnt_lock);
160 /* Inode number overflow is currently not supported */
161 if (c->highest_inum >= INUM_WARN_WATERMARK) {
162 if (c->highest_inum >= INUM_WATERMARK) {
163 spin_unlock(&c->cnt_lock);
164 ubifs_err(c, "out of inode numbers");
165 make_bad_inode(inode);
167 return ERR_PTR(-EINVAL);
169 ubifs_warn(c, "running out of inode numbers (current %lu, max %u)",
170 (unsigned long)c->highest_inum, INUM_WATERMARK);
173 inode->i_ino = ++c->highest_inum;
175 * The creation sequence number remains with this inode for its
176 * lifetime. All nodes for this inode have a greater sequence number,
177 * and so it is possible to distinguish obsolete nodes belonging to a
178 * previous incarnation of the same inode number - for example, for the
179 * purpose of rebuilding the index.
181 ui->creat_sqnum = ++c->max_sqnum;
182 spin_unlock(&c->cnt_lock);
185 err = fscrypt_inherit_context(dir, inode, &encrypted, true);
187 ubifs_err(c, "fscrypt_inherit_context failed: %i", err);
188 make_bad_inode(inode);
197 static int dbg_check_name(const struct ubifs_info *c,
198 const struct ubifs_dent_node *dent,
199 const struct fscrypt_name *nm)
201 if (!dbg_is_chk_gen(c))
203 if (le16_to_cpu(dent->nlen) != fname_len(nm))
205 if (memcmp(dent->name, fname_name(nm), fname_len(nm)))
210 static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
215 struct inode *inode = NULL;
216 struct ubifs_dent_node *dent;
217 struct ubifs_info *c = dir->i_sb->s_fs_info;
218 struct fscrypt_name nm;
220 dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino);
222 if (ubifs_crypt_is_encrypted(dir)) {
223 err = fscrypt_get_encryption_info(dir);
226 * DCACHE_ENCRYPTED_WITH_KEY is set if the dentry is
227 * created while the directory was encrypted and we
228 * have access to the key.
230 if (fscrypt_has_encryption_key(dir))
231 fscrypt_set_encrypted_dentry(dentry);
232 fscrypt_set_d_op(dentry);
233 if (err && err != -ENOKEY)
237 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm);
241 if (fname_len(&nm) > UBIFS_MAX_NLEN) {
246 dent = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS);
253 ubifs_assert(fname_len(&nm) == 0);
254 ubifs_assert(fname_name(&nm) == NULL);
255 dent_key_init_hash(c, &key, dir->i_ino, nm.hash);
256 err = ubifs_tnc_lookup_dh(c, &key, dent, nm.minor_hash);
258 dent_key_init(c, &key, dir->i_ino, &nm);
259 err = ubifs_tnc_lookup_nm(c, &key, dent, &nm);
263 if (err == -ENOENT) {
264 dbg_gen("not found");
270 if (dbg_check_name(c, dent, &nm)) {
275 inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum));
278 * This should not happen. Probably the file-system needs
281 err = PTR_ERR(inode);
282 ubifs_err(c, "dead directory entry '%pd', error %d",
284 ubifs_ro_mode(c, err);
288 if (ubifs_crypt_is_encrypted(dir) &&
289 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
290 !fscrypt_has_permitted_context(dir, inode)) {
291 ubifs_warn(c, "Inconsistent encryption contexts: %lu/%lu",
292 dir->i_ino, inode->i_ino);
299 fscrypt_free_filename(&nm);
301 * Note, d_splice_alias() would be required instead if we supported
304 d_add(dentry, inode);
312 fscrypt_free_filename(&nm);
316 static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
320 struct ubifs_info *c = dir->i_sb->s_fs_info;
321 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
323 struct ubifs_inode *dir_ui = ubifs_inode(dir);
324 struct fscrypt_name nm;
328 * Budget request settings: new inode, new direntry, changing the
329 * parent directory inode.
332 dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
333 dentry, mode, dir->i_ino);
335 err = ubifs_budget_space(c, &req);
339 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
343 sz_change = CALC_DENT_SIZE(fname_len(&nm));
345 inode = ubifs_new_inode(c, dir, mode);
347 err = PTR_ERR(inode);
351 err = ubifs_init_security(dir, inode, &dentry->d_name);
355 mutex_lock(&dir_ui->ui_mutex);
356 dir->i_size += sz_change;
357 dir_ui->ui_size = dir->i_size;
358 dir->i_mtime = dir->i_ctime = inode->i_ctime;
359 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
362 mutex_unlock(&dir_ui->ui_mutex);
364 ubifs_release_budget(c, &req);
365 fscrypt_free_filename(&nm);
366 insert_inode_hash(inode);
367 d_instantiate(dentry, inode);
371 dir->i_size -= sz_change;
372 dir_ui->ui_size = dir->i_size;
373 mutex_unlock(&dir_ui->ui_mutex);
375 make_bad_inode(inode);
378 fscrypt_free_filename(&nm);
380 ubifs_release_budget(c, &req);
381 ubifs_err(c, "cannot create regular file, error %d", err);
385 static int do_tmpfile(struct inode *dir, struct dentry *dentry,
386 umode_t mode, struct inode **whiteout)
389 struct ubifs_info *c = dir->i_sb->s_fs_info;
390 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1};
391 struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };
392 struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir);
393 int err, instantiated = 0;
394 struct fscrypt_name nm;
397 * Budget request settings: new dirty inode, new direntry,
398 * budget for dirtied inode will be released via writeback.
401 dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
402 dentry, mode, dir->i_ino);
404 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
408 err = ubifs_budget_space(c, &req);
410 fscrypt_free_filename(&nm);
414 err = ubifs_budget_space(c, &ino_req);
416 ubifs_release_budget(c, &req);
417 fscrypt_free_filename(&nm);
421 inode = ubifs_new_inode(c, dir, mode);
423 err = PTR_ERR(inode);
426 ui = ubifs_inode(inode);
429 init_special_inode(inode, inode->i_mode, WHITEOUT_DEV);
430 ubifs_assert(inode->i_op == &ubifs_file_inode_operations);
433 err = ubifs_init_security(dir, inode, &dentry->d_name);
437 mutex_lock(&ui->ui_mutex);
438 insert_inode_hash(inode);
441 mark_inode_dirty(inode);
445 d_tmpfile(dentry, inode);
447 ubifs_assert(ui->dirty);
450 mutex_unlock(&ui->ui_mutex);
452 mutex_lock(&dir_ui->ui_mutex);
453 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
456 mutex_unlock(&dir_ui->ui_mutex);
458 ubifs_release_budget(c, &req);
463 mutex_unlock(&dir_ui->ui_mutex);
465 make_bad_inode(inode);
469 ubifs_release_budget(c, &req);
471 ubifs_release_budget(c, &ino_req);
472 fscrypt_free_filename(&nm);
473 ubifs_err(c, "cannot create temporary file, error %d", err);
477 static int ubifs_tmpfile(struct inode *dir, struct dentry *dentry,
480 return do_tmpfile(dir, dentry, mode, NULL);
484 * vfs_dent_type - get VFS directory entry type.
485 * @type: UBIFS directory entry type
487 * This function converts UBIFS directory entry type into VFS directory entry
490 static unsigned int vfs_dent_type(uint8_t type)
493 case UBIFS_ITYPE_REG:
495 case UBIFS_ITYPE_DIR:
497 case UBIFS_ITYPE_LNK:
499 case UBIFS_ITYPE_BLK:
501 case UBIFS_ITYPE_CHR:
503 case UBIFS_ITYPE_FIFO:
505 case UBIFS_ITYPE_SOCK:
514 * The classical Unix view for directory is that it is a linear array of
515 * (name, inode number) entries. Linux/VFS assumes this model as well.
516 * Particularly, 'readdir()' call wants us to return a directory entry offset
517 * which later may be used to continue 'readdir()'ing the directory or to
518 * 'seek()' to that specific direntry. Obviously UBIFS does not really fit this
519 * model because directory entries are identified by keys, which may collide.
521 * UBIFS uses directory entry hash value for directory offsets, so
522 * 'seekdir()'/'telldir()' may not always work because of possible key
523 * collisions. But UBIFS guarantees that consecutive 'readdir()' calls work
524 * properly by means of saving full directory entry name in the private field
525 * of the file description object.
527 * This means that UBIFS cannot support NFS which requires full
528 * 'seekdir()'/'telldir()' support.
530 static int ubifs_readdir(struct file *file, struct dir_context *ctx)
532 int fstr_real_len = 0, err = 0;
533 struct fscrypt_name nm;
534 struct fscrypt_str fstr = {0};
536 struct ubifs_dent_node *dent;
537 struct inode *dir = file_inode(file);
538 struct ubifs_info *c = dir->i_sb->s_fs_info;
539 bool encrypted = ubifs_crypt_is_encrypted(dir);
541 dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos);
543 if (ctx->pos > UBIFS_S_KEY_HASH_MASK || ctx->pos == 2)
545 * The directory was seek'ed to a senseless position or there
546 * are no more entries.
551 err = fscrypt_get_encryption_info(dir);
552 if (err && err != -ENOKEY)
555 err = fscrypt_fname_alloc_buffer(dir, UBIFS_MAX_NLEN, &fstr);
559 fstr_real_len = fstr.len;
562 if (file->f_version == 0) {
564 * The file was seek'ed, which means that @file->private_data
565 * is now invalid. This may also be just the first
566 * 'ubifs_readdir()' invocation, in which case
567 * @file->private_data is NULL, and the below code is
570 kfree(file->private_data);
571 file->private_data = NULL;
575 * 'generic_file_llseek()' unconditionally sets @file->f_version to
576 * zero, and we use this for detecting whether the file was seek'ed.
580 /* File positions 0 and 1 correspond to "." and ".." */
582 ubifs_assert(!file->private_data);
583 if (!dir_emit_dots(file, ctx)) {
585 fscrypt_fname_free_buffer(&fstr);
589 /* Find the first entry in TNC and save it */
590 lowest_dent_key(c, &key, dir->i_ino);
592 dent = ubifs_tnc_next_ent(c, &key, &nm);
598 ctx->pos = key_hash_flash(c, &dent->key);
599 file->private_data = dent;
602 dent = file->private_data;
605 * The directory was seek'ed to and is now readdir'ed.
606 * Find the entry corresponding to @ctx->pos or the closest one.
608 dent_key_init_hash(c, &key, dir->i_ino, ctx->pos);
610 dent = ubifs_tnc_next_ent(c, &key, &nm);
615 ctx->pos = key_hash_flash(c, &dent->key);
616 file->private_data = dent;
620 dbg_gen("feed '%s', ino %llu, new f_pos %#x",
621 dent->name, (unsigned long long)le64_to_cpu(dent->inum),
622 key_hash_flash(c, &dent->key));
623 ubifs_assert(le64_to_cpu(dent->ch.sqnum) >
624 ubifs_inode(dir)->creat_sqnum);
626 fname_len(&nm) = le16_to_cpu(dent->nlen);
627 fname_name(&nm) = dent->name;
630 fstr.len = fstr_real_len;
632 err = fscrypt_fname_disk_to_usr(dir, key_hash_flash(c,
634 le32_to_cpu(dent->cookie),
635 &nm.disk_name, &fstr);
639 fstr.len = fname_len(&nm);
640 fstr.name = fname_name(&nm);
643 if (!dir_emit(ctx, fstr.name, fstr.len,
644 le64_to_cpu(dent->inum),
645 vfs_dent_type(dent->type))) {
647 fscrypt_fname_free_buffer(&fstr);
651 /* Switch to the next entry */
652 key_read(c, &dent->key, &key);
653 dent = ubifs_tnc_next_ent(c, &key, &nm);
659 kfree(file->private_data);
660 ctx->pos = key_hash_flash(c, &dent->key);
661 file->private_data = dent;
666 kfree(file->private_data);
667 file->private_data = NULL;
670 fscrypt_fname_free_buffer(&fstr);
673 ubifs_err(c, "cannot find next direntry, error %d", err);
676 * -ENOENT is a non-fatal error in this context, the TNC uses
677 * it to indicate that the cursor moved past the current directory
678 * and readdir() has to stop.
683 /* 2 is a special value indicating that there are no more direntries */
688 /* Free saved readdir() state when the directory is closed */
689 static int ubifs_dir_release(struct inode *dir, struct file *file)
691 kfree(file->private_data);
692 file->private_data = NULL;
697 * lock_2_inodes - a wrapper for locking two UBIFS inodes.
698 * @inode1: first inode
699 * @inode2: second inode
701 * We do not implement any tricks to guarantee strict lock ordering, because
702 * VFS has already done it for us on the @i_mutex. So this is just a simple
705 static void lock_2_inodes(struct inode *inode1, struct inode *inode2)
707 mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_1);
708 mutex_lock_nested(&ubifs_inode(inode2)->ui_mutex, WB_MUTEX_2);
712 * unlock_2_inodes - a wrapper for unlocking two UBIFS inodes.
713 * @inode1: first inode
714 * @inode2: second inode
716 static void unlock_2_inodes(struct inode *inode1, struct inode *inode2)
718 mutex_unlock(&ubifs_inode(inode2)->ui_mutex);
719 mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
722 static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
723 struct dentry *dentry)
725 struct ubifs_info *c = dir->i_sb->s_fs_info;
726 struct inode *inode = d_inode(old_dentry);
727 struct ubifs_inode *ui = ubifs_inode(inode);
728 struct ubifs_inode *dir_ui = ubifs_inode(dir);
729 int err, sz_change = CALC_DENT_SIZE(dentry->d_name.len);
730 struct ubifs_budget_req req = { .new_dent = 1, .dirtied_ino = 2,
731 .dirtied_ino_d = ALIGN(ui->data_len, 8) };
732 struct fscrypt_name nm;
735 * Budget request settings: new direntry, changing the target inode,
736 * changing the parent inode.
739 dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu",
740 dentry, inode->i_ino,
741 inode->i_nlink, dir->i_ino);
742 ubifs_assert(inode_is_locked(dir));
743 ubifs_assert(inode_is_locked(inode));
745 if (ubifs_crypt_is_encrypted(dir) &&
746 !fscrypt_has_permitted_context(dir, inode))
749 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
753 err = dbg_check_synced_i_size(c, inode);
757 err = ubifs_budget_space(c, &req);
761 lock_2_inodes(dir, inode);
764 inode->i_ctime = ubifs_current_time(inode);
765 dir->i_size += sz_change;
766 dir_ui->ui_size = dir->i_size;
767 dir->i_mtime = dir->i_ctime = inode->i_ctime;
768 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
771 unlock_2_inodes(dir, inode);
773 ubifs_release_budget(c, &req);
774 d_instantiate(dentry, inode);
775 fscrypt_free_filename(&nm);
779 dir->i_size -= sz_change;
780 dir_ui->ui_size = dir->i_size;
782 unlock_2_inodes(dir, inode);
783 ubifs_release_budget(c, &req);
786 fscrypt_free_filename(&nm);
790 static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
792 struct ubifs_info *c = dir->i_sb->s_fs_info;
793 struct inode *inode = d_inode(dentry);
794 struct ubifs_inode *dir_ui = ubifs_inode(dir);
795 int err, sz_change, budgeted = 1;
796 struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 };
797 unsigned int saved_nlink = inode->i_nlink;
798 struct fscrypt_name nm;
801 * Budget request settings: deletion direntry, deletion inode (+1 for
802 * @dirtied_ino), changing the parent directory inode. If budgeting
803 * fails, go ahead anyway because we have extra space reserved for
807 dbg_gen("dent '%pd' from ino %lu (nlink %d) in dir ino %lu",
808 dentry, inode->i_ino,
809 inode->i_nlink, dir->i_ino);
811 if (ubifs_crypt_is_encrypted(dir)) {
812 err = fscrypt_get_encryption_info(dir);
813 if (err && err != -ENOKEY)
817 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm);
821 sz_change = CALC_DENT_SIZE(fname_len(&nm));
823 ubifs_assert(inode_is_locked(dir));
824 ubifs_assert(inode_is_locked(inode));
825 err = dbg_check_synced_i_size(c, inode);
829 err = ubifs_budget_space(c, &req);
836 lock_2_inodes(dir, inode);
837 inode->i_ctime = ubifs_current_time(dir);
839 dir->i_size -= sz_change;
840 dir_ui->ui_size = dir->i_size;
841 dir->i_mtime = dir->i_ctime = inode->i_ctime;
842 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
845 unlock_2_inodes(dir, inode);
848 ubifs_release_budget(c, &req);
850 /* We've deleted something - clean the "no space" flags */
851 c->bi.nospace = c->bi.nospace_rp = 0;
854 fscrypt_free_filename(&nm);
858 dir->i_size += sz_change;
859 dir_ui->ui_size = dir->i_size;
860 set_nlink(inode, saved_nlink);
861 unlock_2_inodes(dir, inode);
863 ubifs_release_budget(c, &req);
865 fscrypt_free_filename(&nm);
870 * check_dir_empty - check if a directory is empty or not.
871 * @dir: VFS inode object of the directory to check
873 * This function checks if directory @dir is empty. Returns zero if the
874 * directory is empty, %-ENOTEMPTY if it is not, and other negative error codes
875 * in case of of errors.
877 int ubifs_check_dir_empty(struct inode *dir)
879 struct ubifs_info *c = dir->i_sb->s_fs_info;
880 struct fscrypt_name nm = { 0 };
881 struct ubifs_dent_node *dent;
885 lowest_dent_key(c, &key, dir->i_ino);
886 dent = ubifs_tnc_next_ent(c, &key, &nm);
898 static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
900 struct ubifs_info *c = dir->i_sb->s_fs_info;
901 struct inode *inode = d_inode(dentry);
902 int err, sz_change, budgeted = 1;
903 struct ubifs_inode *dir_ui = ubifs_inode(dir);
904 struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 };
905 struct fscrypt_name nm;
908 * Budget request settings: deletion direntry, deletion inode and
909 * changing the parent inode. If budgeting fails, go ahead anyway
910 * because we have extra space reserved for deletions.
913 dbg_gen("directory '%pd', ino %lu in dir ino %lu", dentry,
914 inode->i_ino, dir->i_ino);
915 ubifs_assert(inode_is_locked(dir));
916 ubifs_assert(inode_is_locked(inode));
917 err = ubifs_check_dir_empty(d_inode(dentry));
921 if (ubifs_crypt_is_encrypted(dir)) {
922 err = fscrypt_get_encryption_info(dir);
923 if (err && err != -ENOKEY)
927 err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &nm);
931 sz_change = CALC_DENT_SIZE(fname_len(&nm));
933 err = ubifs_budget_space(c, &req);
940 lock_2_inodes(dir, inode);
941 inode->i_ctime = ubifs_current_time(dir);
944 dir->i_size -= sz_change;
945 dir_ui->ui_size = dir->i_size;
946 dir->i_mtime = dir->i_ctime = inode->i_ctime;
947 err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
950 unlock_2_inodes(dir, inode);
953 ubifs_release_budget(c, &req);
955 /* We've deleted something - clean the "no space" flags */
956 c->bi.nospace = c->bi.nospace_rp = 0;
959 fscrypt_free_filename(&nm);
963 dir->i_size += sz_change;
964 dir_ui->ui_size = dir->i_size;
967 unlock_2_inodes(dir, inode);
969 ubifs_release_budget(c, &req);
971 fscrypt_free_filename(&nm);
975 static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
978 struct ubifs_inode *dir_ui = ubifs_inode(dir);
979 struct ubifs_info *c = dir->i_sb->s_fs_info;
981 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1 };
982 struct fscrypt_name nm;
985 * Budget request settings: new inode, new direntry and changing parent
989 dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
990 dentry, mode, dir->i_ino);
992 err = ubifs_budget_space(c, &req);
996 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
1000 sz_change = CALC_DENT_SIZE(fname_len(&nm));
1002 inode = ubifs_new_inode(c, dir, S_IFDIR | mode);
1003 if (IS_ERR(inode)) {
1004 err = PTR_ERR(inode);
1008 err = ubifs_init_security(dir, inode, &dentry->d_name);
1012 mutex_lock(&dir_ui->ui_mutex);
1013 insert_inode_hash(inode);
1016 dir->i_size += sz_change;
1017 dir_ui->ui_size = dir->i_size;
1018 dir->i_mtime = dir->i_ctime = inode->i_ctime;
1019 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
1021 ubifs_err(c, "cannot create directory, error %d", err);
1024 mutex_unlock(&dir_ui->ui_mutex);
1026 ubifs_release_budget(c, &req);
1027 d_instantiate(dentry, inode);
1028 fscrypt_free_filename(&nm);
1032 dir->i_size -= sz_change;
1033 dir_ui->ui_size = dir->i_size;
1035 mutex_unlock(&dir_ui->ui_mutex);
1037 make_bad_inode(inode);
1040 fscrypt_free_filename(&nm);
1042 ubifs_release_budget(c, &req);
1046 static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
1047 umode_t mode, dev_t rdev)
1049 struct inode *inode;
1050 struct ubifs_inode *ui;
1051 struct ubifs_inode *dir_ui = ubifs_inode(dir);
1052 struct ubifs_info *c = dir->i_sb->s_fs_info;
1053 union ubifs_dev_desc *dev = NULL;
1055 int err, devlen = 0;
1056 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
1057 .new_ino_d = ALIGN(devlen, 8),
1059 struct fscrypt_name nm;
1062 * Budget request settings: new inode, new direntry and changing parent
1066 dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino);
1068 if (S_ISBLK(mode) || S_ISCHR(mode)) {
1069 dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
1072 devlen = ubifs_encode_dev(dev, rdev);
1075 err = ubifs_budget_space(c, &req);
1081 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
1085 sz_change = CALC_DENT_SIZE(fname_len(&nm));
1087 inode = ubifs_new_inode(c, dir, mode);
1088 if (IS_ERR(inode)) {
1090 err = PTR_ERR(inode);
1094 init_special_inode(inode, inode->i_mode, rdev);
1095 inode->i_size = ubifs_inode(inode)->ui_size = devlen;
1096 ui = ubifs_inode(inode);
1098 ui->data_len = devlen;
1100 err = ubifs_init_security(dir, inode, &dentry->d_name);
1104 mutex_lock(&dir_ui->ui_mutex);
1105 dir->i_size += sz_change;
1106 dir_ui->ui_size = dir->i_size;
1107 dir->i_mtime = dir->i_ctime = inode->i_ctime;
1108 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
1111 mutex_unlock(&dir_ui->ui_mutex);
1113 ubifs_release_budget(c, &req);
1114 insert_inode_hash(inode);
1115 d_instantiate(dentry, inode);
1116 fscrypt_free_filename(&nm);
1120 dir->i_size -= sz_change;
1121 dir_ui->ui_size = dir->i_size;
1122 mutex_unlock(&dir_ui->ui_mutex);
1124 make_bad_inode(inode);
1127 fscrypt_free_filename(&nm);
1129 ubifs_release_budget(c, &req);
1133 static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
1134 const char *symname)
1136 struct inode *inode;
1137 struct ubifs_inode *ui;
1138 struct ubifs_inode *dir_ui = ubifs_inode(dir);
1139 struct ubifs_info *c = dir->i_sb->s_fs_info;
1140 int err, len = strlen(symname);
1141 int sz_change = CALC_DENT_SIZE(len);
1142 struct fscrypt_str disk_link = FSTR_INIT((char *)symname, len + 1);
1143 struct fscrypt_symlink_data *sd = NULL;
1144 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
1145 .new_ino_d = ALIGN(len, 8),
1147 struct fscrypt_name nm;
1149 if (ubifs_crypt_is_encrypted(dir)) {
1150 err = fscrypt_get_encryption_info(dir);
1154 if (!fscrypt_has_encryption_key(dir)) {
1159 disk_link.len = (fscrypt_fname_encrypted_size(dir, len) +
1160 sizeof(struct fscrypt_symlink_data));
1164 * Budget request settings: new inode, new direntry and changing parent
1168 dbg_gen("dent '%pd', target '%s' in dir ino %lu", dentry,
1169 symname, dir->i_ino);
1171 if (disk_link.len > UBIFS_MAX_INO_DATA)
1172 return -ENAMETOOLONG;
1174 err = ubifs_budget_space(c, &req);
1178 err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
1182 inode = ubifs_new_inode(c, dir, S_IFLNK | S_IRWXUGO);
1183 if (IS_ERR(inode)) {
1184 err = PTR_ERR(inode);
1188 ui = ubifs_inode(inode);
1189 ui->data = kmalloc(disk_link.len, GFP_NOFS);
1195 if (ubifs_crypt_is_encrypted(dir)) {
1196 struct qstr istr = QSTR_INIT(symname, len);
1197 struct fscrypt_str ostr;
1199 sd = kzalloc(disk_link.len, GFP_NOFS);
1205 ostr.name = sd->encrypted_path;
1206 ostr.len = disk_link.len;
1208 err = fscrypt_fname_usr_to_disk(inode, &istr, &ostr);
1214 sd->len = cpu_to_le16(ostr.len);
1215 disk_link.name = (char *)sd;
1217 inode->i_link = ui->data;
1220 memcpy(ui->data, disk_link.name, disk_link.len);
1221 ((char *)ui->data)[disk_link.len - 1] = '\0';
1224 * The terminating zero byte is not written to the flash media and it
1225 * is put just to make later in-memory string processing simpler. Thus,
1226 * data length is @len, not @len + %1.
1228 ui->data_len = disk_link.len - 1;
1229 inode->i_size = ubifs_inode(inode)->ui_size = disk_link.len - 1;
1231 err = ubifs_init_security(dir, inode, &dentry->d_name);
1235 mutex_lock(&dir_ui->ui_mutex);
1236 dir->i_size += sz_change;
1237 dir_ui->ui_size = dir->i_size;
1238 dir->i_mtime = dir->i_ctime = inode->i_ctime;
1239 err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
1242 mutex_unlock(&dir_ui->ui_mutex);
1244 ubifs_release_budget(c, &req);
1245 insert_inode_hash(inode);
1246 d_instantiate(dentry, inode);
1247 fscrypt_free_filename(&nm);
1251 dir->i_size -= sz_change;
1252 dir_ui->ui_size = dir->i_size;
1253 mutex_unlock(&dir_ui->ui_mutex);
1255 make_bad_inode(inode);
1258 fscrypt_free_filename(&nm);
1260 ubifs_release_budget(c, &req);
1265 * lock_4_inodes - a wrapper for locking three UBIFS inodes.
1266 * @inode1: first inode
1267 * @inode2: second inode
1268 * @inode3: third inode
1269 * @inode4: fouth inode
1271 * This function is used for 'ubifs_rename()' and @inode1 may be the same as
1272 * @inode2 whereas @inode3 and @inode4 may be %NULL.
1274 * We do not implement any tricks to guarantee strict lock ordering, because
1275 * VFS has already done it for us on the @i_mutex. So this is just a simple
1278 static void lock_4_inodes(struct inode *inode1, struct inode *inode2,
1279 struct inode *inode3, struct inode *inode4)
1281 mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_1);
1282 if (inode2 != inode1)
1283 mutex_lock_nested(&ubifs_inode(inode2)->ui_mutex, WB_MUTEX_2);
1285 mutex_lock_nested(&ubifs_inode(inode3)->ui_mutex, WB_MUTEX_3);
1287 mutex_lock_nested(&ubifs_inode(inode4)->ui_mutex, WB_MUTEX_4);
1291 * unlock_4_inodes - a wrapper for unlocking three UBIFS inodes for rename.
1292 * @inode1: first inode
1293 * @inode2: second inode
1294 * @inode3: third inode
1295 * @inode4: fouth inode
1297 static void unlock_4_inodes(struct inode *inode1, struct inode *inode2,
1298 struct inode *inode3, struct inode *inode4)
1301 mutex_unlock(&ubifs_inode(inode4)->ui_mutex);
1303 mutex_unlock(&ubifs_inode(inode3)->ui_mutex);
1304 if (inode1 != inode2)
1305 mutex_unlock(&ubifs_inode(inode2)->ui_mutex);
1306 mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
1309 static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
1310 struct inode *new_dir, struct dentry *new_dentry,
1313 struct ubifs_info *c = old_dir->i_sb->s_fs_info;
1314 struct inode *old_inode = d_inode(old_dentry);
1315 struct inode *new_inode = d_inode(new_dentry);
1316 struct inode *whiteout = NULL;
1317 struct ubifs_inode *old_inode_ui = ubifs_inode(old_inode);
1318 struct ubifs_inode *whiteout_ui = NULL;
1319 int err, release, sync = 0, move = (new_dir != old_dir);
1320 int is_dir = S_ISDIR(old_inode->i_mode);
1321 int unlink = !!new_inode, new_sz, old_sz;
1322 struct ubifs_budget_req req = { .new_dent = 1, .mod_dent = 1,
1324 struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
1325 .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
1326 struct timespec time;
1327 unsigned int uninitialized_var(saved_nlink);
1328 struct fscrypt_name old_nm, new_nm;
1330 if (flags & ~RENAME_NOREPLACE)
1334 * Budget request settings: deletion direntry, new direntry, removing
1335 * the old inode, and changing old and new parent directory inodes.
1337 * However, this operation also marks the target inode as dirty and
1338 * does not write it, so we allocate budget for the target inode
1342 dbg_gen("dent '%pd' ino %lu in dir ino %lu to dent '%pd' in dir ino %lu flags 0x%x",
1343 old_dentry, old_inode->i_ino, old_dir->i_ino,
1344 new_dentry, new_dir->i_ino, flags);
1347 ubifs_assert(inode_is_locked(new_inode));
1349 if (old_dir != new_dir) {
1350 if (ubifs_crypt_is_encrypted(new_dir) &&
1351 !fscrypt_has_permitted_context(new_dir, old_inode))
1355 if (unlink && is_dir) {
1356 err = ubifs_check_dir_empty(new_inode);
1361 err = fscrypt_setup_filename(old_dir, &old_dentry->d_name, 0, &old_nm);
1365 err = fscrypt_setup_filename(new_dir, &new_dentry->d_name, 0, &new_nm);
1367 fscrypt_free_filename(&old_nm);
1371 new_sz = CALC_DENT_SIZE(fname_len(&new_nm));
1372 old_sz = CALC_DENT_SIZE(fname_len(&old_nm));
1374 err = ubifs_budget_space(c, &req);
1376 fscrypt_free_filename(&old_nm);
1377 fscrypt_free_filename(&new_nm);
1380 err = ubifs_budget_space(c, &ino_req);
1382 fscrypt_free_filename(&old_nm);
1383 fscrypt_free_filename(&new_nm);
1384 ubifs_release_budget(c, &req);
1388 if (flags & RENAME_WHITEOUT) {
1389 union ubifs_dev_desc *dev = NULL;
1391 dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
1393 ubifs_release_budget(c, &req);
1394 ubifs_release_budget(c, &ino_req);
1398 err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout);
1400 ubifs_release_budget(c, &req);
1401 ubifs_release_budget(c, &ino_req);
1406 whiteout->i_state |= I_LINKABLE;
1407 whiteout_ui = ubifs_inode(whiteout);
1408 whiteout_ui->data = dev;
1409 whiteout_ui->data_len = ubifs_encode_dev(dev, MKDEV(0, 0));
1410 ubifs_assert(!whiteout_ui->dirty);
1413 lock_4_inodes(old_dir, new_dir, new_inode, whiteout);
1416 * Like most other Unix systems, set the @i_ctime for inodes on a
1419 time = ubifs_current_time(old_dir);
1420 old_inode->i_ctime = time;
1422 /* We must adjust parent link count when renaming directories */
1426 * @old_dir loses a link because we are moving
1427 * @old_inode to a different directory.
1429 drop_nlink(old_dir);
1431 * @new_dir only gains a link if we are not also
1432 * overwriting an existing directory.
1438 * @old_inode is not moving to a different directory,
1439 * but @old_dir still loses a link if we are
1440 * overwriting an existing directory.
1443 drop_nlink(old_dir);
1447 old_dir->i_size -= old_sz;
1448 ubifs_inode(old_dir)->ui_size = old_dir->i_size;
1449 old_dir->i_mtime = old_dir->i_ctime = time;
1450 new_dir->i_mtime = new_dir->i_ctime = time;
1453 * And finally, if we unlinked a direntry which happened to have the
1454 * same name as the moved direntry, we have to decrement @i_nlink of
1455 * the unlinked inode and change its ctime.
1459 * Directories cannot have hard-links, so if this is a
1460 * directory, just clear @i_nlink.
1462 saved_nlink = new_inode->i_nlink;
1464 clear_nlink(new_inode);
1466 drop_nlink(new_inode);
1467 new_inode->i_ctime = time;
1469 new_dir->i_size += new_sz;
1470 ubifs_inode(new_dir)->ui_size = new_dir->i_size;
1474 * Do not ask 'ubifs_jnl_rename()' to flush write-buffer if @old_inode
1475 * is dirty, because this will be done later on at the end of
1478 if (IS_SYNC(old_inode)) {
1479 sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
1480 if (unlink && IS_SYNC(new_inode))
1485 struct ubifs_budget_req wht_req = { .dirtied_ino = 1,
1487 ALIGN(ubifs_inode(whiteout)->data_len, 8) };
1489 err = ubifs_budget_space(c, &wht_req);
1491 ubifs_release_budget(c, &req);
1492 ubifs_release_budget(c, &ino_req);
1493 kfree(whiteout_ui->data);
1494 whiteout_ui->data_len = 0;
1499 inc_nlink(whiteout);
1500 mark_inode_dirty(whiteout);
1501 whiteout->i_state &= ~I_LINKABLE;
1505 err = ubifs_jnl_rename(c, old_dir, old_inode, &old_nm, new_dir,
1506 new_inode, &new_nm, whiteout, sync);
1510 unlock_4_inodes(old_dir, new_dir, new_inode, whiteout);
1511 ubifs_release_budget(c, &req);
1513 mutex_lock(&old_inode_ui->ui_mutex);
1514 release = old_inode_ui->dirty;
1515 mark_inode_dirty_sync(old_inode);
1516 mutex_unlock(&old_inode_ui->ui_mutex);
1519 ubifs_release_budget(c, &ino_req);
1520 if (IS_SYNC(old_inode))
1521 err = old_inode->i_sb->s_op->write_inode(old_inode, NULL);
1523 fscrypt_free_filename(&old_nm);
1524 fscrypt_free_filename(&new_nm);
1529 set_nlink(new_inode, saved_nlink);
1531 new_dir->i_size -= new_sz;
1532 ubifs_inode(new_dir)->ui_size = new_dir->i_size;
1534 old_dir->i_size += old_sz;
1535 ubifs_inode(old_dir)->ui_size = old_dir->i_size;
1540 drop_nlink(new_dir);
1547 drop_nlink(whiteout);
1550 unlock_4_inodes(old_dir, new_dir, new_inode, whiteout);
1551 ubifs_release_budget(c, &ino_req);
1552 ubifs_release_budget(c, &req);
1553 fscrypt_free_filename(&old_nm);
1554 fscrypt_free_filename(&new_nm);
1558 static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
1559 struct inode *new_dir, struct dentry *new_dentry)
1561 struct ubifs_info *c = old_dir->i_sb->s_fs_info;
1562 struct ubifs_budget_req req = { .new_dent = 1, .mod_dent = 1,
1564 int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
1565 struct inode *fst_inode = d_inode(old_dentry);
1566 struct inode *snd_inode = d_inode(new_dentry);
1567 struct timespec time;
1569 struct fscrypt_name fst_nm, snd_nm;
1571 ubifs_assert(fst_inode && snd_inode);
1573 if ((ubifs_crypt_is_encrypted(old_dir) ||
1574 ubifs_crypt_is_encrypted(new_dir)) &&
1575 (old_dir != new_dir) &&
1576 (!fscrypt_has_permitted_context(new_dir, fst_inode) ||
1577 !fscrypt_has_permitted_context(old_dir, snd_inode)))
1580 err = fscrypt_setup_filename(old_dir, &old_dentry->d_name, 0, &fst_nm);
1584 err = fscrypt_setup_filename(new_dir, &new_dentry->d_name, 0, &snd_nm);
1586 fscrypt_free_filename(&fst_nm);
1590 lock_4_inodes(old_dir, new_dir, NULL, NULL);
1592 time = ubifs_current_time(old_dir);
1593 fst_inode->i_ctime = time;
1594 snd_inode->i_ctime = time;
1595 old_dir->i_mtime = old_dir->i_ctime = time;
1596 new_dir->i_mtime = new_dir->i_ctime = time;
1598 if (old_dir != new_dir) {
1599 if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
1601 drop_nlink(old_dir);
1603 else if (!S_ISDIR(fst_inode->i_mode) && S_ISDIR(snd_inode->i_mode)) {
1604 drop_nlink(new_dir);
1609 err = ubifs_jnl_xrename(c, old_dir, fst_inode, &fst_nm, new_dir,
1610 snd_inode, &snd_nm, sync);
1612 unlock_4_inodes(old_dir, new_dir, NULL, NULL);
1613 ubifs_release_budget(c, &req);
1615 fscrypt_free_filename(&fst_nm);
1616 fscrypt_free_filename(&snd_nm);
1620 static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
1621 struct inode *new_dir, struct dentry *new_dentry,
1624 if (flags & ~(RENAME_NOREPLACE | RENAME_WHITEOUT | RENAME_EXCHANGE))
1627 ubifs_assert(inode_is_locked(old_dir));
1628 ubifs_assert(inode_is_locked(new_dir));
1630 if (flags & RENAME_EXCHANGE)
1631 return ubifs_xrename(old_dir, old_dentry, new_dir, new_dentry);
1633 return do_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
1636 int ubifs_getattr(const struct path *path, struct kstat *stat,
1637 u32 request_mask, unsigned int flags)
1640 struct inode *inode = d_inode(path->dentry);
1641 struct ubifs_inode *ui = ubifs_inode(inode);
1643 mutex_lock(&ui->ui_mutex);
1644 generic_fillattr(inode, stat);
1645 stat->blksize = UBIFS_BLOCK_SIZE;
1646 stat->size = ui->ui_size;
1649 * Unfortunately, the 'stat()' system call was designed for block
1650 * device based file systems, and it is not appropriate for UBIFS,
1651 * because UBIFS does not have notion of "block". For example, it is
1652 * difficult to tell how many block a directory takes - it actually
1653 * takes less than 300 bytes, but we have to round it to block size,
1654 * which introduces large mistake. This makes utilities like 'du' to
1655 * report completely senseless numbers. This is the reason why UBIFS
1656 * goes the same way as JFFS2 - it reports zero blocks for everything
1657 * but regular files, which makes more sense than reporting completely
1660 if (S_ISREG(inode->i_mode)) {
1661 size = ui->xattr_size;
1663 size = ALIGN(size, UBIFS_BLOCK_SIZE);
1665 * Note, user-space expects 512-byte blocks count irrespectively
1666 * of what was reported in @stat->size.
1668 stat->blocks = size >> 9;
1671 mutex_unlock(&ui->ui_mutex);
1675 static int ubifs_dir_open(struct inode *dir, struct file *file)
1677 if (ubifs_crypt_is_encrypted(dir))
1678 return fscrypt_get_encryption_info(dir) ? -EACCES : 0;
1683 const struct inode_operations ubifs_dir_inode_operations = {
1684 .lookup = ubifs_lookup,
1685 .create = ubifs_create,
1687 .symlink = ubifs_symlink,
1688 .unlink = ubifs_unlink,
1689 .mkdir = ubifs_mkdir,
1690 .rmdir = ubifs_rmdir,
1691 .mknod = ubifs_mknod,
1692 .rename = ubifs_rename,
1693 .setattr = ubifs_setattr,
1694 .getattr = ubifs_getattr,
1695 .listxattr = ubifs_listxattr,
1696 #ifdef CONFIG_UBIFS_ATIME_SUPPORT
1697 .update_time = ubifs_update_time,
1699 .tmpfile = ubifs_tmpfile,
1702 const struct file_operations ubifs_dir_operations = {
1703 .llseek = generic_file_llseek,
1704 .release = ubifs_dir_release,
1705 .read = generic_read_dir,
1706 .iterate_shared = ubifs_readdir,
1707 .fsync = ubifs_fsync,
1708 .unlocked_ioctl = ubifs_ioctl,
1709 .open = ubifs_dir_open,
1710 #ifdef CONFIG_COMPAT
1711 .compat_ioctl = ubifs_compat_ioctl,