aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/catalog.c
diff options
context:
space:
mode:
authorVyacheslav Dubeyko <slava@dubeyko.com>2013-02-27 20:03:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:10 -0500
commit324ef39a8a4f693035d63527f16100ed27310ecc (patch)
tree1814515cf6139fe1b4ebae8d6641c9ec6293d396 /fs/hfsplus/catalog.c
parent127e5f5ae51eff44c9bff673f24e8587caa4e29f (diff)
hfsplus: add support of manipulation by attributes file
Add support of manipulation by attributes file. Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com> Reported-by: Hin-Tak Leung <htl10@users.sourceforge.net> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hfsplus/catalog.c')
-rw-r--r--fs/hfsplus/catalog.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index 798d9c4c5e71..840d71edd193 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -45,7 +45,8 @@ void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,
45 45
46 key->cat.parent = cpu_to_be32(parent); 46 key->cat.parent = cpu_to_be32(parent);
47 if (str) { 47 if (str) {
48 hfsplus_asc2uni(sb, &key->cat.name, str->name, str->len); 48 hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN,
49 str->name, str->len);
49 len = be16_to_cpu(key->cat.name.length); 50 len = be16_to_cpu(key->cat.name.length);
50 } else { 51 } else {
51 key->cat.name.length = 0; 52 key->cat.name.length = 0;
@@ -167,7 +168,8 @@ static int hfsplus_fill_cat_thread(struct super_block *sb,
167 entry->type = cpu_to_be16(type); 168 entry->type = cpu_to_be16(type);
168 entry->thread.reserved = 0; 169 entry->thread.reserved = 0;
169 entry->thread.parentID = cpu_to_be32(parentid); 170 entry->thread.parentID = cpu_to_be32(parentid);
170 hfsplus_asc2uni(sb, &entry->thread.nodeName, str->name, str->len); 171 hfsplus_asc2uni(sb, &entry->thread.nodeName, HFSPLUS_MAX_STRLEN,
172 str->name, str->len);
171 return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2; 173 return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2;
172} 174}
173 175
@@ -198,7 +200,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
198 hfsplus_cat_build_key_uni(fd->search_key, 200 hfsplus_cat_build_key_uni(fd->search_key,
199 be32_to_cpu(tmp.thread.parentID), 201 be32_to_cpu(tmp.thread.parentID),
200 &tmp.thread.nodeName); 202 &tmp.thread.nodeName);
201 return hfs_brec_find(fd); 203 return hfs_brec_find(fd, hfs_find_rec_by_key);
202} 204}
203 205
204int hfsplus_create_cat(u32 cnid, struct inode *dir, 206int hfsplus_create_cat(u32 cnid, struct inode *dir,
@@ -221,7 +223,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
221 S_ISDIR(inode->i_mode) ? 223 S_ISDIR(inode->i_mode) ?
222 HFSPLUS_FOLDER_THREAD : HFSPLUS_FILE_THREAD, 224 HFSPLUS_FOLDER_THREAD : HFSPLUS_FILE_THREAD,
223 dir->i_ino, str); 225 dir->i_ino, str);
224 err = hfs_brec_find(&fd); 226 err = hfs_brec_find(&fd, hfs_find_rec_by_key);
225 if (err != -ENOENT) { 227 if (err != -ENOENT) {
226 if (!err) 228 if (!err)
227 err = -EEXIST; 229 err = -EEXIST;
@@ -233,7 +235,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
233 235
234 hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); 236 hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str);
235 entry_size = hfsplus_cat_build_record(&entry, cnid, inode); 237 entry_size = hfsplus_cat_build_record(&entry, cnid, inode);
236 err = hfs_brec_find(&fd); 238 err = hfs_brec_find(&fd, hfs_find_rec_by_key);
237 if (err != -ENOENT) { 239 if (err != -ENOENT) {
238 /* panic? */ 240 /* panic? */
239 if (!err) 241 if (!err)
@@ -253,7 +255,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
253 255
254err1: 256err1:
255 hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL); 257 hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
256 if (!hfs_brec_find(&fd)) 258 if (!hfs_brec_find(&fd, hfs_find_rec_by_key))
257 hfs_brec_remove(&fd); 259 hfs_brec_remove(&fd);
258err2: 260err2:
259 hfs_find_exit(&fd); 261 hfs_find_exit(&fd);
@@ -279,7 +281,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
279 int len; 281 int len;
280 282
281 hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL); 283 hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
282 err = hfs_brec_find(&fd); 284 err = hfs_brec_find(&fd, hfs_find_rec_by_key);
283 if (err) 285 if (err)
284 goto out; 286 goto out;
285 287
@@ -296,7 +298,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
296 } else 298 } else
297 hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); 299 hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str);
298 300
299 err = hfs_brec_find(&fd); 301 err = hfs_brec_find(&fd, hfs_find_rec_by_key);
300 if (err) 302 if (err)
301 goto out; 303 goto out;
302 304
@@ -326,7 +328,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
326 goto out; 328 goto out;
327 329
328 hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL); 330 hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
329 err = hfs_brec_find(&fd); 331 err = hfs_brec_find(&fd, hfs_find_rec_by_key);
330 if (err) 332 if (err)
331 goto out; 333 goto out;
332 334
@@ -337,6 +339,12 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
337 dir->i_size--; 339 dir->i_size--;
338 dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; 340 dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
339 hfsplus_mark_inode_dirty(dir, HFSPLUS_I_CAT_DIRTY); 341 hfsplus_mark_inode_dirty(dir, HFSPLUS_I_CAT_DIRTY);
342
343 if (type == HFSPLUS_FILE || type == HFSPLUS_FOLDER) {
344 if (HFSPLUS_SB(sb)->attr_tree)
345 hfsplus_delete_all_attrs(dir, cnid);
346 }
347
340out: 348out:
341 hfs_find_exit(&fd); 349 hfs_find_exit(&fd);
342 350
@@ -363,7 +371,7 @@ int hfsplus_rename_cat(u32 cnid,
363 371
364 /* find the old dir entry and read the data */ 372 /* find the old dir entry and read the data */
365 hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name); 373 hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);
366 err = hfs_brec_find(&src_fd); 374 err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
367 if (err) 375 if (err)
368 goto out; 376 goto out;
369 if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) { 377 if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
@@ -376,7 +384,7 @@ int hfsplus_rename_cat(u32 cnid,
376 384
377 /* create new dir entry with the data from the old entry */ 385 /* create new dir entry with the data from the old entry */
378 hfsplus_cat_build_key(sb, dst_fd.search_key, dst_dir->i_ino, dst_name); 386 hfsplus_cat_build_key(sb, dst_fd.search_key, dst_dir->i_ino, dst_name);
379 err = hfs_brec_find(&dst_fd); 387 err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key);
380 if (err != -ENOENT) { 388 if (err != -ENOENT) {
381 if (!err) 389 if (!err)
382 err = -EEXIST; 390 err = -EEXIST;
@@ -391,7 +399,7 @@ int hfsplus_rename_cat(u32 cnid,
391 399
392 /* finally remove the old entry */ 400 /* finally remove the old entry */
393 hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name); 401 hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);
394 err = hfs_brec_find(&src_fd); 402 err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
395 if (err) 403 if (err)
396 goto out; 404 goto out;
397 err = hfs_brec_remove(&src_fd); 405 err = hfs_brec_remove(&src_fd);
@@ -402,7 +410,7 @@ int hfsplus_rename_cat(u32 cnid,
402 410
403 /* remove old thread entry */ 411 /* remove old thread entry */
404 hfsplus_cat_build_key(sb, src_fd.search_key, cnid, NULL); 412 hfsplus_cat_build_key(sb, src_fd.search_key, cnid, NULL);
405 err = hfs_brec_find(&src_fd); 413 err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
406 if (err) 414 if (err)
407 goto out; 415 goto out;
408 type = hfs_bnode_read_u16(src_fd.bnode, src_fd.entryoffset); 416 type = hfs_bnode_read_u16(src_fd.bnode, src_fd.entryoffset);
@@ -414,7 +422,7 @@ int hfsplus_rename_cat(u32 cnid,
414 hfsplus_cat_build_key(sb, dst_fd.search_key, cnid, NULL); 422 hfsplus_cat_build_key(sb, dst_fd.search_key, cnid, NULL);
415 entry_size = hfsplus_fill_cat_thread(sb, &entry, type, 423 entry_size = hfsplus_fill_cat_thread(sb, &entry, type,
416 dst_dir->i_ino, dst_name); 424 dst_dir->i_ino, dst_name);
417 err = hfs_brec_find(&dst_fd); 425 err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key);
418 if (err != -ENOENT) { 426 if (err != -ENOENT) {
419 if (!err) 427 if (!err)
420 err = -EEXIST; 428 err = -EEXIST;