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