Commit 9ac6b2af authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] fat endianness annotations

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5c520b7f
......@@ -45,13 +45,13 @@ int __fat_access(struct super_block *sb, int nr, int new_value)
}
if (sbi->fat_bits == 32) {
p_first = p_last = NULL; /* GCC needs that stuff */
next = CF_LE_L(((__u32 *) bh->b_data)[(first &
next = CF_LE_L(((__le32 *) bh->b_data)[(first &
(sb->s_blocksize - 1)) >> 2]);
/* Fscking Microsoft marketing department. Their "32" is 28. */
next &= 0x0fffffff;
} else if (sbi->fat_bits == 16) {
p_first = p_last = NULL; /* GCC needs that stuff */
next = CF_LE_W(((__u16 *) bh->b_data)[(first &
next = CF_LE_W(((__le16 *) bh->b_data)[(first &
(sb->s_blocksize - 1)) >> 1]);
} else {
p_first = &((__u8 *)bh->b_data)[first & (sb->s_blocksize - 1)];
......@@ -63,10 +63,10 @@ int __fat_access(struct super_block *sb, int nr, int new_value)
}
if (new_value != -1) {
if (sbi->fat_bits == 32) {
((__u32 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 2]
((__le32 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 2]
= CT_LE_L(new_value);
} else if (sbi->fat_bits == 16) {
((__u16 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 1]
((__le16 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 1]
= CT_LE_W(new_value);
} else {
if (nr & 1) {
......
......@@ -714,7 +714,7 @@ int fat_new_dir(struct inode *dir, struct inode *parent, int is_vfat)
{
struct buffer_head *bh;
struct msdos_dir_entry *de;
__u16 date, time;
__le16 date, time;
bh = fat_extend_dir(dir);
if (IS_ERR(bh))
......
......@@ -857,7 +857,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
brelse(bh);
goto out_invalid;
}
logical_sector_size = CF_LE_W(get_unaligned((u16 *)&b->sector_size));
logical_sector_size = CF_LE_W(get_unaligned((__le16 *)&b->sector_size));
if (!logical_sector_size
|| (logical_sector_size & (logical_sector_size - 1))
|| (logical_sector_size < 512)
......@@ -957,7 +957,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1;
sbi->dir_start = sbi->fat_start + sbi->fats * sbi->fat_length;
sbi->dir_entries = CF_LE_W(get_unaligned((u16 *)&b->dir_entries));
sbi->dir_entries = CF_LE_W(get_unaligned((__le16 *)&b->dir_entries));
if (sbi->dir_entries & (sbi->dir_per_block - 1)) {
if (!silent)
printk(KERN_ERR "FAT: bogus directroy-entries per block"
......@@ -969,7 +969,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
rootdir_sectors = sbi->dir_entries
* sizeof(struct msdos_dir_entry) / sb->s_blocksize;
sbi->data_start = sbi->dir_start + rootdir_sectors;
total_sectors = CF_LE_W(get_unaligned((u16 *)&b->sectors));
total_sectors = CF_LE_W(get_unaligned((__le16 *)&b->sectors));
if (total_sectors == 0)
total_sectors = CF_LE_L(b->total_sect);
......
......@@ -73,9 +73,9 @@ void fat_clusters_flush(struct super_block *sb)
sbi->fsinfo_sector);
} else {
if (sbi->free_clusters != -1)
fsinfo->free_clusters = CF_LE_L(sbi->free_clusters);
fsinfo->free_clusters = cpu_to_le32(sbi->free_clusters);
if (sbi->prev_free != -1)
fsinfo->next_cluster = CF_LE_L(sbi->prev_free);
fsinfo->next_cluster = cpu_to_le32(sbi->prev_free);
mark_buffer_dirty(bh);
}
brelse(bh);
......@@ -243,8 +243,7 @@ int date_dos2unix(unsigned short time,unsigned short date)
/* Convert linear UNIX date to a MS-DOS time/date pair. */
void fat_date_unix2dos(int unix_date,unsigned short *time,
unsigned short *date)
void fat_date_unix2dos(int unix_date,__le16 *time, __le16 *date)
{
int day,year,nl_day,month;
......
......@@ -677,7 +677,8 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
de->attr = is_dir ? ATTR_DIR : ATTR_ARCH;
de->lcase = lcase;
de->adate = de->cdate = de->date = 0;
de->ctime_ms = de->ctime = de->time = 0;
de->ctime = de->time = 0;
de->ctime_ms = 0;
de->start = 0;
de->starthi = 0;
de->size = 0;
......@@ -1046,8 +1047,8 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
if (is_dir) {
int start = MSDOS_I(new_dir)->i_logstart;
dotdot_de->start = CT_LE_W(start);
dotdot_de->starthi = CT_LE_W(start>>16);
dotdot_de->start = cpu_to_le16(start);
dotdot_de->starthi = cpu_to_le16(start>>16);
mark_buffer_dirty(dotdot_bh);
old_dir->i_nlink--;
if (new_inode) {
......
......@@ -123,34 +123,34 @@ struct fat_boot_sector {
partition manager volumes */
__u8 sector_size[2]; /* bytes per logical sector */
__u8 sec_per_clus; /* sectors/cluster */
__u16 reserved; /* reserved sectors */
__le16 reserved; /* reserved sectors */
__u8 fats; /* number of FATs */
__u8 dir_entries[2]; /* root directory entries */
__u8 sectors[2]; /* number of sectors */
__u8 media; /* media code */
__u16 fat_length; /* sectors/FAT */
__u16 secs_track; /* sectors per track */
__u16 heads; /* number of heads */
__u32 hidden; /* hidden sectors (unused) */
__u32 total_sect; /* number of sectors (if sectors == 0) */
__le16 fat_length; /* sectors/FAT */
__le16 secs_track; /* sectors per track */
__le16 heads; /* number of heads */
__le32 hidden; /* hidden sectors (unused) */
__le32 total_sect; /* number of sectors (if sectors == 0) */
/* The following fields are only used by FAT32 */
__u32 fat32_length; /* sectors/FAT */
__u16 flags; /* bit 8: fat mirroring, low 4: active fat */
__le32 fat32_length; /* sectors/FAT */
__le16 flags; /* bit 8: fat mirroring, low 4: active fat */
__u8 version[2]; /* major, minor filesystem version */
__u32 root_cluster; /* first cluster in root directory */
__u16 info_sector; /* filesystem info sector */
__u16 backup_boot; /* backup boot sector */
__u16 reserved2[6]; /* Unused */
__le32 root_cluster; /* first cluster in root directory */
__le16 info_sector; /* filesystem info sector */
__le16 backup_boot; /* backup boot sector */
__le16 reserved2[6]; /* Unused */
};
struct fat_boot_fsinfo {
__u32 signature1; /* 0x41615252L */
__u32 reserved1[120]; /* Nothing as far as I can tell */
__u32 signature2; /* 0x61417272L */
__u32 free_clusters; /* Free cluster count. -1 if unknown */
__u32 next_cluster; /* Most recently allocated cluster */
__u32 reserved2[4];
__le32 signature1; /* 0x41615252L */
__le32 reserved1[120]; /* Nothing as far as I can tell */
__le32 signature2; /* 0x61417272L */
__le32 free_clusters; /* Free cluster count. -1 if unknown */
__le32 next_cluster; /* Most recently allocated cluster */
__le32 reserved2[4];
};
struct msdos_dir_entry {
......@@ -158,12 +158,12 @@ struct msdos_dir_entry {
__u8 attr; /* attribute bits */
__u8 lcase; /* Case for base and extension */
__u8 ctime_ms; /* Creation time, milliseconds */
__u16 ctime; /* Creation time */
__u16 cdate; /* Creation date */
__u16 adate; /* Last access date */
__u16 starthi; /* High 16 bits of cluster in FAT32 */
__u16 time,date,start;/* time, date and first cluster */
__u32 size; /* file size (in bytes) */
__le16 ctime; /* Creation time */
__le16 cdate; /* Creation date */
__le16 adate; /* Last access date */
__le16 starthi; /* High 16 bits of cluster in FAT32 */
__le16 time,date,start;/* time, date and first cluster */
__le32 size; /* file size (in bytes) */
};
/* Up to 13 characters of the name */
......@@ -174,7 +174,7 @@ struct msdos_dir_slot {
__u8 reserved; /* always 0 */
__u8 alias_checksum; /* checksum for 8.3 alias */
__u8 name5_10[12]; /* 6 more characters in name */
__u16 start; /* starting cluster number, 0 in long slots */
__le16 start; /* starting cluster number, 0 in long slots */
__u8 name11_12[4]; /* last 2 characters in name */
};
......@@ -287,8 +287,7 @@ extern void fat_clusters_flush(struct super_block *sb);
extern int fat_add_cluster(struct inode *inode);
extern struct buffer_head *fat_extend_dir(struct inode *inode);
extern int date_dos2unix(unsigned short time, unsigned short date);
extern void fat_date_unix2dos(int unix_date, unsigned short *time,
unsigned short *date);
extern void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date);
extern int fat__get_entry(struct inode *dir, loff_t *pos,
struct buffer_head **bh,
struct msdos_dir_entry **de, loff_t *i_pos);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment