Lines Matching +full:entry +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
21 k1p = k1->cat.parent; in hfsplus_cat_case_cmp_key()
22 k2p = k2->cat.parent; in hfsplus_cat_case_cmp_key()
24 return be32_to_cpu(k1p) < be32_to_cpu(k2p) ? -1 : 1; in hfsplus_cat_case_cmp_key()
26 return hfsplus_strcasecmp(&k1->cat.name, &k2->cat.name); in hfsplus_cat_case_cmp_key()
34 k1p = k1->cat.parent; in hfsplus_cat_bin_cmp_key()
35 k2p = k2->cat.parent; in hfsplus_cat_bin_cmp_key()
37 return be32_to_cpu(k1p) < be32_to_cpu(k2p) ? -1 : 1; in hfsplus_cat_bin_cmp_key()
39 return hfsplus_strcmp(&k1->cat.name, &k2->cat.name); in hfsplus_cat_bin_cmp_key()
48 key->cat.parent = cpu_to_be32(parent); in hfsplus_cat_build_key()
49 err = hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN, in hfsplus_cat_build_key()
50 str->name, str->len); in hfsplus_cat_build_key()
54 len = be16_to_cpu(key->cat.name.length); in hfsplus_cat_build_key()
55 key->key_len = cpu_to_be16(6 + 2 * len); in hfsplus_cat_build_key()
63 key->cat.parent = cpu_to_be32(parent); in hfsplus_cat_build_key_with_cnid()
64 key->cat.name.length = 0; in hfsplus_cat_build_key_with_cnid()
65 key->key_len = cpu_to_be16(6); in hfsplus_cat_build_key_with_cnid()
69 struct hfsplus_unistr *name) in hfsplus_cat_build_key_uni() argument
73 ustrlen = be16_to_cpu(name->length); in hfsplus_cat_build_key_uni()
74 key->cat.parent = cpu_to_be32(parent); in hfsplus_cat_build_key_uni()
75 key->cat.name.length = cpu_to_be16(ustrlen); in hfsplus_cat_build_key_uni()
77 memcpy(key->cat.name.unicode, name->unicode, ustrlen); in hfsplus_cat_build_key_uni()
78 key->key_len = cpu_to_be16(6 + ustrlen); in hfsplus_cat_build_key_uni()
83 if (inode->i_flags & S_IMMUTABLE) in hfsplus_cat_set_perms()
84 perms->rootflags |= HFSPLUS_FLG_IMMUTABLE; in hfsplus_cat_set_perms()
86 perms->rootflags &= ~HFSPLUS_FLG_IMMUTABLE; in hfsplus_cat_set_perms()
87 if (inode->i_flags & S_APPEND) in hfsplus_cat_set_perms()
88 perms->rootflags |= HFSPLUS_FLG_APPEND; in hfsplus_cat_set_perms()
90 perms->rootflags &= ~HFSPLUS_FLG_APPEND; in hfsplus_cat_set_perms()
92 perms->userflags = HFSPLUS_I(inode)->userflags; in hfsplus_cat_set_perms()
93 perms->mode = cpu_to_be16(inode->i_mode); in hfsplus_cat_set_perms()
94 perms->owner = cpu_to_be32(i_uid_read(inode)); in hfsplus_cat_set_perms()
95 perms->group = cpu_to_be32(i_gid_read(inode)); in hfsplus_cat_set_perms()
97 if (S_ISREG(inode->i_mode)) in hfsplus_cat_set_perms()
98 perms->dev = cpu_to_be32(inode->i_nlink); in hfsplus_cat_set_perms()
99 else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) in hfsplus_cat_set_perms()
100 perms->dev = cpu_to_be32(inode->i_rdev); in hfsplus_cat_set_perms()
102 perms->dev = 0; in hfsplus_cat_set_perms()
105 static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, in hfsplus_cat_build_record() argument
108 struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb); in hfsplus_cat_build_record()
110 if (S_ISDIR(inode->i_mode)) { in hfsplus_cat_build_record()
113 folder = &entry->folder; in hfsplus_cat_build_record()
115 folder->type = cpu_to_be16(HFSPLUS_FOLDER); in hfsplus_cat_build_record()
116 if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) in hfsplus_cat_build_record()
117 folder->flags |= cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT); in hfsplus_cat_build_record()
118 folder->id = cpu_to_be32(inode->i_ino); in hfsplus_cat_build_record()
119 HFSPLUS_I(inode)->create_date = in hfsplus_cat_build_record()
120 folder->create_date = in hfsplus_cat_build_record()
121 folder->content_mod_date = in hfsplus_cat_build_record()
122 folder->attribute_mod_date = in hfsplus_cat_build_record()
123 folder->access_date = hfsp_now2mt(); in hfsplus_cat_build_record()
124 hfsplus_cat_set_perms(inode, &folder->permissions); in hfsplus_cat_build_record()
125 if (inode == sbi->hidden_dir) in hfsplus_cat_build_record()
127 folder->user_info.frFlags = cpu_to_be16(0x5000); in hfsplus_cat_build_record()
132 file = &entry->file; in hfsplus_cat_build_record()
134 file->type = cpu_to_be16(HFSPLUS_FILE); in hfsplus_cat_build_record()
135 file->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS); in hfsplus_cat_build_record()
136 file->id = cpu_to_be32(cnid); in hfsplus_cat_build_record()
137 HFSPLUS_I(inode)->create_date = in hfsplus_cat_build_record()
138 file->create_date = in hfsplus_cat_build_record()
139 file->content_mod_date = in hfsplus_cat_build_record()
140 file->attribute_mod_date = in hfsplus_cat_build_record()
141 file->access_date = hfsp_now2mt(); in hfsplus_cat_build_record()
142 if (cnid == inode->i_ino) { in hfsplus_cat_build_record()
143 hfsplus_cat_set_perms(inode, &file->permissions); in hfsplus_cat_build_record()
144 if (S_ISLNK(inode->i_mode)) { in hfsplus_cat_build_record()
145 file->user_info.fdType = in hfsplus_cat_build_record()
147 file->user_info.fdCreator = in hfsplus_cat_build_record()
150 file->user_info.fdType = in hfsplus_cat_build_record()
151 cpu_to_be32(sbi->type); in hfsplus_cat_build_record()
152 file->user_info.fdCreator = in hfsplus_cat_build_record()
153 cpu_to_be32(sbi->creator); in hfsplus_cat_build_record()
156 (file->permissions.rootflags | in hfsplus_cat_build_record()
157 file->permissions.userflags)) in hfsplus_cat_build_record()
158 file->flags |= in hfsplus_cat_build_record()
161 file->user_info.fdType = in hfsplus_cat_build_record()
163 file->user_info.fdCreator = in hfsplus_cat_build_record()
165 file->user_info.fdFlags = in hfsplus_cat_build_record()
167 file->create_date = in hfsplus_cat_build_record()
168 HFSPLUS_I(sbi->hidden_dir)->create_date; in hfsplus_cat_build_record()
169 file->permissions.dev = in hfsplus_cat_build_record()
170 cpu_to_be32(HFSPLUS_I(inode)->linkid); in hfsplus_cat_build_record()
177 hfsplus_cat_entry *entry, int type, in hfsplus_fill_cat_thread() argument
182 entry->type = cpu_to_be16(type); in hfsplus_fill_cat_thread()
183 entry->thread.reserved = 0; in hfsplus_fill_cat_thread()
184 entry->thread.parentID = cpu_to_be32(parentid); in hfsplus_fill_cat_thread()
185 err = hfsplus_asc2uni(sb, &entry->thread.nodeName, HFSPLUS_MAX_STRLEN, in hfsplus_fill_cat_thread()
186 str->name, str->len); in hfsplus_fill_cat_thread()
190 return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2; in hfsplus_fill_cat_thread()
193 /* Try to get a catalog entry for given catalog id */
201 hfsplus_cat_build_key_with_cnid(sb, fd->search_key, cnid); in hfsplus_find_cat()
209 return -EIO; in hfsplus_find_cat()
213 pr_err("catalog name length corrupted\n"); in hfsplus_find_cat()
214 return -EIO; in hfsplus_find_cat()
217 hfsplus_cat_build_key_uni(fd->search_key, in hfsplus_find_cat()
225 struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); in hfsplus_subfolders_inc()
227 if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) { in hfsplus_subfolders_inc()
232 HFSPLUS_I(dir)->subfolders++; in hfsplus_subfolders_inc()
238 struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); in hfsplus_subfolders_dec()
240 if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) { in hfsplus_subfolders_dec()
248 if (HFSPLUS_I(dir)->subfolders) in hfsplus_subfolders_dec()
249 HFSPLUS_I(dir)->subfolders--; in hfsplus_subfolders_dec()
256 struct super_block *sb = dir->i_sb; in hfsplus_create_cat()
258 hfsplus_cat_entry entry; in hfsplus_create_cat() local
262 hfs_dbg("name %s, cnid %u, i_nlink %d\n", in hfsplus_create_cat()
263 str->name, cnid, inode->i_nlink); in hfsplus_create_cat()
264 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); in hfsplus_create_cat()
272 err = hfs_bmap_reserve(fd.tree, 2 * fd.tree->depth); in hfsplus_create_cat()
277 entry_size = hfsplus_fill_cat_thread(sb, &entry, in hfsplus_create_cat()
278 S_ISDIR(inode->i_mode) ? in hfsplus_create_cat()
280 dir->i_ino, str); in hfsplus_create_cat()
287 if (err != -ENOENT) { in hfsplus_create_cat()
289 err = -EEXIST; in hfsplus_create_cat()
292 err = hfs_brec_insert(&fd, &entry, entry_size); in hfsplus_create_cat()
296 err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); in hfsplus_create_cat()
300 entry_size = hfsplus_cat_build_record(&entry, cnid, inode); in hfsplus_create_cat()
302 if (err != -ENOENT) { in hfsplus_create_cat()
305 err = -EEXIST; in hfsplus_create_cat()
308 err = hfs_brec_insert(&fd, &entry, entry_size); in hfsplus_create_cat()
312 dir->i_size++; in hfsplus_create_cat()
313 if (S_ISDIR(inode->i_mode)) in hfsplus_create_cat()
332 struct super_block *sb = dir->i_sb; in hfsplus_delete_cat()
339 hfs_dbg("name %s, cnid %u\n", str ? str->name : NULL, cnid); in hfsplus_delete_cat()
340 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); in hfsplus_delete_cat()
348 err = hfs_bmap_reserve(fd.tree, 2 * (int)fd.tree->depth - 2); in hfsplus_delete_cat()
362 fd.search_key->cat.parent = cpu_to_be32(dir->i_ino); in hfsplus_delete_cat()
364 &fd.search_key->cat.name.length, off, 2); in hfsplus_delete_cat()
365 len = be16_to_cpu(fd.search_key->cat.name.length) * 2; in hfsplus_delete_cat()
367 &fd.search_key->cat.name.unicode, in hfsplus_delete_cat()
369 fd.search_key->key_len = cpu_to_be16(6 + len); in hfsplus_delete_cat()
371 err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); in hfsplus_delete_cat()
394 /* we only need to take spinlock for exclusion with ->release() */ in hfsplus_delete_cat()
395 spin_lock(&HFSPLUS_I(dir)->open_dir_lock); in hfsplus_delete_cat()
396 list_for_each(pos, &HFSPLUS_I(dir)->open_dir_list) { in hfsplus_delete_cat()
399 if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0) in hfsplus_delete_cat()
400 rd->file->f_pos--; in hfsplus_delete_cat()
402 spin_unlock(&HFSPLUS_I(dir)->open_dir_lock); in hfsplus_delete_cat()
417 dir->i_size--; in hfsplus_delete_cat()
424 if (HFSPLUS_SB(sb)->attr_tree) in hfsplus_delete_cat()
438 struct super_block *sb = src_dir->i_sb; in hfsplus_rename_cat()
440 hfsplus_cat_entry entry; in hfsplus_rename_cat() local
444 hfs_dbg("cnid %u - ino %lu, name %s - ino %lu, name %s\n", in hfsplus_rename_cat()
445 cnid, src_dir->i_ino, src_name->name, in hfsplus_rename_cat()
446 dst_dir->i_ino, dst_name->name); in hfsplus_rename_cat()
447 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &src_fd); in hfsplus_rename_cat()
456 err = hfs_bmap_reserve(src_fd.tree, 4 * (int)src_fd.tree->depth - 1); in hfsplus_rename_cat()
460 /* find the old dir entry and read the data */ in hfsplus_rename_cat()
462 src_dir->i_ino, src_name); in hfsplus_rename_cat()
469 if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) { in hfsplus_rename_cat()
470 err = -EIO; in hfsplus_rename_cat()
474 hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, in hfsplus_rename_cat()
476 type = be16_to_cpu(entry.type); in hfsplus_rename_cat()
478 /* create new dir entry with the data from the old entry */ in hfsplus_rename_cat()
480 dst_dir->i_ino, dst_name); in hfsplus_rename_cat()
485 if (err != -ENOENT) { in hfsplus_rename_cat()
487 err = -EEXIST; in hfsplus_rename_cat()
491 err = hfs_brec_insert(&dst_fd, &entry, src_fd.entrylength); in hfsplus_rename_cat()
494 dst_dir->i_size++; in hfsplus_rename_cat()
499 /* finally remove the old entry */ in hfsplus_rename_cat()
501 src_dir->i_ino, src_name); in hfsplus_rename_cat()
511 src_dir->i_size--; in hfsplus_rename_cat()
516 /* remove old thread entry */ in hfsplus_rename_cat()
526 /* create new thread entry */ in hfsplus_rename_cat()
528 entry_size = hfsplus_fill_cat_thread(sb, &entry, type, in hfsplus_rename_cat()
529 dst_dir->i_ino, dst_name); in hfsplus_rename_cat()
536 if (err != -ENOENT) { in hfsplus_rename_cat()
538 err = -EEXIST; in hfsplus_rename_cat()
541 err = hfs_brec_insert(&dst_fd, &entry, entry_size); in hfsplus_rename_cat()