vvfat.c (7267c0947d7e8ae5dff7bafd932c3bc285f43e5c) | vvfat.c (541dc0d47f10973c241e9955afc2aefc96adec51) |
---|---|
1/* vim:set shiftwidth=4 ts=8: */ 2/* 3 * QEMU Block driver for virtual VFAT (shadows a local directory) 4 * 5 * Copyright (c) 2004,2005 Johannes E. Schindelin 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 186 unchanged lines hidden (view full) --- 195{ 196 size_t offset = (char*)pointer - array->pointer; 197 assert((offset % array->item_size) == 0); 198 assert(offset/array->item_size < array->next); 199 return offset/array->item_size; 200} 201 202/* These structures are used to fake a disk and the VFAT filesystem. | 1/* vim:set shiftwidth=4 ts=8: */ 2/* 3 * QEMU Block driver for virtual VFAT (shadows a local directory) 4 * 5 * Copyright (c) 2004,2005 Johannes E. Schindelin 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 186 unchanged lines hidden (view full) --- 195{ 196 size_t offset = (char*)pointer - array->pointer; 197 assert((offset % array->item_size) == 0); 198 assert(offset/array->item_size < array->next); 199 return offset/array->item_size; 200} 201 202/* These structures are used to fake a disk and the VFAT filesystem. |
203 * For this reason we need to use __attribute__((packed)). */ | 203 * For this reason we need to use QEMU_PACKED. */ |
204 205typedef struct bootsector_t { 206 uint8_t jump[3]; 207 uint8_t name[8]; 208 uint16_t sector_size; 209 uint8_t sectors_per_cluster; 210 uint16_t reserved_sectors; 211 uint8_t number_of_fats; --- 7 unchanged lines hidden (view full) --- 219 uint32_t total_sectors; 220 union { 221 struct { 222 uint8_t drive_number; 223 uint8_t current_head; 224 uint8_t signature; 225 uint32_t id; 226 uint8_t volume_label[11]; | 204 205typedef struct bootsector_t { 206 uint8_t jump[3]; 207 uint8_t name[8]; 208 uint16_t sector_size; 209 uint8_t sectors_per_cluster; 210 uint16_t reserved_sectors; 211 uint8_t number_of_fats; --- 7 unchanged lines hidden (view full) --- 219 uint32_t total_sectors; 220 union { 221 struct { 222 uint8_t drive_number; 223 uint8_t current_head; 224 uint8_t signature; 225 uint32_t id; 226 uint8_t volume_label[11]; |
227 } __attribute__((packed)) fat16; | 227 } QEMU_PACKED fat16; |
228 struct { 229 uint32_t sectors_per_fat; 230 uint16_t flags; 231 uint8_t major,minor; 232 uint32_t first_cluster_of_root_directory; 233 uint16_t info_sector; 234 uint16_t backup_boot_sector; 235 uint16_t ignored; | 228 struct { 229 uint32_t sectors_per_fat; 230 uint16_t flags; 231 uint8_t major,minor; 232 uint32_t first_cluster_of_root_directory; 233 uint16_t info_sector; 234 uint16_t backup_boot_sector; 235 uint16_t ignored; |
236 } __attribute__((packed)) fat32; | 236 } QEMU_PACKED fat32; |
237 } u; 238 uint8_t fat_type[8]; 239 uint8_t ignored[0x1c0]; 240 uint8_t magic[2]; | 237 } u; 238 uint8_t fat_type[8]; 239 uint8_t ignored[0x1c0]; 240 uint8_t magic[2]; |
241} __attribute__((packed)) bootsector_t; | 241} QEMU_PACKED bootsector_t; |
242 243typedef struct { 244 uint8_t head; 245 uint8_t sector; 246 uint8_t cylinder; 247} mbr_chs_t; 248 249typedef struct partition_t { 250 uint8_t attributes; /* 0x80 = bootable */ 251 mbr_chs_t start_CHS; 252 uint8_t fs_type; /* 0x1 = FAT12, 0x6 = FAT16, 0xe = FAT16_LBA, 0xb = FAT32, 0xc = FAT32_LBA */ 253 mbr_chs_t end_CHS; 254 uint32_t start_sector_long; 255 uint32_t length_sector_long; | 242 243typedef struct { 244 uint8_t head; 245 uint8_t sector; 246 uint8_t cylinder; 247} mbr_chs_t; 248 249typedef struct partition_t { 250 uint8_t attributes; /* 0x80 = bootable */ 251 mbr_chs_t start_CHS; 252 uint8_t fs_type; /* 0x1 = FAT12, 0x6 = FAT16, 0xe = FAT16_LBA, 0xb = FAT32, 0xc = FAT32_LBA */ 253 mbr_chs_t end_CHS; 254 uint32_t start_sector_long; 255 uint32_t length_sector_long; |
256} __attribute__((packed)) partition_t; | 256} QEMU_PACKED partition_t; |
257 258typedef struct mbr_t { 259 uint8_t ignored[0x1b8]; 260 uint32_t nt_id; 261 uint8_t ignored2[2]; 262 partition_t partition[4]; 263 uint8_t magic[2]; | 257 258typedef struct mbr_t { 259 uint8_t ignored[0x1b8]; 260 uint32_t nt_id; 261 uint8_t ignored2[2]; 262 partition_t partition[4]; 263 uint8_t magic[2]; |
264} __attribute__((packed)) mbr_t; | 264} QEMU_PACKED mbr_t; |
265 266typedef struct direntry_t { 267 uint8_t name[8]; 268 uint8_t extension[3]; 269 uint8_t attributes; 270 uint8_t reserved[2]; 271 uint16_t ctime; 272 uint16_t cdate; 273 uint16_t adate; 274 uint16_t begin_hi; 275 uint16_t mtime; 276 uint16_t mdate; 277 uint16_t begin; 278 uint32_t size; | 265 266typedef struct direntry_t { 267 uint8_t name[8]; 268 uint8_t extension[3]; 269 uint8_t attributes; 270 uint8_t reserved[2]; 271 uint16_t ctime; 272 uint16_t cdate; 273 uint16_t adate; 274 uint16_t begin_hi; 275 uint16_t mtime; 276 uint16_t mdate; 277 uint16_t begin; 278 uint32_t size; |
279} __attribute__((packed)) direntry_t; | 279} QEMU_PACKED direntry_t; |
280 281/* this structure are used to transparently access the files */ 282 283typedef struct mapping_t { 284 /* begin is the first cluster, end is the last+1 */ 285 uint32_t begin,end; 286 /* as s->directory is growable, no pointer may be used here */ 287 unsigned int dir_index; --- 2601 unchanged lines hidden --- | 280 281/* this structure are used to transparently access the files */ 282 283typedef struct mapping_t { 284 /* begin is the first cluster, end is the last+1 */ 285 uint32_t begin,end; 286 /* as s->directory is growable, no pointer may be used here */ 287 unsigned int dir_index; --- 2601 unchanged lines hidden --- |