Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/hfsplus/dir.c |
| 3 | * |
| 4 | * Copyright (C) 2001 |
| 5 | * Brad Boyer (flar@allandria.com) |
| 6 | * (C) 2003 Ardis Technologies <roman@ardistech.com> |
| 7 | * |
| 8 | * Handling of directories |
| 9 | */ |
| 10 | |
| 11 | #include <linux/errno.h> |
| 12 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/slab.h> |
| 14 | #include <linux/random.h> |
Hin-Tak Leung | 017f8da | 2014-06-06 14:36:21 -0700 | [diff] [blame] | 15 | #include <linux/nls.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | #include "hfsplus_fs.h" |
| 18 | #include "hfsplus_raw.h" |
Vyacheslav Dubeyko | 324ef39 | 2013-02-27 17:03:04 -0800 | [diff] [blame] | 19 | #include "xattr.h" |
Vyacheslav Dubeyko | b4c1107 | 2013-09-11 14:24:30 -0700 | [diff] [blame] | 20 | #include "acl.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | static inline void hfsplus_instantiate(struct dentry *dentry, |
| 23 | struct inode *inode, u32 cnid) |
| 24 | { |
| 25 | dentry->d_fsdata = (void *)(unsigned long)cnid; |
| 26 | d_instantiate(dentry, inode); |
| 27 | } |
| 28 | |
| 29 | /* Find the entry inside dir named dentry->d_name */ |
| 30 | static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry, |
Al Viro | 00cd8dd | 2012-06-10 17:13:09 -0400 | [diff] [blame] | 31 | unsigned int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { |
| 33 | struct inode *inode = NULL; |
| 34 | struct hfs_find_data fd; |
| 35 | struct super_block *sb; |
| 36 | hfsplus_cat_entry entry; |
| 37 | int err; |
| 38 | u32 cnid, linkid = 0; |
| 39 | u16 type; |
| 40 | |
| 41 | sb = dir->i_sb; |
Duane Griffin | d45bce8 | 2007-07-15 23:41:23 -0700 | [diff] [blame] | 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | dentry->d_fsdata = NULL; |
Alexey Khoroshilov | 5bd9d99 | 2011-07-06 02:29:59 +0400 | [diff] [blame] | 44 | err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); |
| 45 | if (err) |
| 46 | return ERR_PTR(err); |
Sougata Santra | 89ac9b4 | 2014-12-18 16:17:12 -0800 | [diff] [blame] | 47 | err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, |
| 48 | &dentry->d_name); |
| 49 | if (unlikely(err < 0)) |
| 50 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | again: |
| 52 | err = hfs_brec_read(&fd, &entry, sizeof(entry)); |
| 53 | if (err) { |
| 54 | if (err == -ENOENT) { |
| 55 | hfs_find_exit(&fd); |
| 56 | /* No such entry */ |
| 57 | inode = NULL; |
| 58 | goto out; |
| 59 | } |
| 60 | goto fail; |
| 61 | } |
| 62 | type = be16_to_cpu(entry.type); |
| 63 | if (type == HFSPLUS_FOLDER) { |
| 64 | if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) { |
| 65 | err = -EIO; |
| 66 | goto fail; |
| 67 | } |
| 68 | cnid = be32_to_cpu(entry.folder.id); |
| 69 | dentry->d_fsdata = (void *)(unsigned long)cnid; |
| 70 | } else if (type == HFSPLUS_FILE) { |
| 71 | if (fd.entrylength < sizeof(struct hfsplus_cat_file)) { |
| 72 | err = -EIO; |
| 73 | goto fail; |
| 74 | } |
| 75 | cnid = be32_to_cpu(entry.file.id); |
Anton Salikhmetov | 2753cc2 | 2010-12-16 18:08:38 +0200 | [diff] [blame] | 76 | if (entry.file.user_info.fdType == |
| 77 | cpu_to_be32(HFSP_HARDLINK_TYPE) && |
| 78 | entry.file.user_info.fdCreator == |
| 79 | cpu_to_be32(HFSP_HFSPLUS_CREATOR) && |
| 80 | (entry.file.create_date == |
| 81 | HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)-> |
| 82 | create_date || |
| 83 | entry.file.create_date == |
| 84 | HFSPLUS_I(sb->s_root->d_inode)-> |
| 85 | create_date) && |
| 86 | HFSPLUS_SB(sb)->hidden_dir) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct qstr str; |
| 88 | char name[32]; |
| 89 | |
| 90 | if (dentry->d_fsdata) { |
Roman Zippel | af8c85b | 2006-01-18 17:43:10 -0800 | [diff] [blame] | 91 | /* |
| 92 | * We found a link pointing to another link, |
| 93 | * so ignore it and treat it as regular file. |
| 94 | */ |
| 95 | cnid = (unsigned long)dentry->d_fsdata; |
| 96 | linkid = 0; |
| 97 | } else { |
| 98 | dentry->d_fsdata = (void *)(unsigned long)cnid; |
Anton Salikhmetov | 2753cc2 | 2010-12-16 18:08:38 +0200 | [diff] [blame] | 99 | linkid = |
| 100 | be32_to_cpu(entry.file.permissions.dev); |
Roman Zippel | af8c85b | 2006-01-18 17:43:10 -0800 | [diff] [blame] | 101 | str.len = sprintf(name, "iNode%d", linkid); |
| 102 | str.name = name; |
Sougata Santra | 89ac9b4 | 2014-12-18 16:17:12 -0800 | [diff] [blame] | 103 | err = hfsplus_cat_build_key(sb, fd.search_key, |
Anton Salikhmetov | 2753cc2 | 2010-12-16 18:08:38 +0200 | [diff] [blame] | 104 | HFSPLUS_SB(sb)->hidden_dir->i_ino, |
| 105 | &str); |
Sougata Santra | 89ac9b4 | 2014-12-18 16:17:12 -0800 | [diff] [blame] | 106 | if (unlikely(err < 0)) |
| 107 | goto fail; |
Roman Zippel | af8c85b | 2006-01-18 17:43:10 -0800 | [diff] [blame] | 108 | goto again; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } else if (!dentry->d_fsdata) |
| 111 | dentry->d_fsdata = (void *)(unsigned long)cnid; |
| 112 | } else { |
Joe Perches | d614267 | 2013-04-30 15:27:55 -0700 | [diff] [blame] | 113 | pr_err("invalid catalog entry type in lookup\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | err = -EIO; |
| 115 | goto fail; |
| 116 | } |
| 117 | hfs_find_exit(&fd); |
David Howells | 6352539 | 2008-02-07 00:15:40 -0800 | [diff] [blame] | 118 | inode = hfsplus_iget(dir->i_sb, cnid); |
| 119 | if (IS_ERR(inode)) |
| 120 | return ERR_CAST(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | if (S_ISREG(inode->i_mode)) |
Christoph Hellwig | f6089ff | 2010-10-14 09:54:28 -0400 | [diff] [blame] | 122 | HFSPLUS_I(inode)->linkid = linkid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | out: |
| 124 | d_add(dentry, inode); |
| 125 | return NULL; |
| 126 | fail: |
| 127 | hfs_find_exit(&fd); |
| 128 | return ERR_PTR(err); |
| 129 | } |
| 130 | |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 131 | static int hfsplus_readdir(struct file *file, struct dir_context *ctx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | { |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 133 | struct inode *inode = file_inode(file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | struct super_block *sb = inode->i_sb; |
| 135 | int len, err; |
Hin-Tak Leung | 017f8da | 2014-06-06 14:36:21 -0700 | [diff] [blame] | 136 | char *strbuf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | hfsplus_cat_entry entry; |
| 138 | struct hfs_find_data fd; |
| 139 | struct hfsplus_readdir_data *rd; |
| 140 | u16 type; |
| 141 | |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 142 | if (file->f_pos >= inode->i_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | return 0; |
| 144 | |
Alexey Khoroshilov | 5bd9d99 | 2011-07-06 02:29:59 +0400 | [diff] [blame] | 145 | err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); |
| 146 | if (err) |
| 147 | return err; |
Hin-Tak Leung | 017f8da | 2014-06-06 14:36:21 -0700 | [diff] [blame] | 148 | strbuf = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN + 1, GFP_KERNEL); |
| 149 | if (!strbuf) { |
| 150 | err = -ENOMEM; |
| 151 | goto out; |
| 152 | } |
Sougata Santra | 89ac9b4 | 2014-12-18 16:17:12 -0800 | [diff] [blame] | 153 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, inode->i_ino); |
Vyacheslav Dubeyko | 324ef39 | 2013-02-27 17:03:04 -0800 | [diff] [blame] | 154 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | if (err) |
| 156 | goto out; |
| 157 | |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 158 | if (ctx->pos == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | /* This is completely artificial... */ |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 160 | if (!dir_emit_dot(file, ctx)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | goto out; |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 162 | ctx->pos = 1; |
| 163 | } |
| 164 | if (ctx->pos == 1) { |
Greg Kroah-Hartman | 6f24f89 | 2012-05-04 12:09:39 -0700 | [diff] [blame] | 165 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { |
| 166 | err = -EIO; |
| 167 | goto out; |
| 168 | } |
| 169 | |
Anton Salikhmetov | 2753cc2 | 2010-12-16 18:08:38 +0200 | [diff] [blame] | 170 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
| 171 | fd.entrylength); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) { |
Joe Perches | d614267 | 2013-04-30 15:27:55 -0700 | [diff] [blame] | 173 | pr_err("bad catalog folder thread\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | err = -EIO; |
| 175 | goto out; |
| 176 | } |
| 177 | if (fd.entrylength < HFSPLUS_MIN_THREAD_SZ) { |
Joe Perches | d614267 | 2013-04-30 15:27:55 -0700 | [diff] [blame] | 178 | pr_err("truncated catalog thread\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | err = -EIO; |
| 180 | goto out; |
| 181 | } |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 182 | if (!dir_emit(ctx, "..", 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | be32_to_cpu(entry.thread.parentID), DT_DIR)) |
| 184 | goto out; |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 185 | ctx->pos = 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | } |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 187 | if (ctx->pos >= inode->i_size) |
| 188 | goto out; |
| 189 | err = hfs_brec_goto(&fd, ctx->pos - 1); |
| 190 | if (err) |
| 191 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | for (;;) { |
| 193 | if (be32_to_cpu(fd.key->cat.parent) != inode->i_ino) { |
Joe Perches | d614267 | 2013-04-30 15:27:55 -0700 | [diff] [blame] | 194 | pr_err("walked past end of dir\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | err = -EIO; |
| 196 | goto out; |
| 197 | } |
Greg Kroah-Hartman | 6f24f89 | 2012-05-04 12:09:39 -0700 | [diff] [blame] | 198 | |
| 199 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { |
| 200 | err = -EIO; |
| 201 | goto out; |
| 202 | } |
| 203 | |
Anton Salikhmetov | 2753cc2 | 2010-12-16 18:08:38 +0200 | [diff] [blame] | 204 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
| 205 | fd.entrylength); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | type = be16_to_cpu(entry.type); |
Hin-Tak Leung | 017f8da | 2014-06-06 14:36:21 -0700 | [diff] [blame] | 207 | len = NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | err = hfsplus_uni2asc(sb, &fd.key->cat.name, strbuf, &len); |
| 209 | if (err) |
| 210 | goto out; |
| 211 | if (type == HFSPLUS_FOLDER) { |
Anton Salikhmetov | 2753cc2 | 2010-12-16 18:08:38 +0200 | [diff] [blame] | 212 | if (fd.entrylength < |
| 213 | sizeof(struct hfsplus_cat_folder)) { |
Joe Perches | d614267 | 2013-04-30 15:27:55 -0700 | [diff] [blame] | 214 | pr_err("small dir entry\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | err = -EIO; |
| 216 | goto out; |
| 217 | } |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 218 | if (HFSPLUS_SB(sb)->hidden_dir && |
| 219 | HFSPLUS_SB(sb)->hidden_dir->i_ino == |
| 220 | be32_to_cpu(entry.folder.id)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | goto next; |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 222 | if (!dir_emit(ctx, strbuf, len, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | be32_to_cpu(entry.folder.id), DT_DIR)) |
| 224 | break; |
| 225 | } else if (type == HFSPLUS_FILE) { |
Sergei Antonov | 97a62ea | 2014-06-06 14:36:24 -0700 | [diff] [blame] | 226 | u16 mode; |
| 227 | unsigned type = DT_UNKNOWN; |
| 228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | if (fd.entrylength < sizeof(struct hfsplus_cat_file)) { |
Joe Perches | d614267 | 2013-04-30 15:27:55 -0700 | [diff] [blame] | 230 | pr_err("small file entry\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | err = -EIO; |
| 232 | goto out; |
| 233 | } |
Sergei Antonov | 97a62ea | 2014-06-06 14:36:24 -0700 | [diff] [blame] | 234 | |
| 235 | mode = be16_to_cpu(entry.file.permissions.mode); |
| 236 | if (S_ISREG(mode)) |
| 237 | type = DT_REG; |
| 238 | else if (S_ISLNK(mode)) |
| 239 | type = DT_LNK; |
| 240 | else if (S_ISFIFO(mode)) |
| 241 | type = DT_FIFO; |
| 242 | else if (S_ISCHR(mode)) |
| 243 | type = DT_CHR; |
| 244 | else if (S_ISBLK(mode)) |
| 245 | type = DT_BLK; |
| 246 | else if (S_ISSOCK(mode)) |
| 247 | type = DT_SOCK; |
| 248 | |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 249 | if (!dir_emit(ctx, strbuf, len, |
Sergei Antonov | 97a62ea | 2014-06-06 14:36:24 -0700 | [diff] [blame] | 250 | be32_to_cpu(entry.file.id), type)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | break; |
| 252 | } else { |
Joe Perches | d614267 | 2013-04-30 15:27:55 -0700 | [diff] [blame] | 253 | pr_err("bad catalog entry type\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | err = -EIO; |
| 255 | goto out; |
| 256 | } |
Anton Salikhmetov | 20b7643 | 2010-12-16 18:08:40 +0200 | [diff] [blame] | 257 | next: |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 258 | ctx->pos++; |
| 259 | if (ctx->pos >= inode->i_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | goto out; |
| 261 | err = hfs_brec_goto(&fd, 1); |
| 262 | if (err) |
| 263 | goto out; |
| 264 | } |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 265 | rd = file->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | if (!rd) { |
| 267 | rd = kmalloc(sizeof(struct hfsplus_readdir_data), GFP_KERNEL); |
| 268 | if (!rd) { |
| 269 | err = -ENOMEM; |
| 270 | goto out; |
| 271 | } |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 272 | file->private_data = rd; |
| 273 | rd->file = file; |
Christoph Hellwig | 6af502d | 2010-10-01 05:43:31 +0200 | [diff] [blame] | 274 | list_add(&rd->list, &HFSPLUS_I(inode)->open_dir_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
| 276 | memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key)); |
| 277 | out: |
Hin-Tak Leung | 017f8da | 2014-06-06 14:36:21 -0700 | [diff] [blame] | 278 | kfree(strbuf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | hfs_find_exit(&fd); |
| 280 | return err; |
| 281 | } |
| 282 | |
| 283 | static int hfsplus_dir_release(struct inode *inode, struct file *file) |
| 284 | { |
| 285 | struct hfsplus_readdir_data *rd = file->private_data; |
| 286 | if (rd) { |
Christoph Hellwig | 89755dc | 2010-10-01 05:45:25 +0200 | [diff] [blame] | 287 | mutex_lock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | list_del(&rd->list); |
Christoph Hellwig | 89755dc | 2010-10-01 05:45:25 +0200 | [diff] [blame] | 289 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | kfree(rd); |
| 291 | } |
| 292 | return 0; |
| 293 | } |
| 294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir, |
| 296 | struct dentry *dst_dentry) |
| 297 | { |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 298 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(dst_dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | struct inode *inode = src_dentry->d_inode; |
| 300 | struct inode *src_dir = src_dentry->d_parent->d_inode; |
| 301 | struct qstr str; |
| 302 | char name[32]; |
| 303 | u32 cnid, id; |
| 304 | int res; |
| 305 | |
| 306 | if (HFSPLUS_IS_RSRC(inode)) |
| 307 | return -EPERM; |
Christoph Hellwig | f6089ff | 2010-10-14 09:54:28 -0400 | [diff] [blame] | 308 | if (!S_ISREG(inode->i_mode)) |
| 309 | return -EPERM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 311 | mutex_lock(&sbi->vh_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | if (inode->i_ino == (u32)(unsigned long)src_dentry->d_fsdata) { |
| 313 | for (;;) { |
| 314 | get_random_bytes(&id, sizeof(cnid)); |
| 315 | id &= 0x3fffffff; |
| 316 | str.name = name; |
| 317 | str.len = sprintf(name, "iNode%d", id); |
| 318 | res = hfsplus_rename_cat(inode->i_ino, |
| 319 | src_dir, &src_dentry->d_name, |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 320 | sbi->hidden_dir, &str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | if (!res) |
| 322 | break; |
| 323 | if (res != -EEXIST) |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 324 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
Christoph Hellwig | f6089ff | 2010-10-14 09:54:28 -0400 | [diff] [blame] | 326 | HFSPLUS_I(inode)->linkid = id; |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 327 | cnid = sbi->next_cnid++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | src_dentry->d_fsdata = (void *)(unsigned long)cnid; |
Anton Salikhmetov | 2753cc2 | 2010-12-16 18:08:38 +0200 | [diff] [blame] | 329 | res = hfsplus_create_cat(cnid, src_dir, |
| 330 | &src_dentry->d_name, inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | if (res) |
| 332 | /* panic? */ |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 333 | goto out; |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 334 | sbi->file_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | } |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 336 | cnid = sbi->next_cnid++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | res = hfsplus_create_cat(cnid, dst_dir, &dst_dentry->d_name, inode); |
| 338 | if (res) |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 339 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
Dave Hansen | d8c76e6 | 2006-09-30 23:29:04 -0700 | [diff] [blame] | 341 | inc_nlink(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | hfsplus_instantiate(dst_dentry, inode, cnid); |
Al Viro | 7de9c6ee | 2010-10-23 11:11:40 -0400 | [diff] [blame] | 343 | ihold(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | inode->i_ctime = CURRENT_TIME_SEC; |
| 345 | mark_inode_dirty(inode); |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 346 | sbi->file_count++; |
Artem Bityutskiy | 9e6c582 | 2012-07-12 17:26:31 +0300 | [diff] [blame] | 347 | hfsplus_mark_mdb_dirty(dst_dir->i_sb); |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 348 | out: |
| 349 | mutex_unlock(&sbi->vh_mutex); |
| 350 | return res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | static int hfsplus_unlink(struct inode *dir, struct dentry *dentry) |
| 354 | { |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 355 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | struct inode *inode = dentry->d_inode; |
| 357 | struct qstr str; |
| 358 | char name[32]; |
| 359 | u32 cnid; |
| 360 | int res; |
| 361 | |
| 362 | if (HFSPLUS_IS_RSRC(inode)) |
| 363 | return -EPERM; |
| 364 | |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 365 | mutex_lock(&sbi->vh_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | cnid = (u32)(unsigned long)dentry->d_fsdata; |
| 367 | if (inode->i_ino == cnid && |
Christoph Hellwig | 6af502d | 2010-10-01 05:43:31 +0200 | [diff] [blame] | 368 | atomic_read(&HFSPLUS_I(inode)->opencnt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | str.name = name; |
| 370 | str.len = sprintf(name, "temp%lu", inode->i_ino); |
| 371 | res = hfsplus_rename_cat(inode->i_ino, |
| 372 | dir, &dentry->d_name, |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 373 | sbi->hidden_dir, &str); |
Christoph Hellwig | 85b8fe8 | 2010-10-27 13:45:50 +0200 | [diff] [blame] | 374 | if (!res) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | inode->i_flags |= S_DEAD; |
Christoph Hellwig | 85b8fe8 | 2010-10-27 13:45:50 +0200 | [diff] [blame] | 376 | drop_nlink(inode); |
| 377 | } |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 378 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | } |
| 380 | res = hfsplus_delete_cat(cnid, dir, &dentry->d_name); |
| 381 | if (res) |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 382 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
Roman Zippel | af8c85b | 2006-01-18 17:43:10 -0800 | [diff] [blame] | 384 | if (inode->i_nlink > 0) |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 385 | drop_nlink(inode); |
Roman Zippel | 76b0c26 | 2008-04-09 17:44:07 +0200 | [diff] [blame] | 386 | if (inode->i_ino == cnid) |
Dave Hansen | ce71ec3 | 2006-09-30 23:29:06 -0700 | [diff] [blame] | 387 | clear_nlink(inode); |
Roman Zippel | 76b0c26 | 2008-04-09 17:44:07 +0200 | [diff] [blame] | 388 | if (!inode->i_nlink) { |
| 389 | if (inode->i_ino != cnid) { |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 390 | sbi->file_count--; |
Christoph Hellwig | 6af502d | 2010-10-01 05:43:31 +0200 | [diff] [blame] | 391 | if (!atomic_read(&HFSPLUS_I(inode)->opencnt)) { |
Roman Zippel | 76b0c26 | 2008-04-09 17:44:07 +0200 | [diff] [blame] | 392 | res = hfsplus_delete_cat(inode->i_ino, |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 393 | sbi->hidden_dir, |
Roman Zippel | 76b0c26 | 2008-04-09 17:44:07 +0200 | [diff] [blame] | 394 | NULL); |
| 395 | if (!res) |
| 396 | hfsplus_delete_inode(inode); |
| 397 | } else |
| 398 | inode->i_flags |= S_DEAD; |
| 399 | } else |
| 400 | hfsplus_delete_inode(inode); |
| 401 | } else |
Christoph Hellwig | dd73a01 | 2010-10-01 05:42:59 +0200 | [diff] [blame] | 402 | sbi->file_count--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | inode->i_ctime = CURRENT_TIME_SEC; |
| 404 | mark_inode_dirty(inode); |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 405 | out: |
| 406 | mutex_unlock(&sbi->vh_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | return res; |
| 408 | } |
| 409 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry) |
| 411 | { |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 412 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); |
| 413 | struct inode *inode = dentry->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | int res; |
| 415 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | if (inode->i_size != 2) |
| 417 | return -ENOTEMPTY; |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 418 | |
| 419 | mutex_lock(&sbi->vh_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | res = hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name); |
| 421 | if (res) |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 422 | goto out; |
Dave Hansen | ce71ec3 | 2006-09-30 23:29:06 -0700 | [diff] [blame] | 423 | clear_nlink(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | inode->i_ctime = CURRENT_TIME_SEC; |
| 425 | hfsplus_delete_inode(inode); |
| 426 | mark_inode_dirty(inode); |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 427 | out: |
| 428 | mutex_unlock(&sbi->vh_mutex); |
| 429 | return res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | static int hfsplus_symlink(struct inode *dir, struct dentry *dentry, |
| 433 | const char *symname) |
| 434 | { |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 435 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | struct inode *inode; |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 437 | int res = -ENOSPC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 439 | mutex_lock(&sbi->vh_mutex); |
Christoph Hellwig | f17c89b | 2010-10-01 05:43:54 +0200 | [diff] [blame] | 440 | inode = hfsplus_new_inode(dir->i_sb, S_IFLNK | S_IRWXUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | if (!inode) |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 442 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | |
| 444 | res = page_symlink(inode, symname, strlen(symname) + 1); |
Christoph Hellwig | f17c89b | 2010-10-01 05:43:54 +0200 | [diff] [blame] | 445 | if (res) |
| 446 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode); |
Christoph Hellwig | f17c89b | 2010-10-01 05:43:54 +0200 | [diff] [blame] | 449 | if (res) |
| 450 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | |
Vyacheslav Dubeyko | 324ef39 | 2013-02-27 17:03:04 -0800 | [diff] [blame] | 452 | res = hfsplus_init_inode_security(inode, dir, &dentry->d_name); |
| 453 | if (res == -EOPNOTSUPP) |
| 454 | res = 0; /* Operation is not supported. */ |
| 455 | else if (res) { |
| 456 | /* Try to delete anyway without error analysis. */ |
| 457 | hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name); |
| 458 | goto out_err; |
| 459 | } |
| 460 | |
Christoph Hellwig | f17c89b | 2010-10-01 05:43:54 +0200 | [diff] [blame] | 461 | hfsplus_instantiate(dentry, inode, inode->i_ino); |
| 462 | mark_inode_dirty(inode); |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 463 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | |
Christoph Hellwig | f17c89b | 2010-10-01 05:43:54 +0200 | [diff] [blame] | 465 | out_err: |
Miklos Szeredi | 6d6b77f | 2011-10-28 14:13:28 +0200 | [diff] [blame] | 466 | clear_nlink(inode); |
Christoph Hellwig | f17c89b | 2010-10-01 05:43:54 +0200 | [diff] [blame] | 467 | hfsplus_delete_inode(inode); |
| 468 | iput(inode); |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 469 | out: |
| 470 | mutex_unlock(&sbi->vh_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | return res; |
| 472 | } |
| 473 | |
| 474 | static int hfsplus_mknod(struct inode *dir, struct dentry *dentry, |
Al Viro | 1a67aaf | 2011-07-26 01:52:52 -0400 | [diff] [blame] | 475 | umode_t mode, dev_t rdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | { |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 477 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | struct inode *inode; |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 479 | int res = -ENOSPC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 481 | mutex_lock(&sbi->vh_mutex); |
Christoph Hellwig | 30d3abb | 2010-10-01 05:43:50 +0200 | [diff] [blame] | 482 | inode = hfsplus_new_inode(dir->i_sb, mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | if (!inode) |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 484 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | |
Christoph Hellwig | 90e6169 | 2010-10-14 09:54:39 -0400 | [diff] [blame] | 486 | if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) |
| 487 | init_special_inode(inode, mode, rdev); |
| 488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode); |
Vyacheslav Dubeyko | 324ef39 | 2013-02-27 17:03:04 -0800 | [diff] [blame] | 490 | if (res) |
| 491 | goto failed_mknod; |
| 492 | |
| 493 | res = hfsplus_init_inode_security(inode, dir, &dentry->d_name); |
| 494 | if (res == -EOPNOTSUPP) |
| 495 | res = 0; /* Operation is not supported. */ |
| 496 | else if (res) { |
| 497 | /* Try to delete anyway without error analysis. */ |
| 498 | hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name); |
| 499 | goto failed_mknod; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | } |
Christoph Hellwig | 30d3abb | 2010-10-01 05:43:50 +0200 | [diff] [blame] | 501 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | hfsplus_instantiate(dentry, inode, inode->i_ino); |
| 503 | mark_inode_dirty(inode); |
Vyacheslav Dubeyko | 324ef39 | 2013-02-27 17:03:04 -0800 | [diff] [blame] | 504 | goto out; |
| 505 | |
| 506 | failed_mknod: |
| 507 | clear_nlink(inode); |
| 508 | hfsplus_delete_inode(inode); |
| 509 | iput(inode); |
Christoph Hellwig | 7ac9fb9 | 2010-10-01 05:45:08 +0200 | [diff] [blame] | 510 | out: |
| 511 | mutex_unlock(&sbi->vh_mutex); |
| 512 | return res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | } |
| 514 | |
Al Viro | 4acdaf2 | 2011-07-26 01:42:34 -0400 | [diff] [blame] | 515 | static int hfsplus_create(struct inode *dir, struct dentry *dentry, umode_t mode, |
Al Viro | ebfc3b4 | 2012-06-10 18:05:36 -0400 | [diff] [blame] | 516 | bool excl) |
Christoph Hellwig | 30d3abb | 2010-10-01 05:43:50 +0200 | [diff] [blame] | 517 | { |
| 518 | return hfsplus_mknod(dir, dentry, mode, 0); |
| 519 | } |
| 520 | |
Al Viro | 18bb1db | 2011-07-26 01:41:39 -0400 | [diff] [blame] | 521 | static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) |
Christoph Hellwig | 30d3abb | 2010-10-01 05:43:50 +0200 | [diff] [blame] | 522 | { |
| 523 | return hfsplus_mknod(dir, dentry, mode | S_IFDIR, 0); |
| 524 | } |
| 525 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 527 | struct inode *new_dir, struct dentry *new_dentry) |
| 528 | { |
| 529 | int res; |
| 530 | |
| 531 | /* Unlink destination if it already exists */ |
| 532 | if (new_dentry->d_inode) { |
David Howells | e36cb0b | 2015-01-29 12:02:35 +0000 | [diff] [blame] | 533 | if (d_is_dir(new_dentry)) |
Christoph Hellwig | 40de9a7 | 2010-10-01 09:12:08 +0200 | [diff] [blame] | 534 | res = hfsplus_rmdir(new_dir, new_dentry); |
Sage Weil | e391178 | 2011-05-27 13:42:06 -0700 | [diff] [blame] | 535 | else |
Christoph Hellwig | 40de9a7 | 2010-10-01 09:12:08 +0200 | [diff] [blame] | 536 | res = hfsplus_unlink(new_dir, new_dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | if (res) |
| 538 | return res; |
| 539 | } |
| 540 | |
| 541 | res = hfsplus_rename_cat((u32)(unsigned long)old_dentry->d_fsdata, |
| 542 | old_dir, &old_dentry->d_name, |
| 543 | new_dir, &new_dentry->d_name); |
| 544 | if (!res) |
| 545 | new_dentry->d_fsdata = old_dentry->d_fsdata; |
| 546 | return res; |
| 547 | } |
| 548 | |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 549 | const struct inode_operations hfsplus_dir_inode_operations = { |
Vyacheslav Dubeyko | 324ef39 | 2013-02-27 17:03:04 -0800 | [diff] [blame] | 550 | .lookup = hfsplus_lookup, |
| 551 | .create = hfsplus_create, |
| 552 | .link = hfsplus_link, |
| 553 | .unlink = hfsplus_unlink, |
| 554 | .mkdir = hfsplus_mkdir, |
| 555 | .rmdir = hfsplus_rmdir, |
| 556 | .symlink = hfsplus_symlink, |
| 557 | .mknod = hfsplus_mknod, |
| 558 | .rename = hfsplus_rename, |
| 559 | .setxattr = generic_setxattr, |
| 560 | .getxattr = generic_getxattr, |
| 561 | .listxattr = hfsplus_listxattr, |
Christoph Hellwig | b168fff | 2014-01-29 23:59:19 -0800 | [diff] [blame] | 562 | .removexattr = generic_removexattr, |
Vyacheslav Dubeyko | b4c1107 | 2013-09-11 14:24:30 -0700 | [diff] [blame] | 563 | #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL |
| 564 | .get_acl = hfsplus_get_posix_acl, |
Christoph Hellwig | b0a7ab5 | 2013-12-20 05:16:46 -0800 | [diff] [blame] | 565 | .set_acl = hfsplus_set_posix_acl, |
Vyacheslav Dubeyko | b4c1107 | 2013-09-11 14:24:30 -0700 | [diff] [blame] | 566 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | }; |
| 568 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 569 | const struct file_operations hfsplus_dir_operations = { |
Christoph Hellwig | eb29d66 | 2010-11-23 14:38:10 +0100 | [diff] [blame] | 570 | .fsync = hfsplus_file_fsync, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | .read = generic_read_dir, |
Al Viro | e72514e | 2013-05-22 14:59:39 -0400 | [diff] [blame] | 572 | .iterate = hfsplus_readdir, |
Arnd Bergmann | 7cc4bcc | 2010-04-27 16:24:20 +0200 | [diff] [blame] | 573 | .unlocked_ioctl = hfsplus_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | .llseek = generic_file_llseek, |
| 575 | .release = hfsplus_dir_release, |
| 576 | }; |