dir.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * linux/fs/ext4/dir.c
  3. *
  4. * Copyright (C) 1992, 1993, 1994, 1995
  5. * Remy Card (card@masi.ibp.fr)
  6. * Laboratoire MASI - Institut Blaise Pascal
  7. * Universite Pierre et Marie Curie (Paris VI)
  8. *
  9. * from
  10. *
  11. * linux/fs/minix/dir.c
  12. *
  13. * Copyright (C) 1991, 1992 Linus Torvalds
  14. *
  15. * ext4 directory handling functions
  16. *
  17. * Big-endian to little-endian byte-swapping/bitmaps by
  18. * David S. Miller (davem@caip.rutgers.edu), 1995
  19. *
  20. * Hash Tree Directory indexing (c) 2001 Daniel Phillips
  21. *
  22. */
  23. #include <linux/fs.h>
  24. #include <linux/buffer_head.h>
  25. #include <linux/slab.h>
  26. #include "ext4.h"
  27. #include "xattr.h"
  28. static int ext4_dx_readdir(struct file *, struct dir_context *);
  29. /**
  30. * Check if the given dir-inode refers to an htree-indexed directory
  31. * (or a directory which could potentially get converted to use htree
  32. * indexing).
  33. *
  34. * Return 1 if it is a dx dir, 0 if not
  35. */
  36. static int is_dx_dir(struct inode *inode)
  37. {
  38. struct super_block *sb = inode->i_sb;
  39. if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb,
  40. EXT4_FEATURE_COMPAT_DIR_INDEX) &&
  41. ((ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) ||
  42. ((inode->i_size >> sb->s_blocksize_bits) == 1) ||
  43. ext4_has_inline_data(inode)))
  44. return 1;
  45. return 0;
  46. }
  47. /*
  48. * Return 0 if the directory entry is OK, and 1 if there is a problem
  49. *
  50. * Note: this is the opposite of what ext2 and ext3 historically returned...
  51. *
  52. * bh passed here can be an inode block or a dir data block, depending
  53. * on the inode inline data flag.
  54. */
  55. int __ext4_check_dir_entry(const char *function, unsigned int line,
  56. struct inode *dir, struct file *filp,
  57. struct ext4_dir_entry_2 *de,
  58. struct buffer_head *bh, char *buf, int size,
  59. unsigned int offset)
  60. {
  61. const char *error_msg = NULL;
  62. const int rlen = ext4_rec_len_from_disk(de->rec_len,
  63. dir->i_sb->s_blocksize);
  64. if (unlikely(rlen < EXT4_DIR_REC_LEN(1)))
  65. error_msg = "rec_len is smaller than minimal";
  66. else if (unlikely(rlen % 4 != 0))
  67. error_msg = "rec_len % 4 != 0";
  68. else if (unlikely(rlen < EXT4_DIR_REC_LEN(de->name_len)))
  69. error_msg = "rec_len is too small for name_len";
  70. else if (unlikely(((char *) de - buf) + rlen > size))
  71. error_msg = "directory entry across range";
  72. else if (unlikely(le32_to_cpu(de->inode) >
  73. le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count)))
  74. error_msg = "inode out of bounds";
  75. else
  76. return 0;
  77. if (filp)
  78. ext4_error_file(filp, function, line, bh->b_blocknr,
  79. "bad entry in directory: %s - offset=%u(%u), "
  80. "inode=%u, rec_len=%d, name_len=%d",
  81. error_msg, (unsigned) (offset % size),
  82. offset, le32_to_cpu(de->inode),
  83. rlen, de->name_len);
  84. else
  85. ext4_error_inode(dir, function, line, bh->b_blocknr,
  86. "bad entry in directory: %s - offset=%u(%u), "
  87. "inode=%u, rec_len=%d, name_len=%d",
  88. error_msg, (unsigned) (offset % size),
  89. offset, le32_to_cpu(de->inode),
  90. rlen, de->name_len);
  91. return 1;
  92. }
  93. static int ext4_readdir(struct file *file, struct dir_context *ctx)
  94. {
  95. unsigned int offset;
  96. int i;
  97. struct ext4_dir_entry_2 *de;
  98. int err;
  99. struct inode *inode = file_inode(file);
  100. struct super_block *sb = inode->i_sb;
  101. struct buffer_head *bh = NULL;
  102. int dir_has_error = 0;
  103. struct ext4_fname_crypto_ctx *enc_ctx = NULL;
  104. struct ext4_str fname_crypto_str = {.name = NULL, .len = 0};
  105. if (is_dx_dir(inode)) {
  106. err = ext4_dx_readdir(file, ctx);
  107. if (err != ERR_BAD_DX_DIR) {
  108. return err;
  109. }
  110. /*
  111. * We don't set the inode dirty flag since it's not
  112. * critical that it get flushed back to the disk.
  113. */
  114. ext4_clear_inode_flag(file_inode(file),
  115. EXT4_INODE_INDEX);
  116. }
  117. if (ext4_has_inline_data(inode)) {
  118. int has_inline_data = 1;
  119. err = ext4_read_inline_dir(file, ctx,
  120. &has_inline_data);
  121. if (has_inline_data)
  122. return err;
  123. }
  124. enc_ctx = ext4_get_fname_crypto_ctx(inode, EXT4_NAME_LEN);
  125. if (IS_ERR(enc_ctx))
  126. return PTR_ERR(enc_ctx);
  127. if (enc_ctx) {
  128. err = ext4_fname_crypto_alloc_buffer(enc_ctx, EXT4_NAME_LEN,
  129. &fname_crypto_str);
  130. if (err < 0) {
  131. ext4_put_fname_crypto_ctx(&enc_ctx);
  132. return err;
  133. }
  134. }
  135. offset = ctx->pos & (sb->s_blocksize - 1);
  136. while (ctx->pos < inode->i_size) {
  137. struct ext4_map_blocks map;
  138. map.m_lblk = ctx->pos >> EXT4_BLOCK_SIZE_BITS(sb);
  139. map.m_len = 1;
  140. err = ext4_map_blocks(NULL, inode, &map, 0);
  141. if (err > 0) {
  142. pgoff_t index = map.m_pblk >>
  143. (PAGE_CACHE_SHIFT - inode->i_blkbits);
  144. if (!ra_has_index(&file->f_ra, index))
  145. page_cache_sync_readahead(
  146. sb->s_bdev->bd_inode->i_mapping,
  147. &file->f_ra, file,
  148. index, 1);
  149. file->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT;
  150. bh = ext4_bread(NULL, inode, map.m_lblk, 0);
  151. if (IS_ERR(bh))
  152. return PTR_ERR(bh);
  153. }
  154. if (!bh) {
  155. if (!dir_has_error) {
  156. EXT4_ERROR_FILE(file, 0,
  157. "directory contains a "
  158. "hole at offset %llu",
  159. (unsigned long long) ctx->pos);
  160. dir_has_error = 1;
  161. }
  162. /* corrupt size? Maybe no more blocks to read */
  163. if (ctx->pos > inode->i_blocks << 9)
  164. break;
  165. ctx->pos += sb->s_blocksize - offset;
  166. continue;
  167. }
  168. /* Check the checksum */
  169. if (!buffer_verified(bh) &&
  170. !ext4_dirent_csum_verify(inode,
  171. (struct ext4_dir_entry *)bh->b_data)) {
  172. EXT4_ERROR_FILE(file, 0, "directory fails checksum "
  173. "at offset %llu",
  174. (unsigned long long)ctx->pos);
  175. ctx->pos += sb->s_blocksize - offset;
  176. brelse(bh);
  177. bh = NULL;
  178. continue;
  179. }
  180. set_buffer_verified(bh);
  181. /* If the dir block has changed since the last call to
  182. * readdir(2), then we might be pointing to an invalid
  183. * dirent right now. Scan from the start of the block
  184. * to make sure. */
  185. if (file->f_version != inode->i_version) {
  186. for (i = 0; i < sb->s_blocksize && i < offset; ) {
  187. de = (struct ext4_dir_entry_2 *)
  188. (bh->b_data + i);
  189. /* It's too expensive to do a full
  190. * dirent test each time round this
  191. * loop, but we do have to test at
  192. * least that it is non-zero. A
  193. * failure will be detected in the
  194. * dirent test below. */
  195. if (ext4_rec_len_from_disk(de->rec_len,
  196. sb->s_blocksize) < EXT4_DIR_REC_LEN(1))
  197. break;
  198. i += ext4_rec_len_from_disk(de->rec_len,
  199. sb->s_blocksize);
  200. }
  201. offset = i;
  202. ctx->pos = (ctx->pos & ~(sb->s_blocksize - 1))
  203. | offset;
  204. file->f_version = inode->i_version;
  205. }
  206. while (ctx->pos < inode->i_size
  207. && offset < sb->s_blocksize) {
  208. de = (struct ext4_dir_entry_2 *) (bh->b_data + offset);
  209. if (ext4_check_dir_entry(inode, file, de, bh,
  210. bh->b_data, bh->b_size,
  211. offset)) {
  212. /*
  213. * On error, skip to the next block
  214. */
  215. ctx->pos = (ctx->pos |
  216. (sb->s_blocksize - 1)) + 1;
  217. break;
  218. }
  219. offset += ext4_rec_len_from_disk(de->rec_len,
  220. sb->s_blocksize);
  221. if (le32_to_cpu(de->inode)) {
  222. if (enc_ctx == NULL) {
  223. /* Directory is not encrypted */
  224. if (!dir_emit(ctx, de->name,
  225. de->name_len,
  226. le32_to_cpu(de->inode),
  227. get_dtype(sb, de->file_type)))
  228. goto done;
  229. } else {
  230. /* Directory is encrypted */
  231. err = ext4_fname_disk_to_usr(enc_ctx,
  232. NULL, de, &fname_crypto_str);
  233. if (err < 0)
  234. goto errout;
  235. if (!dir_emit(ctx,
  236. fname_crypto_str.name, err,
  237. le32_to_cpu(de->inode),
  238. get_dtype(sb, de->file_type)))
  239. goto done;
  240. }
  241. }
  242. ctx->pos += ext4_rec_len_from_disk(de->rec_len,
  243. sb->s_blocksize);
  244. }
  245. if ((ctx->pos < inode->i_size) && !dir_relax(inode))
  246. goto done;
  247. brelse(bh);
  248. bh = NULL;
  249. offset = 0;
  250. }
  251. done:
  252. err = 0;
  253. errout:
  254. #ifdef CONFIG_EXT4_FS_ENCRYPTION
  255. ext4_put_fname_crypto_ctx(&enc_ctx);
  256. ext4_fname_crypto_free_buffer(&fname_crypto_str);
  257. #endif
  258. brelse(bh);
  259. return err;
  260. }
  261. static inline int is_32bit_api(void)
  262. {
  263. #ifdef CONFIG_COMPAT
  264. return is_compat_task();
  265. #else
  266. return (BITS_PER_LONG == 32);
  267. #endif
  268. }
  269. /*
  270. * These functions convert from the major/minor hash to an f_pos
  271. * value for dx directories
  272. *
  273. * Upper layer (for example NFS) should specify FMODE_32BITHASH or
  274. * FMODE_64BITHASH explicitly. On the other hand, we allow ext4 to be mounted
  275. * directly on both 32-bit and 64-bit nodes, under such case, neither
  276. * FMODE_32BITHASH nor FMODE_64BITHASH is specified.
  277. */
  278. static inline loff_t hash2pos(struct file *filp, __u32 major, __u32 minor)
  279. {
  280. if ((filp->f_mode & FMODE_32BITHASH) ||
  281. (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
  282. return major >> 1;
  283. else
  284. return ((__u64)(major >> 1) << 32) | (__u64)minor;
  285. }
  286. static inline __u32 pos2maj_hash(struct file *filp, loff_t pos)
  287. {
  288. if ((filp->f_mode & FMODE_32BITHASH) ||
  289. (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
  290. return (pos << 1) & 0xffffffff;
  291. else
  292. return ((pos >> 32) << 1) & 0xffffffff;
  293. }
  294. static inline __u32 pos2min_hash(struct file *filp, loff_t pos)
  295. {
  296. if ((filp->f_mode & FMODE_32BITHASH) ||
  297. (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
  298. return 0;
  299. else
  300. return pos & 0xffffffff;
  301. }
  302. /*
  303. * Return 32- or 64-bit end-of-file for dx directories
  304. */
  305. static inline loff_t ext4_get_htree_eof(struct file *filp)
  306. {
  307. if ((filp->f_mode & FMODE_32BITHASH) ||
  308. (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
  309. return EXT4_HTREE_EOF_32BIT;
  310. else
  311. return EXT4_HTREE_EOF_64BIT;
  312. }
  313. /*
  314. * ext4_dir_llseek() calls generic_file_llseek_size to handle htree
  315. * directories, where the "offset" is in terms of the filename hash
  316. * value instead of the byte offset.
  317. *
  318. * Because we may return a 64-bit hash that is well beyond offset limits,
  319. * we need to pass the max hash as the maximum allowable offset in
  320. * the htree directory case.
  321. *
  322. * For non-htree, ext4_llseek already chooses the proper max offset.
  323. */
  324. static loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence)
  325. {
  326. struct inode *inode = file->f_mapping->host;
  327. int dx_dir = is_dx_dir(inode);
  328. loff_t htree_max = ext4_get_htree_eof(file);
  329. if (likely(dx_dir))
  330. return generic_file_llseek_size(file, offset, whence,
  331. htree_max, htree_max);
  332. else
  333. return ext4_llseek(file, offset, whence);
  334. }
  335. /*
  336. * This structure holds the nodes of the red-black tree used to store
  337. * the directory entry in hash order.
  338. */
  339. struct fname {
  340. __u32 hash;
  341. __u32 minor_hash;
  342. struct rb_node rb_hash;
  343. struct fname *next;
  344. __u32 inode;
  345. __u8 name_len;
  346. __u8 file_type;
  347. char name[0];
  348. };
  349. /*
  350. * This functoin implements a non-recursive way of freeing all of the
  351. * nodes in the red-black tree.
  352. */
  353. static void free_rb_tree_fname(struct rb_root *root)
  354. {
  355. struct fname *fname, *next;
  356. rbtree_postorder_for_each_entry_safe(fname, next, root, rb_hash)
  357. while (fname) {
  358. struct fname *old = fname;
  359. fname = fname->next;
  360. kfree(old);
  361. }
  362. *root = RB_ROOT;
  363. }
  364. static struct dir_private_info *ext4_htree_create_dir_info(struct file *filp,
  365. loff_t pos)
  366. {
  367. struct dir_private_info *p;
  368. p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
  369. if (!p)
  370. return NULL;
  371. p->curr_hash = pos2maj_hash(filp, pos);
  372. p->curr_minor_hash = pos2min_hash(filp, pos);
  373. return p;
  374. }
  375. void ext4_htree_free_dir_info(struct dir_private_info *p)
  376. {
  377. free_rb_tree_fname(&p->root);
  378. kfree(p);
  379. }
  380. /*
  381. * Given a directory entry, enter it into the fname rb tree.
  382. *
  383. * When filename encryption is enabled, the dirent will hold the
  384. * encrypted filename, while the htree will hold decrypted filename.
  385. * The decrypted filename is passed in via ent_name. parameter.
  386. */
  387. int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
  388. __u32 minor_hash,
  389. struct ext4_dir_entry_2 *dirent,
  390. struct ext4_str *ent_name)
  391. {
  392. struct rb_node **p, *parent = NULL;
  393. struct fname *fname, *new_fn;
  394. struct dir_private_info *info;
  395. int len;
  396. info = dir_file->private_data;
  397. p = &info->root.rb_node;
  398. /* Create and allocate the fname structure */
  399. len = sizeof(struct fname) + ent_name->len + 1;
  400. new_fn = kzalloc(len, GFP_KERNEL);
  401. if (!new_fn)
  402. return -ENOMEM;
  403. new_fn->hash = hash;
  404. new_fn->minor_hash = minor_hash;
  405. new_fn->inode = le32_to_cpu(dirent->inode);
  406. new_fn->name_len = ent_name->len;
  407. new_fn->file_type = dirent->file_type;
  408. memcpy(new_fn->name, ent_name->name, ent_name->len);
  409. new_fn->name[ent_name->len] = 0;
  410. while (*p) {
  411. parent = *p;
  412. fname = rb_entry(parent, struct fname, rb_hash);
  413. /*
  414. * If the hash and minor hash match up, then we put
  415. * them on a linked list. This rarely happens...
  416. */
  417. if ((new_fn->hash == fname->hash) &&
  418. (new_fn->minor_hash == fname->minor_hash)) {
  419. new_fn->next = fname->next;
  420. fname->next = new_fn;
  421. return 0;
  422. }
  423. if (new_fn->hash < fname->hash)
  424. p = &(*p)->rb_left;
  425. else if (new_fn->hash > fname->hash)
  426. p = &(*p)->rb_right;
  427. else if (new_fn->minor_hash < fname->minor_hash)
  428. p = &(*p)->rb_left;
  429. else /* if (new_fn->minor_hash > fname->minor_hash) */
  430. p = &(*p)->rb_right;
  431. }
  432. rb_link_node(&new_fn->rb_hash, parent, p);
  433. rb_insert_color(&new_fn->rb_hash, &info->root);
  434. return 0;
  435. }
  436. /*
  437. * This is a helper function for ext4_dx_readdir. It calls filldir
  438. * for all entres on the fname linked list. (Normally there is only
  439. * one entry on the linked list, unless there are 62 bit hash collisions.)
  440. */
  441. static int call_filldir(struct file *file, struct dir_context *ctx,
  442. struct fname *fname)
  443. {
  444. struct dir_private_info *info = file->private_data;
  445. struct inode *inode = file_inode(file);
  446. struct super_block *sb = inode->i_sb;
  447. if (!fname) {
  448. ext4_msg(sb, KERN_ERR, "%s:%d: inode #%lu: comm %s: "
  449. "called with null fname?!?", __func__, __LINE__,
  450. inode->i_ino, current->comm);
  451. return 0;
  452. }
  453. ctx->pos = hash2pos(file, fname->hash, fname->minor_hash);
  454. while (fname) {
  455. if (!dir_emit(ctx, fname->name,
  456. fname->name_len,
  457. fname->inode,
  458. get_dtype(sb, fname->file_type))) {
  459. info->extra_fname = fname;
  460. return 1;
  461. }
  462. fname = fname->next;
  463. }
  464. return 0;
  465. }
  466. static int ext4_dx_readdir(struct file *file, struct dir_context *ctx)
  467. {
  468. struct dir_private_info *info = file->private_data;
  469. struct inode *inode = file_inode(file);
  470. struct fname *fname;
  471. int ret;
  472. if (!info) {
  473. info = ext4_htree_create_dir_info(file, ctx->pos);
  474. if (!info)
  475. return -ENOMEM;
  476. file->private_data = info;
  477. }
  478. if (ctx->pos == ext4_get_htree_eof(file))
  479. return 0; /* EOF */
  480. /* Some one has messed with f_pos; reset the world */
  481. if (info->last_pos != ctx->pos) {
  482. free_rb_tree_fname(&info->root);
  483. info->curr_node = NULL;
  484. info->extra_fname = NULL;
  485. info->curr_hash = pos2maj_hash(file, ctx->pos);
  486. info->curr_minor_hash = pos2min_hash(file, ctx->pos);
  487. }
  488. /*
  489. * If there are any leftover names on the hash collision
  490. * chain, return them first.
  491. */
  492. if (info->extra_fname) {
  493. if (call_filldir(file, ctx, info->extra_fname))
  494. goto finished;
  495. info->extra_fname = NULL;
  496. goto next_node;
  497. } else if (!info->curr_node)
  498. info->curr_node = rb_first(&info->root);
  499. while (1) {
  500. /*
  501. * Fill the rbtree if we have no more entries,
  502. * or the inode has changed since we last read in the
  503. * cached entries.
  504. */
  505. if ((!info->curr_node) ||
  506. (file->f_version != inode->i_version)) {
  507. info->curr_node = NULL;
  508. free_rb_tree_fname(&info->root);
  509. file->f_version = inode->i_version;
  510. ret = ext4_htree_fill_tree(file, info->curr_hash,
  511. info->curr_minor_hash,
  512. &info->next_hash);
  513. if (ret < 0)
  514. return ret;
  515. if (ret == 0) {
  516. ctx->pos = ext4_get_htree_eof(file);
  517. break;
  518. }
  519. info->curr_node = rb_first(&info->root);
  520. }
  521. fname = rb_entry(info->curr_node, struct fname, rb_hash);
  522. info->curr_hash = fname->hash;
  523. info->curr_minor_hash = fname->minor_hash;
  524. if (call_filldir(file, ctx, fname))
  525. break;
  526. next_node:
  527. info->curr_node = rb_next(info->curr_node);
  528. if (info->curr_node) {
  529. fname = rb_entry(info->curr_node, struct fname,
  530. rb_hash);
  531. info->curr_hash = fname->hash;
  532. info->curr_minor_hash = fname->minor_hash;
  533. } else {
  534. if (info->next_hash == ~0) {
  535. ctx->pos = ext4_get_htree_eof(file);
  536. break;
  537. }
  538. info->curr_hash = info->next_hash;
  539. info->curr_minor_hash = 0;
  540. }
  541. }
  542. finished:
  543. info->last_pos = ctx->pos;
  544. return 0;
  545. }
  546. static int ext4_release_dir(struct inode *inode, struct file *filp)
  547. {
  548. if (filp->private_data)
  549. ext4_htree_free_dir_info(filp->private_data);
  550. return 0;
  551. }
  552. int ext4_check_all_de(struct inode *dir, struct buffer_head *bh, void *buf,
  553. int buf_size)
  554. {
  555. struct ext4_dir_entry_2 *de;
  556. int nlen, rlen;
  557. unsigned int offset = 0;
  558. char *top;
  559. de = (struct ext4_dir_entry_2 *)buf;
  560. top = buf + buf_size;
  561. while ((char *) de < top) {
  562. if (ext4_check_dir_entry(dir, NULL, de, bh,
  563. buf, buf_size, offset))
  564. return -EIO;
  565. nlen = EXT4_DIR_REC_LEN(de->name_len);
  566. rlen = ext4_rec_len_from_disk(de->rec_len, buf_size);
  567. de = (struct ext4_dir_entry_2 *)((char *)de + rlen);
  568. offset += rlen;
  569. }
  570. if ((char *) de > top)
  571. return -EIO;
  572. return 0;
  573. }
  574. const struct file_operations ext4_dir_operations = {
  575. .llseek = ext4_dir_llseek,
  576. .read = generic_read_dir,
  577. .iterate = ext4_readdir,
  578. .unlocked_ioctl = ext4_ioctl,
  579. #ifdef CONFIG_COMPAT
  580. .compat_ioctl = ext4_compat_ioctl,
  581. #endif
  582. .fsync = ext4_sync_file,
  583. .release = ext4_release_dir,
  584. };