Hey guys, I have a question. I am writing a FAT16 filesystem for my OS right now, and the structure I created to hold the filesystem information obviously did not work correctly without __attribute__((packed)). So I started reading into what this statement actually does since I realized I really didn't understand it well. As I was looking, I found lots of information that said that __attribute__((packed)) actually causes code to slow down due to misaligned accesses. So the question is, how do I know which structs I can pack, and which I can't? Also, does anyone have a suggestion how I may implement the filesystem driver without the packing attribute? I am basically using a FAT16-formatted ramdisk loaded by GRUB for loading the drivers necessary to start the system, and so I did something like this:
Code:
static uint8_t *ramdisk_data;
struct fat16_bpb bios_blk;
initrd_initialize (void *ramfs) {
ramdisk_data = (uint8_t *) ramfs;
struct fat16_bpb *bios_blk_ptr = (&bios_blk);
memcpy ((void *)bios_blk_ptr, (void *) ramdisk_data, sizeof (struct fat16_bpb));
}
I guess if I was going to ask OS-specific questions I should have posted in the OS Development thread... if that causes a problem, can this be moved? This is just a genuine curiosity for me. Thanks!