hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/ocfs2/dir.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* -*- mode: c; c-basic-offset: 8; -*-
23 * vim: noexpandtab sw=8 ts=8 sts=0:
34 *
....@@ -19,21 +20,6 @@
1920 * linux/fs/minix/dir.c
2021 *
2122 * Copyright (C) 1991, 1992 Linus Torvalds
22
- *
23
- * This program is free software; you can redistribute it and/or
24
- * modify it under the terms of the GNU General Public
25
- * License as published by the Free Software Foundation; either
26
- * version 2 of the License, or (at your option) any later version.
27
- *
28
- * This program is distributed in the hope that it will be useful,
29
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31
- * General Public License for more details.
32
- *
33
- * You should have received a copy of the GNU General Public
34
- * License along with this program; if not, write to the
35
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
36
- * Boston, MA 021110-1307, USA.
3723 */
3824
3925 #include <linux/fs.h>
....@@ -68,10 +54,6 @@
6854 #define NAMEI_RA_CHUNKS 2
6955 #define NAMEI_RA_BLOCKS 4
7056 #define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
71
-
72
-static unsigned char ocfs2_filetype_table[] = {
73
- DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
74
-};
7557
7658 static int ocfs2_do_extend_dir(struct super_block *sb,
7759 handle_t *handle,
....@@ -694,7 +676,7 @@
694676 int ra_ptr = 0; /* Current index into readahead
695677 buffer */
696678 int num = 0;
697
- int nblocks, i, err;
679
+ int nblocks, i;
698680
699681 sb = dir->i_sb;
700682
....@@ -726,7 +708,7 @@
726708 num++;
727709
728710 bh = NULL;
729
- err = ocfs2_read_dir_block(dir, b++, &bh,
711
+ ocfs2_read_dir_block(dir, b++, &bh,
730712 OCFS2_BH_READAHEAD);
731713 bh_use[ra_max] = bh;
732714 }
....@@ -866,9 +848,9 @@
866848 u64 *ret_phys_blkno)
867849 {
868850 int ret = 0;
869
- unsigned int cend, uninitialized_var(clen);
870
- u32 uninitialized_var(cpos);
871
- u64 uninitialized_var(blkno);
851
+ unsigned int cend, clen;
852
+ u32 cpos;
853
+ u64 blkno;
872854 u32 name_hash = hinfo->major_hash;
873855
874856 ret = ocfs2_dx_dir_lookup_rec(inode, el, name_hash, &cpos, &blkno,
....@@ -912,7 +894,7 @@
912894 struct ocfs2_dir_lookup_result *res)
913895 {
914896 int ret, i, found;
915
- u64 uninitialized_var(phys);
897
+ u64 phys;
916898 struct buffer_head *dx_leaf_bh = NULL;
917899 struct ocfs2_dx_leaf *dx_leaf;
918900 struct ocfs2_dx_entry *dx_entry = NULL;
....@@ -1718,7 +1700,7 @@
17181700 de->rec_len = cpu_to_le16(OCFS2_DIR_REC_LEN(de->name_len));
17191701 de = de1;
17201702 }
1721
- de->file_type = OCFS2_FT_UNKNOWN;
1703
+ de->file_type = FT_UNKNOWN;
17221704 if (blkno) {
17231705 de->inode = cpu_to_le64(blkno);
17241706 ocfs2_set_de_type(de, inode->i_mode);
....@@ -1803,13 +1785,9 @@
18031785 }
18041786 offset += le16_to_cpu(de->rec_len);
18051787 if (le64_to_cpu(de->inode)) {
1806
- unsigned char d_type = DT_UNKNOWN;
1807
-
1808
- if (de->file_type < OCFS2_FT_MAX)
1809
- d_type = ocfs2_filetype_table[de->file_type];
1810
-
18111788 if (!dir_emit(ctx, de->name, de->name_len,
1812
- le64_to_cpu(de->inode), d_type))
1789
+ le64_to_cpu(de->inode),
1790
+ fs_ftype_to_dtype(de->file_type)))
18131791 goto out;
18141792 }
18151793 ctx->pos += le16_to_cpu(de->rec_len);
....@@ -1900,14 +1878,10 @@
19001878 break;
19011879 }
19021880 if (le64_to_cpu(de->inode)) {
1903
- unsigned char d_type = DT_UNKNOWN;
1904
-
1905
- if (de->file_type < OCFS2_FT_MAX)
1906
- d_type = ocfs2_filetype_table[de->file_type];
19071881 if (!dir_emit(ctx, de->name,
19081882 de->name_len,
19091883 le64_to_cpu(de->inode),
1910
- d_type)) {
1884
+ fs_ftype_to_dtype(de->file_type))) {
19111885 brelse(bh);
19121886 return 0;
19131887 }
....@@ -3662,7 +3636,7 @@
36623636 int i, j, num_used;
36633637 u32 major_hash;
36643638 struct ocfs2_dx_leaf *orig_dx_leaf, *new_dx_leaf;
3665
- struct ocfs2_dx_entry_list *orig_list, *new_list, *tmp_list;
3639
+ struct ocfs2_dx_entry_list *orig_list, *tmp_list;
36663640 struct ocfs2_dx_entry *dx_entry;
36673641
36683642 tmp_list = &tmp_dx_leaf->dl_list;
....@@ -3671,7 +3645,6 @@
36713645 orig_dx_leaf = (struct ocfs2_dx_leaf *) orig_dx_leaves[i]->b_data;
36723646 orig_list = &orig_dx_leaf->dl_list;
36733647 new_dx_leaf = (struct ocfs2_dx_leaf *) new_dx_leaves[i]->b_data;
3674
- new_list = &new_dx_leaf->dl_list;
36753648
36763649 num_used = le16_to_cpu(orig_list->de_num_used);
36773650
....@@ -4420,9 +4393,9 @@
44204393 int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh)
44214394 {
44224395 int ret;
4423
- unsigned int uninitialized_var(clen);
4424
- u32 major_hash = UINT_MAX, p_cpos, uninitialized_var(cpos);
4425
- u64 uninitialized_var(blkno);
4396
+ unsigned int clen;
4397
+ u32 major_hash = UINT_MAX, p_cpos, cpos;
4398
+ u64 blkno;
44264399 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
44274400 struct buffer_head *dx_root_bh = NULL;
44284401 struct ocfs2_dx_root_block *dx_root;