| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
|---|
| 2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 19 | 20 | * linux/fs/minix/dir.c |
|---|
| 20 | 21 | * |
|---|
| 21 | 22 | * 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. |
|---|
| 37 | 23 | */ |
|---|
| 38 | 24 | |
|---|
| 39 | 25 | #include <linux/fs.h> |
|---|
| .. | .. |
|---|
| 68 | 54 | #define NAMEI_RA_CHUNKS 2 |
|---|
| 69 | 55 | #define NAMEI_RA_BLOCKS 4 |
|---|
| 70 | 56 | #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 | | -}; |
|---|
| 75 | 57 | |
|---|
| 76 | 58 | static int ocfs2_do_extend_dir(struct super_block *sb, |
|---|
| 77 | 59 | handle_t *handle, |
|---|
| .. | .. |
|---|
| 694 | 676 | int ra_ptr = 0; /* Current index into readahead |
|---|
| 695 | 677 | buffer */ |
|---|
| 696 | 678 | int num = 0; |
|---|
| 697 | | - int nblocks, i, err; |
|---|
| 679 | + int nblocks, i; |
|---|
| 698 | 680 | |
|---|
| 699 | 681 | sb = dir->i_sb; |
|---|
| 700 | 682 | |
|---|
| .. | .. |
|---|
| 726 | 708 | num++; |
|---|
| 727 | 709 | |
|---|
| 728 | 710 | bh = NULL; |
|---|
| 729 | | - err = ocfs2_read_dir_block(dir, b++, &bh, |
|---|
| 711 | + ocfs2_read_dir_block(dir, b++, &bh, |
|---|
| 730 | 712 | OCFS2_BH_READAHEAD); |
|---|
| 731 | 713 | bh_use[ra_max] = bh; |
|---|
| 732 | 714 | } |
|---|
| .. | .. |
|---|
| 866 | 848 | u64 *ret_phys_blkno) |
|---|
| 867 | 849 | { |
|---|
| 868 | 850 | 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; |
|---|
| 872 | 854 | u32 name_hash = hinfo->major_hash; |
|---|
| 873 | 855 | |
|---|
| 874 | 856 | ret = ocfs2_dx_dir_lookup_rec(inode, el, name_hash, &cpos, &blkno, |
|---|
| .. | .. |
|---|
| 912 | 894 | struct ocfs2_dir_lookup_result *res) |
|---|
| 913 | 895 | { |
|---|
| 914 | 896 | int ret, i, found; |
|---|
| 915 | | - u64 uninitialized_var(phys); |
|---|
| 897 | + u64 phys; |
|---|
| 916 | 898 | struct buffer_head *dx_leaf_bh = NULL; |
|---|
| 917 | 899 | struct ocfs2_dx_leaf *dx_leaf; |
|---|
| 918 | 900 | struct ocfs2_dx_entry *dx_entry = NULL; |
|---|
| .. | .. |
|---|
| 1718 | 1700 | de->rec_len = cpu_to_le16(OCFS2_DIR_REC_LEN(de->name_len)); |
|---|
| 1719 | 1701 | de = de1; |
|---|
| 1720 | 1702 | } |
|---|
| 1721 | | - de->file_type = OCFS2_FT_UNKNOWN; |
|---|
| 1703 | + de->file_type = FT_UNKNOWN; |
|---|
| 1722 | 1704 | if (blkno) { |
|---|
| 1723 | 1705 | de->inode = cpu_to_le64(blkno); |
|---|
| 1724 | 1706 | ocfs2_set_de_type(de, inode->i_mode); |
|---|
| .. | .. |
|---|
| 1803 | 1785 | } |
|---|
| 1804 | 1786 | offset += le16_to_cpu(de->rec_len); |
|---|
| 1805 | 1787 | 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 | | - |
|---|
| 1811 | 1788 | 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))) |
|---|
| 1813 | 1791 | goto out; |
|---|
| 1814 | 1792 | } |
|---|
| 1815 | 1793 | ctx->pos += le16_to_cpu(de->rec_len); |
|---|
| .. | .. |
|---|
| 1900 | 1878 | break; |
|---|
| 1901 | 1879 | } |
|---|
| 1902 | 1880 | 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]; |
|---|
| 1907 | 1881 | if (!dir_emit(ctx, de->name, |
|---|
| 1908 | 1882 | de->name_len, |
|---|
| 1909 | 1883 | le64_to_cpu(de->inode), |
|---|
| 1910 | | - d_type)) { |
|---|
| 1884 | + fs_ftype_to_dtype(de->file_type))) { |
|---|
| 1911 | 1885 | brelse(bh); |
|---|
| 1912 | 1886 | return 0; |
|---|
| 1913 | 1887 | } |
|---|
| .. | .. |
|---|
| 3662 | 3636 | int i, j, num_used; |
|---|
| 3663 | 3637 | u32 major_hash; |
|---|
| 3664 | 3638 | 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; |
|---|
| 3666 | 3640 | struct ocfs2_dx_entry *dx_entry; |
|---|
| 3667 | 3641 | |
|---|
| 3668 | 3642 | tmp_list = &tmp_dx_leaf->dl_list; |
|---|
| .. | .. |
|---|
| 3671 | 3645 | orig_dx_leaf = (struct ocfs2_dx_leaf *) orig_dx_leaves[i]->b_data; |
|---|
| 3672 | 3646 | orig_list = &orig_dx_leaf->dl_list; |
|---|
| 3673 | 3647 | new_dx_leaf = (struct ocfs2_dx_leaf *) new_dx_leaves[i]->b_data; |
|---|
| 3674 | | - new_list = &new_dx_leaf->dl_list; |
|---|
| 3675 | 3648 | |
|---|
| 3676 | 3649 | num_used = le16_to_cpu(orig_list->de_num_used); |
|---|
| 3677 | 3650 | |
|---|
| .. | .. |
|---|
| 4420 | 4393 | int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh) |
|---|
| 4421 | 4394 | { |
|---|
| 4422 | 4395 | 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; |
|---|
| 4426 | 4399 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
|---|
| 4427 | 4400 | struct buffer_head *dx_root_bh = NULL; |
|---|
| 4428 | 4401 | struct ocfs2_dx_root_block *dx_root; |
|---|