Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: use struct parsed_partitions *state universally in partition check code

Make the following changes to partition check code.

* Add ->bdev to struct parsed_partitions.

* Introduce read_part_sector() which is a simple wrapper around
read_dev_sector() which takes struct parsed_partitions *state
instead of @bdev.

* For functions which used to take @state and @bdev, drop @bdev. For
functions which used to take @bdev, replace it with @state.

* While updating, drop superflous checks on NULL state/bdev in ldm.c.

This cleans up the API a bit and enables better handling of IO errors
during partition check as the generic partition check code now has
much better visibility into what went wrong in the low level code
paths.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

authored by

Tejun Heo and committed by
Jens Axboe
1493bf21 c3e33e04

+225 -239
+32 -36
fs/partitions/acorn.c
··· 70 70 71 71 #if defined(CONFIG_ACORN_PARTITION_CUMANA) || \ 72 72 defined(CONFIG_ACORN_PARTITION_ADFS) 73 - static int 74 - riscix_partition(struct parsed_partitions *state, struct block_device *bdev, 75 - unsigned long first_sect, int slot, unsigned long nr_sects) 73 + static int riscix_partition(struct parsed_partitions *state, 74 + unsigned long first_sect, int slot, 75 + unsigned long nr_sects) 76 76 { 77 77 Sector sect; 78 78 struct riscix_record *rr; 79 79 80 - rr = (struct riscix_record *)read_dev_sector(bdev, first_sect, &sect); 80 + rr = read_part_sector(state, first_sect, &sect); 81 81 if (!rr) 82 82 return -1; 83 83 ··· 123 123 124 124 #if defined(CONFIG_ACORN_PARTITION_CUMANA) || \ 125 125 defined(CONFIG_ACORN_PARTITION_ADFS) 126 - static int 127 - linux_partition(struct parsed_partitions *state, struct block_device *bdev, 128 - unsigned long first_sect, int slot, unsigned long nr_sects) 126 + static int linux_partition(struct parsed_partitions *state, 127 + unsigned long first_sect, int slot, 128 + unsigned long nr_sects) 129 129 { 130 130 Sector sect; 131 131 struct linux_part *linuxp; ··· 135 135 136 136 put_partition(state, slot++, first_sect, size); 137 137 138 - linuxp = (struct linux_part *)read_dev_sector(bdev, first_sect, &sect); 138 + linuxp = read_part_sector(state, first_sect, &sect); 139 139 if (!linuxp) 140 140 return -1; 141 141 ··· 157 157 #endif 158 158 159 159 #ifdef CONFIG_ACORN_PARTITION_CUMANA 160 - int 161 - adfspart_check_CUMANA(struct parsed_partitions *state, struct block_device *bdev) 160 + int adfspart_check_CUMANA(struct parsed_partitions *state) 162 161 { 163 162 unsigned long first_sector = 0; 164 163 unsigned int start_blk = 0; ··· 184 185 struct adfs_discrecord *dr; 185 186 unsigned int nr_sects; 186 187 187 - data = read_dev_sector(bdev, start_blk * 2 + 6, &sect); 188 + data = read_part_sector(state, start_blk * 2 + 6, &sect); 188 189 if (!data) 189 190 return -1; 190 191 ··· 216 217 #ifdef CONFIG_ACORN_PARTITION_RISCIX 217 218 case PARTITION_RISCIX_SCSI: 218 219 /* RISCiX - we don't know how to find the next one. */ 219 - slot = riscix_partition(state, bdev, first_sector, 220 - slot, nr_sects); 220 + slot = riscix_partition(state, first_sector, slot, 221 + nr_sects); 221 222 break; 222 223 #endif 223 224 224 225 case PARTITION_LINUX: 225 - slot = linux_partition(state, bdev, first_sector, 226 - slot, nr_sects); 226 + slot = linux_partition(state, first_sector, slot, 227 + nr_sects); 227 228 break; 228 229 } 229 230 put_dev_sector(sect); ··· 248 249 * hda1 = ADFS partition on first drive. 249 250 * hda2 = non-ADFS partition. 250 251 */ 251 - int 252 - adfspart_check_ADFS(struct parsed_partitions *state, struct block_device *bdev) 252 + int adfspart_check_ADFS(struct parsed_partitions *state) 253 253 { 254 254 unsigned long start_sect, nr_sects, sectscyl, heads; 255 255 Sector sect; ··· 257 259 unsigned char id; 258 260 int slot = 1; 259 261 260 - data = read_dev_sector(bdev, 6, &sect); 262 + data = read_part_sector(state, 6, &sect); 261 263 if (!data) 262 264 return -1; 263 265 ··· 276 278 /* 277 279 * Work out start of non-adfs partition. 278 280 */ 279 - nr_sects = (bdev->bd_inode->i_size >> 9) - start_sect; 281 + nr_sects = (state->bdev->bd_inode->i_size >> 9) - start_sect; 280 282 281 283 if (start_sect) { 282 284 switch (id) { 283 285 #ifdef CONFIG_ACORN_PARTITION_RISCIX 284 286 case PARTITION_RISCIX_SCSI: 285 287 case PARTITION_RISCIX_MFM: 286 - slot = riscix_partition(state, bdev, start_sect, 287 - slot, nr_sects); 288 + slot = riscix_partition(state, start_sect, slot, 289 + nr_sects); 288 290 break; 289 291 #endif 290 292 291 293 case PARTITION_LINUX: 292 - slot = linux_partition(state, bdev, start_sect, 293 - slot, nr_sects); 294 + slot = linux_partition(state, start_sect, slot, 295 + nr_sects); 294 296 break; 295 297 } 296 298 } ··· 306 308 __le32 size; 307 309 }; 308 310 309 - static int adfspart_check_ICSLinux(struct block_device *bdev, unsigned long block) 311 + static int adfspart_check_ICSLinux(struct parsed_partitions *state, 312 + unsigned long block) 310 313 { 311 314 Sector sect; 312 - unsigned char *data = read_dev_sector(bdev, block, &sect); 315 + unsigned char *data = read_part_sector(state, block, &sect); 313 316 int result = 0; 314 317 315 318 if (data) { ··· 348 349 * hda2 = ADFS partition 1 on first drive. 349 350 * ..etc.. 350 351 */ 351 - int 352 - adfspart_check_ICS(struct parsed_partitions *state, struct block_device *bdev) 352 + int adfspart_check_ICS(struct parsed_partitions *state) 353 353 { 354 354 const unsigned char *data; 355 355 const struct ics_part *p; ··· 358 360 /* 359 361 * Try ICS style partitions - sector 0 contains partition info. 360 362 */ 361 - data = read_dev_sector(bdev, 0, &sect); 363 + data = read_part_sector(state, 0, &sect); 362 364 if (!data) 363 365 return -1; 364 366 ··· 390 392 * partition is. We must not make this visible 391 393 * to the filesystem. 392 394 */ 393 - if (size > 1 && adfspart_check_ICSLinux(bdev, start)) { 395 + if (size > 1 && adfspart_check_ICSLinux(state, start)) { 394 396 start += 1; 395 397 size -= 1; 396 398 } ··· 444 446 * hda2 = ADFS partition 1 on first drive. 445 447 * ..etc.. 446 448 */ 447 - int 448 - adfspart_check_POWERTEC(struct parsed_partitions *state, struct block_device *bdev) 449 + int adfspart_check_POWERTEC(struct parsed_partitions *state) 449 450 { 450 451 Sector sect; 451 452 const unsigned char *data; ··· 452 455 int slot = 1; 453 456 int i; 454 457 455 - data = read_dev_sector(bdev, 0, &sect); 458 + data = read_part_sector(state, 0, &sect); 456 459 if (!data) 457 460 return -1; 458 461 ··· 505 508 * 1. The individual ADFS boot block entries that are placed on the disk. 506 509 * 2. The start address of the next entry. 507 510 */ 508 - int 509 - adfspart_check_EESOX(struct parsed_partitions *state, struct block_device *bdev) 511 + int adfspart_check_EESOX(struct parsed_partitions *state) 510 512 { 511 513 Sector sect; 512 514 const unsigned char *data; ··· 514 518 sector_t start = 0; 515 519 int i, slot = 1; 516 520 517 - data = read_dev_sector(bdev, 7, &sect); 521 + data = read_part_sector(state, 7, &sect); 518 522 if (!data) 519 523 return -1; 520 524 ··· 541 545 if (i != 0) { 542 546 sector_t size; 543 547 544 - size = get_capacity(bdev->bd_disk); 548 + size = get_capacity(state->bdev->bd_disk); 545 549 put_partition(state, slot++, start, size - start); 546 550 printk("\n"); 547 551 }
+5 -5
fs/partitions/acorn.h
··· 7 7 * format, and everyone stick to it? 8 8 */ 9 9 10 - int adfspart_check_CUMANA(struct parsed_partitions *state, struct block_device *bdev); 11 - int adfspart_check_ADFS(struct parsed_partitions *state, struct block_device *bdev); 12 - int adfspart_check_ICS(struct parsed_partitions *state, struct block_device *bdev); 13 - int adfspart_check_POWERTEC(struct parsed_partitions *state, struct block_device *bdev); 14 - int adfspart_check_EESOX(struct parsed_partitions *state, struct block_device *bdev); 10 + int adfspart_check_CUMANA(struct parsed_partitions *state); 11 + int adfspart_check_ADFS(struct parsed_partitions *state); 12 + int adfspart_check_ICS(struct parsed_partitions *state); 13 + int adfspart_check_POWERTEC(struct parsed_partitions *state); 14 + int adfspart_check_EESOX(struct parsed_partitions *state);
+6 -7
fs/partitions/amiga.c
··· 23 23 return sum; 24 24 } 25 25 26 - int 27 - amiga_partition(struct parsed_partitions *state, struct block_device *bdev) 26 + int amiga_partition(struct parsed_partitions *state) 28 27 { 29 28 Sector sect; 30 29 unsigned char *data; ··· 37 38 for (blk = 0; ; blk++, put_dev_sector(sect)) { 38 39 if (blk == RDB_ALLOCATION_LIMIT) 39 40 goto rdb_done; 40 - data = read_dev_sector(bdev, blk, &sect); 41 + data = read_part_sector(state, blk, &sect); 41 42 if (!data) { 42 43 if (warn_no_part) 43 44 printk("Dev %s: unable to read RDB block %d\n", 44 - bdevname(bdev, b), blk); 45 + bdevname(state->bdev, b), blk); 45 46 res = -1; 46 47 goto rdb_done; 47 48 } ··· 63 64 } 64 65 65 66 printk("Dev %s: RDB in block %d has bad checksum\n", 66 - bdevname(bdev, b), blk); 67 + bdevname(state->bdev, b), blk); 67 68 } 68 69 69 70 /* blksize is blocks per 512 byte standard block */ ··· 74 75 put_dev_sector(sect); 75 76 for (part = 1; blk>0 && part<=16; part++, put_dev_sector(sect)) { 76 77 blk *= blksize; /* Read in terms partition table understands */ 77 - data = read_dev_sector(bdev, blk, &sect); 78 + data = read_part_sector(state, blk, &sect); 78 79 if (!data) { 79 80 if (warn_no_part) 80 81 printk("Dev %s: unable to read partition block %d\n", 81 - bdevname(bdev, b), blk); 82 + bdevname(state->bdev, b), blk); 82 83 res = -1; 83 84 goto rdb_done; 84 85 }
+1 -1
fs/partitions/amiga.h
··· 2 2 * fs/partitions/amiga.h 3 3 */ 4 4 5 - int amiga_partition(struct parsed_partitions *state, struct block_device *bdev); 5 + int amiga_partition(struct parsed_partitions *state); 6 6
+4 -4
fs/partitions/atari.c
··· 30 30 memcmp (s, "RAW", 3) == 0 ; 31 31 } 32 32 33 - int atari_partition(struct parsed_partitions *state, struct block_device *bdev) 33 + int atari_partition(struct parsed_partitions *state) 34 34 { 35 35 Sector sect; 36 36 struct rootsector *rs; ··· 42 42 int part_fmt = 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */ 43 43 #endif 44 44 45 - rs = (struct rootsector *) read_dev_sector(bdev, 0, &sect); 45 + rs = read_part_sector(state, 0, &sect); 46 46 if (!rs) 47 47 return -1; 48 48 49 49 /* Verify this is an Atari rootsector: */ 50 - hd_size = bdev->bd_inode->i_size >> 9; 50 + hd_size = state->bdev->bd_inode->i_size >> 9; 51 51 if (!VALID_PARTITION(&rs->part[0], hd_size) && 52 52 !VALID_PARTITION(&rs->part[1], hd_size) && 53 53 !VALID_PARTITION(&rs->part[2], hd_size) && ··· 84 84 printk(" XGM<"); 85 85 partsect = extensect = be32_to_cpu(pi->st); 86 86 while (1) { 87 - xrs = (struct rootsector *)read_dev_sector(bdev, partsect, &sect2); 87 + xrs = read_part_sector(state, partsect, &sect2); 88 88 if (!xrs) { 89 89 printk (" block %ld read failed\n", partsect); 90 90 put_dev_sector(sect);
+1 -1
fs/partitions/atari.h
··· 31 31 u16 checksum; /* checksum for bootable disks */ 32 32 } __attribute__((__packed__)); 33 33 34 - int atari_partition(struct parsed_partitions *state, struct block_device *bdev); 34 + int atari_partition(struct parsed_partitions *state);
+3 -2
fs/partitions/check.c
··· 45 45 46 46 int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/ 47 47 48 - static int (*check_part[])(struct parsed_partitions *, struct block_device *) = { 48 + static int (*check_part[])(struct parsed_partitions *) = { 49 49 /* 50 50 * Probe partition formats with tables at disk address 0 51 51 * that also have an ADFS boot block at 0xdc0. ··· 165 165 if (!state) 166 166 return NULL; 167 167 168 + state->bdev = bdev; 168 169 disk_name(hd, 0, state->name); 169 170 printk(KERN_INFO " %s:", state->name); 170 171 if (isdigit(state->name[strlen(state->name)-1])) ··· 175 174 i = res = err = 0; 176 175 while (!res && check_part[i]) { 177 176 memset(&state->parts, 0, sizeof(state->parts)); 178 - res = check_part[i++](state, bdev); 177 + res = check_part[i++](state); 179 178 if (res < 0) { 180 179 /* We have hit an I/O error which we don't report now. 181 180 * But record it, and let the others do their job.
+7
fs/partitions/check.h
··· 6 6 * description. 7 7 */ 8 8 struct parsed_partitions { 9 + struct block_device *bdev; 9 10 char name[BDEVNAME_SIZE]; 10 11 struct { 11 12 sector_t from; ··· 16 15 int next; 17 16 int limit; 18 17 }; 18 + 19 + static inline void *read_part_sector(struct parsed_partitions *state, 20 + sector_t n, Sector *p) 21 + { 22 + return read_dev_sector(state->bdev, n, p); 23 + } 19 24 20 25 static inline void 21 26 put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
+43 -48
fs/partitions/efi.c
··· 140 140 * the part[0] entry for this disk, and is the number of 141 141 * physical sectors available on the disk. 142 142 */ 143 - static u64 144 - last_lba(struct block_device *bdev) 143 + static u64 last_lba(struct block_device *bdev) 145 144 { 146 145 if (!bdev || !bdev->bd_inode) 147 146 return 0; ··· 180 181 181 182 /** 182 183 * read_lba(): Read bytes from disk, starting at given LBA 183 - * @bdev 184 + * @state 184 185 * @lba 185 186 * @buffer 186 187 * @size_t 187 188 * 188 - * Description: Reads @count bytes from @bdev into @buffer. 189 + * Description: Reads @count bytes from @state->bdev into @buffer. 189 190 * Returns number of bytes read on success, 0 on error. 190 191 */ 191 - static size_t 192 - read_lba(struct block_device *bdev, u64 lba, u8 * buffer, size_t count) 192 + static size_t read_lba(struct parsed_partitions *state, 193 + u64 lba, u8 *buffer, size_t count) 193 194 { 194 195 size_t totalreadcount = 0; 196 + struct block_device *bdev = state->bdev; 195 197 sector_t n = lba * (bdev_logical_block_size(bdev) / 512); 196 198 197 - if (!bdev || !buffer || lba > last_lba(bdev)) 199 + if (!buffer || lba > last_lba(bdev)) 198 200 return 0; 199 201 200 202 while (count) { 201 203 int copied = 512; 202 204 Sector sect; 203 - unsigned char *data = read_dev_sector(bdev, n++, &sect); 205 + unsigned char *data = read_part_sector(state, n++, &sect); 204 206 if (!data) 205 207 break; 206 208 if (copied > count) ··· 217 217 218 218 /** 219 219 * alloc_read_gpt_entries(): reads partition entries from disk 220 - * @bdev 220 + * @state 221 221 * @gpt - GPT header 222 222 * 223 223 * Description: Returns ptes on success, NULL on error. 224 224 * Allocates space for PTEs based on information found in @gpt. 225 225 * Notes: remember to free pte when you're done! 226 226 */ 227 - static gpt_entry * 228 - alloc_read_gpt_entries(struct block_device *bdev, gpt_header *gpt) 227 + static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state, 228 + gpt_header *gpt) 229 229 { 230 230 size_t count; 231 231 gpt_entry *pte; 232 - if (!bdev || !gpt) 232 + 233 + if (!gpt) 233 234 return NULL; 234 235 235 236 count = le32_to_cpu(gpt->num_partition_entries) * ··· 241 240 if (!pte) 242 241 return NULL; 243 242 244 - if (read_lba(bdev, le64_to_cpu(gpt->partition_entry_lba), 243 + if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba), 245 244 (u8 *) pte, 246 245 count) < count) { 247 246 kfree(pte); ··· 253 252 254 253 /** 255 254 * alloc_read_gpt_header(): Allocates GPT header, reads into it from disk 256 - * @bdev 255 + * @state 257 256 * @lba is the Logical Block Address of the partition table 258 257 * 259 258 * Description: returns GPT header on success, NULL on error. Allocates 260 - * and fills a GPT header starting at @ from @bdev. 259 + * and fills a GPT header starting at @ from @state->bdev. 261 260 * Note: remember to free gpt when finished with it. 262 261 */ 263 - static gpt_header * 264 - alloc_read_gpt_header(struct block_device *bdev, u64 lba) 262 + static gpt_header *alloc_read_gpt_header(struct parsed_partitions *state, 263 + u64 lba) 265 264 { 266 265 gpt_header *gpt; 267 - unsigned ssz = bdev_logical_block_size(bdev); 268 - 269 - if (!bdev) 270 - return NULL; 266 + unsigned ssz = bdev_logical_block_size(state->bdev); 271 267 272 268 gpt = kzalloc(ssz, GFP_KERNEL); 273 269 if (!gpt) 274 270 return NULL; 275 271 276 - if (read_lba(bdev, lba, (u8 *) gpt, ssz) < ssz) { 272 + if (read_lba(state, lba, (u8 *) gpt, ssz) < ssz) { 277 273 kfree(gpt); 278 274 gpt=NULL; 279 275 return NULL; ··· 281 283 282 284 /** 283 285 * is_gpt_valid() - tests one GPT header and PTEs for validity 284 - * @bdev 286 + * @state 285 287 * @lba is the logical block address of the GPT header to test 286 288 * @gpt is a GPT header ptr, filled on return. 287 289 * @ptes is a PTEs ptr, filled on return. ··· 289 291 * Description: returns 1 if valid, 0 on error. 290 292 * If valid, returns pointers to newly allocated GPT header and PTEs. 291 293 */ 292 - static int 293 - is_gpt_valid(struct block_device *bdev, u64 lba, 294 - gpt_header **gpt, gpt_entry **ptes) 294 + static int is_gpt_valid(struct parsed_partitions *state, u64 lba, 295 + gpt_header **gpt, gpt_entry **ptes) 295 296 { 296 297 u32 crc, origcrc; 297 298 u64 lastlba; 298 299 299 - if (!bdev || !gpt || !ptes) 300 + if (!ptes) 300 301 return 0; 301 - if (!(*gpt = alloc_read_gpt_header(bdev, lba))) 302 + if (!(*gpt = alloc_read_gpt_header(state, lba))) 302 303 return 0; 303 304 304 305 /* Check the GUID Partition Table signature */ ··· 333 336 /* Check the first_usable_lba and last_usable_lba are 334 337 * within the disk. 335 338 */ 336 - lastlba = last_lba(bdev); 339 + lastlba = last_lba(state->bdev); 337 340 if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) { 338 341 pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n", 339 342 (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba), ··· 347 350 goto fail; 348 351 } 349 352 350 - if (!(*ptes = alloc_read_gpt_entries(bdev, *gpt))) 353 + if (!(*ptes = alloc_read_gpt_entries(state, *gpt))) 351 354 goto fail; 352 355 353 356 /* Check the GUID Partition Entry Array CRC */ ··· 492 495 493 496 /** 494 497 * find_valid_gpt() - Search disk for valid GPT headers and PTEs 495 - * @bdev 498 + * @state 496 499 * @gpt is a GPT header ptr, filled on return. 497 500 * @ptes is a PTEs ptr, filled on return. 498 501 * Description: Returns 1 if valid, 0 on error. ··· 505 508 * This protects against devices which misreport their size, and forces 506 509 * the user to decide to use the Alternate GPT. 507 510 */ 508 - static int 509 - find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes) 511 + static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt, 512 + gpt_entry **ptes) 510 513 { 511 514 int good_pgpt = 0, good_agpt = 0, good_pmbr = 0; 512 515 gpt_header *pgpt = NULL, *agpt = NULL; 513 516 gpt_entry *pptes = NULL, *aptes = NULL; 514 517 legacy_mbr *legacymbr; 515 518 u64 lastlba; 516 - if (!bdev || !gpt || !ptes) 519 + 520 + if (!ptes) 517 521 return 0; 518 522 519 - lastlba = last_lba(bdev); 523 + lastlba = last_lba(state->bdev); 520 524 if (!force_gpt) { 521 525 /* This will be added to the EFI Spec. per Intel after v1.02. */ 522 526 legacymbr = kzalloc(sizeof (*legacymbr), GFP_KERNEL); 523 527 if (legacymbr) { 524 - read_lba(bdev, 0, (u8 *) legacymbr, 525 - sizeof (*legacymbr)); 528 + read_lba(state, 0, (u8 *) legacymbr, 529 + sizeof (*legacymbr)); 526 530 good_pmbr = is_pmbr_valid(legacymbr); 527 531 kfree(legacymbr); 528 532 } ··· 531 533 goto fail; 532 534 } 533 535 534 - good_pgpt = is_gpt_valid(bdev, GPT_PRIMARY_PARTITION_TABLE_LBA, 536 + good_pgpt = is_gpt_valid(state, GPT_PRIMARY_PARTITION_TABLE_LBA, 535 537 &pgpt, &pptes); 536 538 if (good_pgpt) 537 - good_agpt = is_gpt_valid(bdev, 539 + good_agpt = is_gpt_valid(state, 538 540 le64_to_cpu(pgpt->alternate_lba), 539 541 &agpt, &aptes); 540 542 if (!good_agpt && force_gpt) 541 - good_agpt = is_gpt_valid(bdev, lastlba, 542 - &agpt, &aptes); 543 + good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes); 543 544 544 545 /* The obviously unsuccessful case */ 545 546 if (!good_pgpt && !good_agpt) ··· 580 583 } 581 584 582 585 /** 583 - * efi_partition(struct parsed_partitions *state, struct block_device *bdev) 586 + * efi_partition(struct parsed_partitions *state) 584 587 * @state 585 - * @bdev 586 588 * 587 589 * Description: called from check.c, if the disk contains GPT 588 590 * partitions, sets up partition entries in the kernel. ··· 598 602 * 1 if successful 599 603 * 600 604 */ 601 - int 602 - efi_partition(struct parsed_partitions *state, struct block_device *bdev) 605 + int efi_partition(struct parsed_partitions *state) 603 606 { 604 607 gpt_header *gpt = NULL; 605 608 gpt_entry *ptes = NULL; 606 609 u32 i; 607 - unsigned ssz = bdev_logical_block_size(bdev) / 512; 610 + unsigned ssz = bdev_logical_block_size(state->bdev) / 512; 608 611 609 - if (!find_valid_gpt(bdev, &gpt, &ptes) || !gpt || !ptes) { 612 + if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { 610 613 kfree(gpt); 611 614 kfree(ptes); 612 615 return 0; ··· 618 623 u64 size = le64_to_cpu(ptes[i].ending_lba) - 619 624 le64_to_cpu(ptes[i].starting_lba) + 1ULL; 620 625 621 - if (!is_pte_valid(&ptes[i], last_lba(bdev))) 626 + if (!is_pte_valid(&ptes[i], last_lba(state->bdev))) 622 627 continue; 623 628 624 629 put_partition(state, i+1, start * ssz, size * ssz);
+1 -1
fs/partitions/efi.h
··· 110 110 } __attribute__ ((packed)) legacy_mbr; 111 111 112 112 /* Functions */ 113 - extern int efi_partition(struct parsed_partitions *state, struct block_device *bdev); 113 + extern int efi_partition(struct parsed_partitions *state); 114 114 115 115 #endif 116 116
+10 -11
fs/partitions/ibm.c
··· 58 58 59 59 /* 60 60 */ 61 - int 62 - ibm_partition(struct parsed_partitions *state, struct block_device *bdev) 61 + int ibm_partition(struct parsed_partitions *state) 63 62 { 63 + struct block_device *bdev = state->bdev; 64 64 int blocksize, res; 65 65 loff_t i_size, offset, size, fmt_size; 66 66 dasd_information2_t *info; ··· 100 100 /* 101 101 * Get volume label, extract name and type. 102 102 */ 103 - data = read_dev_sector(bdev, info->label_block*(blocksize/512), &sect); 103 + data = read_part_sector(state, info->label_block*(blocksize/512), 104 + &sect); 104 105 if (data == NULL) 105 106 goto out_readerr; 106 107 ··· 194 193 */ 195 194 blk = cchhb2blk(&label->vol.vtoc, geo) + 1; 196 195 counter = 0; 197 - data = read_dev_sector(bdev, blk * (blocksize/512), 198 - &sect); 196 + data = read_part_sector(state, blk * (blocksize/512), 197 + &sect); 199 198 while (data != NULL) { 200 199 struct vtoc_format1_label f1; 201 200 ··· 209 208 || f1.DS1FMTID == _ascebc['7'] 210 209 || f1.DS1FMTID == _ascebc['9']) { 211 210 blk++; 212 - data = read_dev_sector(bdev, blk * 213 - (blocksize/512), 214 - &sect); 211 + data = read_part_sector(state, 212 + blk * (blocksize/512), &sect); 215 213 continue; 216 214 } 217 215 ··· 230 230 size * (blocksize >> 9)); 231 231 counter++; 232 232 blk++; 233 - data = read_dev_sector(bdev, 234 - blk * (blocksize/512), 235 - &sect); 233 + data = read_part_sector(state, 234 + blk * (blocksize/512), &sect); 236 235 } 237 236 238 237 if (!data)
+1 -1
fs/partitions/ibm.h
··· 1 - int ibm_partition(struct parsed_partitions *, struct block_device *); 1 + int ibm_partition(struct parsed_partitions *);
+2 -2
fs/partitions/karma.c
··· 9 9 #include "check.h" 10 10 #include "karma.h" 11 11 12 - int karma_partition(struct parsed_partitions *state, struct block_device *bdev) 12 + int karma_partition(struct parsed_partitions *state) 13 13 { 14 14 int i; 15 15 int slot = 1; ··· 29 29 } __attribute__((packed)) *label; 30 30 struct d_partition *p; 31 31 32 - data = read_dev_sector(bdev, 0, &sect); 32 + data = read_part_sector(state, 0, &sect); 33 33 if (!data) 34 34 return -1; 35 35
+1 -1
fs/partitions/karma.h
··· 4 4 5 5 #define KARMA_LABEL_MAGIC 0xAB56 6 6 7 - int karma_partition(struct parsed_partitions *state, struct block_device *bdev); 7 + int karma_partition(struct parsed_partitions *state); 8 8
+44 -45
fs/partitions/ldm.c
··· 309 309 310 310 /** 311 311 * ldm_validate_privheads - Compare the primary privhead with its backups 312 - * @bdev: Device holding the LDM Database 312 + * @state: Partition check state including device holding the LDM Database 313 313 * @ph1: Memory struct to fill with ph contents 314 314 * 315 315 * Read and compare all three privheads from disk. ··· 321 321 * Return: 'true' Success 322 322 * 'false' Error 323 323 */ 324 - static bool ldm_validate_privheads (struct block_device *bdev, 325 - struct privhead *ph1) 324 + static bool ldm_validate_privheads(struct parsed_partitions *state, 325 + struct privhead *ph1) 326 326 { 327 327 static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 }; 328 328 struct privhead *ph[3] = { ph1 }; ··· 332 332 long num_sects; 333 333 int i; 334 334 335 - BUG_ON (!bdev || !ph1); 335 + BUG_ON (!state || !ph1); 336 336 337 337 ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL); 338 338 ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL); ··· 346 346 347 347 /* Read and parse privheads */ 348 348 for (i = 0; i < 3; i++) { 349 - data = read_dev_sector (bdev, 350 - ph[0]->config_start + off[i], &sect); 349 + data = read_part_sector(state, ph[0]->config_start + off[i], 350 + &sect); 351 351 if (!data) { 352 352 ldm_crit ("Disk read failed."); 353 353 goto out; ··· 363 363 } 364 364 } 365 365 366 - num_sects = bdev->bd_inode->i_size >> 9; 366 + num_sects = state->bdev->bd_inode->i_size >> 9; 367 367 368 368 if ((ph[0]->config_start > num_sects) || 369 369 ((ph[0]->config_start + ph[0]->config_size) > num_sects)) { ··· 397 397 398 398 /** 399 399 * ldm_validate_tocblocks - Validate the table of contents and its backups 400 - * @bdev: Device holding the LDM Database 401 - * @base: Offset, into @bdev, of the database 400 + * @state: Partition check state including device holding the LDM Database 401 + * @base: Offset, into @state->bdev, of the database 402 402 * @ldb: Cache of the database structures 403 403 * 404 404 * Find and compare the four tables of contents of the LDM Database stored on 405 - * @bdev and return the parsed information into @toc1. 405 + * @state->bdev and return the parsed information into @toc1. 406 406 * 407 407 * The offsets and sizes of the configs are range-checked against a privhead. 408 408 * 409 409 * Return: 'true' @toc1 contains validated TOCBLOCK info 410 410 * 'false' @toc1 contents are undefined 411 411 */ 412 - static bool ldm_validate_tocblocks(struct block_device *bdev, 413 - unsigned long base, struct ldmdb *ldb) 412 + static bool ldm_validate_tocblocks(struct parsed_partitions *state, 413 + unsigned long base, struct ldmdb *ldb) 414 414 { 415 415 static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4}; 416 416 struct tocblock *tb[4]; ··· 420 420 int i, nr_tbs; 421 421 bool result = false; 422 422 423 - BUG_ON(!bdev || !ldb); 423 + BUG_ON(!state || !ldb); 424 424 ph = &ldb->ph; 425 425 tb[0] = &ldb->toc; 426 426 tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL); ··· 437 437 * skip any that fail as long as we get at least one valid TOCBLOCK. 438 438 */ 439 439 for (nr_tbs = i = 0; i < 4; i++) { 440 - data = read_dev_sector(bdev, base + off[i], &sect); 440 + data = read_part_sector(state, base + off[i], &sect); 441 441 if (!data) { 442 442 ldm_error("Disk read failed for TOCBLOCK %d.", i); 443 443 continue; ··· 473 473 474 474 /** 475 475 * ldm_validate_vmdb - Read the VMDB and validate it 476 - * @bdev: Device holding the LDM Database 476 + * @state: Partition check state including device holding the LDM Database 477 477 * @base: Offset, into @bdev, of the database 478 478 * @ldb: Cache of the database structures 479 479 * ··· 483 483 * Return: 'true' @ldb contains validated VBDB info 484 484 * 'false' @ldb contents are undefined 485 485 */ 486 - static bool ldm_validate_vmdb (struct block_device *bdev, unsigned long base, 487 - struct ldmdb *ldb) 486 + static bool ldm_validate_vmdb(struct parsed_partitions *state, 487 + unsigned long base, struct ldmdb *ldb) 488 488 { 489 489 Sector sect; 490 490 u8 *data; ··· 492 492 struct vmdb *vm; 493 493 struct tocblock *toc; 494 494 495 - BUG_ON (!bdev || !ldb); 495 + BUG_ON (!state || !ldb); 496 496 497 497 vm = &ldb->vm; 498 498 toc = &ldb->toc; 499 499 500 - data = read_dev_sector (bdev, base + OFF_VMDB, &sect); 500 + data = read_part_sector(state, base + OFF_VMDB, &sect); 501 501 if (!data) { 502 502 ldm_crit ("Disk read failed."); 503 503 return false; ··· 534 534 535 535 /** 536 536 * ldm_validate_partition_table - Determine whether bdev might be a dynamic disk 537 - * @bdev: Device holding the LDM Database 537 + * @state: Partition check state including device holding the LDM Database 538 538 * 539 539 * This function provides a weak test to decide whether the device is a dynamic 540 540 * disk or not. It looks for an MS-DOS-style partition table containing at 541 541 * least one partition of type 0x42 (formerly SFS, now used by Windows for 542 542 * dynamic disks). 543 543 * 544 - * N.B. The only possible error can come from the read_dev_sector and that is 544 + * N.B. The only possible error can come from the read_part_sector and that is 545 545 * only likely to happen if the underlying device is strange. If that IS 546 546 * the case we should return zero to let someone else try. 547 547 * 548 - * Return: 'true' @bdev is a dynamic disk 549 - * 'false' @bdev is not a dynamic disk, or an error occurred 548 + * Return: 'true' @state->bdev is a dynamic disk 549 + * 'false' @state->bdev is not a dynamic disk, or an error occurred 550 550 */ 551 - static bool ldm_validate_partition_table (struct block_device *bdev) 551 + static bool ldm_validate_partition_table(struct parsed_partitions *state) 552 552 { 553 553 Sector sect; 554 554 u8 *data; ··· 556 556 int i; 557 557 bool result = false; 558 558 559 - BUG_ON (!bdev); 559 + BUG_ON(!state); 560 560 561 - data = read_dev_sector (bdev, 0, &sect); 561 + data = read_part_sector(state, 0, &sect); 562 562 if (!data) { 563 563 ldm_crit ("Disk read failed."); 564 564 return false; ··· 1391 1391 1392 1392 /** 1393 1393 * ldm_get_vblks - Read the on-disk database of VBLKs into memory 1394 - * @bdev: Device holding the LDM Database 1395 - * @base: Offset, into @bdev, of the database 1394 + * @state: Partition check state including device holding the LDM Database 1395 + * @base: Offset, into @state->bdev, of the database 1396 1396 * @ldb: Cache of the database structures 1397 1397 * 1398 1398 * To use the information from the VBLKs, they need to be read from the disk, ··· 1401 1401 * Return: 'true' All the VBLKs were read successfully 1402 1402 * 'false' An error occurred 1403 1403 */ 1404 - static bool ldm_get_vblks (struct block_device *bdev, unsigned long base, 1405 - struct ldmdb *ldb) 1404 + static bool ldm_get_vblks(struct parsed_partitions *state, unsigned long base, 1405 + struct ldmdb *ldb) 1406 1406 { 1407 1407 int size, perbuf, skip, finish, s, v, recs; 1408 1408 u8 *data = NULL; ··· 1410 1410 bool result = false; 1411 1411 LIST_HEAD (frags); 1412 1412 1413 - BUG_ON (!bdev || !ldb); 1413 + BUG_ON(!state || !ldb); 1414 1414 1415 1415 size = ldb->vm.vblk_size; 1416 1416 perbuf = 512 / size; ··· 1418 1418 finish = (size * ldb->vm.last_vblk_seq) >> 9; 1419 1419 1420 1420 for (s = skip; s < finish; s++) { /* For each sector */ 1421 - data = read_dev_sector (bdev, base + OFF_VMDB + s, &sect); 1421 + data = read_part_sector(state, base + OFF_VMDB + s, &sect); 1422 1422 if (!data) { 1423 1423 ldm_crit ("Disk read failed."); 1424 1424 goto out; ··· 1474 1474 1475 1475 /** 1476 1476 * ldm_partition - Find out whether a device is a dynamic disk and handle it 1477 - * @pp: List of the partitions parsed so far 1478 - * @bdev: Device holding the LDM Database 1477 + * @state: Partition check state including device holding the LDM Database 1479 1478 * 1480 1479 * This determines whether the device @bdev is a dynamic disk and if so creates 1481 1480 * the partitions necessary in the gendisk structure pointed to by @hd. ··· 1484 1485 * example, if the device is hda, we would have: hda1: LDM database, hda2, hda3, 1485 1486 * and so on: the actual data containing partitions. 1486 1487 * 1487 - * Return: 1 Success, @bdev is a dynamic disk and we handled it 1488 - * 0 Success, @bdev is not a dynamic disk 1488 + * Return: 1 Success, @state->bdev is a dynamic disk and we handled it 1489 + * 0 Success, @state->bdev is not a dynamic disk 1489 1490 * -1 An error occurred before enough information had been read 1490 - * Or @bdev is a dynamic disk, but it may be corrupted 1491 + * Or @state->bdev is a dynamic disk, but it may be corrupted 1491 1492 */ 1492 - int ldm_partition (struct parsed_partitions *pp, struct block_device *bdev) 1493 + int ldm_partition(struct parsed_partitions *state) 1493 1494 { 1494 1495 struct ldmdb *ldb; 1495 1496 unsigned long base; 1496 1497 int result = -1; 1497 1498 1498 - BUG_ON (!pp || !bdev); 1499 + BUG_ON(!state); 1499 1500 1500 1501 /* Look for signs of a Dynamic Disk */ 1501 - if (!ldm_validate_partition_table (bdev)) 1502 + if (!ldm_validate_partition_table(state)) 1502 1503 return 0; 1503 1504 1504 1505 ldb = kmalloc (sizeof (*ldb), GFP_KERNEL); ··· 1508 1509 } 1509 1510 1510 1511 /* Parse and check privheads. */ 1511 - if (!ldm_validate_privheads (bdev, &ldb->ph)) 1512 + if (!ldm_validate_privheads(state, &ldb->ph)) 1512 1513 goto out; /* Already logged */ 1513 1514 1514 1515 /* All further references are relative to base (database start). */ 1515 1516 base = ldb->ph.config_start; 1516 1517 1517 1518 /* Parse and check tocs and vmdb. */ 1518 - if (!ldm_validate_tocblocks (bdev, base, ldb) || 1519 - !ldm_validate_vmdb (bdev, base, ldb)) 1519 + if (!ldm_validate_tocblocks(state, base, ldb) || 1520 + !ldm_validate_vmdb(state, base, ldb)) 1520 1521 goto out; /* Already logged */ 1521 1522 1522 1523 /* Initialize vblk lists in ldmdb struct */ ··· 1526 1527 INIT_LIST_HEAD (&ldb->v_comp); 1527 1528 INIT_LIST_HEAD (&ldb->v_part); 1528 1529 1529 - if (!ldm_get_vblks (bdev, base, ldb)) { 1530 + if (!ldm_get_vblks(state, base, ldb)) { 1530 1531 ldm_crit ("Failed to read the VBLKs from the database."); 1531 1532 goto cleanup; 1532 1533 } 1533 1534 1534 1535 /* Finally, create the data partition devices. */ 1535 - if (ldm_create_data_partitions (pp, ldb)) { 1536 + if (ldm_create_data_partitions(state, ldb)) { 1536 1537 ldm_debug ("Parsed LDM database successfully."); 1537 1538 result = 1; 1538 1539 }
+1 -1
fs/partitions/ldm.h
··· 209 209 struct list_head v_part; 210 210 }; 211 211 212 - int ldm_partition (struct parsed_partitions *state, struct block_device *bdev); 212 + int ldm_partition(struct parsed_partitions *state); 213 213 214 214 #endif /* _FS_PT_LDM_H_ */ 215 215
+6 -5
fs/partitions/mac.c
··· 27 27 stg[i] = 0; 28 28 } 29 29 30 - int mac_partition(struct parsed_partitions *state, struct block_device *bdev) 30 + int mac_partition(struct parsed_partitions *state) 31 31 { 32 32 int slot = 1; 33 33 Sector sect; ··· 42 42 struct mac_driver_desc *md; 43 43 44 44 /* Get 0th block and look at the first partition map entry. */ 45 - md = (struct mac_driver_desc *) read_dev_sector(bdev, 0, &sect); 45 + md = read_part_sector(state, 0, &sect); 46 46 if (!md) 47 47 return -1; 48 48 if (be16_to_cpu(md->signature) != MAC_DRIVER_MAGIC) { ··· 51 51 } 52 52 secsize = be16_to_cpu(md->block_size); 53 53 put_dev_sector(sect); 54 - data = read_dev_sector(bdev, secsize/512, &sect); 54 + data = read_part_sector(state, secsize/512, &sect); 55 55 if (!data) 56 56 return -1; 57 57 part = (struct mac_partition *) (data + secsize%512); ··· 64 64 for (blk = 1; blk <= blocks_in_map; ++blk) { 65 65 int pos = blk * secsize; 66 66 put_dev_sector(sect); 67 - data = read_dev_sector(bdev, pos/512, &sect); 67 + data = read_part_sector(state, pos/512, &sect); 68 68 if (!data) 69 69 return -1; 70 70 part = (struct mac_partition *) (data + pos%512); ··· 123 123 } 124 124 #ifdef CONFIG_PPC_PMAC 125 125 if (found_root_goodness) 126 - note_bootable_part(bdev->bd_dev, found_root, found_root_goodness); 126 + note_bootable_part(state->bdev->bd_dev, found_root, 127 + found_root_goodness); 127 128 #endif 128 129 129 130 put_dev_sector(sect);
+1 -1
fs/partitions/mac.h
··· 41 41 /* ... more stuff */ 42 42 }; 43 43 44 - int mac_partition(struct parsed_partitions *state, struct block_device *bdev); 44 + int mac_partition(struct parsed_partitions *state);
+37 -48
fs/partitions/msdos.c
··· 64 64 #define AIX_LABEL_MAGIC2 0xC2 65 65 #define AIX_LABEL_MAGIC3 0xD4 66 66 #define AIX_LABEL_MAGIC4 0xC1 67 - static int aix_magic_present(unsigned char *p, struct block_device *bdev) 67 + static int aix_magic_present(struct parsed_partitions *state, unsigned char *p) 68 68 { 69 69 struct partition *pt = (struct partition *) (p + 0x1be); 70 70 Sector sect; ··· 85 85 is_extended_partition(pt)) 86 86 return 0; 87 87 } 88 - d = read_dev_sector(bdev, 7, &sect); 88 + d = read_part_sector(state, 7, &sect); 89 89 if (d) { 90 90 if (d[0] == '_' && d[1] == 'L' && d[2] == 'V' && d[3] == 'M') 91 91 ret = 1; ··· 105 105 * only for the actual data partitions. 106 106 */ 107 107 108 - static void 109 - parse_extended(struct parsed_partitions *state, struct block_device *bdev, 110 - sector_t first_sector, sector_t first_size) 108 + static void parse_extended(struct parsed_partitions *state, 109 + sector_t first_sector, sector_t first_size) 111 110 { 112 111 struct partition *p; 113 112 Sector sect; 114 113 unsigned char *data; 115 114 sector_t this_sector, this_size; 116 - sector_t sector_size = bdev_logical_block_size(bdev) / 512; 115 + sector_t sector_size = bdev_logical_block_size(state->bdev) / 512; 117 116 int loopct = 0; /* number of links followed 118 117 without finding a data partition */ 119 118 int i; ··· 125 126 return; 126 127 if (state->next == state->limit) 127 128 return; 128 - data = read_dev_sector(bdev, this_sector, &sect); 129 + data = read_part_sector(state, this_sector, &sect); 129 130 if (!data) 130 131 return; 131 132 ··· 197 198 /* james@bpgc.com: Solaris has a nasty indicator: 0x82 which also 198 199 indicates linux swap. Be careful before believing this is Solaris. */ 199 200 200 - static void 201 - parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev, 202 - sector_t offset, sector_t size, int origin) 201 + static void parse_solaris_x86(struct parsed_partitions *state, 202 + sector_t offset, sector_t size, int origin) 203 203 { 204 204 #ifdef CONFIG_SOLARIS_X86_PARTITION 205 205 Sector sect; ··· 206 208 int i; 207 209 short max_nparts; 208 210 209 - v = (struct solaris_x86_vtoc *)read_dev_sector(bdev, offset+1, &sect); 211 + v = read_part_sector(state, offset + 1, &sect); 210 212 if (!v) 211 213 return; 212 214 if (le32_to_cpu(v->v_sanity) != SOLARIS_X86_VTOC_SANE) { ··· 243 245 * Create devices for BSD partitions listed in a disklabel, under a 244 246 * dos-like partition. See parse_extended() for more information. 245 247 */ 246 - static void 247 - parse_bsd(struct parsed_partitions *state, struct block_device *bdev, 248 - sector_t offset, sector_t size, int origin, char *flavour, 249 - int max_partitions) 248 + static void parse_bsd(struct parsed_partitions *state, 249 + sector_t offset, sector_t size, int origin, char *flavour, 250 + int max_partitions) 250 251 { 251 252 Sector sect; 252 253 struct bsd_disklabel *l; 253 254 struct bsd_partition *p; 254 255 255 - l = (struct bsd_disklabel *)read_dev_sector(bdev, offset+1, &sect); 256 + l = read_part_sector(state, offset + 1, &sect); 256 257 if (!l) 257 258 return; 258 259 if (le32_to_cpu(l->d_magic) != BSD_DISKMAGIC) { ··· 288 291 } 289 292 #endif 290 293 291 - static void 292 - parse_freebsd(struct parsed_partitions *state, struct block_device *bdev, 293 - sector_t offset, sector_t size, int origin) 294 + static void parse_freebsd(struct parsed_partitions *state, 295 + sector_t offset, sector_t size, int origin) 294 296 { 295 297 #ifdef CONFIG_BSD_DISKLABEL 296 - parse_bsd(state, bdev, offset, size, origin, 297 - "bsd", BSD_MAXPARTITIONS); 298 + parse_bsd(state, offset, size, origin, "bsd", BSD_MAXPARTITIONS); 298 299 #endif 299 300 } 300 301 301 - static void 302 - parse_netbsd(struct parsed_partitions *state, struct block_device *bdev, 303 - sector_t offset, sector_t size, int origin) 302 + static void parse_netbsd(struct parsed_partitions *state, 303 + sector_t offset, sector_t size, int origin) 304 304 { 305 305 #ifdef CONFIG_BSD_DISKLABEL 306 - parse_bsd(state, bdev, offset, size, origin, 307 - "netbsd", BSD_MAXPARTITIONS); 306 + parse_bsd(state, offset, size, origin, "netbsd", BSD_MAXPARTITIONS); 308 307 #endif 309 308 } 310 309 311 - static void 312 - parse_openbsd(struct parsed_partitions *state, struct block_device *bdev, 313 - sector_t offset, sector_t size, int origin) 310 + static void parse_openbsd(struct parsed_partitions *state, 311 + sector_t offset, sector_t size, int origin) 314 312 { 315 313 #ifdef CONFIG_BSD_DISKLABEL 316 - parse_bsd(state, bdev, offset, size, origin, 317 - "openbsd", OPENBSD_MAXPARTITIONS); 314 + parse_bsd(state, offset, size, origin, "openbsd", 315 + OPENBSD_MAXPARTITIONS); 318 316 #endif 319 317 } 320 318 ··· 317 325 * Create devices for Unixware partitions listed in a disklabel, under a 318 326 * dos-like partition. See parse_extended() for more information. 319 327 */ 320 - static void 321 - parse_unixware(struct parsed_partitions *state, struct block_device *bdev, 322 - sector_t offset, sector_t size, int origin) 328 + static void parse_unixware(struct parsed_partitions *state, 329 + sector_t offset, sector_t size, int origin) 323 330 { 324 331 #ifdef CONFIG_UNIXWARE_DISKLABEL 325 332 Sector sect; 326 333 struct unixware_disklabel *l; 327 334 struct unixware_slice *p; 328 335 329 - l = (struct unixware_disklabel *)read_dev_sector(bdev, offset+29, &sect); 336 + l = read_part_sector(state, offset + 29, &sect); 330 337 if (!l) 331 338 return; 332 339 if (le32_to_cpu(l->d_magic) != UNIXWARE_DISKMAGIC || ··· 356 365 * Anand Krishnamurthy <anandk@wiproge.med.ge.com> 357 366 * Rajeev V. Pillai <rajeevvp@yahoo.com> 358 367 */ 359 - static void 360 - parse_minix(struct parsed_partitions *state, struct block_device *bdev, 361 - sector_t offset, sector_t size, int origin) 368 + static void parse_minix(struct parsed_partitions *state, 369 + sector_t offset, sector_t size, int origin) 362 370 { 363 371 #ifdef CONFIG_MINIX_SUBPARTITION 364 372 Sector sect; ··· 365 375 struct partition *p; 366 376 int i; 367 377 368 - data = read_dev_sector(bdev, offset, &sect); 378 + data = read_part_sector(state, offset, &sect); 369 379 if (!data) 370 380 return; 371 381 ··· 394 404 395 405 static struct { 396 406 unsigned char id; 397 - void (*parse)(struct parsed_partitions *, struct block_device *, 398 - sector_t, sector_t, int); 407 + void (*parse)(struct parsed_partitions *, sector_t, sector_t, int); 399 408 } subtypes[] = { 400 409 {FREEBSD_PARTITION, parse_freebsd}, 401 410 {NETBSD_PARTITION, parse_netbsd}, ··· 406 417 {0, NULL}, 407 418 }; 408 419 409 - int msdos_partition(struct parsed_partitions *state, struct block_device *bdev) 420 + int msdos_partition(struct parsed_partitions *state) 410 421 { 411 - sector_t sector_size = bdev_logical_block_size(bdev) / 512; 422 + sector_t sector_size = bdev_logical_block_size(state->bdev) / 512; 412 423 Sector sect; 413 424 unsigned char *data; 414 425 struct partition *p; 415 426 struct fat_boot_sector *fb; 416 427 int slot; 417 428 418 - data = read_dev_sector(bdev, 0, &sect); 429 + data = read_part_sector(state, 0, &sect); 419 430 if (!data) 420 431 return -1; 421 432 if (!msdos_magic_present(data + 510)) { ··· 423 434 return 0; 424 435 } 425 436 426 - if (aix_magic_present(data, bdev)) { 437 + if (aix_magic_present(state, data)) { 427 438 put_dev_sector(sect); 428 439 printk( " [AIX]"); 429 440 return 0; ··· 492 503 put_partition(state, slot, start, n); 493 504 494 505 printk(" <"); 495 - parse_extended(state, bdev, start, size); 506 + parse_extended(state, start, size); 496 507 printk(" >"); 497 508 continue; 498 509 } ··· 521 532 522 533 if (!subtypes[n].parse) 523 534 continue; 524 - subtypes[n].parse(state, bdev, start_sect(p)*sector_size, 525 - nr_sects(p)*sector_size, slot); 535 + subtypes[n].parse(state, start_sect(p) * sector_size, 536 + nr_sects(p) * sector_size, slot); 526 537 } 527 538 put_dev_sector(sect); 528 539 return 1;
+1 -1
fs/partitions/msdos.h
··· 4 4 5 5 #define MSDOS_LABEL_MAGIC 0xAA55 6 6 7 - int msdos_partition(struct parsed_partitions *state, struct block_device *bdev); 7 + int msdos_partition(struct parsed_partitions *state); 8 8
+2 -2
fs/partitions/osf.c
··· 10 10 #include "check.h" 11 11 #include "osf.h" 12 12 13 - int osf_partition(struct parsed_partitions *state, struct block_device *bdev) 13 + int osf_partition(struct parsed_partitions *state) 14 14 { 15 15 int i; 16 16 int slot = 1; ··· 49 49 } * label; 50 50 struct d_partition * partition; 51 51 52 - data = read_dev_sector(bdev, 0, &sect); 52 + data = read_part_sector(state, 0, &sect); 53 53 if (!data) 54 54 return -1; 55 55
+1 -1
fs/partitions/osf.h
··· 4 4 5 5 #define DISKLABELMAGIC (0x82564557UL) 6 6 7 - int osf_partition(struct parsed_partitions *state, struct block_device *bdev); 7 + int osf_partition(struct parsed_partitions *state);
+3 -3
fs/partitions/sgi.c
··· 27 27 __be32 _unused1; /* Padding */ 28 28 }; 29 29 30 - int sgi_partition(struct parsed_partitions *state, struct block_device *bdev) 30 + int sgi_partition(struct parsed_partitions *state) 31 31 { 32 32 int i, csum; 33 33 __be32 magic; ··· 39 39 struct sgi_partition *p; 40 40 char b[BDEVNAME_SIZE]; 41 41 42 - label = (struct sgi_disklabel *) read_dev_sector(bdev, 0, &sect); 42 + label = read_part_sector(state, 0, &sect); 43 43 if (!label) 44 44 return -1; 45 45 p = &label->partitions[0]; ··· 57 57 } 58 58 if(csum) { 59 59 printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n", 60 - bdevname(bdev, b)); 60 + bdevname(state->bdev, b)); 61 61 put_dev_sector(sect); 62 62 return 0; 63 63 }
+1 -1
fs/partitions/sgi.h
··· 2 2 * fs/partitions/sgi.h 3 3 */ 4 4 5 - extern int sgi_partition(struct parsed_partitions *state, struct block_device *bdev); 5 + extern int sgi_partition(struct parsed_partitions *state); 6 6 7 7 #define SGI_LABEL_MAGIC 0x0be5a941 8 8
+3 -3
fs/partitions/sun.c
··· 10 10 #include "check.h" 11 11 #include "sun.h" 12 12 13 - int sun_partition(struct parsed_partitions *state, struct block_device *bdev) 13 + int sun_partition(struct parsed_partitions *state) 14 14 { 15 15 int i; 16 16 __be16 csum; ··· 61 61 int use_vtoc; 62 62 int nparts; 63 63 64 - label = (struct sun_disklabel *)read_dev_sector(bdev, 0, &sect); 64 + label = read_part_sector(state, 0, &sect); 65 65 if (!label) 66 66 return -1; 67 67 ··· 78 78 csum ^= *ush--; 79 79 if (csum) { 80 80 printk("Dev %s Sun disklabel: Csum bad, label corrupted\n", 81 - bdevname(bdev, b)); 81 + bdevname(state->bdev, b)); 82 82 put_dev_sector(sect); 83 83 return 0; 84 84 }
+1 -1
fs/partitions/sun.h
··· 5 5 #define SUN_LABEL_MAGIC 0xDABE 6 6 #define SUN_VTOC_SANITY 0x600DDEEE 7 7 8 - int sun_partition(struct parsed_partitions *state, struct block_device *bdev); 8 + int sun_partition(struct parsed_partitions *state);
+3 -3
fs/partitions/sysv68.c
··· 46 46 }; 47 47 48 48 49 - int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev) 49 + int sysv68_partition(struct parsed_partitions *state) 50 50 { 51 51 int i, slices; 52 52 int slot = 1; ··· 55 55 struct dkblk0 *b; 56 56 struct slice *slice; 57 57 58 - data = read_dev_sector(bdev, 0, &sect); 58 + data = read_part_sector(state, 0, &sect); 59 59 if (!data) 60 60 return -1; 61 61 ··· 68 68 i = be32_to_cpu(b->dk_ios.ios_slcblk); 69 69 put_dev_sector(sect); 70 70 71 - data = read_dev_sector(bdev, i, &sect); 71 + data = read_part_sector(state, i, &sect); 72 72 if (!data) 73 73 return -1; 74 74
+1 -1
fs/partitions/sysv68.h
··· 1 - extern int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev); 1 + extern int sysv68_partition(struct parsed_partitions *state);
+2 -2
fs/partitions/ultrix.c
··· 9 9 #include "check.h" 10 10 #include "ultrix.h" 11 11 12 - int ultrix_partition(struct parsed_partitions *state, struct block_device *bdev) 12 + int ultrix_partition(struct parsed_partitions *state) 13 13 { 14 14 int i; 15 15 Sector sect; ··· 26 26 #define PT_MAGIC 0x032957 /* Partition magic number */ 27 27 #define PT_VALID 1 /* Indicates if struct is valid */ 28 28 29 - data = read_dev_sector(bdev, (16384 - sizeof(*label))/512, &sect); 29 + data = read_part_sector(state, (16384 - sizeof(*label))/512, &sect); 30 30 if (!data) 31 31 return -1; 32 32
+1 -1
fs/partitions/ultrix.h
··· 2 2 * fs/partitions/ultrix.h 3 3 */ 4 4 5 - int ultrix_partition(struct parsed_partitions *state, struct block_device *bdev); 5 + int ultrix_partition(struct parsed_partitions *state);