namei.c (87a0b2fafc09766d8c55461a18345a1cfb10a7fe) namei.c (5298d4bfe80f6ae6ae2777bcd1357b0022d98573)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/ext4/namei.c
4 *
5 * Copyright (C) 1992, 1993, 1994, 1995
6 * Remy Card (card@masi.ibp.fr)
7 * Laboratoire MASI - Institut Blaise Pascal
8 * Universite Pierre et Marie Curie (Paris VI)

--- 1303 unchanged lines hidden (view full) ---

1312 ASSERT(count < dx_get_limit(entries));
1313 ASSERT(old < entries + count);
1314 memmove(new + 1, new, (char *)(entries + count) - (char *)(new));
1315 dx_set_hash(new, hash);
1316 dx_set_block(new, block);
1317 dx_set_count(entries, count + 1);
1318}
1319
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/ext4/namei.c
4 *
5 * Copyright (C) 1992, 1993, 1994, 1995
6 * Remy Card (card@masi.ibp.fr)
7 * Laboratoire MASI - Institut Blaise Pascal
8 * Universite Pierre et Marie Curie (Paris VI)

--- 1303 unchanged lines hidden (view full) ---

1312 ASSERT(count < dx_get_limit(entries));
1313 ASSERT(old < entries + count);
1314 memmove(new + 1, new, (char *)(entries + count) - (char *)(new));
1315 dx_set_hash(new, hash);
1316 dx_set_block(new, block);
1317 dx_set_count(entries, count + 1);
1318}
1319
1320#ifdef CONFIG_UNICODE
1320#if IS_ENABLED(CONFIG_UNICODE)
1321/*
1322 * Test whether a case-insensitive directory entry matches the filename
1323 * being searched for. If quick is set, assume the name being looked up
1324 * is already in the casefolded form.
1325 *
1326 * Returns: 0 if the directory entry matches, more than 0 if it
1327 * doesn't match or less than zero on error.
1328 */

--- 94 unchanged lines hidden (view full) ---

1423 return false;
1424
1425 f.usr_fname = fname->usr_fname;
1426 f.disk_name = fname->disk_name;
1427#ifdef CONFIG_FS_ENCRYPTION
1428 f.crypto_buf = fname->crypto_buf;
1429#endif
1430
1321/*
1322 * Test whether a case-insensitive directory entry matches the filename
1323 * being searched for. If quick is set, assume the name being looked up
1324 * is already in the casefolded form.
1325 *
1326 * Returns: 0 if the directory entry matches, more than 0 if it
1327 * doesn't match or less than zero on error.
1328 */

--- 94 unchanged lines hidden (view full) ---

1423 return false;
1424
1425 f.usr_fname = fname->usr_fname;
1426 f.disk_name = fname->disk_name;
1427#ifdef CONFIG_FS_ENCRYPTION
1428 f.crypto_buf = fname->crypto_buf;
1429#endif
1430
1431#ifdef CONFIG_UNICODE
1431#if IS_ENABLED(CONFIG_UNICODE)
1432 if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) &&
1433 (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) {
1434 if (fname->cf_name.name) {
1435 struct qstr cf = {.name = fname->cf_name.name,
1436 .len = fname->cf_name.len};
1437 if (IS_ENCRYPTED(parent)) {
1438 if (fname->hinfo.hash != EXT4_DIRENT_HASH(de) ||
1439 fname->hinfo.minor_hash !=

--- 355 unchanged lines hidden (view full) ---

1795 ext4_warning(inode->i_sb,
1796 "Inconsistent encryption contexts: %lu/%lu",
1797 dir->i_ino, inode->i_ino);
1798 iput(inode);
1799 return ERR_PTR(-EPERM);
1800 }
1801 }
1802
1432 if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) &&
1433 (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) {
1434 if (fname->cf_name.name) {
1435 struct qstr cf = {.name = fname->cf_name.name,
1436 .len = fname->cf_name.len};
1437 if (IS_ENCRYPTED(parent)) {
1438 if (fname->hinfo.hash != EXT4_DIRENT_HASH(de) ||
1439 fname->hinfo.minor_hash !=

--- 355 unchanged lines hidden (view full) ---

1795 ext4_warning(inode->i_sb,
1796 "Inconsistent encryption contexts: %lu/%lu",
1797 dir->i_ino, inode->i_ino);
1798 iput(inode);
1799 return ERR_PTR(-EPERM);
1800 }
1801 }
1802
1803#ifdef CONFIG_UNICODE
1803#if IS_ENABLED(CONFIG_UNICODE)
1804 if (!inode && IS_CASEFOLDED(dir)) {
1805 /* Eventually we want to call d_add_ci(dentry, NULL)
1806 * for negative dentries in the encoding case as
1807 * well. For now, prevent the negative dentry
1808 * from being cached.
1809 */
1810 return NULL;
1811 }

--- 491 unchanged lines hidden (view full) ---

2303 sb = dir->i_sb;
2304 blocksize = sb->s_blocksize;
2305 if (!dentry->d_name.len)
2306 return -EINVAL;
2307
2308 if (fscrypt_is_nokey_name(dentry))
2309 return -ENOKEY;
2310
1804 if (!inode && IS_CASEFOLDED(dir)) {
1805 /* Eventually we want to call d_add_ci(dentry, NULL)
1806 * for negative dentries in the encoding case as
1807 * well. For now, prevent the negative dentry
1808 * from being cached.
1809 */
1810 return NULL;
1811 }

--- 491 unchanged lines hidden (view full) ---

2303 sb = dir->i_sb;
2304 blocksize = sb->s_blocksize;
2305 if (!dentry->d_name.len)
2306 return -EINVAL;
2307
2308 if (fscrypt_is_nokey_name(dentry))
2309 return -ENOKEY;
2310
2311#ifdef CONFIG_UNICODE
2311#if IS_ENABLED(CONFIG_UNICODE)
2312 if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) &&
2313 sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name))
2314 return -EINVAL;
2315#endif
2316
2317 retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname);
2318 if (retval)
2319 return retval;

--- 801 unchanged lines hidden (view full) ---

3121 retval = ext4_mark_inode_dirty(handle, inode);
3122 if (retval)
3123 goto end_rmdir;
3124 ext4_dec_count(dir);
3125 ext4_update_dx_flag(dir);
3126 ext4_fc_track_unlink(handle, dentry);
3127 retval = ext4_mark_inode_dirty(handle, dir);
3128
2312 if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) &&
2313 sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name))
2314 return -EINVAL;
2315#endif
2316
2317 retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname);
2318 if (retval)
2319 return retval;

--- 801 unchanged lines hidden (view full) ---

3121 retval = ext4_mark_inode_dirty(handle, inode);
3122 if (retval)
3123 goto end_rmdir;
3124 ext4_dec_count(dir);
3125 ext4_update_dx_flag(dir);
3126 ext4_fc_track_unlink(handle, dentry);
3127 retval = ext4_mark_inode_dirty(handle, dir);
3128
3129#ifdef CONFIG_UNICODE
3129#if IS_ENABLED(CONFIG_UNICODE)
3130 /* VFS negative dentries are incompatible with Encoding and
3131 * Case-insensitiveness. Eventually we'll want avoid
3132 * invalidating the dentries here, alongside with returning the
3133 * negative dentries at ext4_lookup(), when it is better
3134 * supported by the VFS for the CI case.
3135 */
3136 if (IS_CASEFOLDED(dir))
3137 d_invalidate(dentry);

--- 88 unchanged lines hidden (view full) ---

3226 if (IS_ERR(handle)) {
3227 retval = PTR_ERR(handle);
3228 goto out_trace;
3229 }
3230
3231 retval = __ext4_unlink(handle, dir, &dentry->d_name, d_inode(dentry));
3232 if (!retval)
3233 ext4_fc_track_unlink(handle, dentry);
3130 /* VFS negative dentries are incompatible with Encoding and
3131 * Case-insensitiveness. Eventually we'll want avoid
3132 * invalidating the dentries here, alongside with returning the
3133 * negative dentries at ext4_lookup(), when it is better
3134 * supported by the VFS for the CI case.
3135 */
3136 if (IS_CASEFOLDED(dir))
3137 d_invalidate(dentry);

--- 88 unchanged lines hidden (view full) ---

3226 if (IS_ERR(handle)) {
3227 retval = PTR_ERR(handle);
3228 goto out_trace;
3229 }
3230
3231 retval = __ext4_unlink(handle, dir, &dentry->d_name, d_inode(dentry));
3232 if (!retval)
3233 ext4_fc_track_unlink(handle, dentry);
3234#ifdef CONFIG_UNICODE
3234#if IS_ENABLED(CONFIG_UNICODE)
3235 /* VFS negative dentries are incompatible with Encoding and
3236 * Case-insensitiveness. Eventually we'll want avoid
3237 * invalidating the dentries here, alongside with returning the
3238 * negative dentries at ext4_lookup(), when it is better
3239 * supported by the VFS for the CI case.
3240 */
3241 if (IS_CASEFOLDED(dir))
3242 d_invalidate(dentry);

--- 891 unchanged lines hidden ---
3235 /* VFS negative dentries are incompatible with Encoding and
3236 * Case-insensitiveness. Eventually we'll want avoid
3237 * invalidating the dentries here, alongside with returning the
3238 * negative dentries at ext4_lookup(), when it is better
3239 * supported by the VFS for the CI case.
3240 */
3241 if (IS_CASEFOLDED(dir))
3242 d_invalidate(dentry);

--- 891 unchanged lines hidden ---