^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * dir.c - NILFS directory entry operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Modified for NILFS by Amagai Yoshiji.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * linux/fs/ext2/dir.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Copyright (C) 1992, 1993, 1994, 1995
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Remy Card (card@masi.ibp.fr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Laboratoire MASI - Institut Blaise Pascal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Universite Pierre et Marie Curie (Paris VI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * linux/fs/minix/dir.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Copyright (C) 1991, 1992 Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * ext2 directory handling functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * Big-endian to little-endian byte-swapping/bitmaps by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * David S. Miller (davem@caip.rutgers.edu), 1995
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * All code that works with directory layout had been switched to pagecache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * and moved here. AV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include "nilfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include "page.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static inline unsigned int nilfs_rec_len_from_disk(__le16 dlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned int len = le16_to_cpu(dlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #if (PAGE_SIZE >= 65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (len == NILFS_MAX_REC_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return 1 << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static inline __le16 nilfs_rec_len_to_disk(unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #if (PAGE_SIZE >= 65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) if (len == (1 << 16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return cpu_to_le16(NILFS_MAX_REC_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) BUG_ON(len > (1 << 16));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return cpu_to_le16(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * nilfs uses block-sized chunks. Arguably, sector-sized ones would be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * more robust, but we have what we have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline unsigned int nilfs_chunk_size(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return inode->i_sb->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline void nilfs_put_page(struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) kunmap(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * Return the offset into page `page_nr' of the last valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * byte in that page, plus one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static unsigned int nilfs_last_byte(struct inode *inode, unsigned long page_nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) unsigned int last_byte = inode->i_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) last_byte -= page_nr << PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (last_byte > PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) last_byte = PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return last_byte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static int nilfs_prepare_chunk(struct page *page, unsigned int from,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) unsigned int to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) loff_t pos = page_offset(page) + from;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return __block_write_begin(page, pos, to - from, nilfs_get_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static void nilfs_commit_chunk(struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) unsigned int from, unsigned int to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct inode *dir = mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) loff_t pos = page_offset(page) + from;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) unsigned int len = to - from;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) unsigned int nr_dirty, copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) nr_dirty = nilfs_page_count_clean_buffers(page, from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) copied = block_write_end(NULL, mapping, pos, len, len, page, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) if (pos + copied > dir->i_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) i_size_write(dir, pos + copied);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (IS_DIRSYNC(dir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) nilfs_set_transaction_flag(NILFS_TI_SYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) err = nilfs_set_file_dirty(dir, nr_dirty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) WARN_ON(err); /* do not happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) unlock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static bool nilfs_check_page(struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct inode *dir = page->mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct super_block *sb = dir->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) unsigned int chunk_size = nilfs_chunk_size(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) char *kaddr = page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned int offs, rec_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) unsigned int limit = PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct nilfs_dir_entry *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) char *error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if ((dir->i_size >> PAGE_SHIFT) == page->index) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) limit = dir->i_size & ~PAGE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (limit & (chunk_size - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) goto Ebadsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (!limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) for (offs = 0; offs <= limit - NILFS_DIR_REC_LEN(1); offs += rec_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) p = (struct nilfs_dir_entry *)(kaddr + offs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) rec_len = nilfs_rec_len_from_disk(p->rec_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (rec_len < NILFS_DIR_REC_LEN(1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) goto Eshort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (rec_len & 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) goto Ealign;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (rec_len < NILFS_DIR_REC_LEN(p->name_len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) goto Enamelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) goto Espan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (offs != limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) goto Eend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) SetPageChecked(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* Too bad, we had an error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) Ebadsize:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) nilfs_error(sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) "size of directory #%lu is not a multiple of chunk size",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) dir->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) Eshort:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) error = "rec_len is smaller than minimal";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) goto bad_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) Ealign:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) error = "unaligned directory entry";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) goto bad_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) Enamelen:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) error = "rec_len is too small for name_len";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) goto bad_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) Espan:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) error = "directory entry across blocks";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) bad_entry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) nilfs_error(sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) "bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) dir->i_ino, error, (page->index << PAGE_SHIFT) + offs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) (unsigned long)le64_to_cpu(p->inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) rec_len, p->name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) Eend:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) p = (struct nilfs_dir_entry *)(kaddr + offs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) nilfs_error(sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) "entry in directory #%lu spans the page boundary offset=%lu, inode=%lu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) dir->i_ino, (page->index << PAGE_SHIFT) + offs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) (unsigned long)le64_to_cpu(p->inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) SetPageError(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static struct page *nilfs_get_page(struct inode *dir, unsigned long n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct address_space *mapping = dir->i_mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct page *page = read_mapping_page(mapping, n, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (!IS_ERR(page)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) kmap(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (unlikely(!PageChecked(page))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (PageError(page) || !nilfs_check_page(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return ERR_PTR(-EIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * NOTE! unlike strncmp, nilfs_match returns 1 for success, 0 for failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * len <= NILFS_NAME_LEN and de != NULL are guaranteed by caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) nilfs_match(int len, const unsigned char *name, struct nilfs_dir_entry *de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (len != de->name_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (!de->inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return !memcmp(name, de->name, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * p is at least 6 bytes before the end of page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static struct nilfs_dir_entry *nilfs_next_entry(struct nilfs_dir_entry *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return (struct nilfs_dir_entry *)((char *)p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) nilfs_rec_len_from_disk(p->rec_len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) nilfs_filetype_table[NILFS_FT_MAX] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) [NILFS_FT_UNKNOWN] = DT_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) [NILFS_FT_REG_FILE] = DT_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) [NILFS_FT_DIR] = DT_DIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) [NILFS_FT_CHRDEV] = DT_CHR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) [NILFS_FT_BLKDEV] = DT_BLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) [NILFS_FT_FIFO] = DT_FIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) [NILFS_FT_SOCK] = DT_SOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) [NILFS_FT_SYMLINK] = DT_LNK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #define S_SHIFT 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) nilfs_type_by_mode[S_IFMT >> S_SHIFT] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) [S_IFREG >> S_SHIFT] = NILFS_FT_REG_FILE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) [S_IFDIR >> S_SHIFT] = NILFS_FT_DIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) [S_IFCHR >> S_SHIFT] = NILFS_FT_CHRDEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) [S_IFBLK >> S_SHIFT] = NILFS_FT_BLKDEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) [S_IFIFO >> S_SHIFT] = NILFS_FT_FIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) [S_IFSOCK >> S_SHIFT] = NILFS_FT_SOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) [S_IFLNK >> S_SHIFT] = NILFS_FT_SYMLINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static void nilfs_set_de_type(struct nilfs_dir_entry *de, struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) umode_t mode = inode->i_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static int nilfs_readdir(struct file *file, struct dir_context *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) loff_t pos = ctx->pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) unsigned int offset = pos & ~PAGE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) unsigned long n = pos >> PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) unsigned long npages = dir_pages(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (pos > inode->i_size - NILFS_DIR_REC_LEN(1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) for ( ; n < npages; n++, offset = 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) char *kaddr, *limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct nilfs_dir_entry *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct page *page = nilfs_get_page(inode, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (IS_ERR(page)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) nilfs_error(sb, "bad page in #%lu", inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) ctx->pos += PAGE_SIZE - offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) kaddr = page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) de = (struct nilfs_dir_entry *)(kaddr + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) limit = kaddr + nilfs_last_byte(inode, n) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) NILFS_DIR_REC_LEN(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) for ( ; (char *)de <= limit; de = nilfs_next_entry(de)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) if (de->rec_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) nilfs_error(sb, "zero-length directory entry");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (de->inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) unsigned char t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) if (de->file_type < NILFS_FT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) t = nilfs_filetype_table[de->file_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) t = DT_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (!dir_emit(ctx, de->name, de->name_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) le64_to_cpu(de->inode), t)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) ctx->pos += nilfs_rec_len_from_disk(de->rec_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * nilfs_find_entry()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * finds an entry in the specified directory with the wanted name. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * returns the page in which the entry was found, and the entry itself
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * (as a parameter - res_dir). Page is returned mapped and unlocked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * Entry is guaranteed to be valid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) struct nilfs_dir_entry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) nilfs_find_entry(struct inode *dir, const struct qstr *qstr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) struct page **res_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) const unsigned char *name = qstr->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) int namelen = qstr->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) unsigned int reclen = NILFS_DIR_REC_LEN(namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) unsigned long start, n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) unsigned long npages = dir_pages(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) struct page *page = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) struct nilfs_inode_info *ei = NILFS_I(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct nilfs_dir_entry *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) if (npages == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) /* OFFSET_CACHE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) *res_page = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) start = ei->i_dir_start_lookup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) if (start >= npages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) n = start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) char *kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) page = nilfs_get_page(dir, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (!IS_ERR(page)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) kaddr = page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) de = (struct nilfs_dir_entry *)kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) kaddr += nilfs_last_byte(dir, n) - reclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) while ((char *) de <= kaddr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) if (de->rec_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) nilfs_error(dir->i_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) "zero-length directory entry");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) if (nilfs_match(namelen, name, de))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) goto found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) de = nilfs_next_entry(de);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if (++n >= npages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) n = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) /* next page is past the blocks we've got */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) nilfs_error(dir->i_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) "dir %lu size %lld exceeds block count %llu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) dir->i_ino, dir->i_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) (unsigned long long)dir->i_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) } while (n != start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) *res_page = page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) ei->i_dir_start_lookup = n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) return de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct page *page = nilfs_get_page(dir, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) struct nilfs_dir_entry *de = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) if (!IS_ERR(page)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) de = nilfs_next_entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) (struct nilfs_dir_entry *)page_address(page));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) *p = page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) ino_t res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) struct nilfs_dir_entry *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) struct page *page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) de = nilfs_find_entry(dir, qstr, &page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) if (de) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) res = le64_to_cpu(de->inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) kunmap(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /* Releases the page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) struct page *page, struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) unsigned int from = (char *)de - (char *)page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) unsigned int to = from + nilfs_rec_len_from_disk(de->rec_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) struct address_space *mapping = page->mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) lock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) err = nilfs_prepare_chunk(page, from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) BUG_ON(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) de->inode = cpu_to_le64(inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) nilfs_set_de_type(de, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) nilfs_commit_chunk(page, mapping, from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) dir->i_mtime = dir->i_ctime = current_time(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) * Parent is locked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) int nilfs_add_link(struct dentry *dentry, struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) struct inode *dir = d_inode(dentry->d_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) const unsigned char *name = dentry->d_name.name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) int namelen = dentry->d_name.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) unsigned int chunk_size = nilfs_chunk_size(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) unsigned int reclen = NILFS_DIR_REC_LEN(namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) unsigned short rec_len, name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) struct page *page = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) struct nilfs_dir_entry *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) unsigned long npages = dir_pages(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) unsigned long n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) char *kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) unsigned int from, to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * We take care of directory expansion in the same loop.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * This code plays outside i_size, so it locks the page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * to protect that region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) for (n = 0; n <= npages; n++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) char *dir_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) page = nilfs_get_page(dir, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) err = PTR_ERR(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) if (IS_ERR(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) lock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) kaddr = page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) dir_end = kaddr + nilfs_last_byte(dir, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) de = (struct nilfs_dir_entry *)kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) kaddr += PAGE_SIZE - reclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) while ((char *)de <= kaddr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) if ((char *)de == dir_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) /* We hit i_size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) name_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) rec_len = chunk_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) de->rec_len = nilfs_rec_len_to_disk(chunk_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) de->inode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) goto got_it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) if (de->rec_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) nilfs_error(dir->i_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) "zero-length directory entry");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) err = -EEXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (nilfs_match(namelen, name, de))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) name_len = NILFS_DIR_REC_LEN(de->name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) rec_len = nilfs_rec_len_from_disk(de->rec_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) if (!de->inode && rec_len >= reclen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) goto got_it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) if (rec_len >= name_len + reclen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) goto got_it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) de = (struct nilfs_dir_entry *)((char *)de + rec_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) unlock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) got_it:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) from = (char *)de - (char *)page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) to = from + rec_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) err = nilfs_prepare_chunk(page, from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if (de->inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct nilfs_dir_entry *de1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) de1 = (struct nilfs_dir_entry *)((char *)de + name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) de1->rec_len = nilfs_rec_len_to_disk(rec_len - name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) de->rec_len = nilfs_rec_len_to_disk(name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) de = de1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) de->name_len = namelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) memcpy(de->name, name, namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) de->inode = cpu_to_le64(inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) nilfs_set_de_type(de, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) nilfs_commit_chunk(page, page->mapping, from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) dir->i_mtime = dir->i_ctime = current_time(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) nilfs_mark_inode_dirty(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) /* OFFSET_CACHE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) out_put:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) unlock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) goto out_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * nilfs_delete_entry deletes a directory entry by merging it with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * previous entry. Page is up-to-date. Releases the page.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) struct address_space *mapping = page->mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) struct inode *inode = mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) char *kaddr = page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) unsigned int from, to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) struct nilfs_dir_entry *de, *pde = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) from = ((char *)dir - kaddr) & ~(nilfs_chunk_size(inode) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) to = ((char *)dir - kaddr) + nilfs_rec_len_from_disk(dir->rec_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) de = (struct nilfs_dir_entry *)(kaddr + from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) while ((char *)de < (char *)dir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) if (de->rec_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) nilfs_error(inode->i_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) "zero-length directory entry");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) pde = de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) de = nilfs_next_entry(de);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) if (pde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) from = (char *)pde - (char *)page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) lock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) err = nilfs_prepare_chunk(page, from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) BUG_ON(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) if (pde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) pde->rec_len = nilfs_rec_len_to_disk(to - from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) dir->inode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) nilfs_commit_chunk(page, mapping, from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) inode->i_ctime = inode->i_mtime = current_time(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * Set the first fragment of directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) int nilfs_make_empty(struct inode *inode, struct inode *parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) struct address_space *mapping = inode->i_mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct page *page = grab_cache_page(mapping, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) unsigned int chunk_size = nilfs_chunk_size(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) struct nilfs_dir_entry *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) void *kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) if (!page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) err = nilfs_prepare_chunk(page, 0, chunk_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) if (unlikely(err)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) unlock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) kaddr = kmap_atomic(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) memset(kaddr, 0, chunk_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) de = (struct nilfs_dir_entry *)kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) de->name_len = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) de->rec_len = nilfs_rec_len_to_disk(NILFS_DIR_REC_LEN(1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) memcpy(de->name, ".\0\0", 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) de->inode = cpu_to_le64(inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) nilfs_set_de_type(de, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) de = (struct nilfs_dir_entry *)(kaddr + NILFS_DIR_REC_LEN(1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) de->name_len = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) de->rec_len = nilfs_rec_len_to_disk(chunk_size - NILFS_DIR_REC_LEN(1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) de->inode = cpu_to_le64(parent->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) memcpy(de->name, "..\0", 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) nilfs_set_de_type(de, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) kunmap_atomic(kaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) nilfs_commit_chunk(page, mapping, 0, chunk_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * routine to check that the specified directory is empty (for rmdir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) int nilfs_empty_dir(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) struct page *page = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) unsigned long i, npages = dir_pages(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) for (i = 0; i < npages; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) char *kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) struct nilfs_dir_entry *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) page = nilfs_get_page(inode, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) if (IS_ERR(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) kaddr = page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) de = (struct nilfs_dir_entry *)kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) kaddr += nilfs_last_byte(inode, i) - NILFS_DIR_REC_LEN(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) while ((char *)de <= kaddr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if (de->rec_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) nilfs_error(inode->i_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) "zero-length directory entry (kaddr=%p, de=%p)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) kaddr, de);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) goto not_empty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) if (de->inode != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) /* check for . and .. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) if (de->name[0] != '.')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) goto not_empty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) if (de->name_len > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) goto not_empty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) if (de->name_len < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) if (de->inode !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) cpu_to_le64(inode->i_ino))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) goto not_empty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) } else if (de->name[1] != '.')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) goto not_empty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) de = nilfs_next_entry(de);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) not_empty:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) nilfs_put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) const struct file_operations nilfs_dir_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) .llseek = generic_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) .read = generic_read_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) .iterate_shared = nilfs_readdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) .unlocked_ioctl = nilfs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) .compat_ioctl = nilfs_compat_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) #endif /* CONFIG_COMPAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) .fsync = nilfs_sync_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) };