summaryrefslogtreecommitdiff
path: root/fs/exfat/super.c
diff options
context:
space:
mode:
authorTetsuhiro Kohada <kohada.t2@gmail.com>2020-05-29 19:14:56 +0900
committerNamjae Jeon <namjae.jeon@samsung.com>2020-06-09 16:49:10 +0900
commit181a9e8009a8a8bdb19c2e24eeeae7d8e77c8c47 (patch)
tree4bab700570fd4e874c10220df29735ae3ab363e8 /fs/exfat/super.c
parent943af1fdacfebe4ff13430655abc460a5e1072f7 (diff)
exfat: redefine PBR as boot_sector
Aggregate PBR related definitions and redefine as "boot_sector" to comply with the exFAT specification. And, rename variable names including 'pbr'. Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Diffstat (limited to 'fs/exfat/super.c')
-rw-r--r--fs/exfat/super.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index c1f47f4071a8..e60d28e73ff0 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -49,7 +49,7 @@ static void exfat_put_super(struct super_block *sb)
sync_blockdev(sb->s_bdev);
exfat_set_vol_flags(sb, VOL_CLEAN);
exfat_free_bitmap(sbi);
- brelse(sbi->pbr_bh);
+ brelse(sbi->boot_bh);
mutex_unlock(&sbi->s_lock);
call_rcu(&sbi->rcu, exfat_delayed_free);
@@ -101,7 +101,7 @@ static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf)
int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flag)
{
struct exfat_sb_info *sbi = EXFAT_SB(sb);
- struct pbr64 *bpb = (struct pbr64 *)sbi->pbr_bh->b_data;
+ struct boot_sector *p_boot = (struct boot_sector *)sbi->boot_bh->b_data;
bool sync;
/* flags are not changed */
@@ -116,18 +116,18 @@ int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flag)
if (sb_rdonly(sb))
return 0;
- bpb->bsx.vol_flags = cpu_to_le16(new_flag);
+ p_boot->vol_flags = cpu_to_le16(new_flag);
- if (new_flag == VOL_DIRTY && !buffer_dirty(sbi->pbr_bh))
+ if (new_flag == VOL_DIRTY && !buffer_dirty(sbi->boot_bh))
sync = true;
else
sync = false;
- set_buffer_uptodate(sbi->pbr_bh);
- mark_buffer_dirty(sbi->pbr_bh);
+ set_buffer_uptodate(sbi->boot_bh);
+ mark_buffer_dirty(sbi->boot_bh);
if (sync)
- sync_dirty_buffer(sbi->pbr_bh);
+ sync_dirty_buffer(sbi->boot_bh);
return 0;
}
@@ -366,13 +366,14 @@ static int exfat_read_root(struct inode *inode)
return 0;
}
-static struct pbr *exfat_read_pbr_with_logical_sector(struct super_block *sb)
+static struct boot_sector *exfat_read_boot_with_logical_sector(
+ struct super_block *sb)
{
struct exfat_sb_info *sbi = EXFAT_SB(sb);
- struct pbr *p_pbr = (struct pbr *) (sbi->pbr_bh)->b_data;
+ struct boot_sector *p_boot = (struct boot_sector *)sbi->boot_bh->b_data;
unsigned short logical_sect = 0;
- logical_sect = 1 << p_pbr->bsx.f64.sect_size_bits;
+ logical_sect = 1 << p_boot->sect_size_bits;
if (!is_power_of_2(logical_sect) ||
logical_sect < 512 || logical_sect > 4096) {
@@ -387,49 +388,48 @@ static struct pbr *exfat_read_pbr_with_logical_sector(struct super_block *sb)
}
if (logical_sect > sb->s_blocksize) {
- brelse(sbi->pbr_bh);
- sbi->pbr_bh = NULL;
+ brelse(sbi->boot_bh);
+ sbi->boot_bh = NULL;
if (!sb_set_blocksize(sb, logical_sect)) {
exfat_err(sb, "unable to set blocksize %u",
logical_sect);
return NULL;
}
- sbi->pbr_bh = sb_bread(sb, 0);
- if (!sbi->pbr_bh) {
+ sbi->boot_bh = sb_bread(sb, 0);
+ if (!sbi->boot_bh) {
exfat_err(sb, "unable to read boot sector (logical sector size = %lu)",
sb->s_blocksize);
return NULL;
}
- p_pbr = (struct pbr *)sbi->pbr_bh->b_data;
+ p_boot = (struct boot_sector *)sbi->boot_bh->b_data;
}
- return p_pbr;
+ return p_boot;
}
/* mount the file system volume */
static int __exfat_fill_super(struct super_block *sb)
{
int ret;
- struct pbr *p_pbr;
- struct pbr64 *p_bpb;
+ struct boot_sector *p_boot;
struct exfat_sb_info *sbi = EXFAT_SB(sb);
/* set block size to read super block */
sb_min_blocksize(sb, 512);
/* read boot sector */
- sbi->pbr_bh = sb_bread(sb, 0);
- if (!sbi->pbr_bh) {
+ sbi->boot_bh = sb_bread(sb, 0);
+ if (!sbi->boot_bh) {
exfat_err(sb, "unable to read boot sector");
return -EIO;
}
/* PRB is read */
- p_pbr = (struct pbr *)sbi->pbr_bh->b_data;
+ p_boot = (struct boot_sector *)sbi->boot_bh->b_data;
- /* check the validity of PBR */
- if (le16_to_cpu((p_pbr->signature)) != PBR_SIGNATURE) {
+ /* check the validity of BOOT */
+ if (le16_to_cpu((p_boot->signature)) != BOOT_SIGNATURE) {
exfat_err(sb, "invalid boot record signature");
ret = -EINVAL;
goto free_bh;
@@ -437,8 +437,8 @@ static int __exfat_fill_super(struct super_block *sb)
/* check logical sector size */
- p_pbr = exfat_read_pbr_with_logical_sector(sb);
- if (!p_pbr) {
+ p_boot = exfat_read_boot_with_logical_sector(sb);
+ if (!p_boot) {
ret = -EIO;
goto free_bh;
}
@@ -447,43 +447,43 @@ static int __exfat_fill_super(struct super_block *sb)
* res_zero field must be filled with zero to prevent mounting
* from FAT volume.
*/
- if (memchr_inv(p_pbr->bpb.f64.res_zero, 0,
- sizeof(p_pbr->bpb.f64.res_zero))) {
+ if (memchr_inv(p_boot->must_be_zero, 0,
+ sizeof(p_boot->must_be_zero))) {
ret = -EINVAL;
goto free_bh;
}
- p_bpb = (struct pbr64 *)p_pbr;
- if (!p_bpb->bsx.num_fats) {
+ p_boot = (struct boot_sector *)p_boot;
+ if (!p_boot->num_fats) {
exfat_err(sb, "bogus number of FAT structure");
ret = -EINVAL;
goto free_bh;
}
- sbi->sect_per_clus = 1 << p_bpb->bsx.sect_per_clus_bits;
- sbi->sect_per_clus_bits = p_bpb->bsx.sect_per_clus_bits;
+ sbi->sect_per_clus = 1 << p_boot->sect_per_clus_bits;
+ sbi->sect_per_clus_bits = p_boot->sect_per_clus_bits;
sbi->cluster_size_bits = sbi->sect_per_clus_bits + sb->s_blocksize_bits;
sbi->cluster_size = 1 << sbi->cluster_size_bits;
- sbi->num_FAT_sectors = le32_to_cpu(p_bpb->bsx.fat_length);
- sbi->FAT1_start_sector = le32_to_cpu(p_bpb->bsx.fat_offset);
- sbi->FAT2_start_sector = p_bpb->bsx.num_fats == 1 ?
+ sbi->num_FAT_sectors = le32_to_cpu(p_boot->fat_length);
+ sbi->FAT1_start_sector = le32_to_cpu(p_boot->fat_offset);
+ sbi->FAT2_start_sector = p_boot->num_fats == 1 ?
sbi->FAT1_start_sector :
sbi->FAT1_start_sector + sbi->num_FAT_sectors;
- sbi->data_start_sector = le32_to_cpu(p_bpb->bsx.clu_offset);
- sbi->num_sectors = le64_to_cpu(p_bpb->bsx.vol_length);
+ sbi->data_start_sector = le32_to_cpu(p_boot->clu_offset);
+ sbi->num_sectors = le64_to_cpu(p_boot->vol_length);
/* because the cluster index starts with 2 */
- sbi->num_clusters = le32_to_cpu(p_bpb->bsx.clu_count) +
+ sbi->num_clusters = le32_to_cpu(p_boot->clu_count) +
EXFAT_RESERVED_CLUSTERS;
- sbi->root_dir = le32_to_cpu(p_bpb->bsx.root_cluster);
+ sbi->root_dir = le32_to_cpu(p_boot->root_cluster);
sbi->dentries_per_clu = 1 <<
(sbi->cluster_size_bits - DENTRY_SIZE_BITS);
- sbi->vol_flag = le16_to_cpu(p_bpb->bsx.vol_flags);
+ sbi->vol_flag = le16_to_cpu(p_boot->vol_flags);
sbi->clu_srch_ptr = EXFAT_FIRST_CLUSTER;
sbi->used_clusters = EXFAT_CLUSTERS_UNTRACKED;
- if (le16_to_cpu(p_bpb->bsx.vol_flags) & VOL_DIRTY) {
+ if (le16_to_cpu(p_boot->vol_flags) & VOL_DIRTY) {
sbi->vol_flag |= VOL_DIRTY;
exfat_warn(sb, "Volume was not properly unmounted. Some data may be corrupt. Please run fsck.");
}
@@ -517,7 +517,7 @@ free_alloc_bitmap:
free_upcase_table:
exfat_free_upcase_table(sbi);
free_bh:
- brelse(sbi->pbr_bh);
+ brelse(sbi->boot_bh);
return ret;
}
@@ -608,7 +608,7 @@ put_inode:
free_table:
exfat_free_upcase_table(sbi);
exfat_free_bitmap(sbi);
- brelse(sbi->pbr_bh);
+ brelse(sbi->boot_bh);
check_nls_io:
unload_nls(sbi->nls_io);