dir.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * linux/fs/ufs/ufs_dir.c
  3. *
  4. * Copyright (C) 1996
  5. * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu)
  6. * Laboratory for Computer Science Research Computing Facility
  7. * Rutgers, The State University of New Jersey
  8. *
  9. * swab support by Francois-Rene Rideau <fare@tunes.org> 19970406
  10. *
  11. * 4.4BSD (FreeBSD) support added on February 1st 1998 by
  12. * Niels Kristian Bech Jensen <nkbj@image.dk> partially based
  13. * on code by Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>.
  14. *
  15. * Migration to usage of "page cache" on May 2006 by
  16. * Evgeniy Dushistov <dushistov@mail.ru> based on ext2 code base.
  17. */
  18. #include <linux/time.h>
  19. #include <linux/fs.h>
  20. #include <linux/swap.h>
  21. #include "ufs_fs.h"
  22. #include "ufs.h"
  23. #include "swab.h"
  24. #include "util.h"
  25. /*
  26. * NOTE! unlike strncmp, ufs_match returns 1 for success, 0 for failure.
  27. *
  28. * len <= UFS_MAXNAMLEN and de != NULL are guaranteed by caller.
  29. */
  30. static inline int ufs_match(struct super_block *sb, int len,
  31. const unsigned char *name, struct ufs_dir_entry *de)
  32. {
  33. if (len != ufs_get_de_namlen(sb, de))
  34. return 0;
  35. if (!de->d_ino)
  36. return 0;
  37. return !memcmp(name, de->d_name, len);
  38. }
  39. static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len)
  40. {
  41. struct address_space *mapping = page->mapping;
  42. struct inode *dir = mapping->host;
  43. int err = 0;
  44. dir->i_version++;
  45. block_write_end(NULL, mapping, pos, len, len, page, NULL);
  46. if (pos+len > dir->i_size) {
  47. i_size_write(dir, pos+len);
  48. mark_inode_dirty(dir);
  49. }
  50. if (IS_DIRSYNC(dir))
  51. err = write_one_page(page, 1);
  52. else
  53. unlock_page(page);
  54. return err;
  55. }
  56. static inline void ufs_put_page(struct page *page)
  57. {
  58. kunmap(page);
  59. put_page(page);
  60. }
  61. ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr)
  62. {
  63. ino_t res = 0;
  64. struct ufs_dir_entry *de;
  65. struct page *page;
  66. de = ufs_find_entry(dir, qstr, &page);
  67. if (de) {
  68. res = fs32_to_cpu(dir->i_sb, de->d_ino);
  69. ufs_put_page(page);
  70. }
  71. return res;
  72. }
  73. /* Releases the page */
  74. void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
  75. struct page *page, struct inode *inode,
  76. bool update_times)
  77. {
  78. loff_t pos = page_offset(page) +
  79. (char *) de - (char *) page_address(page);
  80. unsigned len = fs16_to_cpu(dir->i_sb, de->d_reclen);
  81. int err;
  82. lock_page(page);
  83. err = ufs_prepare_chunk(page, pos, len);
  84. BUG_ON(err);
  85. de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino);
  86. ufs_set_de_type(dir->i_sb, de, inode->i_mode);
  87. err = ufs_commit_chunk(page, pos, len);
  88. ufs_put_page(page);
  89. if (update_times)
  90. dir->i_mtime = dir->i_ctime = current_time(dir);
  91. mark_inode_dirty(dir);
  92. }
  93. static bool ufs_check_page(struct page *page)
  94. {
  95. struct inode *dir = page->mapping->host;
  96. struct super_block *sb = dir->i_sb;
  97. char *kaddr = page_address(page);
  98. unsigned offs, rec_len;
  99. unsigned limit = PAGE_SIZE;
  100. const unsigned chunk_mask = UFS_SB(sb)->s_uspi->s_dirblksize - 1;
  101. struct ufs_dir_entry *p;
  102. char *error;
  103. if ((dir->i_size >> PAGE_SHIFT) == page->index) {
  104. limit = dir->i_size & ~PAGE_MASK;
  105. if (limit & chunk_mask)
  106. goto Ebadsize;
  107. if (!limit)
  108. goto out;
  109. }
  110. for (offs = 0; offs <= limit - UFS_DIR_REC_LEN(1); offs += rec_len) {
  111. p = (struct ufs_dir_entry *)(kaddr + offs);
  112. rec_len = fs16_to_cpu(sb, p->d_reclen);
  113. if (rec_len < UFS_DIR_REC_LEN(1))
  114. goto Eshort;
  115. if (rec_len & 3)
  116. goto Ealign;
  117. if (rec_len < UFS_DIR_REC_LEN(ufs_get_de_namlen(sb, p)))
  118. goto Enamelen;
  119. if (((offs + rec_len - 1) ^ offs) & ~chunk_mask)
  120. goto Espan;
  121. if (fs32_to_cpu(sb, p->d_ino) > (UFS_SB(sb)->s_uspi->s_ipg *
  122. UFS_SB(sb)->s_uspi->s_ncg))
  123. goto Einumber;
  124. }
  125. if (offs != limit)
  126. goto Eend;
  127. out:
  128. SetPageChecked(page);
  129. return true;
  130. /* Too bad, we had an error */
  131. Ebadsize:
  132. ufs_error(sb, "ufs_check_page",
  133. "size of directory #%lu is not a multiple of chunk size",
  134. dir->i_ino
  135. );
  136. goto fail;
  137. Eshort:
  138. error = "rec_len is smaller than minimal";
  139. goto bad_entry;
  140. Ealign:
  141. error = "unaligned directory entry";
  142. goto bad_entry;
  143. Enamelen:
  144. error = "rec_len is too small for name_len";
  145. goto bad_entry;
  146. Espan:
  147. error = "directory entry across blocks";
  148. goto bad_entry;
  149. Einumber:
  150. error = "inode out of bounds";
  151. bad_entry:
  152. ufs_error (sb, "ufs_check_page", "bad entry in directory #%lu: %s - "
  153. "offset=%lu, rec_len=%d, name_len=%d",
  154. dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs,
  155. rec_len, ufs_get_de_namlen(sb, p));
  156. goto fail;
  157. Eend:
  158. p = (struct ufs_dir_entry *)(kaddr + offs);
  159. ufs_error(sb, __func__,
  160. "entry in directory #%lu spans the page boundary"
  161. "offset=%lu",
  162. dir->i_ino, (page->index<<PAGE_SHIFT)+offs);
  163. fail:
  164. SetPageError(page);
  165. return false;
  166. }
  167. static struct page *ufs_get_page(struct inode *dir, unsigned long n)
  168. {
  169. struct address_space *mapping = dir->i_mapping;
  170. struct page *page = read_mapping_page(mapping, n, NULL);
  171. if (!IS_ERR(page)) {
  172. kmap(page);
  173. if (unlikely(!PageChecked(page))) {
  174. if (PageError(page) || !ufs_check_page(page))
  175. goto fail;
  176. }
  177. }
  178. return page;
  179. fail:
  180. ufs_put_page(page);
  181. return ERR_PTR(-EIO);
  182. }
  183. /*
  184. * Return the offset into page `page_nr' of the last valid
  185. * byte in that page, plus one.
  186. */
  187. static unsigned
  188. ufs_last_byte(struct inode *inode, unsigned long page_nr)
  189. {
  190. unsigned last_byte = inode->i_size;
  191. last_byte -= page_nr << PAGE_SHIFT;
  192. if (last_byte > PAGE_SIZE)
  193. last_byte = PAGE_SIZE;
  194. return last_byte;
  195. }
  196. static inline struct ufs_dir_entry *
  197. ufs_next_entry(struct super_block *sb, struct ufs_dir_entry *p)
  198. {
  199. return (struct ufs_dir_entry *)((char *)p +
  200. fs16_to_cpu(sb, p->d_reclen));
  201. }
  202. struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p)
  203. {
  204. struct page *page = ufs_get_page(dir, 0);
  205. struct ufs_dir_entry *de = NULL;
  206. if (!IS_ERR(page)) {
  207. de = ufs_next_entry(dir->i_sb,
  208. (struct ufs_dir_entry *)page_address(page));
  209. *p = page;
  210. }
  211. return de;
  212. }
  213. /*
  214. * ufs_find_entry()
  215. *
  216. * finds an entry in the specified directory with the wanted name. It
  217. * returns the page in which the entry was found, and the entry itself
  218. * (as a parameter - res_dir). Page is returned mapped and unlocked.
  219. * Entry is guaranteed to be valid.
  220. */
  221. struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr,
  222. struct page **res_page)
  223. {
  224. struct super_block *sb = dir->i_sb;
  225. const unsigned char *name = qstr->name;
  226. int namelen = qstr->len;
  227. unsigned reclen = UFS_DIR_REC_LEN(namelen);
  228. unsigned long start, n;
  229. unsigned long npages = dir_pages(dir);
  230. struct page *page = NULL;
  231. struct ufs_inode_info *ui = UFS_I(dir);
  232. struct ufs_dir_entry *de;
  233. UFSD("ENTER, dir_ino %lu, name %s, namlen %u\n", dir->i_ino, name, namelen);
  234. if (npages == 0 || namelen > UFS_MAXNAMLEN)
  235. goto out;
  236. /* OFFSET_CACHE */
  237. *res_page = NULL;
  238. start = ui->i_dir_start_lookup;
  239. if (start >= npages)
  240. start = 0;
  241. n = start;
  242. do {
  243. char *kaddr;
  244. page = ufs_get_page(dir, n);
  245. if (!IS_ERR(page)) {
  246. kaddr = page_address(page);
  247. de = (struct ufs_dir_entry *) kaddr;
  248. kaddr += ufs_last_byte(dir, n) - reclen;
  249. while ((char *) de <= kaddr) {
  250. if (ufs_match(sb, namelen, name, de))
  251. goto found;
  252. de = ufs_next_entry(sb, de);
  253. }
  254. ufs_put_page(page);
  255. }
  256. if (++n >= npages)
  257. n = 0;
  258. } while (n != start);
  259. out:
  260. return NULL;
  261. found:
  262. *res_page = page;
  263. ui->i_dir_start_lookup = n;
  264. return de;
  265. }
  266. /*
  267. * Parent is locked.
  268. */
  269. int ufs_add_link(struct dentry *dentry, struct inode *inode)
  270. {
  271. struct inode *dir = d_inode(dentry->d_parent);
  272. const unsigned char *name = dentry->d_name.name;
  273. int namelen = dentry->d_name.len;
  274. struct super_block *sb = dir->i_sb;
  275. unsigned reclen = UFS_DIR_REC_LEN(namelen);
  276. const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
  277. unsigned short rec_len, name_len;
  278. struct page *page = NULL;
  279. struct ufs_dir_entry *de;
  280. unsigned long npages = dir_pages(dir);
  281. unsigned long n;
  282. char *kaddr;
  283. loff_t pos;
  284. int err;
  285. UFSD("ENTER, name %s, namelen %u\n", name, namelen);
  286. /*
  287. * We take care of directory expansion in the same loop.
  288. * This code plays outside i_size, so it locks the page
  289. * to protect that region.
  290. */
  291. for (n = 0; n <= npages; n++) {
  292. char *dir_end;
  293. page = ufs_get_page(dir, n);
  294. err = PTR_ERR(page);
  295. if (IS_ERR(page))
  296. goto out;
  297. lock_page(page);
  298. kaddr = page_address(page);
  299. dir_end = kaddr + ufs_last_byte(dir, n);
  300. de = (struct ufs_dir_entry *)kaddr;
  301. kaddr += PAGE_SIZE - reclen;
  302. while ((char *)de <= kaddr) {
  303. if ((char *)de == dir_end) {
  304. /* We hit i_size */
  305. name_len = 0;
  306. rec_len = chunk_size;
  307. de->d_reclen = cpu_to_fs16(sb, chunk_size);
  308. de->d_ino = 0;
  309. goto got_it;
  310. }
  311. if (de->d_reclen == 0) {
  312. ufs_error(dir->i_sb, __func__,
  313. "zero-length directory entry");
  314. err = -EIO;
  315. goto out_unlock;
  316. }
  317. err = -EEXIST;
  318. if (ufs_match(sb, namelen, name, de))
  319. goto out_unlock;
  320. name_len = UFS_DIR_REC_LEN(ufs_get_de_namlen(sb, de));
  321. rec_len = fs16_to_cpu(sb, de->d_reclen);
  322. if (!de->d_ino && rec_len >= reclen)
  323. goto got_it;
  324. if (rec_len >= name_len + reclen)
  325. goto got_it;
  326. de = (struct ufs_dir_entry *) ((char *) de + rec_len);
  327. }
  328. unlock_page(page);
  329. ufs_put_page(page);
  330. }
  331. BUG();
  332. return -EINVAL;
  333. got_it:
  334. pos = page_offset(page) +
  335. (char*)de - (char*)page_address(page);
  336. err = ufs_prepare_chunk(page, pos, rec_len);
  337. if (err)
  338. goto out_unlock;
  339. if (de->d_ino) {
  340. struct ufs_dir_entry *de1 =
  341. (struct ufs_dir_entry *) ((char *) de + name_len);
  342. de1->d_reclen = cpu_to_fs16(sb, rec_len - name_len);
  343. de->d_reclen = cpu_to_fs16(sb, name_len);
  344. de = de1;
  345. }
  346. ufs_set_de_namlen(sb, de, namelen);
  347. memcpy(de->d_name, name, namelen + 1);
  348. de->d_ino = cpu_to_fs32(sb, inode->i_ino);
  349. ufs_set_de_type(sb, de, inode->i_mode);
  350. err = ufs_commit_chunk(page, pos, rec_len);
  351. dir->i_mtime = dir->i_ctime = current_time(dir);
  352. mark_inode_dirty(dir);
  353. /* OFFSET_CACHE */
  354. out_put:
  355. ufs_put_page(page);
  356. out:
  357. return err;
  358. out_unlock:
  359. unlock_page(page);
  360. goto out_put;
  361. }
  362. static inline unsigned
  363. ufs_validate_entry(struct super_block *sb, char *base,
  364. unsigned offset, unsigned mask)
  365. {
  366. struct ufs_dir_entry *de = (struct ufs_dir_entry*)(base + offset);
  367. struct ufs_dir_entry *p = (struct ufs_dir_entry*)(base + (offset&mask));
  368. while ((char*)p < (char*)de)
  369. p = ufs_next_entry(sb, p);
  370. return (char *)p - base;
  371. }
  372. /*
  373. * This is blatantly stolen from ext2fs
  374. */
  375. static int
  376. ufs_readdir(struct file *file, struct dir_context *ctx)
  377. {
  378. loff_t pos = ctx->pos;
  379. struct inode *inode = file_inode(file);
  380. struct super_block *sb = inode->i_sb;
  381. unsigned int offset = pos & ~PAGE_MASK;
  382. unsigned long n = pos >> PAGE_SHIFT;
  383. unsigned long npages = dir_pages(inode);
  384. unsigned chunk_mask = ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
  385. int need_revalidate = file->f_version != inode->i_version;
  386. unsigned flags = UFS_SB(sb)->s_flags;
  387. UFSD("BEGIN\n");
  388. if (pos > inode->i_size - UFS_DIR_REC_LEN(1))
  389. return 0;
  390. for ( ; n < npages; n++, offset = 0) {
  391. char *kaddr, *limit;
  392. struct ufs_dir_entry *de;
  393. struct page *page = ufs_get_page(inode, n);
  394. if (IS_ERR(page)) {
  395. ufs_error(sb, __func__,
  396. "bad page in #%lu",
  397. inode->i_ino);
  398. ctx->pos += PAGE_SIZE - offset;
  399. return -EIO;
  400. }
  401. kaddr = page_address(page);
  402. if (unlikely(need_revalidate)) {
  403. if (offset) {
  404. offset = ufs_validate_entry(sb, kaddr, offset, chunk_mask);
  405. ctx->pos = (n<<PAGE_SHIFT) + offset;
  406. }
  407. file->f_version = inode->i_version;
  408. need_revalidate = 0;
  409. }
  410. de = (struct ufs_dir_entry *)(kaddr+offset);
  411. limit = kaddr + ufs_last_byte(inode, n) - UFS_DIR_REC_LEN(1);
  412. for ( ;(char*)de <= limit; de = ufs_next_entry(sb, de)) {
  413. if (de->d_ino) {
  414. unsigned char d_type = DT_UNKNOWN;
  415. UFSD("filldir(%s,%u)\n", de->d_name,
  416. fs32_to_cpu(sb, de->d_ino));
  417. UFSD("namlen %u\n", ufs_get_de_namlen(sb, de));
  418. if ((flags & UFS_DE_MASK) == UFS_DE_44BSD)
  419. d_type = de->d_u.d_44.d_type;
  420. if (!dir_emit(ctx, de->d_name,
  421. ufs_get_de_namlen(sb, de),
  422. fs32_to_cpu(sb, de->d_ino),
  423. d_type)) {
  424. ufs_put_page(page);
  425. return 0;
  426. }
  427. }
  428. ctx->pos += fs16_to_cpu(sb, de->d_reclen);
  429. }
  430. ufs_put_page(page);
  431. }
  432. return 0;
  433. }
  434. /*
  435. * ufs_delete_entry deletes a directory entry by merging it with the
  436. * previous entry.
  437. */
  438. int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
  439. struct page * page)
  440. {
  441. struct super_block *sb = inode->i_sb;
  442. char *kaddr = page_address(page);
  443. unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
  444. unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen);
  445. loff_t pos;
  446. struct ufs_dir_entry *pde = NULL;
  447. struct ufs_dir_entry *de = (struct ufs_dir_entry *) (kaddr + from);
  448. int err;
  449. UFSD("ENTER\n");
  450. UFSD("ino %u, reclen %u, namlen %u, name %s\n",
  451. fs32_to_cpu(sb, de->d_ino),
  452. fs16_to_cpu(sb, de->d_reclen),
  453. ufs_get_de_namlen(sb, de), de->d_name);
  454. while ((char*)de < (char*)dir) {
  455. if (de->d_reclen == 0) {
  456. ufs_error(inode->i_sb, __func__,
  457. "zero-length directory entry");
  458. err = -EIO;
  459. goto out;
  460. }
  461. pde = de;
  462. de = ufs_next_entry(sb, de);
  463. }
  464. if (pde)
  465. from = (char*)pde - (char*)page_address(page);
  466. pos = page_offset(page) + from;
  467. lock_page(page);
  468. err = ufs_prepare_chunk(page, pos, to - from);
  469. BUG_ON(err);
  470. if (pde)
  471. pde->d_reclen = cpu_to_fs16(sb, to - from);
  472. dir->d_ino = 0;
  473. err = ufs_commit_chunk(page, pos, to - from);
  474. inode->i_ctime = inode->i_mtime = current_time(inode);
  475. mark_inode_dirty(inode);
  476. out:
  477. ufs_put_page(page);
  478. UFSD("EXIT\n");
  479. return err;
  480. }
  481. int ufs_make_empty(struct inode * inode, struct inode *dir)
  482. {
  483. struct super_block * sb = dir->i_sb;
  484. struct address_space *mapping = inode->i_mapping;
  485. struct page *page = grab_cache_page(mapping, 0);
  486. const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
  487. struct ufs_dir_entry * de;
  488. char *base;
  489. int err;
  490. if (!page)
  491. return -ENOMEM;
  492. err = ufs_prepare_chunk(page, 0, chunk_size);
  493. if (err) {
  494. unlock_page(page);
  495. goto fail;
  496. }
  497. kmap(page);
  498. base = (char*)page_address(page);
  499. memset(base, 0, PAGE_SIZE);
  500. de = (struct ufs_dir_entry *) base;
  501. de->d_ino = cpu_to_fs32(sb, inode->i_ino);
  502. ufs_set_de_type(sb, de, inode->i_mode);
  503. ufs_set_de_namlen(sb, de, 1);
  504. de->d_reclen = cpu_to_fs16(sb, UFS_DIR_REC_LEN(1));
  505. strcpy (de->d_name, ".");
  506. de = (struct ufs_dir_entry *)
  507. ((char *)de + fs16_to_cpu(sb, de->d_reclen));
  508. de->d_ino = cpu_to_fs32(sb, dir->i_ino);
  509. ufs_set_de_type(sb, de, dir->i_mode);
  510. de->d_reclen = cpu_to_fs16(sb, chunk_size - UFS_DIR_REC_LEN(1));
  511. ufs_set_de_namlen(sb, de, 2);
  512. strcpy (de->d_name, "..");
  513. kunmap(page);
  514. err = ufs_commit_chunk(page, 0, chunk_size);
  515. fail:
  516. put_page(page);
  517. return err;
  518. }
  519. /*
  520. * routine to check that the specified directory is empty (for rmdir)
  521. */
  522. int ufs_empty_dir(struct inode * inode)
  523. {
  524. struct super_block *sb = inode->i_sb;
  525. struct page *page = NULL;
  526. unsigned long i, npages = dir_pages(inode);
  527. for (i = 0; i < npages; i++) {
  528. char *kaddr;
  529. struct ufs_dir_entry *de;
  530. page = ufs_get_page(inode, i);
  531. if (IS_ERR(page))
  532. continue;
  533. kaddr = page_address(page);
  534. de = (struct ufs_dir_entry *)kaddr;
  535. kaddr += ufs_last_byte(inode, i) - UFS_DIR_REC_LEN(1);
  536. while ((char *)de <= kaddr) {
  537. if (de->d_reclen == 0) {
  538. ufs_error(inode->i_sb, __func__,
  539. "zero-length directory entry: "
  540. "kaddr=%p, de=%p\n", kaddr, de);
  541. goto not_empty;
  542. }
  543. if (de->d_ino) {
  544. u16 namelen=ufs_get_de_namlen(sb, de);
  545. /* check for . and .. */
  546. if (de->d_name[0] != '.')
  547. goto not_empty;
  548. if (namelen > 2)
  549. goto not_empty;
  550. if (namelen < 2) {
  551. if (inode->i_ino !=
  552. fs32_to_cpu(sb, de->d_ino))
  553. goto not_empty;
  554. } else if (de->d_name[1] != '.')
  555. goto not_empty;
  556. }
  557. de = ufs_next_entry(sb, de);
  558. }
  559. ufs_put_page(page);
  560. }
  561. return 1;
  562. not_empty:
  563. ufs_put_page(page);
  564. return 0;
  565. }
  566. const struct file_operations ufs_dir_operations = {
  567. .read = generic_read_dir,
  568. .iterate_shared = ufs_readdir,
  569. .fsync = generic_file_fsync,
  570. .llseek = generic_file_llseek,
  571. };