From patchwork Wed Oct 23 05:27:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E468112B for ; Wed, 23 Oct 2019 05:28:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAFD62084C for ; Wed, 23 Oct 2019 05:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389313AbfJWF22 (ORCPT ); Wed, 23 Oct 2019 01:28:28 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:60918 "EHLO omr1.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730622AbfJWF22 (ORCPT ); Wed, 23 Oct 2019 01:28:28 -0400 Received: from mr2.cc.vt.edu (mr2.cc.vt.edu [IPv6:2607:b400:92:8400:0:90:e077:bf22]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5SNQu003418 for ; Wed, 23 Oct 2019 01:28:23 -0400 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mr2.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SI8C004972 for ; Wed, 23 Oct 2019 01:28:23 -0400 Received: by mail-qk1-f198.google.com with SMTP id z136so2644027qkb.9 for ; Tue, 22 Oct 2019 22:28:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jKyeWRSqH9KDMrwUslIqCLBGlFRwU4FLz5NzrspktIY=; b=mUnYNRf93eVDyRRsXYBPoj6H9Gfpt4lkM1BVpKrqyEdG7vgaazmjDRaOiEuQhiHF5r Rcx8Lc5J9XcvKKWWcAziRQEpj+mCjol0LlHc8k2SxmsKn/RGvLwycBoTpsQ2RbjdNlVm l1bMhTDUwJUdXkM9geV5Ma5xCTuYGH084UdZuqREs1pwS+aOm76kTB23Vvd/51kwUWzC ZIQUdmrfgSaVfDjtqURkwsYnn/Zgx9W76xpF8W2+OhZmF4tK2QO4P7phLsIxWGLPAzE2 fQF1q4tobhtYclmUIYhllbLgokQb8b1Je4ChrT1Qfb4ucOVCt4q1wVe9dAbCzH38QKsL 1vNw== X-Gm-Message-State: APjAAAXdiadagsHWQKLje37pNN3PD8j4H3E+35CTazp3cqOPCZia62f2 BPNgrCXRTzEidPhCukeYLJifrPw/NRNi0x+fVRvCnaOQ+SNV5Ii3A2B9jenm2KCeZSoUwhkaSEW EQdJk6fIxTOO1Qn9nHjNmN4/nPlcbmiLzqC7Y X-Received: by 2002:ac8:ff5:: with SMTP id f50mr7549125qtk.2.1571808497878; Tue, 22 Oct 2019 22:28:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqySnhlPkV6BMZP0zWSnQNgrYCIQctfc+Oaa9bWTmMfe7aV5gptIbNbtcIMWPtiFwZLQjeaHJw== X-Received: by 2002:ac8:ff5:: with SMTP id f50mr7549090qtk.2.1571808496993; Tue, 22 Oct 2019 22:28:16 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:15 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] staging: exfat: Clean up namespace pollution, part 1 Date: Wed, 23 Oct 2019 01:27:44 -0400 Message-Id: <20191023052752.693689-2-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Make as much as possible static. We're over-exuberant here for the benefit of a following patch, as the compiler will flag now-unused static code Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat.h | 156 ++++++++++++++--------------- drivers/staging/exfat/exfat_core.c | 142 +++++++++++++------------- 2 files changed, 149 insertions(+), 149 deletions(-) diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 3abab33e932c..0c779c8dd858 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -768,107 +768,107 @@ void buf_init(struct super_block *sb); void buf_shutdown(struct super_block *sb); int FAT_read(struct super_block *sb, u32 loc, u32 *content); s32 FAT_write(struct super_block *sb, u32 loc, u32 content); -u8 *FAT_getblk(struct super_block *sb, sector_t sec); -void FAT_modify(struct super_block *sb, sector_t sec); +static u8 *FAT_getblk(struct super_block *sb, sector_t sec); +static void FAT_modify(struct super_block *sb, sector_t sec); void FAT_release_all(struct super_block *sb); -void FAT_sync(struct super_block *sb); +static void FAT_sync(struct super_block *sb); u8 *buf_getblk(struct super_block *sb, sector_t sec); void buf_modify(struct super_block *sb, sector_t sec); void buf_lock(struct super_block *sb, sector_t sec); void buf_unlock(struct super_block *sb, sector_t sec); void buf_release(struct super_block *sb, sector_t sec); void buf_release_all(struct super_block *sb); -void buf_sync(struct super_block *sb); +static void buf_sync(struct super_block *sb); /* fs management functions */ void fs_set_vol_flags(struct super_block *sb, u32 new_flag); -void fs_error(struct super_block *sb); +static void fs_error(struct super_block *sb); /* cluster management functions */ -s32 clear_cluster(struct super_block *sb, u32 clu); -s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, +static s32 clear_cluster(struct super_block *sb, u32 clu); +static s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain); -s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, +static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain); -void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, +static void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse); -void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, +static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse); -u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain); +static u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain); s32 count_num_clusters(struct super_block *sb, struct chain_t *dir); -s32 fat_count_used_clusters(struct super_block *sb); -s32 exfat_count_used_clusters(struct super_block *sb); +static s32 fat_count_used_clusters(struct super_block *sb); +static s32 exfat_count_used_clusters(struct super_block *sb); void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); /* allocation bitmap management functions */ s32 load_alloc_bitmap(struct super_block *sb); void free_alloc_bitmap(struct super_block *sb); -s32 set_alloc_bitmap(struct super_block *sb, u32 clu); -s32 clr_alloc_bitmap(struct super_block *sb, u32 clu); -u32 test_alloc_bitmap(struct super_block *sb, u32 clu); -void sync_alloc_bitmap(struct super_block *sb); +static s32 set_alloc_bitmap(struct super_block *sb, u32 clu); +static s32 clr_alloc_bitmap(struct super_block *sb, u32 clu); +static u32 test_alloc_bitmap(struct super_block *sb, u32 clu); +static void sync_alloc_bitmap(struct super_block *sb); /* upcase table management functions */ s32 load_upcase_table(struct super_block *sb); void free_upcase_table(struct super_block *sb); /* dir entry management functions */ -u32 fat_get_entry_type(struct dentry_t *p_entry); -u32 exfat_get_entry_type(struct dentry_t *p_entry); -void fat_set_entry_type(struct dentry_t *p_entry, u32 type); -void exfat_set_entry_type(struct dentry_t *p_entry, u32 type); -u32 fat_get_entry_attr(struct dentry_t *p_entry); -u32 exfat_get_entry_attr(struct dentry_t *p_entry); -void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr); -void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr); -u8 fat_get_entry_flag(struct dentry_t *p_entry); -u8 exfat_get_entry_flag(struct dentry_t *p_entry); -void fat_set_entry_flag(struct dentry_t *p_entry, u8 flag); -void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flag); -u32 fat_get_entry_clu0(struct dentry_t *p_entry); -u32 exfat_get_entry_clu0(struct dentry_t *p_entry); -void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); -void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); -u64 fat_get_entry_size(struct dentry_t *p_entry); -u64 exfat_get_entry_size(struct dentry_t *p_entry); -void fat_set_entry_size(struct dentry_t *p_entry, u64 size); -void exfat_set_entry_size(struct dentry_t *p_entry, u64 size); +static u32 fat_get_entry_type(struct dentry_t *p_entry); +static u32 exfat_get_entry_type(struct dentry_t *p_entry); +static void fat_set_entry_type(struct dentry_t *p_entry, u32 type); +static void exfat_set_entry_type(struct dentry_t *p_entry, u32 type); +static u32 fat_get_entry_attr(struct dentry_t *p_entry); +static u32 exfat_get_entry_attr(struct dentry_t *p_entry); +static void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr); +static void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr); +static u8 fat_get_entry_flag(struct dentry_t *p_entry); +static u8 exfat_get_entry_flag(struct dentry_t *p_entry); +static void fat_set_entry_flag(struct dentry_t *p_entry, u8 flag); +static void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flag); +static u32 fat_get_entry_clu0(struct dentry_t *p_entry); +static u32 exfat_get_entry_clu0(struct dentry_t *p_entry); +static void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); +static void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); +static u64 fat_get_entry_size(struct dentry_t *p_entry); +static u64 exfat_get_entry_size(struct dentry_t *p_entry); +static void fat_set_entry_size(struct dentry_t *p_entry, u64 size); +static void exfat_set_entry_size(struct dentry_t *p_entry, u64 size); struct timestamp_t *tm_current(struct timestamp_t *tm); -void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, +static s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); -s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); -s32 fat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 fat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 num_entries, struct uni_name_t *p_uniname, struct dos_name_t *p_dosname); -s32 exfat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 num_entries, struct uni_name_t *p_uniname, struct dos_name_t *p_dosname); -void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu); -void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, +static void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu); +static void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 *uniname); -void init_file_entry(struct file_dentry_t *ep, u32 type); -void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, +static void init_file_entry(struct file_dentry_t *ep, u32 type); +static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size); -void init_name_entry(struct name_dentry_t *ep, u16 *uniname); -void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static void init_name_entry(struct name_dentry_t *ep, u16 *uniname); +static void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries); -void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries); -s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, +static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector, s32 *offset); -struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, +static struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, s32 offset); struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector); @@ -877,27 +877,27 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, u32 type, struct dentry_t **file_ep); void release_entry_set(struct entry_set_cache_t *es); -s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es); -s32 write_partial_entries_in_entry_set(struct super_block *sb, +static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es); +static s32 write_partial_entries_in_entry_set(struct super_block *sb, struct entry_set_cache_t *es, struct dentry_t *ep, u32 count); -s32 search_deleted_or_unused_entry(struct super_block *sb, +static s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries); -s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, +static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries); -s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 num_entries, struct dos_name_t *p_dosname, u32 type); -s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 num_entries, struct dos_name_t *p_dosname, u32 type); -s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, +static s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry); -s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, u32 type); -void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, +static void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, s32 entry); void update_dir_checksum_with_entry_set(struct super_block *sb, struct entry_set_cache_t *es); @@ -910,33 +910,33 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, void get_uni_name_from_dos_entry(struct super_block *sb, struct dos_dentry_t *ep, struct uni_name_t *p_uniname, u8 mode); -void fat_get_uni_name_from_ext_entry(struct super_block *sb, +static void fat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname); -void exfat_get_uni_name_from_ext_entry(struct super_block *sb, +static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname); -s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, +static s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, u16 *uniname, s32 order); -s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, +static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order); -s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, +static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, struct dos_name_t *p_dosname); -void fat_attach_count_to_dos_name(u8 *dosname, s32 count); -s32 fat_calc_num_entries(struct uni_name_t *p_uniname); -s32 exfat_calc_num_entries(struct uni_name_t *p_uniname); -u8 calc_checksum_1byte(void *data, s32 len, u8 chksum); +static void fat_attach_count_to_dos_name(u8 *dosname, s32 count); +static s32 fat_calc_num_entries(struct uni_name_t *p_uniname); +static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname); +static u8 calc_checksum_1byte(void *data, s32 len, u8 chksum); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); -u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type); +static u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type); /* name resolution functions */ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, struct uni_name_t *p_uniname); -s32 resolve_name(u8 *name, u8 **arg); +static s32 resolve_name(u8 *name, u8 **arg); /* file operation functions */ -s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); -s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); +static s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); +static s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); s32 create_dir(struct inode *inode, struct chain_t *p_dir, struct uni_name_t *p_uniname, struct file_id_t *fid); @@ -954,9 +954,9 @@ int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, bool read); int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, bool sync); -int multi_sector_read(struct super_block *sb, sector_t sec, +static int multi_sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 num_secs, bool read); -int multi_sector_write(struct super_block *sb, sector_t sec, +static int multi_sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 num_secs, bool sync); void bdev_open(struct super_block *sb); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 79174e5c4145..0260e4fe3762 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -120,7 +120,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag) } } -void fs_error(struct super_block *sb) +static void fs_error(struct super_block *sb) { struct exfat_mount_options *opts = &EXFAT_SB(sb)->options; @@ -136,7 +136,7 @@ void fs_error(struct super_block *sb) * Cluster Management Functions */ -s32 clear_cluster(struct super_block *sb, u32 clu) +static s32 clear_cluster(struct super_block *sb, u32 clu) { sector_t s, n; s32 ret = FFS_SUCCESS; @@ -167,7 +167,7 @@ s32 clear_cluster(struct super_block *sb, u32 clu) return ret; } -s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, +static s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain) { int i, num_clusters = 0; @@ -221,7 +221,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, return num_clusters; } -s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, +static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain) { s32 num_clusters = 0; @@ -300,7 +300,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, return num_clusters; } -void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, +static void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse) { s32 num_clusters = 0; @@ -341,7 +341,7 @@ void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, p_fs->used_clusters -= num_clusters; } -void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, +static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse) { s32 num_clusters = 0; @@ -400,7 +400,7 @@ void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, p_fs->used_clusters -= num_clusters; } -u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain) +static u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain) { u32 clu, next; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -447,7 +447,7 @@ s32 count_num_clusters(struct super_block *sb, struct chain_t *p_chain) return count; } -s32 fat_count_used_clusters(struct super_block *sb) +static s32 fat_count_used_clusters(struct super_block *sb) { int i, count = 0; u32 clu; @@ -463,7 +463,7 @@ s32 fat_count_used_clusters(struct super_block *sb) return count; } -s32 exfat_count_used_clusters(struct super_block *sb) +static s32 exfat_count_used_clusters(struct super_block *sb) { int i, map_i, map_b, count = 0; u8 k; @@ -589,7 +589,7 @@ void free_alloc_bitmap(struct super_block *sb) p_fs->vol_amap = NULL; } -s32 set_alloc_bitmap(struct super_block *sb, u32 clu) +static s32 set_alloc_bitmap(struct super_block *sb, u32 clu) { int i, b; sector_t sector; @@ -606,7 +606,7 @@ s32 set_alloc_bitmap(struct super_block *sb, u32 clu) return sector_write(sb, sector, p_fs->vol_amap[i], 0); } -s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) +static s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) { int i, b; sector_t sector; @@ -640,7 +640,7 @@ s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) #endif /* CONFIG_EXFAT_DISCARD */ } -u32 test_alloc_bitmap(struct super_block *sb, u32 clu) +static u32 test_alloc_bitmap(struct super_block *sb, u32 clu) { int i, map_i, map_b; u32 clu_base, clu_free; @@ -680,7 +680,7 @@ u32 test_alloc_bitmap(struct super_block *sb, u32 clu) return CLUSTER_32(~0); } -void sync_alloc_bitmap(struct super_block *sb) +static void sync_alloc_bitmap(struct super_block *sb) { int i; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -906,7 +906,7 @@ void free_upcase_table(struct super_block *sb) * Directory Entry Management Functions */ -u32 fat_get_entry_type(struct dentry_t *p_entry) +static u32 fat_get_entry_type(struct dentry_t *p_entry) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; @@ -928,7 +928,7 @@ u32 fat_get_entry_type(struct dentry_t *p_entry) return TYPE_FILE; } -u32 exfat_get_entry_type(struct dentry_t *p_entry) +static u32 exfat_get_entry_type(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -973,7 +973,7 @@ u32 exfat_get_entry_type(struct dentry_t *p_entry) return TYPE_BENIGN_SEC; } -void fat_set_entry_type(struct dentry_t *p_entry, u32 type) +static void fat_set_entry_type(struct dentry_t *p_entry, u32 type) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; @@ -996,7 +996,7 @@ void fat_set_entry_type(struct dentry_t *p_entry, u32 type) ep->attr = ATTR_ARCHIVE | ATTR_SYMLINK; } -void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) +static void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -1026,58 +1026,58 @@ void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) } } -u32 fat_get_entry_attr(struct dentry_t *p_entry) +static u32 fat_get_entry_attr(struct dentry_t *p_entry) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; return (u32)ep->attr; } -u32 exfat_get_entry_attr(struct dentry_t *p_entry) +static u32 exfat_get_entry_attr(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; return (u32)GET16_A(ep->attr); } -void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr) +static void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; ep->attr = (u8)attr; } -void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) +static void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; SET16_A(ep->attr, (u16)attr); } -u8 fat_get_entry_flag(struct dentry_t *p_entry) +static u8 fat_get_entry_flag(struct dentry_t *p_entry) { return 0x01; } -u8 exfat_get_entry_flag(struct dentry_t *p_entry) +static u8 exfat_get_entry_flag(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; return ep->flags; } -void fat_set_entry_flag(struct dentry_t *p_entry, u8 flags) +static void fat_set_entry_flag(struct dentry_t *p_entry, u8 flags) { } -void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) +static void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; ep->flags = flags; } -u32 fat_get_entry_clu0(struct dentry_t *p_entry) +static u32 fat_get_entry_clu0(struct dentry_t *p_entry) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; @@ -1085,14 +1085,14 @@ u32 fat_get_entry_clu0(struct dentry_t *p_entry) GET16_A(ep->start_clu_lo); } -u32 exfat_get_entry_clu0(struct dentry_t *p_entry) +static u32 exfat_get_entry_clu0(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; return GET32_A(ep->start_clu); } -void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) +static void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; @@ -1100,35 +1100,35 @@ void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) SET16_A(ep->start_clu_hi, CLUSTER_16(start_clu >> 16)); } -void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) +static void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; SET32_A(ep->start_clu, start_clu); } -u64 fat_get_entry_size(struct dentry_t *p_entry) +static u64 fat_get_entry_size(struct dentry_t *p_entry) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; return (u64)GET32_A(ep->size); } -u64 exfat_get_entry_size(struct dentry_t *p_entry) +static u64 exfat_get_entry_size(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; return GET64_A(ep->valid_size); } -void fat_set_entry_size(struct dentry_t *p_entry, u64 size) +static void fat_set_entry_size(struct dentry_t *p_entry, u64 size) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; SET32_A(ep->size, (u32)size); } -void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) +static void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1136,7 +1136,7 @@ void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) SET64_A(ep->size, size); } -void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { u16 t = 0x00, d = 0x21; @@ -1161,7 +1161,7 @@ void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, tp->year = (d >> 9); } -void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { u16 t = 0x00, d = 0x21; @@ -1190,7 +1190,7 @@ void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, tp->year = (d >> 9); } -void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { u16 t, d; @@ -1211,7 +1211,7 @@ void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, } } -void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { u16 t, d; @@ -1236,7 +1236,7 @@ void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, } } -s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, +static s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size) { sector_t sector; @@ -1253,7 +1253,7 @@ s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, return FFS_SUCCESS; } -s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size) { sector_t sector; @@ -1380,7 +1380,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, return FFS_SUCCESS; } -void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu) +static void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu) { struct timestamp_t tm, *tp; @@ -1396,7 +1396,7 @@ void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu) ep->create_time_ms = 0; } -void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 *uniname) +static void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 *uniname) { int i; bool end = false; @@ -1444,7 +1444,7 @@ void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 *uniname) } } -void init_file_entry(struct file_dentry_t *ep, u32 type) +static void init_file_entry(struct file_dentry_t *ep, u32 type) { struct timestamp_t tm, *tp; @@ -1459,7 +1459,7 @@ void init_file_entry(struct file_dentry_t *ep, u32 type) ep->access_time_ms = 0; } -void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size) +static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size) { exfat_set_entry_type((struct dentry_t *)ep, TYPE_STREAM); ep->flags = flags; @@ -1468,7 +1468,7 @@ void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size SET64_A(ep->size, size); } -void init_name_entry(struct name_dentry_t *ep, u16 *uniname) +static void init_name_entry(struct name_dentry_t *ep, u16 *uniname) { int i; @@ -1483,7 +1483,7 @@ void init_name_entry(struct name_dentry_t *ep, u16 *uniname) } } -void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries) { int i; @@ -1501,7 +1501,7 @@ void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, } } -void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries) { int i; @@ -1519,7 +1519,7 @@ void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, } } -void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, +static void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, s32 entry) { int i, num_entries; @@ -1601,7 +1601,7 @@ static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir, return FFS_SUCCESS; } -s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, +static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector, s32 *offset) { s32 off, ret; @@ -1633,7 +1633,7 @@ s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, return FFS_SUCCESS; } -struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, +static struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, s32 offset) { u8 *buf; @@ -1910,7 +1910,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, } /* write back all entries in entry set */ -s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) +static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) { return __write_partial_entries_in_entry_set(sb, es, es->sector, es->offset, @@ -1918,7 +1918,7 @@ s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) } /* write back some entries in entry set */ -s32 write_partial_entries_in_entry_set(struct super_block *sb, +static s32 write_partial_entries_in_entry_set(struct super_block *sb, struct entry_set_cache_t *es, struct dentry_t *ep, u32 count) { s32 ret, byte_offset, off; @@ -1957,7 +1957,7 @@ s32 write_partial_entries_in_entry_set(struct super_block *sb, } /* search EMPTY CONTINUOUS "num_entries" entries */ -s32 search_deleted_or_unused_entry(struct super_block *sb, +static s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries) { int i, dentry, num_empty = 0; @@ -2051,7 +2051,7 @@ s32 search_deleted_or_unused_entry(struct super_block *sb, return -1; } -s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries) +static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries) { s32 ret, dentry; u32 last_clu; @@ -2142,7 +2142,7 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries * -1 : (root dir, ".") it is the root dir itself * -2 : entry with the name does not exist */ -s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 num_entries, struct dos_name_t *p_dosname, u32 type) { @@ -2240,7 +2240,7 @@ s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, * -1 : (root dir, ".") it is the root dir itself * -2 : entry with the name does not exist */ -s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 num_entries, struct dos_name_t *p_dosname, u32 type) { @@ -2383,7 +2383,7 @@ s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, return -2; } -s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, +static s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry) { s32 count = 0; @@ -2413,7 +2413,7 @@ s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, return count; } -s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry) { int i, count = 0; @@ -2614,7 +2614,7 @@ void get_uni_name_from_dos_entry(struct super_block *sb, nls_dosname_to_uniname(sb, p_uniname, &dos_name); } -void fat_get_uni_name_from_ext_entry(struct super_block *sb, +static void fat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname) { @@ -2641,7 +2641,7 @@ void fat_get_uni_name_from_ext_entry(struct super_block *sb, } } -void exfat_get_uni_name_from_ext_entry(struct super_block *sb, +static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname) { @@ -2678,7 +2678,7 @@ void exfat_get_uni_name_from_ext_entry(struct super_block *sb, release_entry_set(es); } -s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, u16 *uniname, +static s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, u16 *uniname, s32 order) { int i, len = 0; @@ -2723,7 +2723,7 @@ s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, u16 *uniname, return len; } -s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, +static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order) { int i, len = 0; @@ -2740,7 +2740,7 @@ s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, return len; } -s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, +static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, struct dos_name_t *p_dosname) { int i, j, count = 0; @@ -2835,7 +2835,7 @@ s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, return FFS_SUCCESS; } -void fat_attach_count_to_dos_name(u8 *dosname, s32 count) +static void fat_attach_count_to_dos_name(u8 *dosname, s32 count) { int i, j, length; char str_count[6]; @@ -2862,7 +2862,7 @@ void fat_attach_count_to_dos_name(u8 *dosname, s32 count) dosname[7] = ' '; } -s32 fat_calc_num_entries(struct uni_name_t *p_uniname) +static s32 fat_calc_num_entries(struct uni_name_t *p_uniname) { s32 len; @@ -2874,7 +2874,7 @@ s32 fat_calc_num_entries(struct uni_name_t *p_uniname) return (len - 1) / 13 + 2; } -s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) +static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) { s32 len; @@ -2886,7 +2886,7 @@ s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) return (len - 1) / 15 + 3; } -u8 calc_checksum_1byte(void *data, s32 len, u8 chksum) +static u8 calc_checksum_1byte(void *data, s32 len, u8 chksum) { int i; u8 *c = (u8 *)data; @@ -2921,7 +2921,7 @@ u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type) return chksum; } -u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type) +static u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type) { int i; u8 *c = (u8 *)data; @@ -3007,7 +3007,7 @@ static struct fs_func fat_fs_func = { .set_entry_time = fat_set_entry_time, }; -s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) +static s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) { s32 num_reserved, num_root_sectors; struct bpb16_t *p_bpb = (struct bpb16_t *)p_pbr->bpb; @@ -3069,7 +3069,7 @@ s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) return FFS_SUCCESS; } -s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) +static s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) { s32 num_reserved; struct bpb32_t *p_bpb = (struct bpb32_t *)p_pbr->bpb; @@ -3649,7 +3649,7 @@ int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, return ret; } -int multi_sector_read(struct super_block *sb, sector_t sec, +static int multi_sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 num_secs, bool read) { s32 ret = FFS_MEDIAERR; @@ -3672,7 +3672,7 @@ int multi_sector_read(struct super_block *sb, sector_t sec, return ret; } -int multi_sector_write(struct super_block *sb, sector_t sec, +static int multi_sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 num_secs, bool sync) { s32 ret = FFS_MEDIAERR; From patchwork Wed Oct 23 05:27:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D3CA14E5 for ; Wed, 23 Oct 2019 05:28:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55A4521925 for ; Wed, 23 Oct 2019 05:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389315AbfJWF22 (ORCPT ); Wed, 23 Oct 2019 01:28:28 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:44828 "EHLO omr2.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389237AbfJWF22 (ORCPT ); Wed, 23 Oct 2019 01:28:28 -0400 Received: from mr4.cc.vt.edu (mr4.cc.vt.edu [IPv6:2607:b400:92:8300:0:7b:e2b1:6a29]) by omr2.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5SRUZ019982 for ; Wed, 23 Oct 2019 01:28:27 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mr4.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SMI8021384 for ; Wed, 23 Oct 2019 01:28:27 -0400 Received: by mail-qt1-f200.google.com with SMTP id h20so20088292qto.7 for ; Tue, 22 Oct 2019 22:28:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MqAbiLur5D+uHRypbIqnaB77RhB+Sc+h3HCzI8vBmBo=; b=bOLsbptARZ57KO6Zc2kUmOaauu00Pvxcaf0NJcDY/QH2ktwV3YxCNpPNNThASeBYmL e81x60ahztFTYCSRQWKp4jBih5AgTAjWfzYt2UIE30ccxqHWYN4k8nHwOgmI96/Gbt67 Vzl9c3MDTLJd0Cg6Nvs2KLjxkC6uwhMg+wo0G4DSnvHVH2bKF+l2VlxVZAD2LGpD9Z6g fI7v5BfeYvJSeiEHOnZHYvHnQx1k3UBkCDS0hZBp2+w3yQLnZkybfQpykYZsrg7I2zQa NgNZBrHbzt6zRjT+TsHUdLCfjx+rsgGZC7CZ8BYh+z5v3PVYghumHboEDsCbtLPg7S// OWLQ== X-Gm-Message-State: APjAAAWWT8LEp2+gfiQGRDuoumuq/ttcRX6zYYRTsO1LczyAe/WOxm1v ArY7cvUgV44T5kFmjAWXTu7ePx94ONEXSy23tVRCqmsD1zAM0IfFAcC6XmuuLFLLBRPz47CVGsd QY/pQ2Yb/lZuB0h26Uas9FKp0MJlCj8irG+dk X-Received: by 2002:ac8:4656:: with SMTP id f22mr7280164qto.154.1571808501485; Tue, 22 Oct 2019 22:28:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZvkG+dshyYHrPEOmZevnuiQhqYv0WRghnxRFA7+eghHmtEmvEoAeToM1QjGH3Vgj+KQqdng== X-Received: by 2002:ac8:4656:: with SMTP id f22mr7280145qto.154.1571808501087; Tue, 22 Oct 2019 22:28:21 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:19 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] staging: exfat: Remove FAT/VFAT mount support, part 1 Date: Wed, 23 Oct 2019 01:27:45 -0400 Message-Id: <20191023052752.693689-3-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove the top-level mount functionality, to make this driver handle only exfat file systems. Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/Kconfig | 9 -- drivers/staging/exfat/exfat.h | 2 - drivers/staging/exfat/exfat_core.c | 142 ---------------------------- drivers/staging/exfat/exfat_super.c | 8 +- 4 files changed, 1 insertion(+), 160 deletions(-) diff --git a/drivers/staging/exfat/Kconfig b/drivers/staging/exfat/Kconfig index ce32dfe33bec..0130019cbec2 100644 --- a/drivers/staging/exfat/Kconfig +++ b/drivers/staging/exfat/Kconfig @@ -6,15 +6,6 @@ config EXFAT_FS help This adds support for the exFAT file system. -config EXFAT_DONT_MOUNT_VFAT - bool "Prohibit mounting of fat/vfat filesystems by exFAT" - depends on EXFAT_FS - default y - help - By default, the exFAT driver will only mount exFAT filesystems, and refuse - to mount fat/vfat filesystems. Set this to 'n' to allow the exFAT driver - to mount these filesystems. - config EXFAT_DISCARD bool "enable discard support" depends on EXFAT_FS diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 0c779c8dd858..c2db3e9e9785 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -935,8 +935,6 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, static s32 resolve_name(u8 *name, u8 **arg); /* file operation functions */ -static s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); -static s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); s32 create_dir(struct inode *inode, struct chain_t *p_dir, struct uni_name_t *p_uniname, struct file_id_t *fid); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 0260e4fe3762..fd481b21f8b6 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -2980,148 +2980,6 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, /* * File Operation Functions */ -static struct fs_func fat_fs_func = { - .alloc_cluster = fat_alloc_cluster, - .free_cluster = fat_free_cluster, - .count_used_clusters = fat_count_used_clusters, - - .init_dir_entry = fat_init_dir_entry, - .init_ext_entry = fat_init_ext_entry, - .find_dir_entry = fat_find_dir_entry, - .delete_dir_entry = fat_delete_dir_entry, - .get_uni_name_from_ext_entry = fat_get_uni_name_from_ext_entry, - .count_ext_entries = fat_count_ext_entries, - .calc_num_entries = fat_calc_num_entries, - - .get_entry_type = fat_get_entry_type, - .set_entry_type = fat_set_entry_type, - .get_entry_attr = fat_get_entry_attr, - .set_entry_attr = fat_set_entry_attr, - .get_entry_flag = fat_get_entry_flag, - .set_entry_flag = fat_set_entry_flag, - .get_entry_clu0 = fat_get_entry_clu0, - .set_entry_clu0 = fat_set_entry_clu0, - .get_entry_size = fat_get_entry_size, - .set_entry_size = fat_set_entry_size, - .get_entry_time = fat_get_entry_time, - .set_entry_time = fat_set_entry_time, -}; - -static s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) -{ - s32 num_reserved, num_root_sectors; - struct bpb16_t *p_bpb = (struct bpb16_t *)p_pbr->bpb; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - if (p_bpb->num_fats == 0) - return FFS_FORMATERR; - - num_root_sectors = GET16(p_bpb->num_root_entries) << DENTRY_SIZE_BITS; - num_root_sectors = ((num_root_sectors - 1) >> - p_bd->sector_size_bits) + 1; - - p_fs->sectors_per_clu = p_bpb->sectors_per_clu; - p_fs->sectors_per_clu_bits = ilog2(p_bpb->sectors_per_clu); - p_fs->cluster_size_bits = p_fs->sectors_per_clu_bits + - p_bd->sector_size_bits; - p_fs->cluster_size = 1 << p_fs->cluster_size_bits; - - p_fs->num_FAT_sectors = GET16(p_bpb->num_fat_sectors); - - p_fs->FAT1_start_sector = p_fs->PBR_sector + GET16(p_bpb->num_reserved); - if (p_bpb->num_fats == 1) - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector; - else - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector + - p_fs->num_FAT_sectors; - - p_fs->root_start_sector = p_fs->FAT2_start_sector + - p_fs->num_FAT_sectors; - p_fs->data_start_sector = p_fs->root_start_sector + num_root_sectors; - - p_fs->num_sectors = GET16(p_bpb->num_sectors); - if (p_fs->num_sectors == 0) - p_fs->num_sectors = GET32(p_bpb->num_huge_sectors); - - num_reserved = p_fs->data_start_sector - p_fs->PBR_sector; - p_fs->num_clusters = ((p_fs->num_sectors - num_reserved) >> - p_fs->sectors_per_clu_bits) + 2; - /* because the cluster index starts with 2 */ - - if (p_fs->num_clusters < FAT12_THRESHOLD) - p_fs->vol_type = FAT12; - else - p_fs->vol_type = FAT16; - p_fs->vol_id = GET32(p_bpb->vol_serial); - - p_fs->root_dir = 0; - p_fs->dentries_in_root = GET16(p_bpb->num_root_entries); - p_fs->dentries_per_clu = 1 << (p_fs->cluster_size_bits - - DENTRY_SIZE_BITS); - - p_fs->vol_flag = VOL_CLEAN; - p_fs->clu_srch_ptr = 2; - p_fs->used_clusters = UINT_MAX; - - p_fs->fs_func = &fat_fs_func; - - return FFS_SUCCESS; -} - -static s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) -{ - s32 num_reserved; - struct bpb32_t *p_bpb = (struct bpb32_t *)p_pbr->bpb; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - if (p_bpb->num_fats == 0) - return FFS_FORMATERR; - - p_fs->sectors_per_clu = p_bpb->sectors_per_clu; - p_fs->sectors_per_clu_bits = ilog2(p_bpb->sectors_per_clu); - p_fs->cluster_size_bits = p_fs->sectors_per_clu_bits + - p_bd->sector_size_bits; - p_fs->cluster_size = 1 << p_fs->cluster_size_bits; - - p_fs->num_FAT_sectors = GET32(p_bpb->num_fat32_sectors); - - p_fs->FAT1_start_sector = p_fs->PBR_sector + GET16(p_bpb->num_reserved); - if (p_bpb->num_fats == 1) - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector; - else - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector + - p_fs->num_FAT_sectors; - - p_fs->root_start_sector = p_fs->FAT2_start_sector + - p_fs->num_FAT_sectors; - p_fs->data_start_sector = p_fs->root_start_sector; - - p_fs->num_sectors = GET32(p_bpb->num_huge_sectors); - num_reserved = p_fs->data_start_sector - p_fs->PBR_sector; - - p_fs->num_clusters = ((p_fs->num_sectors - num_reserved) >> - p_fs->sectors_per_clu_bits) + 2; - /* because the cluster index starts with 2 */ - - p_fs->vol_type = FAT32; - p_fs->vol_id = GET32(p_bpb->vol_serial); - - p_fs->root_dir = GET32(p_bpb->root_cluster); - p_fs->dentries_in_root = 0; - p_fs->dentries_per_clu = 1 << (p_fs->cluster_size_bits - - DENTRY_SIZE_BITS); - - p_fs->vol_flag = VOL_CLEAN; - p_fs->clu_srch_ptr = 2; - p_fs->used_clusters = UINT_MAX; - - p_fs->fs_func = &fat_fs_func; - - return FFS_SUCCESS; -} - static struct fs_func exfat_fs_func = { .alloc_cluster = exfat_alloc_cluster, .free_cluster = exfat_free_cluster, diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 86ace780a60b..0264be92c2be 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -394,16 +394,10 @@ static int ffsMountVol(struct super_block *sb) break; if (i < 53) { -#ifdef CONFIG_EXFAT_DONT_MOUNT_VFAT + /* Not sure how we'd get here, but complain if it does */ ret = -EINVAL; printk(KERN_INFO "EXFAT: Attempted to mount VFAT filesystem\n"); goto out; -#else - if (GET16(p_pbr->bpb + 11)) /* num_fat_sectors */ - ret = fat16_mount(sb, p_pbr); - else - ret = fat32_mount(sb, p_pbr); -#endif } else { ret = exfat_mount(sb, p_pbr); } From patchwork Wed Oct 23 05:27:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5324313BD for ; Wed, 23 Oct 2019 05:28:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 154F921920 for ; Wed, 23 Oct 2019 05:28:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389401AbfJWF2e (ORCPT ); Wed, 23 Oct 2019 01:28:34 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:44840 "EHLO omr2.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388504AbfJWF2e (ORCPT ); Wed, 23 Oct 2019 01:28:34 -0400 Received: from mr4.cc.vt.edu (mr4.cc.ipv6.vt.edu [IPv6:2607:b400:92:8300:0:7b:e2b1:6a29]) by omr2.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5SVfF019994 for ; Wed, 23 Oct 2019 01:28:31 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mr4.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SQ12021421 for ; Wed, 23 Oct 2019 01:28:31 -0400 Received: by mail-qt1-f200.google.com with SMTP id i25so13201591qtm.17 for ; Tue, 22 Oct 2019 22:28:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=kh/ZJY/e2Y38o2eaan9Rvm9EAE1dWaen+LESE1jJOX4=; b=c+T2p6r8AQEYGQ7310hAK0FZbGFFTthVNhZwudj8thJ2GBWME0m7cahHmdkrRYqPWo DPpaap7zB2sLNDzzFmJqMu2WAg1KZapQVcoSWpyYTmD42HmGiWaNgDsj3rNUgRVanAyR OwQ6EuZRySgKxFcm0jttdp2Wi1YDk7jreg79QsWh5bUuO6QbejvFOi3CPfsPoY29H9jQ d5nUtxtCXXVskNz70ERfKJqeObM6R+6xUfY8GWevYu0FCAHDs/iROQKB2tLDY8/fFADC y3ZIvLDd3Oak7YWXk2ZJNu2N3C7cDWwetSABUYyTk5dgLyPXFVy7ZccMMRFVCYZRMk1a Q+Vg== X-Gm-Message-State: APjAAAVLjaJo2Pu9ZzmxYOJHH5PifuZk+K7QBApRx9MbgvzeMbRq2QTg L9abGtqkEyvh+qTNMEWFOSh+xbu2uWVCGJSKbVR7s9KdlEV2ZDrwrDqw7SIOhY4Qfw7eGKXH6Oj lJ0bRVpl5UBdY6SJWEUpvlLwHCUbHX82gIrdG X-Received: by 2002:a0c:8b57:: with SMTP id d23mr7188295qvc.159.1571808506282; Tue, 22 Oct 2019 22:28:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMVCKNzOT1zlLMXmJMHac4KZPXgN8rWCxjeV79nCLovSww7QToN82lsm5YPWziQVvhD6a5zQ== X-Received: by 2002:a0c:8b57:: with SMTP id d23mr7188250qvc.159.1571808505257; Tue, 22 Oct 2019 22:28:25 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:24 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] staging: exfat: Remove FAT/VFAT mount support, part 2 Date: Wed, 23 Oct 2019 01:27:46 -0400 Message-Id: <20191023052752.693689-4-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove no longer referenced FAT/VFAT routines. Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat.h | 49 +- drivers/staging/exfat/exfat_core.c | 755 ----------------------------- 2 files changed, 2 insertions(+), 802 deletions(-) diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index c2db3e9e9785..9cd78b6417d0 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -786,17 +786,12 @@ static void fs_error(struct super_block *sb); /* cluster management functions */ static s32 clear_cluster(struct super_block *sb, u32 clu); -static s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, - struct chain_t *p_chain); static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain); -static void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, - s32 do_relse); static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse); static u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain); s32 count_num_clusters(struct super_block *sb, struct chain_t *dir); -static s32 fat_count_used_clusters(struct super_block *sb); static s32 exfat_count_used_clusters(struct super_block *sb); void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); @@ -813,63 +808,36 @@ s32 load_upcase_table(struct super_block *sb); void free_upcase_table(struct super_block *sb); /* dir entry management functions */ -static u32 fat_get_entry_type(struct dentry_t *p_entry); static u32 exfat_get_entry_type(struct dentry_t *p_entry); -static void fat_set_entry_type(struct dentry_t *p_entry, u32 type); static void exfat_set_entry_type(struct dentry_t *p_entry, u32 type); -static u32 fat_get_entry_attr(struct dentry_t *p_entry); static u32 exfat_get_entry_attr(struct dentry_t *p_entry); -static void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr); static void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr); -static u8 fat_get_entry_flag(struct dentry_t *p_entry); static u8 exfat_get_entry_flag(struct dentry_t *p_entry); -static void fat_set_entry_flag(struct dentry_t *p_entry, u8 flag); static void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flag); -static u32 fat_get_entry_clu0(struct dentry_t *p_entry); static u32 exfat_get_entry_clu0(struct dentry_t *p_entry); -static void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); static void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); -static u64 fat_get_entry_size(struct dentry_t *p_entry); static u64 exfat_get_entry_size(struct dentry_t *p_entry); -static void fat_set_entry_size(struct dentry_t *p_entry, u64 size); static void exfat_set_entry_size(struct dentry_t *p_entry, u64 size); struct timestamp_t *tm_current(struct timestamp_t *tm); -static void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); static void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -static void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -static s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, - u32 type, u32 start_clu, u64 size); static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); -static s32 fat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 num_entries, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname); static s32 exfat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 num_entries, struct uni_name_t *p_uniname, struct dos_name_t *p_dosname); -static void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu); -static void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, - u16 *uniname); static void init_file_entry(struct file_dentry_t *ep, u32 type); static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size); static void init_name_entry(struct name_dentry_t *ep, u16 *uniname); -static void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 order, s32 num_entries); static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries); static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector, s32 *offset); -static struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, - s32 offset); struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector); struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, @@ -885,14 +853,9 @@ static s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries); static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries); -static s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, - struct uni_name_t *p_uniname, s32 num_entries, - struct dos_name_t *p_dosname, u32 type); static s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 num_entries, struct dos_name_t *p_dosname, u32 type); -static s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, - s32 entry, struct dentry_t *p_entry); static s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, @@ -916,18 +879,14 @@ static void fat_get_uni_name_from_ext_entry(struct super_block *sb, static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname); -static s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, - u16 *uniname, s32 order); -static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, - u16 *uniname, s32 order); +static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, + s32 order); static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, struct dos_name_t *p_dosname); static void fat_attach_count_to_dos_name(u8 *dosname, s32 count); static s32 fat_calc_num_entries(struct uni_name_t *p_uniname); static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname); -static u8 calc_checksum_1byte(void *data, s32 len, u8 chksum); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); -static u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type); /* name resolution functions */ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, @@ -952,10 +911,6 @@ int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, bool read); int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, bool sync); -static int multi_sector_read(struct super_block *sb, sector_t sec, - struct buffer_head **bh, s32 num_secs, bool read); -static int multi_sector_write(struct super_block *sb, sector_t sec, - struct buffer_head *bh, s32 num_secs, bool sync); void bdev_open(struct super_block *sb); void bdev_close(struct super_block *sb); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index fd481b21f8b6..dd69a9a6dddc 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -167,60 +167,6 @@ static s32 clear_cluster(struct super_block *sb, u32 clu) return ret; } -static s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, - struct chain_t *p_chain) -{ - int i, num_clusters = 0; - u32 new_clu, last_clu = CLUSTER_32(~0), read_clu; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - new_clu = p_chain->dir; - if (new_clu == CLUSTER_32(~0)) - new_clu = p_fs->clu_srch_ptr; - else if (new_clu >= p_fs->num_clusters) - new_clu = 2; - - __set_sb_dirty(sb); - - p_chain->dir = CLUSTER_32(~0); - - for (i = 2; i < p_fs->num_clusters; i++) { - if (FAT_read(sb, new_clu, &read_clu) != 0) - return -1; - - if (read_clu == CLUSTER_32(0)) { - if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0) - return -1; - num_clusters++; - - if (p_chain->dir == CLUSTER_32(~0)) { - p_chain->dir = new_clu; - } else { - if (FAT_write(sb, last_clu, new_clu) < 0) - return -1; - } - - last_clu = new_clu; - - if ((--num_alloc) == 0) { - p_fs->clu_srch_ptr = new_clu; - if (p_fs->used_clusters != UINT_MAX) - p_fs->used_clusters += num_clusters; - - return num_clusters; - } - } - if ((++new_clu) >= p_fs->num_clusters) - new_clu = 2; - } - - p_fs->clu_srch_ptr = new_clu; - if (p_fs->used_clusters != UINT_MAX) - p_fs->used_clusters += num_clusters; - - return num_clusters; -} - static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain) { @@ -300,47 +246,6 @@ static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, return num_clusters; } -static void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, - s32 do_relse) -{ - s32 num_clusters = 0; - u32 clu, prev; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - int i; - sector_t sector; - - if ((p_chain->dir == CLUSTER_32(0)) || (p_chain->dir == CLUSTER_32(~0))) - return; - __set_sb_dirty(sb); - clu = p_chain->dir; - - if (p_chain->size <= 0) - return; - - do { - if (p_fs->dev_ejected) - break; - - if (do_relse) { - sector = START_SECTOR(clu); - for (i = 0; i < p_fs->sectors_per_clu; i++) - buf_release(sb, sector + i); - } - - prev = clu; - if (FAT_read(sb, clu, &clu) == -1) - break; - - if (FAT_write(sb, prev, CLUSTER_32(0)) < 0) - break; - num_clusters++; - - } while (clu != CLUSTER_32(~0)); - - if (p_fs->used_clusters != UINT_MAX) - p_fs->used_clusters -= num_clusters; -} - static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse) { @@ -447,22 +352,6 @@ s32 count_num_clusters(struct super_block *sb, struct chain_t *p_chain) return count; } -static s32 fat_count_used_clusters(struct super_block *sb) -{ - int i, count = 0; - u32 clu; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - for (i = 2; i < p_fs->num_clusters; i++) { - if (FAT_read(sb, i, &clu) != 0) - break; - if (clu != CLUSTER_32(0)) - count++; - } - - return count; -} - static s32 exfat_count_used_clusters(struct super_block *sb) { int i, map_i, map_b, count = 0; @@ -906,28 +795,6 @@ void free_upcase_table(struct super_block *sb) * Directory Entry Management Functions */ -static u32 fat_get_entry_type(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - if (*(ep->name) == 0x0) - return TYPE_UNUSED; - - else if (*(ep->name) == 0xE5) - return TYPE_DELETED; - - else if (ep->attr == ATTR_EXTEND) - return TYPE_EXTEND; - - else if ((ep->attr & (ATTR_SUBDIR | ATTR_VOLUME)) == ATTR_VOLUME) - return TYPE_VOLUME; - - else if ((ep->attr & (ATTR_SUBDIR | ATTR_VOLUME)) == ATTR_SUBDIR) - return TYPE_DIR; - - return TYPE_FILE; -} - static u32 exfat_get_entry_type(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -973,29 +840,6 @@ static u32 exfat_get_entry_type(struct dentry_t *p_entry) return TYPE_BENIGN_SEC; } -static void fat_set_entry_type(struct dentry_t *p_entry, u32 type) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - if (type == TYPE_UNUSED) - *(ep->name) = 0x0; - - else if (type == TYPE_DELETED) - *(ep->name) = 0xE5; - - else if (type == TYPE_EXTEND) - ep->attr = ATTR_EXTEND; - - else if (type == TYPE_DIR) - ep->attr = ATTR_SUBDIR; - - else if (type == TYPE_FILE) - ep->attr = ATTR_ARCHIVE; - - else if (type == TYPE_SYMLINK) - ep->attr = ATTR_ARCHIVE | ATTR_SYMLINK; -} - static void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -1026,13 +870,6 @@ static void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) } } -static u32 fat_get_entry_attr(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - return (u32)ep->attr; -} - static u32 exfat_get_entry_attr(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -1040,13 +877,6 @@ static u32 exfat_get_entry_attr(struct dentry_t *p_entry) return (u32)GET16_A(ep->attr); } -static void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - ep->attr = (u8)attr; -} - static void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -1054,11 +884,6 @@ static void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) SET16_A(ep->attr, (u16)attr); } -static u8 fat_get_entry_flag(struct dentry_t *p_entry) -{ - return 0x01; -} - static u8 exfat_get_entry_flag(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1066,10 +891,6 @@ static u8 exfat_get_entry_flag(struct dentry_t *p_entry) return ep->flags; } -static void fat_set_entry_flag(struct dentry_t *p_entry, u8 flags) -{ -} - static void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1077,14 +898,6 @@ static void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) ep->flags = flags; } -static u32 fat_get_entry_clu0(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - return ((u32)GET16_A(ep->start_clu_hi) << 16) | - GET16_A(ep->start_clu_lo); -} - static u32 exfat_get_entry_clu0(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1092,14 +905,6 @@ static u32 exfat_get_entry_clu0(struct dentry_t *p_entry) return GET32_A(ep->start_clu); } -static void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - SET16_A(ep->start_clu_lo, CLUSTER_16(start_clu)); - SET16_A(ep->start_clu_hi, CLUSTER_16(start_clu >> 16)); -} - static void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1107,13 +912,6 @@ static void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) SET32_A(ep->start_clu, start_clu); } -static u64 fat_get_entry_size(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - return (u64)GET32_A(ep->size); -} - static u64 exfat_get_entry_size(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1121,13 +919,6 @@ static u64 exfat_get_entry_size(struct dentry_t *p_entry) return GET64_A(ep->valid_size); } -static void fat_set_entry_size(struct dentry_t *p_entry, u64 size) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - SET32_A(ep->size, (u32)size); -} - static void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1136,31 +927,6 @@ static void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) SET64_A(ep->size, size); } -static void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode) -{ - u16 t = 0x00, d = 0x21; - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - switch (mode) { - case TM_CREATE: - t = GET16_A(ep->create_time); - d = GET16_A(ep->create_date); - break; - case TM_MODIFY: - t = GET16_A(ep->modify_time); - d = GET16_A(ep->modify_date); - break; - } - - tp->sec = (t & 0x001F) << 1; - tp->min = (t >> 5) & 0x003F; - tp->hour = (t >> 11); - tp->day = (d & 0x001F); - tp->mon = (d >> 5) & 0x000F; - tp->year = (d >> 9); -} - static void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { @@ -1190,27 +956,6 @@ static void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *t tp->year = (d >> 9); } -static void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode) -{ - u16 t, d; - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1); - d = (tp->year << 9) | (tp->mon << 5) | tp->day; - - switch (mode) { - case TM_CREATE: - SET16_A(ep->create_time, t); - SET16_A(ep->create_date, d); - break; - case TM_MODIFY: - SET16_A(ep->modify_time, t); - SET16_A(ep->modify_date, d); - break; - } -} - static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { @@ -1236,23 +981,6 @@ static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *t } } -static s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, - u32 type, u32 start_clu, u64 size) -{ - sector_t sector; - struct dos_dentry_t *dos_ep; - - dos_ep = (struct dos_dentry_t *)get_entry_in_dir(sb, p_dir, entry, - §or); - if (!dos_ep) - return FFS_MEDIAERR; - - init_dos_entry(dos_ep, type, start_clu); - buf_modify(sb, sector); - - return FFS_SUCCESS; -} - static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size) { @@ -1283,57 +1011,6 @@ static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, return FFS_SUCCESS; } -static s32 fat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 num_entries, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname) -{ - int i; - sector_t sector; - u8 chksum; - u16 *uniname = p_uniname->name; - struct dos_dentry_t *dos_ep; - struct ext_dentry_t *ext_ep; - - dos_ep = (struct dos_dentry_t *)get_entry_in_dir(sb, p_dir, entry, - §or); - if (!dos_ep) - return FFS_MEDIAERR; - - dos_ep->lcase = p_dosname->name_case; - memcpy(dos_ep->name, p_dosname->name, DOS_NAME_LENGTH); - buf_modify(sb, sector); - - if ((--num_entries) > 0) { - chksum = calc_checksum_1byte((void *)dos_ep->name, - DOS_NAME_LENGTH, 0); - - for (i = 1; i < num_entries; i++) { - ext_ep = (struct ext_dentry_t *)get_entry_in_dir(sb, - p_dir, - entry - i, - §or); - if (!ext_ep) - return FFS_MEDIAERR; - - init_ext_entry(ext_ep, i, chksum, uniname); - buf_modify(sb, sector); - uniname += 13; - } - - ext_ep = (struct ext_dentry_t *)get_entry_in_dir(sb, p_dir, - entry - i, - §or); - if (!ext_ep) - return FFS_MEDIAERR; - - init_ext_entry(ext_ep, i + 0x40, chksum, uniname); - buf_modify(sb, sector); - } - - return FFS_SUCCESS; -} - static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 num_entries, struct uni_name_t *p_uniname, @@ -1380,70 +1057,6 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, return FFS_SUCCESS; } -static void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu) -{ - struct timestamp_t tm, *tp; - - fat_set_entry_type((struct dentry_t *)ep, type); - SET16_A(ep->start_clu_lo, CLUSTER_16(start_clu)); - SET16_A(ep->start_clu_hi, CLUSTER_16(start_clu >> 16)); - SET32_A(ep->size, 0); - - tp = tm_current(&tm); - fat_set_entry_time((struct dentry_t *)ep, tp, TM_CREATE); - fat_set_entry_time((struct dentry_t *)ep, tp, TM_MODIFY); - SET16_A(ep->access_date, 0); - ep->create_time_ms = 0; -} - -static void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 *uniname) -{ - int i; - bool end = false; - - fat_set_entry_type((struct dentry_t *)ep, TYPE_EXTEND); - ep->order = (u8)order; - ep->sysid = 0; - ep->checksum = chksum; - SET16_A(ep->start_clu, 0); - - for (i = 0; i < 10; i += 2) { - if (!end) { - SET16(ep->unicode_0_4 + i, *uniname); - if (*uniname == 0x0) - end = true; - else - uniname++; - } else { - SET16(ep->unicode_0_4 + i, 0xFFFF); - } - } - - for (i = 0; i < 12; i += 2) { - if (!end) { - SET16_A(ep->unicode_5_10 + i, *uniname); - if (*uniname == 0x0) - end = true; - else - uniname++; - } else { - SET16_A(ep->unicode_5_10 + i, 0xFFFF); - } - } - - for (i = 0; i < 4; i += 2) { - if (!end) { - SET16_A(ep->unicode_11_12 + i, *uniname); - if (*uniname == 0x0) - end = true; - else - uniname++; - } else { - SET16_A(ep->unicode_11_12 + i, 0xFFFF); - } - } -} - static void init_file_entry(struct file_dentry_t *ep, u32 type) { struct timestamp_t tm, *tp; @@ -1483,24 +1096,6 @@ static void init_name_entry(struct name_dentry_t *ep, u16 *uniname) } } -static void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 order, s32 num_entries) -{ - int i; - sector_t sector; - struct dentry_t *ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - for (i = num_entries - 1; i >= order; i--) { - ep = get_entry_in_dir(sb, p_dir, entry - i, §or); - if (!ep) - return; - - p_fs->fs_func->set_entry_type(ep, TYPE_DELETED); - buf_modify(sb, sector); - } -} - static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries) { @@ -1633,19 +1228,6 @@ static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entr return FFS_SUCCESS; } -static struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, - s32 offset) -{ - u8 *buf; - - buf = buf_getblk(sb, sector); - - if (!buf) - return NULL; - - return (struct dentry_t *)(buf + offset); -} - struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector) { @@ -1917,45 +1499,6 @@ static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_ es->num_entries); } -/* write back some entries in entry set */ -static s32 write_partial_entries_in_entry_set(struct super_block *sb, - struct entry_set_cache_t *es, struct dentry_t *ep, u32 count) -{ - s32 ret, byte_offset, off; - u32 clu = 0; - sector_t sec; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - struct chain_t dir; - - /* vaidity check */ - if (ep + count > ((struct dentry_t *)&(es->__buf)) + es->num_entries) - return FFS_ERROR; - - dir.dir = GET_CLUSTER_FROM_SECTOR(es->sector); - dir.flags = es->alloc_flag; - dir.size = 0xffffffff; /* XXX */ - - byte_offset = (es->sector - START_SECTOR(dir.dir)) << - p_bd->sector_size_bits; - byte_offset += ((void **)ep - &(es->__buf)) + es->offset; - - ret = _walk_fat_chain(sb, &dir, byte_offset, &clu); - if (ret != FFS_SUCCESS) - return ret; - - /* byte offset in cluster */ - byte_offset &= p_fs->cluster_size - 1; - - /* byte offset in sector */ - off = byte_offset & p_bd->sector_size_mask; - - /* sector offset in cluster */ - sec = byte_offset >> p_bd->sector_size_bits; - sec += START_SECTOR(clu); - return __write_partial_entries_in_entry_set(sb, es, sec, off, count); -} - /* search EMPTY CONTINUOUS "num_entries" entries */ static s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries) @@ -2137,104 +1680,6 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_ return dentry; } -/* return values of fat_find_dir_entry() - * >= 0 : return dir entiry position with the name in dir - * -1 : (root dir, ".") it is the root dir itself - * -2 : entry with the name does not exist - */ -static s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, - struct uni_name_t *p_uniname, s32 num_entries, - struct dos_name_t *p_dosname, u32 type) -{ - int i, dentry = 0, len; - s32 order = 0; - bool is_feasible_entry = true, has_ext_entry = false; - s32 dentries_per_clu; - u32 entry_type; - u16 entry_uniname[14], *uniname = NULL, unichar; - struct chain_t clu; - struct dentry_t *ep; - struct dos_dentry_t *dos_ep; - struct ext_dentry_t *ext_ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - if (p_dir->dir == p_fs->root_dir) { - if ((!nls_uniname_cmp(sb, p_uniname->name, - (u16 *)UNI_CUR_DIR_NAME)) || - (!nls_uniname_cmp(sb, p_uniname->name, - (u16 *)UNI_PAR_DIR_NAME))) - return -1; // special case, root directory itself - } - - if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */ - dentries_per_clu = p_fs->dentries_in_root; - else - dentries_per_clu = p_fs->dentries_per_clu; - - clu.dir = p_dir->dir; - clu.flags = p_dir->flags; - - while (clu.dir != CLUSTER_32(~0)) { - if (p_fs->dev_ejected) - break; - - for (i = 0; i < dentries_per_clu; i++, dentry++) { - ep = get_entry_in_dir(sb, &clu, i, NULL); - if (!ep) - return -2; - - entry_type = p_fs->fs_func->get_entry_type(ep); - - if ((entry_type == TYPE_FILE) || (entry_type == TYPE_DIR)) { - if ((type == TYPE_ALL) || (type == entry_type)) { - if (is_feasible_entry && has_ext_entry) - return dentry; - - dos_ep = (struct dos_dentry_t *)ep; - if (!nls_dosname_cmp(sb, p_dosname->name, dos_ep->name)) - return dentry; - } - is_feasible_entry = true; - has_ext_entry = false; - } else if (entry_type == TYPE_EXTEND) { - if (is_feasible_entry) { - ext_ep = (struct ext_dentry_t *)ep; - if (ext_ep->order > 0x40) { - order = (s32)(ext_ep->order - 0x40); - uniname = p_uniname->name + 13 * (order - 1); - } else { - order = (s32)ext_ep->order; - uniname -= 13; - } - - len = extract_uni_name_from_ext_entry(ext_ep, entry_uniname, order); - - unichar = *(uniname + len); - *(uniname + len) = 0x0; - - if (nls_uniname_cmp(sb, uniname, entry_uniname)) - is_feasible_entry = false; - - *(uniname + len) = unichar; - } - has_ext_entry = true; - } else if (entry_type == TYPE_UNUSED) { - return -2; - } - is_feasible_entry = true; - has_ext_entry = false; - } - - if (p_dir->dir == CLUSTER_32(0)) - break; /* FAT16 root_dir */ - - if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return -2; - } - - return -2; -} - /* return values of exfat_find_dir_entry() * >= 0 : return dir entiry position with the name in dir * -1 : (root dir, ".") it is the root dir itself @@ -2383,36 +1828,6 @@ static s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, return -2; } -static s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, - s32 entry, struct dentry_t *p_entry) -{ - s32 count = 0; - u8 chksum; - struct dos_dentry_t *dos_ep = (struct dos_dentry_t *)p_entry; - struct ext_dentry_t *ext_ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - chksum = calc_checksum_1byte((void *)dos_ep->name, DOS_NAME_LENGTH, 0); - - for (entry--; entry >= 0; entry--) { - ext_ep = (struct ext_dentry_t *)get_entry_in_dir(sb, p_dir, - entry, NULL); - if (!ext_ep) - return -1; - - if ((p_fs->fs_func->get_entry_type((struct dentry_t *)ext_ep) == - TYPE_EXTEND) && (ext_ep->checksum == chksum)) { - count++; - if (ext_ep->order > 0x40) - return count; - } else { - return count; - } - } - - return count; -} - static s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry) { @@ -2614,33 +2029,6 @@ void get_uni_name_from_dos_entry(struct super_block *sb, nls_dosname_to_uniname(sb, p_uniname, &dos_name); } -static void fat_get_uni_name_from_ext_entry(struct super_block *sb, - struct chain_t *p_dir, s32 entry, - u16 *uniname) -{ - int i; - struct ext_dentry_t *ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - for (entry--, i = 1; entry >= 0; entry--, i++) { - ep = (struct ext_dentry_t *)get_entry_in_dir(sb, p_dir, entry, - NULL); - if (!ep) - return; - - if (p_fs->fs_func->get_entry_type((struct dentry_t *)ep) == - TYPE_EXTEND) { - extract_uni_name_from_ext_entry(ep, uniname, i); - if (ep->order > 0x40) - return; - } else { - return; - } - - uniname += 13; - } -} - static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname) @@ -2678,51 +2066,6 @@ static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, release_entry_set(es); } -static s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, u16 *uniname, - s32 order) -{ - int i, len = 0; - - for (i = 0; i < 10; i += 2) { - *uniname = GET16(ep->unicode_0_4 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - - if (order < 20) { - for (i = 0; i < 12; i += 2) { - *uniname = GET16_A(ep->unicode_5_10 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - } else { - for (i = 0; i < 8; i += 2) { - *uniname = GET16_A(ep->unicode_5_10 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - *uniname = 0x0; /* uniname[MAX_NAME_LENGTH-1] */ - return len; - } - - for (i = 0; i < 4; i += 2) { - *uniname = GET16_A(ep->unicode_11_12 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - - *uniname = 0x0; - return len; -} - static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order) { @@ -2862,18 +2205,6 @@ static void fat_attach_count_to_dos_name(u8 *dosname, s32 count) dosname[7] = ' '; } -static s32 fat_calc_num_entries(struct uni_name_t *p_uniname) -{ - s32 len; - - len = p_uniname->name_len; - if (len == 0) - return 0; - - /* 1 dos name entry + extended entries */ - return (len - 1) / 13 + 2; -} - static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) { s32 len; @@ -2886,17 +2217,6 @@ static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) return (len - 1) / 15 + 3; } -static u8 calc_checksum_1byte(void *data, s32 len, u8 chksum) -{ - int i; - u8 *c = (u8 *)data; - - for (i = 0; i < len; i++, c++) - chksum = (((chksum & 1) << 7) | ((chksum & 0xFE) >> 1)) + *c; - - return chksum; -} - u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type) { int i; @@ -2921,30 +2241,6 @@ u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type) return chksum; } -static u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type) -{ - int i; - u8 *c = (u8 *)data; - - switch (type) { - case CS_PBR_SECTOR: - for (i = 0; i < len; i++, c++) { - if ((i == 106) || (i == 107) || (i == 112)) - continue; - chksum = (((chksum & 1) << 31) | - ((chksum & 0xFFFFFFFE) >> 1)) + (u32)*c; - } - break; - default - : - for (i = 0; i < len; i++, c++) - chksum = (((chksum & 1) << 31) | - ((chksum & 0xFFFFFFFE) >> 1)) + (u32)*c; - } - - return chksum; -} - /* * Name Resolution Functions */ @@ -3506,54 +2802,3 @@ int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, return ret; } - -static int multi_sector_read(struct super_block *sb, sector_t sec, - struct buffer_head **bh, s32 num_secs, bool read) -{ - s32 ret = FFS_MEDIAERR; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - if (((sec + num_secs) > (p_fs->PBR_sector + p_fs->num_sectors)) && - (p_fs->num_sectors > 0)) { - pr_err("[EXFAT] %s: out of range error! (sec = %llu, num_secs = %d)\n", - __func__, (unsigned long long)sec, num_secs); - fs_error(sb); - return ret; - } - - if (!p_fs->dev_ejected) { - ret = bdev_read(sb, sec, bh, num_secs, read); - if (ret != FFS_SUCCESS) - p_fs->dev_ejected = 1; - } - - return ret; -} - -static int multi_sector_write(struct super_block *sb, sector_t sec, - struct buffer_head *bh, s32 num_secs, bool sync) -{ - s32 ret = FFS_MEDIAERR; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - if ((sec + num_secs) > (p_fs->PBR_sector + p_fs->num_sectors) && - (p_fs->num_sectors > 0)) { - pr_err("[EXFAT] %s: out of range error! (sec = %llu, num_secs = %d)\n", - __func__, (unsigned long long)sec, num_secs); - fs_error(sb); - return ret; - } - if (!bh) { - pr_err("[EXFAT] %s: bh is NULL!\n", __func__); - fs_error(sb); - return ret; - } - - if (!p_fs->dev_ejected) { - ret = bdev_write(sb, sec, bh, num_secs, sync); - if (ret != FFS_SUCCESS) - p_fs->dev_ejected = 1; - } - - return ret; -} From patchwork Wed Oct 23 05:27:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 305B8112B for ; Wed, 23 Oct 2019 05:28:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EF7021A4C for ; Wed, 23 Oct 2019 05:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389402AbfJWF2f (ORCPT ); Wed, 23 Oct 2019 01:28:35 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:60938 "EHLO omr1.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389394AbfJWF2f (ORCPT ); Wed, 23 Oct 2019 01:28:35 -0400 Received: from mr3.cc.vt.edu (mr3.cc.ipv6.vt.edu [IPv6:2607:b400:92:8500:0:7f:b804:6b0a]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5SXhK003446 for ; Wed, 23 Oct 2019 01:28:33 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by mr3.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SSdS023637 for ; Wed, 23 Oct 2019 01:28:33 -0400 Received: by mail-qt1-f199.google.com with SMTP id m20so20087828qtq.16 for ; Tue, 22 Oct 2019 22:28:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1ZfVmulmjsU3Cyo+ca3bv9XfNhytkiBUHJH7LMRWmLo=; b=lg76M0pShGDo5PAbfj/dOeEaa2YzMK5fkVBR9fH1/72s1jWaD9dLXDKupuCllJQ5ys DshUlB3TXLYv49BXdoB/mcOzMjHhTpPE9pcfwyaTKKijqMBFhc+SnJoFPpAxtgak9IpP 0gJFdiTpB0op9Nv+FCQpJXAMX5pce+12Wi08TXQUh5AMryLAZdrgbBq+S+cgGLNCtGG3 uNmljzM5M/TOkQAkmk7K2HQDDCsvpET6ZxgemEOwsPK88YszK4fjm4u8PLeGqefxB4zO 3uhTagq989a14Hx/iODyLQt+3xyWRGRiOQgqVW7519m9MgkrrQUHKynqqsEqaQlIv8NW 8xGg== X-Gm-Message-State: APjAAAVSr5gTv1WtZQizbqGkuC0uM+caabFaVuf6TwHvP81LmQ1K2yKn eUg/aGKaoei6y+LFxYF/HvHHJ6rPjVpApYgd1MrGJdoMDToDfMe+ZwyF+KMykjjawlNS9e2SE63 Ju3cXy26lE/ITaHTQ4BRPO3zab5WkqX39bHqy X-Received: by 2002:ac8:5556:: with SMTP id o22mr7357015qtr.217.1571808508496; Tue, 22 Oct 2019 22:28:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxa4tINSJ8hrkJr9ykxfcaSkUDylsH8LXjFhl71sfPlJNyCzr5HxGoTpVHwOlGkhBekPk9nvQ== X-Received: by 2002:ac8:5556:: with SMTP id o22mr7357004qtr.217.1571808508213; Tue, 22 Oct 2019 22:28:28 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:27 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] staging: exfat: Cleanup static entries in exfat.h Date: Wed, 23 Oct 2019 01:27:47 -0400 Message-Id: <20191023052752.693689-5-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Many of the static definitions that remain are not needed, as the function definition is already before the first use. Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat.h | 53 ----------------------------------- 1 file changed, 53 deletions(-) diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 9cd78b6417d0..dbd86a6cdc95 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -782,17 +782,9 @@ static void buf_sync(struct super_block *sb); /* fs management functions */ void fs_set_vol_flags(struct super_block *sb, u32 new_flag); -static void fs_error(struct super_block *sb); /* cluster management functions */ -static s32 clear_cluster(struct super_block *sb, u32 clu); -static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, - struct chain_t *p_chain); -static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, - s32 do_relse); -static u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain); s32 count_num_clusters(struct super_block *sb, struct chain_t *dir); -static s32 exfat_count_used_clusters(struct super_block *sb); void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); /* allocation bitmap management functions */ @@ -808,36 +800,12 @@ s32 load_upcase_table(struct super_block *sb); void free_upcase_table(struct super_block *sb); /* dir entry management functions */ -static u32 exfat_get_entry_type(struct dentry_t *p_entry); -static void exfat_set_entry_type(struct dentry_t *p_entry, u32 type); -static u32 exfat_get_entry_attr(struct dentry_t *p_entry); -static void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr); -static u8 exfat_get_entry_flag(struct dentry_t *p_entry); -static void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flag); -static u32 exfat_get_entry_clu0(struct dentry_t *p_entry); -static void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); -static u64 exfat_get_entry_size(struct dentry_t *p_entry); -static void exfat_set_entry_size(struct dentry_t *p_entry, u64 size); struct timestamp_t *tm_current(struct timestamp_t *tm); -static void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); -static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); -static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, u32 type, u32 start_clu, u64 size); -static s32 exfat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 num_entries, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname); static void init_file_entry(struct file_dentry_t *ep, u32 type); static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size); static void init_name_entry(struct name_dentry_t *ep, u16 *uniname); -static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 order, s32 num_entries); -static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, - sector_t *sector, s32 *offset); struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector); struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, @@ -846,18 +814,6 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, struct dentry_t **file_ep); void release_entry_set(struct entry_set_cache_t *es); static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es); -static s32 write_partial_entries_in_entry_set(struct super_block *sb, - struct entry_set_cache_t *es, - struct dentry_t *ep, u32 count); -static s32 search_deleted_or_unused_entry(struct super_block *sb, - struct chain_t *p_dir, s32 num_entries); -static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, - s32 num_entries); -static s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, - struct uni_name_t *p_uniname, s32 num_entries, - struct dos_name_t *p_dosname, u32 type); -static s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, - s32 entry, struct dentry_t *p_entry); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, u32 type); static void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, @@ -873,25 +829,16 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, void get_uni_name_from_dos_entry(struct super_block *sb, struct dos_dentry_t *ep, struct uni_name_t *p_uniname, u8 mode); -static void fat_get_uni_name_from_ext_entry(struct super_block *sb, - struct chain_t *p_dir, s32 entry, - u16 *uniname); -static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, - struct chain_t *p_dir, s32 entry, - u16 *uniname); static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order); static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, struct dos_name_t *p_dosname); static void fat_attach_count_to_dos_name(u8 *dosname, s32 count); -static s32 fat_calc_num_entries(struct uni_name_t *p_uniname); -static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); /* name resolution functions */ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, struct uni_name_t *p_uniname); -static s32 resolve_name(u8 *name, u8 **arg); /* file operation functions */ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); From patchwork Wed Oct 23 05:27:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E47D513BD for ; Wed, 23 Oct 2019 05:28:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C30DB21925 for ; Wed, 23 Oct 2019 05:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732767AbfJWF2j (ORCPT ); Wed, 23 Oct 2019 01:28:39 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:60946 "EHLO omr1.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389463AbfJWF2i (ORCPT ); Wed, 23 Oct 2019 01:28:38 -0400 Received: from mr4.cc.vt.edu (mail.ipv6.vt.edu [IPv6:2607:b400:92:9:0:9d:8fcb:4116]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5Sbcv003456 for ; Wed, 23 Oct 2019 01:28:37 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mr4.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SWFa021458 for ; Wed, 23 Oct 2019 01:28:37 -0400 Received: by mail-qt1-f197.google.com with SMTP id j18so12576868qtp.23 for ; Tue, 22 Oct 2019 22:28:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3R3TYJQENxlxM/7hiSPDOzoGGvmVuWM26HSA4gktLsc=; b=XB/Lip33jqr6WjAOZlobP1ufHfklIC4VRwX3S3gmPn2qpUwos8mfhhi0ZtbENIuXQ5 JpCcHA2um0x1rJukxLy8HmSRCkCOY62AWToUOXbc3+VK2XAddvTuifdLtP7BtHHz9ERx +ZMkkD8AZ2mTKofGk3cftore7nILr6S2swoYySXyFO2JuOpsL6/9isfdUy3CXV3f4yEk 7qoWFdqu7Oxwmr+P+OU/R8vin2zT2153htqlVYEGRGWoJS3VSgwiRNXvwKvKAR53OVHQ /gWLv6PlfuJIavVybwDWkX+lRAejHliEGGvckb4QQQRh3d9pCRzyhlQDGIgJIdHv9M9Z mjZQ== X-Gm-Message-State: APjAAAU3mtfGFbgmsh8soMJvyHvlMe8RfT0Qw9PJ1vfFtki2F/j6nXNl wwbLdlCASXAb5ZUukaFZV39xVqA3CBSEV7hHjYWbZQ+ba2/juQZZKb7tEjbUdCzncHdWD7aI/ID KqUbzlQfWzGGFVG9G9NKSDmtJ6jIixucT0AyS X-Received: by 2002:ac8:70c3:: with SMTP id g3mr7202614qtp.391.1571808512063; Tue, 22 Oct 2019 22:28:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzy4r7y16DC8h4ydIFPzLdAGCvDsekngAhlepEpIYK5p7QCs9OYpm9liB0aPVEfxDo6Cc6ONA== X-Received: by 2002:ac8:70c3:: with SMTP id g3mr7202598qtp.391.1571808511686; Tue, 22 Oct 2019 22:28:31 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:30 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] staging: exfat: Clean up static definitions in exfat_cache.c Date: Wed, 23 Oct 2019 01:27:48 -0400 Message-Id: <20191023052752.693689-6-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Move static function bodies before first use, remove the definition in exfat.h Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat.h | 4 -- drivers/staging/exfat/exfat_cache.c | 94 +++++++++++++++-------------- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index dbd86a6cdc95..654a0c46c1a0 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -768,17 +768,13 @@ void buf_init(struct super_block *sb); void buf_shutdown(struct super_block *sb); int FAT_read(struct super_block *sb, u32 loc, u32 *content); s32 FAT_write(struct super_block *sb, u32 loc, u32 content); -static u8 *FAT_getblk(struct super_block *sb, sector_t sec); -static void FAT_modify(struct super_block *sb, sector_t sec); void FAT_release_all(struct super_block *sb); -static void FAT_sync(struct super_block *sb); u8 *buf_getblk(struct super_block *sb, sector_t sec); void buf_modify(struct super_block *sb, sector_t sec); void buf_lock(struct super_block *sb, sector_t sec); void buf_unlock(struct super_block *sb, sector_t sec); void buf_release(struct super_block *sb, sector_t sec); void buf_release_all(struct super_block *sb); -static void buf_sync(struct super_block *sb); /* fs management functions */ void fs_set_vol_flags(struct super_block *sb, u32 new_flag); diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c index e1b001718709..e9ad0353b4e5 100644 --- a/drivers/staging/exfat/exfat_cache.c +++ b/drivers/staging/exfat/exfat_cache.c @@ -193,6 +193,50 @@ void buf_shutdown(struct super_block *sb) { } +static u8 *FAT_getblk(struct super_block *sb, sector_t sec) +{ + struct buf_cache_t *bp; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + + bp = FAT_cache_find(sb, sec); + if (bp) { + move_to_mru(bp, &p_fs->FAT_cache_lru_list); + return bp->buf_bh->b_data; + } + + bp = FAT_cache_get(sb, sec); + + FAT_cache_remove_hash(bp); + + bp->drv = p_fs->drv; + bp->sec = sec; + bp->flag = 0; + + FAT_cache_insert_hash(sb, bp); + + if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) { + FAT_cache_remove_hash(bp); + bp->drv = -1; + bp->sec = ~0; + bp->flag = 0; + bp->buf_bh = NULL; + + move_to_lru(bp, &p_fs->FAT_cache_lru_list); + return NULL; + } + + return bp->buf_bh->b_data; +} + +static void FAT_modify(struct super_block *sb, sector_t sec) +{ + struct buf_cache_t *bp; + + bp = FAT_cache_find(sb, sec); + if (bp) + sector_write(sb, sec, bp->buf_bh, 0); +} + static int __FAT_read(struct super_block *sb, u32 loc, u32 *content) { s32 off; @@ -441,50 +485,6 @@ int FAT_write(struct super_block *sb, u32 loc, u32 content) return ret; } -u8 *FAT_getblk(struct super_block *sb, sector_t sec) -{ - struct buf_cache_t *bp; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - bp = FAT_cache_find(sb, sec); - if (bp) { - move_to_mru(bp, &p_fs->FAT_cache_lru_list); - return bp->buf_bh->b_data; - } - - bp = FAT_cache_get(sb, sec); - - FAT_cache_remove_hash(bp); - - bp->drv = p_fs->drv; - bp->sec = sec; - bp->flag = 0; - - FAT_cache_insert_hash(sb, bp); - - if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) { - FAT_cache_remove_hash(bp); - bp->drv = -1; - bp->sec = ~0; - bp->flag = 0; - bp->buf_bh = NULL; - - move_to_lru(bp, &p_fs->FAT_cache_lru_list); - return NULL; - } - - return bp->buf_bh->b_data; -} - -void FAT_modify(struct super_block *sb, sector_t sec) -{ - struct buf_cache_t *bp; - - bp = FAT_cache_find(sb, sec); - if (bp) - sector_write(sb, sec, bp->buf_bh, 0); -} - void FAT_release_all(struct super_block *sb) { struct buf_cache_t *bp; @@ -510,7 +510,8 @@ void FAT_release_all(struct super_block *sb) up(&f_sem); } -void FAT_sync(struct super_block *sb) +/* FIXME - this function is not used anyplace. See TODO */ +static void FAT_sync(struct super_block *sb) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -704,7 +705,8 @@ void buf_release_all(struct super_block *sb) up(&b_sem); } -void buf_sync(struct super_block *sb) +/* FIXME - this function is not used anyplace. See TODO */ +static void buf_sync(struct super_block *sb) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); From patchwork Wed Oct 23 05:27:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC9C4112B for ; Wed, 23 Oct 2019 05:28:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B192621920 for ; Wed, 23 Oct 2019 05:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389500AbfJWF2n (ORCPT ); Wed, 23 Oct 2019 01:28:43 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:44864 "EHLO omr2.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389389AbfJWF2n (ORCPT ); Wed, 23 Oct 2019 01:28:43 -0400 Received: from mr3.cc.vt.edu (mr3.cc.vt.edu [IPv6:2607:b400:92:8500:0:7f:b804:6b0a]) by omr2.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5SfAj020022 for ; Wed, 23 Oct 2019 01:28:41 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mr3.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SaOu023702 for ; Wed, 23 Oct 2019 01:28:41 -0400 Received: by mail-qk1-f197.google.com with SMTP id p79so657987qke.0 for ; Tue, 22 Oct 2019 22:28:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9PwOaNGGQfQBttlauOR4COrHeb/BR1Y/sXHYC9tSwaE=; b=FP7FVRRrkfx+M7FAYmoqj4EuOOW6CG2GlLl2exLAJpdwq1arTE2jpEpt/gjpZz1y+N CgntFQ+Kkp8h0sMgZoVezk8gxMiL0lUgemhgdSE84llDJUIjBvQOtXl6xRRzaPtLDOzK vmg6OA1GY3j1LP2EeuaBNJFXYTm9VK4YPpUrJ4d5MOeOMOVTdpMjmtvIpnGbOKAKcPvc jLYg73yXr7x1KiU1q4+7OH0w3d1d/PzJIpAqGTW4WIP4awaXVxPA768oc7+UPFdFeP3w 7hZZGGveU3CiI3wHQrTmniFEOXZXbaU8Q1O1VpWmJKMnc/egYxg/A59Fg8vuYgE3RhEu 1u4g== X-Gm-Message-State: APjAAAVzGCN6fQ9vzTKuotJpVp2euRcoDIILQ/rOmJpXFV/U0ENG4ch2 L7g+Zs7eNHInCRHXXpDH6YNz2FdrFZitSSQZlvby6vYiVAgdW3LoGRp0dticSF2NIyWnuchSQNi ICTokCtGTZ0N8JxzzPt8T8RumQCK1VzTZ8fpk X-Received: by 2002:a37:9a8e:: with SMTP id c136mr6761995qke.0.1571808516217; Tue, 22 Oct 2019 22:28:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxwNT3/lKJQCNdyxfhDUh0PPMzcPfMhEPPCQL+opXtes9uZDZWIkLUHyr4z6dZHQqx15u9eA== X-Received: by 2002:a37:9a8e:: with SMTP id c136mr6761965qke.0.1571808515544; Tue, 22 Oct 2019 22:28:35 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:34 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] staging: exfat: More static cleanups for exfat_core.c Date: Wed, 23 Oct 2019 01:27:49 -0400 Message-Id: <20191023052752.693689-7-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Move static function bodies before first use, remove the definition in exfat.h Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat.h | 6 - drivers/staging/exfat/exfat_core.c | 500 ++++++++++++++--------------- 2 files changed, 250 insertions(+), 256 deletions(-) diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 654a0c46c1a0..b93df526355b 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -786,10 +786,6 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); /* allocation bitmap management functions */ s32 load_alloc_bitmap(struct super_block *sb); void free_alloc_bitmap(struct super_block *sb); -static s32 set_alloc_bitmap(struct super_block *sb, u32 clu); -static s32 clr_alloc_bitmap(struct super_block *sb, u32 clu); -static u32 test_alloc_bitmap(struct super_block *sb, u32 clu); -static void sync_alloc_bitmap(struct super_block *sb); /* upcase table management functions */ s32 load_upcase_table(struct super_block *sb); @@ -812,8 +808,6 @@ void release_entry_set(struct entry_set_cache_t *es); static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, u32 type); -static void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, - s32 entry); void update_dir_checksum_with_entry_set(struct super_block *sb, struct entry_set_cache_t *es); bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index dd69a9a6dddc..1a49da231946 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -132,6 +132,199 @@ static void fs_error(struct super_block *sb) } } +/* + * Allocation Bitmap Management Functions + */ + +s32 load_alloc_bitmap(struct super_block *sb) +{ + int i, j, ret; + u32 map_size; + u32 type; + sector_t sector; + struct chain_t clu; + struct bmap_dentry_t *ep; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + clu.dir = p_fs->root_dir; + clu.flags = 0x01; + + while (clu.dir != CLUSTER_32(~0)) { + if (p_fs->dev_ejected) + break; + + for (i = 0; i < p_fs->dentries_per_clu; i++) { + ep = (struct bmap_dentry_t *)get_entry_in_dir(sb, &clu, + i, NULL); + if (!ep) + return FFS_MEDIAERR; + + type = p_fs->fs_func->get_entry_type((struct dentry_t *)ep); + + if (type == TYPE_UNUSED) + break; + if (type != TYPE_BITMAP) + continue; + + if (ep->flags == 0x0) { + p_fs->map_clu = GET32_A(ep->start_clu); + map_size = (u32)GET64_A(ep->size); + + p_fs->map_sectors = ((map_size - 1) >> p_bd->sector_size_bits) + 1; + + p_fs->vol_amap = kmalloc_array(p_fs->map_sectors, + sizeof(struct buffer_head *), + GFP_KERNEL); + if (!p_fs->vol_amap) + return FFS_MEMORYERR; + + sector = START_SECTOR(p_fs->map_clu); + + for (j = 0; j < p_fs->map_sectors; j++) { + p_fs->vol_amap[j] = NULL; + ret = sector_read(sb, sector + j, &(p_fs->vol_amap[j]), 1); + if (ret != FFS_SUCCESS) { + /* release all buffers and free vol_amap */ + i = 0; + while (i < j) + brelse(p_fs->vol_amap[i++]); + + kfree(p_fs->vol_amap); + p_fs->vol_amap = NULL; + return ret; + } + } + + p_fs->pbr_bh = NULL; + return FFS_SUCCESS; + } + } + + if (FAT_read(sb, clu.dir, &clu.dir) != 0) + return FFS_MEDIAERR; + } + + return FFS_FORMATERR; +} + +void free_alloc_bitmap(struct super_block *sb) +{ + int i; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + + brelse(p_fs->pbr_bh); + + for (i = 0; i < p_fs->map_sectors; i++) + __brelse(p_fs->vol_amap[i]); + + kfree(p_fs->vol_amap); + p_fs->vol_amap = NULL; +} + +static s32 set_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, b; + sector_t sector; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + i = clu >> (p_bd->sector_size_bits + 3); + b = clu & ((p_bd->sector_size << 3) - 1); + + sector = START_SECTOR(p_fs->map_clu) + i; + + exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b); + + return sector_write(sb, sector, p_fs->vol_amap[i], 0); +} + +static s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, b; + sector_t sector; +#ifdef CONFIG_EXFAT_DISCARD + struct exfat_sb_info *sbi = EXFAT_SB(sb); + struct exfat_mount_options *opts = &sbi->options; + int ret; +#endif /* CONFIG_EXFAT_DISCARD */ + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + i = clu >> (p_bd->sector_size_bits + 3); + b = clu & ((p_bd->sector_size << 3) - 1); + + sector = START_SECTOR(p_fs->map_clu) + i; + + exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b); + + return sector_write(sb, sector, p_fs->vol_amap[i], 0); + +#ifdef CONFIG_EXFAT_DISCARD + if (opts->discard) { + ret = sb_issue_discard(sb, START_SECTOR(clu), + (1 << p_fs->sectors_per_clu_bits), + GFP_NOFS, 0); + if (ret == -EOPNOTSUPP) { + pr_warn("discard not supported by device, disabling"); + opts->discard = 0; + } + } +#endif /* CONFIG_EXFAT_DISCARD */ +} + +static u32 test_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, map_i, map_b; + u32 clu_base, clu_free; + u8 k, clu_mask; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + clu_base = (clu & ~(0x7)) + 2; + clu_mask = (1 << (clu - clu_base + 2)) - 1; + + map_i = clu >> (p_bd->sector_size_bits + 3); + map_b = (clu >> 3) & p_bd->sector_size_mask; + + for (i = 2; i < p_fs->num_clusters; i += 8) { + k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b); + if (clu_mask > 0) { + k |= clu_mask; + clu_mask = 0; + } + if (k < 0xFF) { + clu_free = clu_base + free_bit[k]; + if (clu_free < p_fs->num_clusters) + return clu_free; + } + clu_base += 8; + + if (((++map_b) >= p_bd->sector_size) || + (clu_base >= p_fs->num_clusters)) { + if ((++map_i) >= p_fs->map_sectors) { + clu_base = 2; + map_i = 0; + } + map_b = 0; + } + } + + return CLUSTER_32(~0); +} + +static void sync_alloc_bitmap(struct super_block *sb) +{ + int i; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + + if (!p_fs->vol_amap) + return; + + for (i = 0; i < p_fs->map_sectors; i++) + sync_dirty_buffer(p_fs->vol_amap[i]); +} + /* * Cluster Management Functions */ @@ -388,199 +581,6 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len) FAT_write(sb, chain, CLUSTER_32(~0)); } -/* - * Allocation Bitmap Management Functions - */ - -s32 load_alloc_bitmap(struct super_block *sb) -{ - int i, j, ret; - u32 map_size; - u32 type; - sector_t sector; - struct chain_t clu; - struct bmap_dentry_t *ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - clu.dir = p_fs->root_dir; - clu.flags = 0x01; - - while (clu.dir != CLUSTER_32(~0)) { - if (p_fs->dev_ejected) - break; - - for (i = 0; i < p_fs->dentries_per_clu; i++) { - ep = (struct bmap_dentry_t *)get_entry_in_dir(sb, &clu, - i, NULL); - if (!ep) - return FFS_MEDIAERR; - - type = p_fs->fs_func->get_entry_type((struct dentry_t *)ep); - - if (type == TYPE_UNUSED) - break; - if (type != TYPE_BITMAP) - continue; - - if (ep->flags == 0x0) { - p_fs->map_clu = GET32_A(ep->start_clu); - map_size = (u32)GET64_A(ep->size); - - p_fs->map_sectors = ((map_size - 1) >> p_bd->sector_size_bits) + 1; - - p_fs->vol_amap = kmalloc_array(p_fs->map_sectors, - sizeof(struct buffer_head *), - GFP_KERNEL); - if (!p_fs->vol_amap) - return FFS_MEMORYERR; - - sector = START_SECTOR(p_fs->map_clu); - - for (j = 0; j < p_fs->map_sectors; j++) { - p_fs->vol_amap[j] = NULL; - ret = sector_read(sb, sector + j, &(p_fs->vol_amap[j]), 1); - if (ret != FFS_SUCCESS) { - /* release all buffers and free vol_amap */ - i = 0; - while (i < j) - brelse(p_fs->vol_amap[i++]); - - kfree(p_fs->vol_amap); - p_fs->vol_amap = NULL; - return ret; - } - } - - p_fs->pbr_bh = NULL; - return FFS_SUCCESS; - } - } - - if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return FFS_MEDIAERR; - } - - return FFS_FORMATERR; -} - -void free_alloc_bitmap(struct super_block *sb) -{ - int i; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - brelse(p_fs->pbr_bh); - - for (i = 0; i < p_fs->map_sectors; i++) - __brelse(p_fs->vol_amap[i]); - - kfree(p_fs->vol_amap); - p_fs->vol_amap = NULL; -} - -static s32 set_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, b; - sector_t sector; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - i = clu >> (p_bd->sector_size_bits + 3); - b = clu & ((p_bd->sector_size << 3) - 1); - - sector = START_SECTOR(p_fs->map_clu) + i; - - exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b); - - return sector_write(sb, sector, p_fs->vol_amap[i], 0); -} - -static s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, b; - sector_t sector; -#ifdef CONFIG_EXFAT_DISCARD - struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct exfat_mount_options *opts = &sbi->options; - int ret; -#endif /* CONFIG_EXFAT_DISCARD */ - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - i = clu >> (p_bd->sector_size_bits + 3); - b = clu & ((p_bd->sector_size << 3) - 1); - - sector = START_SECTOR(p_fs->map_clu) + i; - - exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b); - - return sector_write(sb, sector, p_fs->vol_amap[i], 0); - -#ifdef CONFIG_EXFAT_DISCARD - if (opts->discard) { - ret = sb_issue_discard(sb, START_SECTOR(clu), - (1 << p_fs->sectors_per_clu_bits), - GFP_NOFS, 0); - if (ret == -EOPNOTSUPP) { - pr_warn("discard not supported by device, disabling"); - opts->discard = 0; - } - } -#endif /* CONFIG_EXFAT_DISCARD */ -} - -static u32 test_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, map_i, map_b; - u32 clu_base, clu_free; - u8 k, clu_mask; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - clu_base = (clu & ~(0x7)) + 2; - clu_mask = (1 << (clu - clu_base + 2)) - 1; - - map_i = clu >> (p_bd->sector_size_bits + 3); - map_b = (clu >> 3) & p_bd->sector_size_mask; - - for (i = 2; i < p_fs->num_clusters; i += 8) { - k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b); - if (clu_mask > 0) { - k |= clu_mask; - clu_mask = 0; - } - if (k < 0xFF) { - clu_free = clu_base + free_bit[k]; - if (clu_free < p_fs->num_clusters) - return clu_free; - } - clu_base += 8; - - if (((++map_b) >= p_bd->sector_size) || - (clu_base >= p_fs->num_clusters)) { - if ((++map_i) >= p_fs->map_sectors) { - clu_base = 2; - map_i = 0; - } - map_b = 0; - } - } - - return CLUSTER_32(~0); -} - -static void sync_alloc_bitmap(struct super_block *sb) -{ - int i; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - if (!p_fs->vol_amap) - return; - - for (i = 0; i < p_fs->map_sectors; i++) - sync_dirty_buffer(p_fs->vol_amap[i]); -} - /* * Upcase table Management Functions */ @@ -791,6 +791,63 @@ void free_upcase_table(struct super_block *sb) p_fs->vol_utbl = NULL; } +static void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, + s32 entry) +{ + int i, num_entries; + sector_t sector; + u16 chksum; + struct file_dentry_t *file_ep; + struct dentry_t *ep; + + file_ep = (struct file_dentry_t *)get_entry_in_dir(sb, p_dir, entry, + §or); + if (!file_ep) + return; + + buf_lock(sb, sector); + + num_entries = (s32)file_ep->num_ext + 1; + chksum = calc_checksum_2byte((void *)file_ep, DENTRY_SIZE, 0, + CS_DIR_ENTRY); + + for (i = 1; i < num_entries; i++) { + ep = get_entry_in_dir(sb, p_dir, entry + i, NULL); + if (!ep) { + buf_unlock(sb, sector); + return; + } + + chksum = calc_checksum_2byte((void *)ep, DENTRY_SIZE, chksum, + CS_DEFAULT); + } + + SET16_A(file_ep->checksum, chksum); + buf_modify(sb, sector); + buf_unlock(sb, sector); +} + +void update_dir_checksum_with_entry_set(struct super_block *sb, + struct entry_set_cache_t *es) +{ + struct dentry_t *ep; + u16 chksum = 0; + s32 chksum_type = CS_DIR_ENTRY, i; + + ep = (struct dentry_t *)&(es->__buf); + for (i = 0; i < es->num_entries; i++) { + pr_debug("%s ep %p\n", __func__, ep); + chksum = calc_checksum_2byte((void *)ep, DENTRY_SIZE, chksum, + chksum_type); + ep++; + chksum_type = CS_DEFAULT; + } + + ep = (struct dentry_t *)&(es->__buf); + SET16_A(((struct file_dentry_t *)ep)->checksum, chksum); + write_whole_entry_set(sb, es); +} + /* * Directory Entry Management Functions */ @@ -1114,63 +1171,6 @@ static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir } } -static void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, - s32 entry) -{ - int i, num_entries; - sector_t sector; - u16 chksum; - struct file_dentry_t *file_ep; - struct dentry_t *ep; - - file_ep = (struct file_dentry_t *)get_entry_in_dir(sb, p_dir, entry, - §or); - if (!file_ep) - return; - - buf_lock(sb, sector); - - num_entries = (s32)file_ep->num_ext + 1; - chksum = calc_checksum_2byte((void *)file_ep, DENTRY_SIZE, 0, - CS_DIR_ENTRY); - - for (i = 1; i < num_entries; i++) { - ep = get_entry_in_dir(sb, p_dir, entry + i, NULL); - if (!ep) { - buf_unlock(sb, sector); - return; - } - - chksum = calc_checksum_2byte((void *)ep, DENTRY_SIZE, chksum, - CS_DEFAULT); - } - - SET16_A(file_ep->checksum, chksum); - buf_modify(sb, sector); - buf_unlock(sb, sector); -} - -void update_dir_checksum_with_entry_set(struct super_block *sb, - struct entry_set_cache_t *es) -{ - struct dentry_t *ep; - u16 chksum = 0; - s32 chksum_type = CS_DIR_ENTRY, i; - - ep = (struct dentry_t *)&(es->__buf); - for (i = 0; i < es->num_entries; i++) { - pr_debug("%s ep %p\n", __func__, ep); - chksum = calc_checksum_2byte((void *)ep, DENTRY_SIZE, chksum, - chksum_type); - ep++; - chksum_type = CS_DEFAULT; - } - - ep = (struct dentry_t *)&(es->__buf); - SET16_A(((struct file_dentry_t *)ep)->checksum, chksum); - write_whole_entry_set(sb, es); -} - static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir, s32 byte_offset, u32 *clu) { From patchwork Wed Oct 23 05:27:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E80213BD for ; Wed, 23 Oct 2019 05:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28CE421920 for ; Wed, 23 Oct 2019 05:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389556AbfJWF2s (ORCPT ); Wed, 23 Oct 2019 01:28:48 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:60956 "EHLO omr1.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389516AbfJWF2r (ORCPT ); Wed, 23 Oct 2019 01:28:47 -0400 Received: from mr1.cc.vt.edu (junk.cc.ipv6.vt.edu [IPv6:2607:b400:92:9:0:9d:8fcb:4116]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5SjUS003477 for ; Wed, 23 Oct 2019 01:28:45 -0400 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mr1.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SeQq006981 for ; Wed, 23 Oct 2019 01:28:45 -0400 Received: by mail-qk1-f198.google.com with SMTP id c4so14507175qkg.22 for ; Tue, 22 Oct 2019 22:28:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3ePf9F6IcLHL4eSAUuR/dFlnNun9yggS3P0eDCd4d5c=; b=nIwPbAzsTBJSCOYss3UNBo2p1tGCx8ZkzA1YQmcZASQN5JaW0bQtiqnCTcJHj7tOIs P5lKWTZ4vRp0gROSN8wti6i4W0ddlD0xWeZpWshYaRWMJxQKUns8X3yOnyzeHp8crm/Q EQ8MX5TtQyu1eKcKmK38TKPjdgUXgNn1mTQIeYlWLEyWg1osOEzvwr25GGu+Yw7fhC17 Oxo6H/DokrPh2s5jzKgjqKDuwUTfDw+PNibO69c0bhvjwTn6KHiAsAwGAN6tFXJRBdu3 8ChYI9PLvhr5CiPbzA9UBBhvseobqhI/aOJwQnYIMgTBO1wFHNHy4CMgUpM92Xmy2X9/ ZKNQ== X-Gm-Message-State: APjAAAXBE8FO96qAYxz+QWvQAFsp62/wOoHdwjDH36X4xBmjRslY1oIq bhRGUKst876xa+RaQ+mhqIxISrqVXCs+MACP/DjpbWtr9lCcV1pRo0bcQti25fR6DZetciRpWuS 7c7Jz3OLTpA3hlJjNV8RKLg+/ObFx+tGb+a7z X-Received: by 2002:a37:8d01:: with SMTP id p1mr6585105qkd.210.1571808520138; Tue, 22 Oct 2019 22:28:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuO7zluAMwyK/JntwxLteqnNrrtioGH29mNPg7W1oCHNmHhCXD0iLHMtI8Xq/wb7MXIKm2dA== X-Received: by 2002:a37:8d01:: with SMTP id p1mr6585081qkd.210.1571808519338; Tue, 22 Oct 2019 22:28:39 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:38 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] staging: exfat: Finished code movement for static cleanups in exfat_core.c Date: Wed, 23 Oct 2019 01:27:50 -0400 Message-Id: <20191023052752.693689-8-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Move static function bodies before first use, remove the definition in exfat.h Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat.h | 10 - drivers/staging/exfat/exfat_core.c | 661 ++++++++++++++--------------- 2 files changed, 330 insertions(+), 341 deletions(-) diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index b93df526355b..8738e41dd5a5 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -793,10 +793,6 @@ void free_upcase_table(struct super_block *sb); /* dir entry management functions */ struct timestamp_t *tm_current(struct timestamp_t *tm); -static void init_file_entry(struct file_dentry_t *ep, u32 type); -static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, - u64 size); -static void init_name_entry(struct name_dentry_t *ep, u16 *uniname); struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector); @@ -805,7 +801,6 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, u32 type, struct dentry_t **file_ep); void release_entry_set(struct entry_set_cache_t *es); -static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, u32 type); void update_dir_checksum_with_entry_set(struct super_block *sb, @@ -819,11 +814,6 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, void get_uni_name_from_dos_entry(struct super_block *sb, struct dos_dentry_t *ep, struct uni_name_t *p_uniname, u8 mode); -static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, - s32 order); -static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, - struct dos_name_t *p_dosname); -static void fat_attach_count_to_dos_name(u8 *dosname, s32 count); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); /* name resolution functions */ diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 1a49da231946..7332e69fcbcd 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -791,6 +791,168 @@ void free_upcase_table(struct super_block *sb) p_fs->vol_utbl = NULL; } +static s32 __write_partial_entries_in_entry_set(struct super_block *sb, + struct entry_set_cache_t *es, + sector_t sec, s32 off, u32 count) +{ + s32 num_entries, buf_off = (off - es->offset); + u32 remaining_byte_in_sector, copy_entries; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + u32 clu; + u8 *buf, *esbuf = (u8 *)&(es->__buf); + + pr_debug("%s entered es %p sec %llu off %d count %d\n", + __func__, es, (unsigned long long)sec, off, count); + num_entries = count; + + while (num_entries) { + /* white per sector base */ + remaining_byte_in_sector = (1 << p_bd->sector_size_bits) - off; + copy_entries = min_t(s32, + remaining_byte_in_sector >> DENTRY_SIZE_BITS, + num_entries); + buf = buf_getblk(sb, sec); + if (!buf) + goto err_out; + pr_debug("es->buf %p buf_off %u\n", esbuf, buf_off); + pr_debug("copying %d entries from %p to sector %llu\n", + copy_entries, (esbuf + buf_off), + (unsigned long long)sec); + memcpy(buf + off, esbuf + buf_off, + copy_entries << DENTRY_SIZE_BITS); + buf_modify(sb, sec); + num_entries -= copy_entries; + + if (num_entries) { + /* get next sector */ + if (IS_LAST_SECTOR_IN_CLUSTER(sec)) { + clu = GET_CLUSTER_FROM_SECTOR(sec); + if (es->alloc_flag == 0x03) { + clu++; + } else { + if (FAT_read(sb, clu, &clu) == -1) + goto err_out; + } + sec = START_SECTOR(clu); + } else { + sec++; + } + off = 0; + buf_off += copy_entries << DENTRY_SIZE_BITS; + } + } + + pr_debug("%s exited successfully\n", __func__); + return FFS_SUCCESS; +err_out: + pr_debug("%s failed\n", __func__); + return FFS_ERROR; +} + +/* write back all entries in entry set */ +static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) +{ + return __write_partial_entries_in_entry_set(sb, es, es->sector, + es->offset, + es->num_entries); +} + +/* search EMPTY CONTINUOUS "num_entries" entries */ +static s32 search_deleted_or_unused_entry(struct super_block *sb, + struct chain_t *p_dir, s32 num_entries) +{ + int i, dentry, num_empty = 0; + s32 dentries_per_clu; + u32 type; + struct chain_t clu; + struct dentry_t *ep; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + + if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */ + dentries_per_clu = p_fs->dentries_in_root; + else + dentries_per_clu = p_fs->dentries_per_clu; + + if (p_fs->hint_uentry.dir == p_dir->dir) { + if (p_fs->hint_uentry.entry == -1) + return -1; + + clu.dir = p_fs->hint_uentry.clu.dir; + clu.size = p_fs->hint_uentry.clu.size; + clu.flags = p_fs->hint_uentry.clu.flags; + + dentry = p_fs->hint_uentry.entry; + } else { + p_fs->hint_uentry.entry = -1; + + clu.dir = p_dir->dir; + clu.size = p_dir->size; + clu.flags = p_dir->flags; + + dentry = 0; + } + + while (clu.dir != CLUSTER_32(~0)) { + if (p_fs->dev_ejected) + break; + + if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */ + i = dentry % dentries_per_clu; + else + i = dentry & (dentries_per_clu - 1); + + for (; i < dentries_per_clu; i++, dentry++) { + ep = get_entry_in_dir(sb, &clu, i, NULL); + if (!ep) + return -1; + + type = p_fs->fs_func->get_entry_type(ep); + + if (type == TYPE_UNUSED) { + num_empty++; + if (p_fs->hint_uentry.entry == -1) { + p_fs->hint_uentry.dir = p_dir->dir; + p_fs->hint_uentry.entry = dentry; + + p_fs->hint_uentry.clu.dir = clu.dir; + p_fs->hint_uentry.clu.size = clu.size; + p_fs->hint_uentry.clu.flags = clu.flags; + } + } else if (type == TYPE_DELETED) { + num_empty++; + } else { + num_empty = 0; + } + + if (num_empty >= num_entries) { + p_fs->hint_uentry.dir = CLUSTER_32(~0); + p_fs->hint_uentry.entry = -1; + + if (p_fs->vol_type == EXFAT) + return dentry - (num_entries - 1); + else + return dentry; + } + } + + if (p_dir->dir == CLUSTER_32(0)) + break; /* FAT16 root_dir */ + + if (clu.flags == 0x03) { + if ((--clu.size) > 0) + clu.dir++; + else + clu.dir = CLUSTER_32(~0); + } else { + if (FAT_read(sb, clu.dir, &clu.dir) != 0) + return -1; + } + } + + return -1; +} + static void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, s32 entry) { @@ -1038,6 +1200,45 @@ static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *t } } +static void init_file_entry(struct file_dentry_t *ep, u32 type) +{ + struct timestamp_t tm, *tp; + + exfat_set_entry_type((struct dentry_t *)ep, type); + + tp = tm_current(&tm); + exfat_set_entry_time((struct dentry_t *)ep, tp, TM_CREATE); + exfat_set_entry_time((struct dentry_t *)ep, tp, TM_MODIFY); + exfat_set_entry_time((struct dentry_t *)ep, tp, TM_ACCESS); + ep->create_time_ms = 0; + ep->modify_time_ms = 0; + ep->access_time_ms = 0; +} + +static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size) +{ + exfat_set_entry_type((struct dentry_t *)ep, TYPE_STREAM); + ep->flags = flags; + SET32_A(ep->start_clu, start_clu); + SET64_A(ep->valid_size, size); + SET64_A(ep->size, size); +} + +static void init_name_entry(struct name_dentry_t *ep, u16 *uniname) +{ + int i; + + exfat_set_entry_type((struct dentry_t *)ep, TYPE_EXTEND); + ep->flags = 0x0; + + for (i = 0; i < 30; i++, i++) { + SET16_A(ep->unicode_0_14 + i, *uniname); + if (*uniname == 0x0) + break; + uniname++; + } +} + static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size) { @@ -1114,45 +1315,6 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, return FFS_SUCCESS; } -static void init_file_entry(struct file_dentry_t *ep, u32 type) -{ - struct timestamp_t tm, *tp; - - exfat_set_entry_type((struct dentry_t *)ep, type); - - tp = tm_current(&tm); - exfat_set_entry_time((struct dentry_t *)ep, tp, TM_CREATE); - exfat_set_entry_time((struct dentry_t *)ep, tp, TM_MODIFY); - exfat_set_entry_time((struct dentry_t *)ep, tp, TM_ACCESS); - ep->create_time_ms = 0; - ep->modify_time_ms = 0; - ep->access_time_ms = 0; -} - -static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size) -{ - exfat_set_entry_type((struct dentry_t *)ep, TYPE_STREAM); - ep->flags = flags; - SET32_A(ep->start_clu, start_clu); - SET64_A(ep->valid_size, size); - SET64_A(ep->size, size); -} - -static void init_name_entry(struct name_dentry_t *ep, u16 *uniname) -{ - int i; - - exfat_set_entry_type((struct dentry_t *)ep, TYPE_EXTEND); - ep->flags = 0x0; - - for (i = 0; i < 30; i++, i++) { - SET16_A(ep->unicode_0_14 + i, *uniname); - if (*uniname == 0x0) - break; - uniname++; - } -} - static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries) { @@ -1432,177 +1594,15 @@ void release_entry_set(struct entry_set_cache_t *es) kfree(es); } -static s32 __write_partial_entries_in_entry_set(struct super_block *sb, - struct entry_set_cache_t *es, - sector_t sec, s32 off, u32 count) +static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries) { - s32 num_entries, buf_off = (off - es->offset); - u32 remaining_byte_in_sector, copy_entries; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - u32 clu; - u8 *buf, *esbuf = (u8 *)&(es->__buf); - - pr_debug("%s entered es %p sec %llu off %d count %d\n", - __func__, es, (unsigned long long)sec, off, count); - num_entries = count; - - while (num_entries) { - /* white per sector base */ - remaining_byte_in_sector = (1 << p_bd->sector_size_bits) - off; - copy_entries = min_t(s32, - remaining_byte_in_sector >> DENTRY_SIZE_BITS, - num_entries); - buf = buf_getblk(sb, sec); - if (!buf) - goto err_out; - pr_debug("es->buf %p buf_off %u\n", esbuf, buf_off); - pr_debug("copying %d entries from %p to sector %llu\n", - copy_entries, (esbuf + buf_off), - (unsigned long long)sec); - memcpy(buf + off, esbuf + buf_off, - copy_entries << DENTRY_SIZE_BITS); - buf_modify(sb, sec); - num_entries -= copy_entries; - - if (num_entries) { - /* get next sector */ - if (IS_LAST_SECTOR_IN_CLUSTER(sec)) { - clu = GET_CLUSTER_FROM_SECTOR(sec); - if (es->alloc_flag == 0x03) { - clu++; - } else { - if (FAT_read(sb, clu, &clu) == -1) - goto err_out; - } - sec = START_SECTOR(clu); - } else { - sec++; - } - off = 0; - buf_off += copy_entries << DENTRY_SIZE_BITS; - } - } - - pr_debug("%s exited successfully\n", __func__); - return FFS_SUCCESS; -err_out: - pr_debug("%s failed\n", __func__); - return FFS_ERROR; -} - -/* write back all entries in entry set */ -static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) -{ - return __write_partial_entries_in_entry_set(sb, es, es->sector, - es->offset, - es->num_entries); -} - -/* search EMPTY CONTINUOUS "num_entries" entries */ -static s32 search_deleted_or_unused_entry(struct super_block *sb, - struct chain_t *p_dir, s32 num_entries) -{ - int i, dentry, num_empty = 0; - s32 dentries_per_clu; - u32 type; - struct chain_t clu; - struct dentry_t *ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */ - dentries_per_clu = p_fs->dentries_in_root; - else - dentries_per_clu = p_fs->dentries_per_clu; - - if (p_fs->hint_uentry.dir == p_dir->dir) { - if (p_fs->hint_uentry.entry == -1) - return -1; - - clu.dir = p_fs->hint_uentry.clu.dir; - clu.size = p_fs->hint_uentry.clu.size; - clu.flags = p_fs->hint_uentry.clu.flags; - - dentry = p_fs->hint_uentry.entry; - } else { - p_fs->hint_uentry.entry = -1; - - clu.dir = p_dir->dir; - clu.size = p_dir->size; - clu.flags = p_dir->flags; - - dentry = 0; - } - - while (clu.dir != CLUSTER_32(~0)) { - if (p_fs->dev_ejected) - break; - - if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */ - i = dentry % dentries_per_clu; - else - i = dentry & (dentries_per_clu - 1); - - for (; i < dentries_per_clu; i++, dentry++) { - ep = get_entry_in_dir(sb, &clu, i, NULL); - if (!ep) - return -1; - - type = p_fs->fs_func->get_entry_type(ep); - - if (type == TYPE_UNUSED) { - num_empty++; - if (p_fs->hint_uentry.entry == -1) { - p_fs->hint_uentry.dir = p_dir->dir; - p_fs->hint_uentry.entry = dentry; - - p_fs->hint_uentry.clu.dir = clu.dir; - p_fs->hint_uentry.clu.size = clu.size; - p_fs->hint_uentry.clu.flags = clu.flags; - } - } else if (type == TYPE_DELETED) { - num_empty++; - } else { - num_empty = 0; - } - - if (num_empty >= num_entries) { - p_fs->hint_uentry.dir = CLUSTER_32(~0); - p_fs->hint_uentry.entry = -1; - - if (p_fs->vol_type == EXFAT) - return dentry - (num_entries - 1); - else - return dentry; - } - } - - if (p_dir->dir == CLUSTER_32(0)) - break; /* FAT16 root_dir */ - - if (clu.flags == 0x03) { - if ((--clu.size) > 0) - clu.dir++; - else - clu.dir = CLUSTER_32(~0); - } else { - if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return -1; - } - } - - return -1; -} - -static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries) -{ - s32 ret, dentry; - u32 last_clu; - sector_t sector; - u64 size = 0; - struct chain_t clu; - struct dentry_t *ep = NULL; - struct super_block *sb = inode->i_sb; + s32 ret, dentry; + u32 last_clu; + sector_t sector; + u64 size = 0; + struct chain_t clu; + struct dentry_t *ep = NULL; + struct super_block *sb = inode->i_sb; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct file_id_t *fid = &(EXFAT_I(inode)->fid); @@ -1680,6 +1680,23 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_ return dentry; } +static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, + s32 order) +{ + int i, len = 0; + + for (i = 0; i < 30; i += 2) { + *uniname = GET16_A(ep->unicode_0_14 + i); + if (*uniname == 0x0) + return len; + uniname++; + len++; + } + + *uniname = 0x0; + return len; +} + /* return values of exfat_find_dir_entry() * >= 0 : return dir entiry position with the name in dir * -1 : (root dir, ".") it is the root dir itself @@ -1971,116 +1988,31 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir) /* * Name Conversion Functions */ - -/* input : dir, uni_name - * output : num_of_entry, dos_name(format : aaaaaa~1.bbb) - */ -s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, - struct uni_name_t *p_uniname, s32 *entries, - struct dos_name_t *p_dosname) -{ - s32 ret, num_entries; - bool lossy = false; - char **r; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - num_entries = p_fs->fs_func->calc_num_entries(p_uniname); - if (num_entries == 0) - return FFS_INVALIDPATH; - - if (p_fs->vol_type != EXFAT) { - nls_uniname_to_dosname(sb, p_dosname, p_uniname, &lossy); - - if (lossy) { - ret = fat_generate_dos_name(sb, p_dir, p_dosname); - if (ret) - return ret; - } else { - for (r = reserved_names; *r; r++) { - if (!strncmp((void *)p_dosname->name, *r, 8)) - return FFS_INVALIDPATH; - } - - if (p_dosname->name_case != 0xFF) - num_entries = 1; - } - - if (num_entries > 1) - p_dosname->name_case = 0x0; - } - - *entries = num_entries; - - return FFS_SUCCESS; -} - -void get_uni_name_from_dos_entry(struct super_block *sb, - struct dos_dentry_t *ep, - struct uni_name_t *p_uniname, u8 mode) -{ - struct dos_name_t dos_name; - - if (mode == 0x0) - dos_name.name_case = 0x0; - else - dos_name.name_case = ep->lcase; - - memcpy(dos_name.name, ep->name, DOS_NAME_LENGTH); - nls_dosname_to_uniname(sb, p_uniname, &dos_name); -} - -static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, - struct chain_t *p_dir, s32 entry, - u16 *uniname) +static void fat_attach_count_to_dos_name(u8 *dosname, s32 count) { - int i; - struct dentry_t *ep; - struct entry_set_cache_t *es; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - es = get_entry_set_in_dir(sb, p_dir, entry, ES_ALL_ENTRIES, &ep); - if (!es || es->num_entries < 3) { - if (es) - release_entry_set(es); - return; - } + int i, j, length; + char str_count[6]; - ep += 2; + snprintf(str_count, sizeof(str_count), "~%d", count); + length = strlen(str_count); - /* - * First entry : file entry - * Second entry : stream-extension entry - * Third entry : first file-name entry - * So, the index of first file-name dentry should start from 2. - */ - for (i = 2; i < es->num_entries; i++, ep++) { - if (p_fs->fs_func->get_entry_type(ep) == TYPE_EXTEND) - extract_uni_name_from_name_entry((struct name_dentry_t *) - ep, uniname, i); + i = 0; + j = 0; + while (j <= (8 - length)) { + i = j; + if (dosname[j] == ' ') + break; + if (dosname[j] & 0x80) + j += 2; else - goto out; - uniname += 15; + j++; } -out: - release_entry_set(es); -} - -static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, - s32 order) -{ - int i, len = 0; - - for (i = 0; i < 30; i += 2) { - *uniname = GET16_A(ep->unicode_0_14 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } + for (j = 0; j < length; i++, j++) + dosname[i] = (u8)str_count[j]; - *uniname = 0x0; - return len; + if (i == 7) + dosname[7] = ' '; } static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, @@ -2178,31 +2110,98 @@ static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, return FFS_SUCCESS; } -static void fat_attach_count_to_dos_name(u8 *dosname, s32 count) +/* input : dir, uni_name + * output : num_of_entry, dos_name(format : aaaaaa~1.bbb) + */ +s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, + struct uni_name_t *p_uniname, s32 *entries, + struct dos_name_t *p_dosname) { - int i, j, length; - char str_count[6]; + s32 ret, num_entries; + bool lossy = false; + char **r; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - snprintf(str_count, sizeof(str_count), "~%d", count); - length = strlen(str_count); + num_entries = p_fs->fs_func->calc_num_entries(p_uniname); + if (num_entries == 0) + return FFS_INVALIDPATH; - i = 0; - j = 0; - while (j <= (8 - length)) { - i = j; - if (dosname[j] == ' ') - break; - if (dosname[j] & 0x80) - j += 2; - else - j++; + if (p_fs->vol_type != EXFAT) { + nls_uniname_to_dosname(sb, p_dosname, p_uniname, &lossy); + + if (lossy) { + ret = fat_generate_dos_name(sb, p_dir, p_dosname); + if (ret) + return ret; + } else { + for (r = reserved_names; *r; r++) { + if (!strncmp((void *)p_dosname->name, *r, 8)) + return FFS_INVALIDPATH; + } + + if (p_dosname->name_case != 0xFF) + num_entries = 1; + } + + if (num_entries > 1) + p_dosname->name_case = 0x0; } - for (j = 0; j < length; i++, j++) - dosname[i] = (u8)str_count[j]; + *entries = num_entries; - if (i == 7) - dosname[7] = ' '; + return FFS_SUCCESS; +} + +void get_uni_name_from_dos_entry(struct super_block *sb, + struct dos_dentry_t *ep, + struct uni_name_t *p_uniname, u8 mode) +{ + struct dos_name_t dos_name; + + if (mode == 0x0) + dos_name.name_case = 0x0; + else + dos_name.name_case = ep->lcase; + + memcpy(dos_name.name, ep->name, DOS_NAME_LENGTH); + nls_dosname_to_uniname(sb, p_uniname, &dos_name); +} + +static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, + struct chain_t *p_dir, s32 entry, + u16 *uniname) +{ + int i; + struct dentry_t *ep; + struct entry_set_cache_t *es; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + + es = get_entry_set_in_dir(sb, p_dir, entry, ES_ALL_ENTRIES, &ep); + if (!es || es->num_entries < 3) { + if (es) + release_entry_set(es); + return; + } + + ep += 2; + + /* + * First entry : file entry + * Second entry : stream-extension entry + * Third entry : first file-name entry + * So, the index of first file-name dentry should start from 2. + */ + for (i = 2; i < es->num_entries; i++, ep++) { + if (p_fs->fs_func->get_entry_type(ep) == TYPE_EXTEND) + extract_uni_name_from_name_entry((struct name_dentry_t *) + ep, uniname, i); + else + goto out; + uniname += 15; + } + +out: + release_entry_set(es); } static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) From patchwork Wed Oct 23 05:27:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Valdis_Kl=C4=93tnieks?= X-Patchwork-Id: 11205697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E63EB13BD for ; Wed, 23 Oct 2019 05:28:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF0CC21920 for ; Wed, 23 Oct 2019 05:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389573AbfJWF2u (ORCPT ); Wed, 23 Oct 2019 01:28:50 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:44880 "EHLO omr2.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389547AbfJWF2t (ORCPT ); Wed, 23 Oct 2019 01:28:49 -0400 Received: from mr6.cc.vt.edu (mr6.cc.vt.edu [IPv6:2607:b400:92:8500:0:af:2d00:4488]) by omr2.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x9N5Sljv020044 for ; Wed, 23 Oct 2019 01:28:47 -0400 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by mr6.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x9N5SgYu018571 for ; Wed, 23 Oct 2019 01:28:47 -0400 Received: by mail-qk1-f199.google.com with SMTP id s14so19087856qkg.12 for ; Tue, 22 Oct 2019 22:28:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ISQDTJmGCoaQ4xeld4Mhg9Q600xoGHfVZT32mcJtg7w=; b=Cs2HVsjwWLPfAFQaWkhydUr06jGbnxLG5xDmG14kdp9xcZhnn6ulzDFXb4Rpq6w4wd d07rNPt/+WP7SzXy0MnbxHN5wpJUiRrYZDVxQKFKAVkM8C2mgKItv4cSDGGI56sab4z5 61ZXofuamuWF12O98iqMmJlDuLUIOXgQng7XdPJFQu2Jjj70UGx2uD0dv+9cFgLThzfD Lcin0cdHzrh13cCXQ2v3yvcmyxI/94EW3BjiI1OSJ65YNnNUdmXFC97x3EJDPjmDETTM VX0xFge+MsuP98L4xLFCKTUW+8Jx9NcvCRokbtlEpmLGEaFJWeKHq2FEvfhrBlTQ/zK7 gxaQ== X-Gm-Message-State: APjAAAXLhhGU4hfjoDOBhNxRFQFj1VACPlzaX7hmDE/WjMZLReNg1EEH 5OL7ZcP2cd20AIP670g0X87sy+DFazJYg2F2DkcBYTMlfpZXM4QJmpxpqbRQOLNgxdxMxtu4act Tkrf7Ch5RJutnP7KoRGRs37BjY1+ChWn646q4 X-Received: by 2002:ac8:4a03:: with SMTP id x3mr1713092qtq.117.1571808522466; Tue, 22 Oct 2019 22:28:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5nRxuWdRuBTyicKO9kNgnNeEtVqZyh2Z4Ty5Wd3Rj/224bq/k+ZD4kmE2tsjBWrP+H4/Kvg== X-Received: by 2002:ac8:4a03:: with SMTP id x3mr1713074qtq.117.1571808522200; Tue, 22 Oct 2019 22:28:42 -0700 (PDT) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 14sm10397445qtb.54.2019.10.22.22.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 22:28:41 -0700 (PDT) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks To: Greg Kroah-Hartman , Valdis.Kletnieks@vt.edu Cc: Valdis Kletnieks , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] staging: exfat: Update TODO Date: Wed, 23 Oct 2019 01:27:51 -0400 Message-Id: <20191023052752.693689-9-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> References: <20191023052752.693689-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/TODO | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/exfat/TODO b/drivers/staging/exfat/TODO index b60e50b9cf4e..110c30834bd2 100644 --- a/drivers/staging/exfat/TODO +++ b/drivers/staging/exfat/TODO @@ -1,21 +1,17 @@ exfat_core.c - ffsReadFile - the goto err_out seem to leak a brelse(). same for ffsWriteFile. -exfat_core.c - fs_sync(sb,0) all over the place looks fishy as hell. -There's only one place that calls it with a non-zero argument. -Randomly removing fs_sync() calls is *not* the right answer, especially -if the removal then leaves a call to fs_set_vol_flags(VOL_CLEAN), as that -says the file system is clean and synced when we *know* it isn't. -The proper fix here is to go through and actually analyze how DELAYED_SYNC -should work, and any time we're setting VOL_CLEAN, ensure the file system -has in fact been synced to disk. In other words, changing the 'false' to -'true' is probably more correct. Also, it's likely that the one current -place where it actually does an bdev_sync isn't sufficient in the DELAYED_SYNC -case. - ffsTruncateFile - if (old_size <= new_size) { That doesn't look right. How did it ever work? Are they relying on lazy block allocation when actual writes happen? If nothing else, it never does the 'fid->size = new_size' and do the inode update.... ffsSetAttr() is just dangling in the breeze, not wired up at all... + +exfat_core.c - The original code called fs_sync(sb,0) all over the place, +with only one place that calls it with a non-zero argument. That's now been +reversed, but a proper audit of sync and flush-to-disk is certainly needed. + +buf_sync(), sync_alloc_bitmap(), and FAT_sync() aren't actually used +anyplace. This is probably related to the borked original implementatin +of fs_sync() that didn't actually do anything either.