2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-27 22:53:55 +08:00

staging: exfat: Clean up the namespace pollution part 6

Move a few more things so we can make them static and clear exfat.h out.
At this point, pretty much everything that can be static is static.
(Note: FAT_sync(), buf_sync(), and sync_alloc_bitmap() aren't called
anyplace, but aren't static because (a) that will toss an error and
(b) they probably *should* be getting called someplace

Signed-off-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Link: https://lore.kernel.org/r/20191112211238.156490-11-Valdis.Kletnieks@vt.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Valdis Kletnieks 2019-11-12 16:12:36 -05:00 committed by Greg Kroah-Hartman
parent a78b34b89b
commit e5a490e037
2 changed files with 85 additions and 93 deletions

View File

@ -780,12 +780,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);
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,
struct entry_set_cache_t *es,
struct dentry_t *ep, u32 count);
s32 search_deleted_or_unused_entry(struct super_block *sb,
struct chain_t *p_dir, s32 num_entries);
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,
@ -798,8 +792,6 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir);
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 extract_uni_name_from_name_entry(struct name_dentry_t *ep,
u16 *uniname, s32 order);
u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type);
/* name resolution functions */

View File

@ -1140,6 +1140,73 @@ void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir,
buf_unlock(sb, sector);
}
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 0;
err_out:
pr_debug("%s failed\n", __func__);
return -EINVAL;
}
/* 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);
}
void update_dir_checksum_with_entry_set(struct super_block *sb,
struct entry_set_cache_t *es)
{
@ -1421,75 +1488,8 @@ 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)
{
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 0;
err_out:
pr_debug("%s failed\n", __func__);
return -EINVAL;
}
/* write back all entries in entry set */
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 */
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;
@ -1665,6 +1665,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
@ -2013,23 +2030,6 @@ out:
release_entry_set(es);
}
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;
}
static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname)
{
s32 len;