lkml.org 
[lkml]   [2002]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [patch] fat/msdos/vfat crud removal
From
Date
"Albert D. Cahalan" <acahalan@cs.uml.edu> writes:

> Use the packed attribute on the struct, along with
> the right types. I don't think you need get_unaligned
> with a packed struct, because gcc will know that it
> needs to emit code for unaligned data.
>
> At the very least you can get rid of the cast.
>
> Before:
> logical_sector_size = le16_to_cpu(get_unaligned((u16*)&b->sector_size));
>
> After:
> logical_sector_size = le16_to_cpu(b->sector_size);
>
> The new struct:
>
> /* Note the end: __attribute__ ((packed)) */
> struct fat_boot_sector {
> char ignored[3]; /* Boot strap short or near jump */
> __u64 system_id; /* Name - can be used to special case
> partition manager volumes */
> __u16 sector_size; /* bytes per logical sector */
> __u8 cluster_size; /* sectors/cluster */
> __u16 reserved; /* reserved sectors */
> __u8 fats; /* number of FATs */
> __u16 dir_entries; /* root directory entries */
> __u16 sectors; /* 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) */
>
> /* The following fields are only used by FAT32 */
> __u32 fat32_length; /* sectors/FAT */
> __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
> __u16 version; /* 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 */
> } __attribute__ ((packed)) ;

BTW, is this safe on other of i386 (ex. mips etc.)? I'm not sure.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:26    [W:0.114 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site