dir.c (762f99f4f3cb41a775b5157dd761217beba65873) | dir.c (5298d4bfe80f6ae6ae2777bcd1357b0022d98573) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * fs/f2fs/dir.c 4 * 5 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 6 * http://www.samsung.com/ 7 */ 8#include <asm/unaligned.h> 9#include <linux/fs.h> 10#include <linux/f2fs_fs.h> 11#include <linux/sched/signal.h> 12#include <linux/unicode.h> 13#include "f2fs.h" 14#include "node.h" 15#include "acl.h" 16#include "xattr.h" 17#include <trace/events/f2fs.h> 18 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * fs/f2fs/dir.c 4 * 5 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 6 * http://www.samsung.com/ 7 */ 8#include <asm/unaligned.h> 9#include <linux/fs.h> 10#include <linux/f2fs_fs.h> 11#include <linux/sched/signal.h> 12#include <linux/unicode.h> 13#include "f2fs.h" 14#include "node.h" 15#include "acl.h" 16#include "xattr.h" 17#include <trace/events/f2fs.h> 18 |
19#ifdef CONFIG_UNICODE | 19#if IS_ENABLED(CONFIG_UNICODE) |
20extern struct kmem_cache *f2fs_cf_name_slab; 21#endif 22 23static unsigned long dir_blocks(struct inode *inode) 24{ 25 return ((unsigned long long) (i_size_read(inode) + PAGE_SIZE - 1)) 26 >> PAGE_SHIFT; 27} --- 46 unchanged lines hidden (view full) --- 74 return f2fs_filetype_table[de->file_type]; 75 return DT_UNKNOWN; 76} 77 78/* If @dir is casefolded, initialize @fname->cf_name from @fname->usr_fname. */ 79int f2fs_init_casefolded_name(const struct inode *dir, 80 struct f2fs_filename *fname) 81{ | 20extern struct kmem_cache *f2fs_cf_name_slab; 21#endif 22 23static unsigned long dir_blocks(struct inode *inode) 24{ 25 return ((unsigned long long) (i_size_read(inode) + PAGE_SIZE - 1)) 26 >> PAGE_SHIFT; 27} --- 46 unchanged lines hidden (view full) --- 74 return f2fs_filetype_table[de->file_type]; 75 return DT_UNKNOWN; 76} 77 78/* If @dir is casefolded, initialize @fname->cf_name from @fname->usr_fname. */ 79int f2fs_init_casefolded_name(const struct inode *dir, 80 struct f2fs_filename *fname) 81{ |
82#ifdef CONFIG_UNICODE | 82#if IS_ENABLED(CONFIG_UNICODE) |
83 struct super_block *sb = dir->i_sb; 84 85 if (IS_CASEFOLDED(dir)) { 86 fname->cf_name.name = f2fs_kmem_cache_alloc(f2fs_cf_name_slab, 87 GFP_NOFS, false, F2FS_SB(sb)); 88 if (!fname->cf_name.name) 89 return -ENOMEM; 90 fname->cf_name.len = utf8_casefold(sb->s_encoding, --- 78 unchanged lines hidden (view full) --- 169} 170 171void f2fs_free_filename(struct f2fs_filename *fname) 172{ 173#ifdef CONFIG_FS_ENCRYPTION 174 kfree(fname->crypto_buf.name); 175 fname->crypto_buf.name = NULL; 176#endif | 83 struct super_block *sb = dir->i_sb; 84 85 if (IS_CASEFOLDED(dir)) { 86 fname->cf_name.name = f2fs_kmem_cache_alloc(f2fs_cf_name_slab, 87 GFP_NOFS, false, F2FS_SB(sb)); 88 if (!fname->cf_name.name) 89 return -ENOMEM; 90 fname->cf_name.len = utf8_casefold(sb->s_encoding, --- 78 unchanged lines hidden (view full) --- 169} 170 171void f2fs_free_filename(struct f2fs_filename *fname) 172{ 173#ifdef CONFIG_FS_ENCRYPTION 174 kfree(fname->crypto_buf.name); 175 fname->crypto_buf.name = NULL; 176#endif |
177#ifdef CONFIG_UNICODE | 177#if IS_ENABLED(CONFIG_UNICODE) |
178 if (fname->cf_name.name) { 179 kmem_cache_free(f2fs_cf_name_slab, fname->cf_name.name); 180 fname->cf_name.name = NULL; 181 } 182#endif 183} 184 185static unsigned long dir_block_index(unsigned int level, --- 17 unchanged lines hidden (view full) --- 203 struct f2fs_dentry_ptr d; 204 205 dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); 206 207 make_dentry_ptr_block(dir, &d, dentry_blk); 208 return f2fs_find_target_dentry(&d, fname, max_slots); 209} 210 | 178 if (fname->cf_name.name) { 179 kmem_cache_free(f2fs_cf_name_slab, fname->cf_name.name); 180 fname->cf_name.name = NULL; 181 } 182#endif 183} 184 185static unsigned long dir_block_index(unsigned int level, --- 17 unchanged lines hidden (view full) --- 203 struct f2fs_dentry_ptr d; 204 205 dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); 206 207 make_dentry_ptr_block(dir, &d, dentry_blk); 208 return f2fs_find_target_dentry(&d, fname, max_slots); 209} 210 |
211#ifdef CONFIG_UNICODE | 211#if IS_ENABLED(CONFIG_UNICODE) |
212/* 213 * Test whether a case-insensitive directory entry matches the filename 214 * being searched for. 215 * 216 * Returns 1 for a match, 0 for no match, and -errno on an error. 217 */ 218static int f2fs_match_ci_name(const struct inode *dir, const struct qstr *name, 219 const u8 *de_name, u32 de_name_len) --- 41 unchanged lines hidden (view full) --- 261#endif /* CONFIG_UNICODE */ 262 263static inline int f2fs_match_name(const struct inode *dir, 264 const struct f2fs_filename *fname, 265 const u8 *de_name, u32 de_name_len) 266{ 267 struct fscrypt_name f; 268 | 212/* 213 * Test whether a case-insensitive directory entry matches the filename 214 * being searched for. 215 * 216 * Returns 1 for a match, 0 for no match, and -errno on an error. 217 */ 218static int f2fs_match_ci_name(const struct inode *dir, const struct qstr *name, 219 const u8 *de_name, u32 de_name_len) --- 41 unchanged lines hidden (view full) --- 261#endif /* CONFIG_UNICODE */ 262 263static inline int f2fs_match_name(const struct inode *dir, 264 const struct f2fs_filename *fname, 265 const u8 *de_name, u32 de_name_len) 266{ 267 struct fscrypt_name f; 268 |
269#ifdef CONFIG_UNICODE | 269#if IS_ENABLED(CONFIG_UNICODE) |
270 if (fname->cf_name.name) { 271 struct qstr cf = FSTR_TO_QSTR(&fname->cf_name); 272 273 return f2fs_match_ci_name(dir, &cf, de_name, de_name_len); 274 } 275#endif 276 f.usr_fname = fname->usr_fname; 277 f.disk_name = fname->disk_name; --- 882 unchanged lines hidden --- | 270 if (fname->cf_name.name) { 271 struct qstr cf = FSTR_TO_QSTR(&fname->cf_name); 272 273 return f2fs_match_ci_name(dir, &cf, de_name, de_name_len); 274 } 275#endif 276 f.usr_fname = fname->usr_fname; 277 f.disk_name = fname->disk_name; --- 882 unchanged lines hidden --- |