Skip to content
Snippets Groups Projects
Commit 557527ee authored by Ethan Wu's avatar Ethan Wu Committed by Chung-Chiang Cheng
Browse files

Support exfat capacity more than 2TB


- Change the size of num_sectors in memory to 64 bits as it is in on-disk
  structure.
- Use type 'sector_t' for all sector variables.
- Fix overflow issue of macro START_SECTOR(x)

Reviewed-by: default avatarPeter Huang <peterh@synology.com>
Signed-off-by: default avatarChung-Chiang Cheng <cccheng@synology.com>
parent a877c799
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -94,7 +94,7 @@ s32 bdev_close(struct super_block *sb)
return FFS_SUCCESS;
}
 
s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 num_secs, s32 read)
s32 bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, s32 read)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -126,7 +126,7 @@ s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 nu
return FFS_MEDIAERR;
}
 
s32 bdev_write(struct super_block *sb, u32 secno, struct buffer_head *bh, u32 num_secs, s32 sync)
s32 bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, s32 sync)
{
s32 count;
struct buffer_head *bh2;
Loading
Loading
Loading
Loading
@@ -66,8 +66,8 @@ s32 bdev_init(void);
s32 bdev_shutdown(void);
s32 bdev_open(struct super_block *sb);
s32 bdev_close(struct super_block *sb);
s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 num_secs, s32 read);
s32 bdev_write(struct super_block *sb, u32 secno, struct buffer_head *bh, u32 num_secs, s32 sync);
s32 bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, s32 read);
s32 bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, s32 sync);
s32 bdev_sync(struct super_block *sb);
 
#endif /* _EXFAT_BLKDEV_H */
Loading
Loading
@@ -50,15 +50,15 @@
static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content);
static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content);
 
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, u32 sec);
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, u32 sec);
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, sector_t sec);
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, sector_t sec);
static void FAT_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp);
static void FAT_cache_remove_hash(BUF_CACHE_T *bp);
 
static u8 *__buf_getblk(struct super_block *sb, u32 sec);
static u8 *__buf_getblk(struct super_block *sb, sector_t sec);
 
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, u32 sec);
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, u32 sec);
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, sector_t sec);
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, sector_t sec);
static void buf_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp);
static void buf_cache_remove_hash(BUF_CACHE_T *bp);
 
Loading
Loading
@@ -165,7 +165,8 @@ s32 FAT_write(struct super_block *sb, u32 loc, u32 content)
static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content)
{
s32 off;
u32 sec, _content;
u32 _content;
sector_t sec;
u8 *fat_sector, *fat_entry;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
Loading
Loading
@@ -276,7 +277,7 @@ static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content)
static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content)
{
s32 off;
u32 sec;
sector_t sec;
u8 *fat_sector, *fat_entry;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
Loading
Loading
@@ -381,7 +382,7 @@ static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content)
return 0;
} /* end of __FAT_write */
 
u8 *FAT_getblk(struct super_block *sb, u32 sec)
u8 *FAT_getblk(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -416,7 +417,7 @@ u8 *FAT_getblk(struct super_block *sb, u32 sec)
return bp->buf_bh->b_data;
} /* end of FAT_getblk */
 
void FAT_modify(struct super_block *sb, u32 sec)
void FAT_modify(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
 
Loading
Loading
@@ -469,7 +470,7 @@ void FAT_sync(struct super_block *sb)
sm_V(&f_sem);
} /* end of FAT_sync */
 
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, u32 sec)
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, sector_t sec)
{
s32 off;
BUF_CACHE_T *bp, *hp;
Loading
Loading
@@ -491,7 +492,7 @@ static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, u32 sec)
return NULL;
} /* end of FAT_cache_find */
 
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, u32 sec)
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -529,7 +530,7 @@ static void FAT_cache_remove_hash(BUF_CACHE_T *bp)
/* Buffer Read/Write Functions */
/*======================================================================*/
 
u8 *buf_getblk(struct super_block *sb, u32 sec)
u8 *buf_getblk(struct super_block *sb, sector_t sec)
{
u8 *buf;
 
Loading
Loading
@@ -542,7 +543,7 @@ u8 *buf_getblk(struct super_block *sb, u32 sec)
return buf;
} /* end of buf_getblk */
 
static u8 *__buf_getblk(struct super_block *sb, u32 sec)
static u8 *__buf_getblk(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -578,7 +579,7 @@ static u8 *__buf_getblk(struct super_block *sb, u32 sec)
 
} /* end of __buf_getblk */
 
void buf_modify(struct super_block *sb, u32 sec)
void buf_modify(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
 
Loading
Loading
@@ -588,12 +589,13 @@ void buf_modify(struct super_block *sb, u32 sec)
if (likely(bp != NULL))
sector_write(sb, sec, bp->buf_bh, 0);
 
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%u).\n", sec);
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);
 
sm_V(&b_sem);
} /* end of buf_modify */
 
void buf_lock(struct super_block *sb, u32 sec)
void buf_lock(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
 
Loading
Loading
@@ -603,12 +605,13 @@ void buf_lock(struct super_block *sb, u32 sec)
if (likely(bp != NULL))
bp->flag |= LOCKBIT;
 
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%u).\n", sec);
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);
 
sm_V(&b_sem);
} /* end of buf_lock */
 
void buf_unlock(struct super_block *sb, u32 sec)
void buf_unlock(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
 
Loading
Loading
@@ -618,12 +621,13 @@ void buf_unlock(struct super_block *sb, u32 sec)
if (likely(bp != NULL))
bp->flag &= ~(LOCKBIT);
 
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%u).\n", sec);
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);
 
sm_V(&b_sem);
} /* end of buf_unlock */
 
void buf_release(struct super_block *sb, u32 sec)
void buf_release(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -691,7 +695,7 @@ void buf_sync(struct super_block *sb)
sm_V(&b_sem);
} /* end of buf_sync */
 
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, u32 sec)
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, sector_t sec)
{
s32 off;
BUF_CACHE_T *bp, *hp;
Loading
Loading
@@ -709,7 +713,7 @@ static BUF_CACHE_T *buf_cache_find(struct super_block *sb, u32 sec)
return NULL;
} /* end of buf_cache_find */
 
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, u32 sec)
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
Loading
Loading
@@ -57,7 +57,7 @@ typedef struct __BUF_CACHE_T {
struct __BUF_CACHE_T *hash_next;
struct __BUF_CACHE_T *hash_prev;
s32 drv;
u32 sec;
sector_t sec;
u32 flag;
struct buffer_head *buf_bh;
} BUF_CACHE_T;
Loading
Loading
@@ -70,15 +70,15 @@ s32 buf_init(struct super_block *sb);
s32 buf_shutdown(struct super_block *sb);
s32 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, u32 sec);
void FAT_modify(struct super_block *sb, u32 sec);
u8 *FAT_getblk(struct super_block *sb, sector_t sec);
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);
u8 *buf_getblk(struct super_block *sb, u32 sec);
void buf_modify(struct super_block *sb, u32 sec);
void buf_lock(struct super_block *sb, u32 sec);
void buf_unlock(struct super_block *sb, u32 sec);
void buf_release(struct super_block *sb, u32 sec);
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);
 
Loading
Loading
Loading
Loading
@@ -429,7 +429,8 @@ s32 ffsCreateFile(struct inode *inode, char *path, u8 mode, FILE_ID_T *fid)
s32 ffsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount)
{
s32 offset, sec_offset, clu_offset;
u32 clu, LogSector;
u32 clu;
sector_t LogSector;
u64 oneblkread, read_bytes;
struct buffer_head *tmp_bh = NULL;
struct super_block *sb = inode->i_sb;
Loading
Loading
@@ -522,7 +523,8 @@ s32 ffsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u
{
s32 modified = FALSE, offset, sec_offset, clu_offset;
s32 num_clusters, num_alloc, num_alloced = (s32) ~0;
u32 clu, last_clu, LogSector, sector = 0;
u32 clu, last_clu;
sector_t LogSector, sector = 0;
u64 oneblkwrite, write_bytes;
CHAIN_T new_clu;
TIMESTAMP_T tm;
Loading
Loading
@@ -732,7 +734,8 @@ err_out:
s32 ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
{
s32 num_clusters;
u32 last_clu = CLUSTER_32(0), sector = 0;
u32 last_clu = CLUSTER_32(0);
sector_t sector = 0;
CHAIN_T clu;
TIMESTAMP_T tm;
DENTRY_T *ep, *ep2;
Loading
Loading
@@ -1011,7 +1014,8 @@ s32 ffsRemoveFile(struct inode *inode, FILE_ID_T *fid)
/* ffsSetAttr : set the attribute of a given file */
s32 ffsSetAttr(struct inode *inode, u32 attr)
{
u32 type, sector = 0;
u32 type;
sector_t sector = 0;
DENTRY_T *ep;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -1087,7 +1091,7 @@ s32 ffsSetAttr(struct inode *inode, u32 attr)
/* ffsGetStat : get the information of a given file */
s32 ffsGetStat(struct inode *inode, DIR_ENTRY_T *info)
{
u32 sector = 0;
sector_t sector = 0;
s32 count;
CHAIN_T dir;
UNI_NAME_T uni_name;
Loading
Loading
@@ -1212,7 +1216,7 @@ s32 ffsGetStat(struct inode *inode, DIR_ENTRY_T *info)
/* ffsSetStat : set the information of a given file */
s32 ffsSetStat(struct inode *inode, DIR_ENTRY_T *info)
{
u32 sector = 0;
sector_t sector = 0;
TIMESTAMP_T tm;
DENTRY_T *ep, *ep2;
ENTRY_SET_CACHE_T *es = NULL;
Loading
Loading
@@ -1285,7 +1289,8 @@ s32 ffsSetStat(struct inode *inode, DIR_ENTRY_T *info)
s32 ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
{
s32 num_clusters, num_alloced, modified = FALSE;
u32 last_clu, sector = 0;
u32 last_clu;
sector_t sector = 0;
CHAIN_T new_clu;
DENTRY_T *ep;
ENTRY_SET_CACHE_T *es = NULL;
Loading
Loading
@@ -1445,7 +1450,8 @@ s32 ffsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry)
{
int i, dentry, clu_offset;
s32 dentries_per_clu, dentries_per_clu_bits = 0;
u32 type, sector;
u32 type;
sector_t sector;
CHAIN_T dir, clu;
UNI_NAME_T uni_name;
TIMESTAMP_T tm;
Loading
Loading
@@ -1762,7 +1768,7 @@ void fs_error(struct super_block *sb)
 
s32 clear_cluster(struct super_block *sb, u32 clu)
{
u32 s, n;
sector_t s, n;
s32 ret = FFS_SUCCESS;
struct buffer_head *tmp_bh = NULL;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -1926,7 +1932,7 @@ void fat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse)
u32 clu, prev;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
int i;
u32 sector;
sector_t sector;
 
if ((p_chain->dir == CLUSTER_32(0)) || (p_chain->dir == CLUSTER_32(~0)))
return;
Loading
Loading
@@ -1966,7 +1972,7 @@ void exfat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse)
u32 clu;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
int i;
u32 sector;
sector_t sector;
 
if ((p_chain->dir == CLUSTER_32(0)) || (p_chain->dir == CLUSTER_32(~0)))
return;
Loading
Loading
@@ -2125,7 +2131,8 @@ s32 load_alloc_bitmap(struct super_block *sb)
{
int i, j, ret;
u32 map_size;
u32 type, sector;
u32 type;
sector_t sector;
CHAIN_T clu;
BMAP_DENTRY_T *ep;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -2208,7 +2215,7 @@ void free_alloc_bitmap(struct super_block *sb)
s32 set_alloc_bitmap(struct super_block *sb, u32 clu)
{
int i, b;
u32 sector;
sector_t sector;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
 
Loading
Loading
@@ -2225,7 +2232,7 @@ s32 set_alloc_bitmap(struct super_block *sb, u32 clu)
s32 clr_alloc_bitmap(struct super_block *sb, u32 clu)
{
int i, b;
u32 sector;
sector_t sector;
#ifdef CONFIG_EXFAT_DISCARD
struct exfat_sb_info *sbi = EXFAT_SB(sb);
struct exfat_mount_options *opts = &sbi->options;
Loading
Loading
@@ -2312,13 +2319,14 @@ void sync_alloc_bitmap(struct super_block *sb)
/*
* Upcase table Management Functions
*/
s32 __load_upcase_table(struct super_block *sb, u32 sector, u32 num_sectors, u32 utbl_checksum)
s32 __load_upcase_table(struct super_block *sb, sector_t sector, u32 num_sectors, u32 utbl_checksum)
{
int i, ret = FFS_ERROR;
u32 j;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
struct buffer_head *tmp_bh = NULL;
sector_t end_sector = num_sectors + sector;
 
u8 skip = FALSE;
u32 index = 0;
Loading
Loading
@@ -2332,12 +2340,10 @@ s32 __load_upcase_table(struct super_block *sb, u32 sector, u32 num_sectors, u32
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
num_sectors += sector;
while (sector < num_sectors) {
while (sector < end_sector) {
ret = sector_read(sb, sector, &tmp_bh, 1);
if (ret != FFS_SUCCESS) {
DPRINTK("sector read (0x%X)fail\n", sector);
DPRINTK("sector read (0x%llX)fail\n", (unsigned long long)sector);
goto error;
}
sector++;
Loading
Loading
@@ -2450,7 +2456,8 @@ s32 load_upcase_table(struct super_block *sb)
{
int i;
u32 tbl_clu, tbl_size;
u32 type, sector, num_sectors;
sector_t sector;
u32 type, num_sectors;
CHAIN_T clu;
CASE_DENTRY_T *ep;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -2827,7 +2834,7 @@ void exfat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode)
s32 fat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type,
u32 start_clu, u64 size)
{
u32 sector;
sector_t sector;
DOS_DENTRY_T *dos_ep;
 
dos_ep = (DOS_DENTRY_T *) get_entry_in_dir(sb, p_dir, entry, &sector);
Loading
Loading
@@ -2843,7 +2850,7 @@ s32 fat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 ty
s32 exfat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type,
u32 start_clu, u64 size)
{
u32 sector;
sector_t sector;
u8 flags;
FILE_DENTRY_T *file_ep;
STRM_DENTRY_T *strm_ep;
Loading
Loading
@@ -2872,7 +2879,7 @@ s32 fat_init_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 nu
UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname)
{
int i;
u32 sector;
sector_t sector;
u8 chksum;
u16 *uniname = p_uniname->name;
DOS_DENTRY_T *dos_ep;
Loading
Loading
@@ -2914,7 +2921,7 @@ s32 exfat_init_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32
UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname)
{
int i;
u32 sector;
sector_t sector;
u16 *uniname = p_uniname->name;
FILE_DENTRY_T *file_ep;
STRM_DENTRY_T *strm_ep;
Loading
Loading
@@ -3056,7 +3063,7 @@ void init_name_entry(NAME_DENTRY_T *ep, u16 *uniname)
void fat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries)
{
int i;
u32 sector;
sector_t sector;
DENTRY_T *ep;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
 
Loading
Loading
@@ -3073,7 +3080,7 @@ void fat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32
void exfat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries)
{
int i;
u32 sector;
sector_t sector;
DENTRY_T *ep;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
 
Loading
Loading
@@ -3090,7 +3097,7 @@ void exfat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s
void update_dir_checksum(struct super_block *sb, CHAIN_T *p_dir, s32 entry)
{
int i, num_entries;
u32 sector;
sector_t sector;
u16 chksum;
FILE_DENTRY_T *file_ep;
DENTRY_T *ep;
Loading
Loading
@@ -3161,7 +3168,7 @@ static s32 _walk_fat_chain(struct super_block *sb, CHAIN_T *p_dir, s32 byte_offs
*clu = cur_clu;
return FFS_SUCCESS;
}
s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector, s32 *offset)
s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, sector_t *sector, s32 *offset)
{
s32 off, ret;
u32 clu = 0;
Loading
Loading
@@ -3188,7 +3195,7 @@ s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector
return FFS_SUCCESS;
} /* end of find_location */
 
DENTRY_T *get_entry_with_sector(struct super_block *sb, u32 sector, s32 offset)
DENTRY_T *get_entry_with_sector(struct super_block *sb, sector_t sector, s32 offset)
{
u8 *buf;
 
Loading
Loading
@@ -3200,10 +3207,10 @@ DENTRY_T *get_entry_with_sector(struct super_block *sb, u32 sector, s32 offset)
return (DENTRY_T *)(buf + offset);
} /* end of get_entry_with_sector */
 
DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector)
DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, sector_t *sector)
{
s32 off;
u32 sec;
sector_t sec;
u8 *buf;
 
if (find_location(sb, p_dir, entry, &sec, &off) != FFS_SUCCESS)
Loading
Loading
@@ -3242,7 +3249,8 @@ ENTRY_SET_CACHE_T *get_entry_set_in_dir(struct super_block *sb, CHAIN_T *p_dir,
{
s32 off, ret, byte_offset;
u32 clu = 0;
u32 sec, entry_type;
sector_t sec;
u32 entry_type;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
ENTRY_SET_CACHE_T *es = NULL;
Loading
Loading
@@ -3375,8 +3383,9 @@ ENTRY_SET_CACHE_T *get_entry_set_in_dir(struct super_block *sb, CHAIN_T *p_dir,
if (file_ep)
*file_ep = (DENTRY_T *)&(es->__buf);
 
DPRINTK("es sec %u offset %d flags %d, num_entries %u buf ptr %p\n",
es->sector, es->offset, es->alloc_flag, es->num_entries, &(es->__buf));
DPRINTK("es sec %llu offset %d flags %d, num_entries %u buf ptr %p\n",
(unsigned long long)es->sector, es->offset, es->alloc_flag,
es->num_entries, &(es->__buf));
DPRINTK("get_entry_set_in_dir exited %p\n", es);
return es;
err_out:
Loading
Loading
@@ -3394,7 +3403,7 @@ void release_entry_set(ENTRY_SET_CACHE_T *es)
}
 
 
static s32 __write_partial_entries_in_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es, u32 sec, s32 off, u32 count)
static s32 __write_partial_entries_in_entry_set(struct super_block *sb, 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;
Loading
Loading
@@ -3404,7 +3413,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, ENTRY_SE
u8 *buf, *esbuf = (u8 *)&(es->__buf);
 
DPRINTK("__write_partial_entries_in_entry_set entered\n");
DPRINTK("es %p sec %u off %d count %d\n", es, sec, off, count);
DPRINTK("es %p sec %llu off %d count %d\n", es, (unsigned long long)sec, off, count);
num_entries = count;
 
while (num_entries) {
Loading
Loading
@@ -3415,7 +3424,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, ENTRY_SE
if (buf == NULL)
goto err_out;
DPRINTK("es->buf %p buf_off %u\n", esbuf, buf_off);
DPRINTK("copying %d entries from %p to sector %u\n", copy_entries, (esbuf + buf_off), sec);
DPRINTK("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;
Loading
Loading
@@ -3456,7 +3465,8 @@ s32 write_whole_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es)
s32 write_partial_entries_in_entry_set (struct super_block *sb, ENTRY_SET_CACHE_T *es, DENTRY_T *ep, u32 count)
{
s32 ret, byte_offset, off;
u32 clu=0, sec;
u32 clu=0;
sector_t sec;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
CHAIN_T dir;
Loading
Loading
@@ -3579,7 +3589,8 @@ s32 search_deleted_or_unused_entry(struct super_block *sb, CHAIN_T *p_dir, s32 n
s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries)
{
s32 ret, dentry;
u32 last_clu, sector;
u32 last_clu;
sector_t sector;
u64 size = 0;
CHAIN_T clu;
DENTRY_T *ep = NULL;
Loading
Loading
@@ -4816,7 +4827,7 @@ s32 create_file(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, u8 m
void remove_file(struct inode *inode, CHAIN_T *p_dir, s32 entry)
{
s32 num_entries;
u32 sector;
sector_t sector;
DENTRY_T *ep;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Loading
Loading
@@ -4844,7 +4855,7 @@ void remove_file(struct inode *inode, CHAIN_T *p_dir, s32 entry)
s32 rename_file(struct inode *inode, CHAIN_T *p_dir, s32 oldentry, UNI_NAME_T *p_uniname, FILE_ID_T *fid)
{
s32 ret, newentry = -1, num_old_entries, num_new_entries;
u32 sector_old, sector_new;
sector_t sector_old, sector_new;
DOS_NAME_T dos_name;
DENTRY_T *epold, *epnew;
struct super_block *sb = inode->i_sb;
Loading
Loading
@@ -4933,7 +4944,7 @@ s32 rename_file(struct inode *inode, CHAIN_T *p_dir, s32 oldentry, UNI_NAME_T *p
s32 move_file(struct inode *inode, CHAIN_T *p_olddir, s32 oldentry, CHAIN_T *p_newdir, UNI_NAME_T *p_uniname, FILE_ID_T *fid)
{
s32 ret, newentry, num_new_entries, num_old_entries;
u32 sector_mov, sector_new;
sector_t sector_mov, sector_new;
CHAIN_T clu;
DOS_NAME_T dos_name;
DENTRY_T *epmov, *epnew;
Loading
Loading
@@ -5032,13 +5043,13 @@ s32 move_file(struct inode *inode, CHAIN_T *p_olddir, s32 oldentry, CHAIN_T *p_n
* Sector Read/Write Functions
*/
 
s32 sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 read)
s32 sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 read)
{
s32 ret = FFS_MEDIAERR;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
 
if ((sec >= (p_fs->PBR_sector+p_fs->num_sectors)) && (p_fs->num_sectors > 0)) {
printk("[EXFAT] sector_read: out of range error! (sec = %d)\n", sec);
printk("[EXFAT] sector_read: out of range error! (sec = %llu)\n", (unsigned long long)sec);
fs_error(sb);
return ret;
}
Loading
Loading
@@ -5052,13 +5063,13 @@ s32 sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 re
return ret;
} /* end of sector_read */
 
s32 sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 sync)
s32 sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 sync)
{
s32 ret = FFS_MEDIAERR;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
 
if (sec >= (p_fs->PBR_sector+p_fs->num_sectors) && (p_fs->num_sectors > 0)) {
printk("[EXFAT] sector_write: out of range error! (sec = %d)\n", sec);
printk("[EXFAT] sector_write: out of range error! (sec = %llu)\n", (unsigned long long)sec);
fs_error(sb);
return ret;
}
Loading
Loading
@@ -5078,13 +5089,14 @@ s32 sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 sy
return ret;
} /* end of sector_write */
 
s32 multi_sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 num_secs, s32 read)
s32 multi_sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 num_secs, s32 read)
{
s32 ret = FFS_MEDIAERR;
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)) {
printk("[EXFAT] multi_sector_read: out of range error! (sec = %d, num_secs = %d)\n", sec, num_secs);
printk("[EXFAT] multi_sector_read: out of range error! (sec = %llu, num_secs = %d)\n",
(unsigned long long)sec, num_secs);
fs_error(sb);
return ret;
}
Loading
Loading
@@ -5098,13 +5110,14 @@ s32 multi_sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh,
return ret;
} /* end of multi_sector_read */
 
s32 multi_sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 num_secs, s32 sync)
s32 multi_sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 num_secs, s32 sync)
{
s32 ret = FFS_MEDIAERR;
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)) {
printk("[EXFAT] multi_sector_write: out of range error! (sec = %d, num_secs = %d)\n", sec, num_secs);
printk("[EXFAT] multi_sector_write: out of range error! (sec = %llu, num_secs = %d)\n",
(unsigned long long)sec, num_secs);
fs_error(sb);
return ret;
}
Loading
Loading
Loading
Loading
@@ -127,13 +127,13 @@
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
 
#define START_SECTOR(x) \
((((x) - 2) << p_fs->sectors_per_clu_bits) + p_fs->data_start_sector)
((((sector_t)((x) - 2)) << p_fs->sectors_per_clu_bits) + p_fs->data_start_sector)
 
#define IS_LAST_SECTOR_IN_CLUSTER(sec) \
((((sec) - p_fs->data_start_sector + 1) & ((1 << p_fs->sectors_per_clu_bits) - 1)) == 0)
 
#define GET_CLUSTER_FROM_SECTOR(sec) \
((((sec) - p_fs->data_start_sector) >> p_fs->sectors_per_clu_bits) + 2)
((u32)((((sec) - p_fs->data_start_sector) >> p_fs->sectors_per_clu_bits) + 2))
 
#define GET16(p_src) \
(((u16)(p_src)[0]) | (((u16)(p_src)[1]) << 8))
Loading
Loading
@@ -449,7 +449,7 @@ typedef struct __FS_INFO_T {
u32 vol_type; /* volume FAT type */
u32 vol_id; /* volume serial number */
 
u32 num_sectors; /* num of sectors in volume */
u64 num_sectors; /* num of sectors in volume */
u32 num_clusters; /* num of clusters in volume */
u32 cluster_size; /* cluster size in bytes */
u32 cluster_size_bits;
Loading
Loading
@@ -501,7 +501,7 @@ typedef struct __FS_INFO_T {
#define ES_ALL_ENTRIES 0
 
typedef struct {
u32 sector; /* sector number that contains file_entry */
sector_t sector; /* sector number that contains file_entry */
s32 offset; /* byte offset in the sector */
s32 alloc_flag; /* flag in stream entry. 01 for cluster chain, 03 for contig. clusteres. */
u32 num_entries;
Loading
Loading
@@ -615,9 +615,9 @@ void init_name_entry(NAME_DENTRY_T *ep, u16 *uniname);
void fat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries);
void exfat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries);
 
s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector, s32 *offset);
DENTRY_T *get_entry_with_sector(struct super_block *sb, u32 sector, s32 offset);
DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector);
s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, sector_t *sector, s32 *offset);
DENTRY_T *get_entry_with_sector(struct super_block *sb, sector_t sector, s32 offset);
DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, sector_t *sector);
ENTRY_SET_CACHE_T *get_entry_set_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, DENTRY_T **file_ep);
void release_entry_set(ENTRY_SET_CACHE_T *es);
s32 write_whole_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es);
Loading
Loading
@@ -663,9 +663,9 @@ s32 rename_file(struct inode *inode, CHAIN_T *p_dir, s32 old_entry, UNI_NAME_T
s32 move_file(struct inode *inode, CHAIN_T *p_olddir, s32 oldentry, CHAIN_T *p_newdir, UNI_NAME_T *p_uniname, FILE_ID_T *fid);
 
/* sector read/write functions */
s32 sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 read);
s32 sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 sync);
s32 multi_sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 num_secs, s32 read);
s32 multi_sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 num_secs, s32 sync);
s32 sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 read);
s32 sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 sync);
s32 multi_sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 num_secs, s32 read);
s32 multi_sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 num_secs, s32 sync);
 
#endif /* _EXFAT_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment