Lines Matching +full:partitions +full:- +full:table +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0
3 * fs/partitions/msdos.c
6 * Copyright (C) 1991-1998 Linus Torvalds
9 * in the early extended-partition checks and added DM partitions
16 * More flexible handling of extended partitions - aeb, 950831
18 * Check partition table on IDE disks for common CHS translations
20 * Re-organised Feb 1998 Russell King
36 * the nr_sects and start_sect partition table entries are
43 return (sector_t)get_unaligned_le32(&p->nr_sects); in nr_sects()
48 return (sector_t)get_unaligned_le32(&p->start_sect); in start_sect()
53 return (p->sys_ind == DOS_EXTENDED_PARTITION || in is_extended_partition()
54 p->sys_ind == WIN98_EXTENDED_PARTITION || in is_extended_partition()
55 p->sys_ind == LINUX_EXTENDED_PARTITION); in is_extended_partition()
86 * Assume the partition table is valid if Linux partitions exists. in aix_magic_present()
87 * Note that old Solaris/x86 partitions use the same indicator as in aix_magic_present()
88 * Linux swap partitions, so we consider that a Linux partition as in aix_magic_present()
92 if (pt->sys_ind == SOLARIS_X86_PARTITION || in aix_magic_present()
93 pt->sys_ind == LINUX_RAID_PARTITION || in aix_magic_present()
94 pt->sys_ind == LINUX_DATA_PARTITION || in aix_magic_present()
95 pt->sys_ind == LINUX_LVM_PARTITION || in aix_magic_present()
111 struct partition_meta_info *info = &state->parts[slot].info; in set_info()
113 snprintf(info->uuid, sizeof(info->uuid), "%08x-%02x", disksig, in set_info()
115 info->volname[0] = 0; in set_info()
116 state->parts[slot].has_info = true; in set_info()
121 * The logical partitions form a linked list, with each entry being
122 * a partition table with two entries. The first entry
124 * table start). The second is a pointer to the next logical partition
127 * only for the actual data partitions.
143 sector_size = queue_logical_block_size(state->disk->queue) / 512; in parse_extended()
150 if (state->next == state->limit) in parse_extended()
179 /* Check the 3rd and 4th entries - in parse_extended()
193 put_partition(state, state->next, next, size); in parse_extended()
194 set_info(state, state->next, disksig); in parse_extended()
195 if (p->sys_ind == LINUX_RAID_PARTITION) in parse_extended()
196 state->parts[state->next].flags = ADDPART_FLAG_RAID; in parse_extended()
198 if (++state->next == state->limit) in parse_extended()
205 * of extended partitions.) in parse_extended()
208 p -= 4; in parse_extended()
239 __le16 v_nparts; /* number of partitions */
251 sector_t offset, sector_t size, int origin) in parse_solaris_x86() argument
259 v = read_part_sector(state, offset + 1, &sect); in parse_solaris_x86()
262 if (le32_to_cpu(v->v_sanity) != SOLARIS_X86_VTOC_SANE) { in parse_solaris_x86()
269 snprintf(tmp, sizeof(tmp), " %s%d: <solaris:", state->name, origin); in parse_solaris_x86()
270 strlcat(state->pp_buf, tmp, PAGE_SIZE); in parse_solaris_x86()
272 if (le32_to_cpu(v->v_version) != 1) { in parse_solaris_x86()
276 le32_to_cpu(v->v_version)); in parse_solaris_x86()
277 strlcat(state->pp_buf, tmp, PAGE_SIZE); in parse_solaris_x86()
282 max_nparts = le16_to_cpu(v->v_nparts) > 8 ? SOLARIS_X86_NUMSLICE : 8; in parse_solaris_x86()
283 for (i = 0; i < max_nparts && state->next < state->limit; i++) { in parse_solaris_x86()
284 struct solaris_x86_slice *s = &v->v_slice[i]; in parse_solaris_x86()
287 if (s->s_size == 0) in parse_solaris_x86()
290 strlcat(state->pp_buf, tmp, PAGE_SIZE); in parse_solaris_x86()
291 /* solaris partitions are relative to current MS-DOS in parse_solaris_x86()
292 * one; must add the offset of the current partition */ in parse_solaris_x86()
293 put_partition(state, state->next++, in parse_solaris_x86()
294 le32_to_cpu(s->s_start)+offset, in parse_solaris_x86()
295 le32_to_cpu(s->s_size)); in parse_solaris_x86()
298 strlcat(state->pp_buf, " >\n", PAGE_SIZE); in parse_solaris_x86()
327 __u32 d_trkseek; /* track-to-track seek, usec */
330 __u32 d_drivedata[NDDATA]; /* drive-type specific information */
334 __le16 d_checksum; /* xor of data incl. partitions */
337 __le16 d_npartitions; /* number of partitions in following */
340 struct bsd_partition { /* the partition table */
352 * Create devices for BSD partitions listed in a disklabel, under a
353 * dos-like partition. See parse_extended() for more information.
356 sector_t offset, sector_t size, int origin, char *flavour, in parse_bsd() argument
364 l = read_part_sector(state, offset + 1, &sect); in parse_bsd()
367 if (le32_to_cpu(l->d_magic) != BSD_DISKMAGIC) { in parse_bsd()
372 snprintf(tmp, sizeof(tmp), " %s%d: <%s:", state->name, origin, flavour); in parse_bsd()
373 strlcat(state->pp_buf, tmp, PAGE_SIZE); in parse_bsd()
375 if (le16_to_cpu(l->d_npartitions) < max_partitions) in parse_bsd()
376 max_partitions = le16_to_cpu(l->d_npartitions); in parse_bsd()
377 for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) { in parse_bsd()
380 if (state->next == state->limit) in parse_bsd()
382 if (p->p_fstype == BSD_FS_UNUSED) in parse_bsd()
384 bsd_start = le32_to_cpu(p->p_offset); in parse_bsd()
385 bsd_size = le32_to_cpu(p->p_size); in parse_bsd()
386 /* FreeBSD has relative offset if C partition offset is zero */ in parse_bsd()
388 le32_to_cpu(l->d_partitions[2].p_offset) == 0) in parse_bsd()
389 bsd_start += offset; in parse_bsd()
390 if (offset == bsd_start && size == bsd_size) in parse_bsd()
393 if (offset > bsd_start || offset+size < bsd_start+bsd_size) { in parse_bsd()
394 strlcat(state->pp_buf, "bad subpartition - ignored\n", PAGE_SIZE); in parse_bsd()
397 put_partition(state, state->next++, bsd_start, bsd_size); in parse_bsd()
400 if (le16_to_cpu(l->d_npartitions) > max_partitions) { in parse_bsd()
402 le16_to_cpu(l->d_npartitions) - max_partitions); in parse_bsd()
403 strlcat(state->pp_buf, tmp, PAGE_SIZE); in parse_bsd()
405 strlcat(state->pp_buf, " >\n", PAGE_SIZE); in parse_bsd()
410 sector_t offset, sector_t size, int origin) in parse_freebsd() argument
413 parse_bsd(state, offset, size, origin, "bsd", BSD_MAXPARTITIONS); in parse_freebsd()
418 sector_t offset, sector_t size, int origin) in parse_netbsd() argument
421 parse_bsd(state, offset, size, origin, "netbsd", BSD_MAXPARTITIONS); in parse_netbsd()
426 sector_t offset, sector_t size, int origin) in parse_openbsd() argument
429 parse_bsd(state, offset, size, origin, "openbsd", in parse_openbsd()
435 #define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */
457 __le32 d_alt_tbl; /* byte offset of alternate table */
458 __le32 d_alt_len; /* byte length of alternate table */
480 * Create devices for Unixware partitions listed in a disklabel, under a
481 * dos-like partition. See parse_extended() for more information.
484 sector_t offset, sector_t size, int origin) in parse_unixware() argument
491 l = read_part_sector(state, offset + 29, &sect); in parse_unixware()
494 if (le32_to_cpu(l->d_magic) != UNIXWARE_DISKMAGIC || in parse_unixware()
495 le32_to_cpu(l->vtoc.v_magic) != UNIXWARE_DISKMAGIC2) { in parse_unixware()
502 snprintf(tmp, sizeof(tmp), " %s%d: <unixware:", state->name, origin); in parse_unixware()
503 strlcat(state->pp_buf, tmp, PAGE_SIZE); in parse_unixware()
505 p = &l->vtoc.v_slice[1]; in parse_unixware()
507 while (p - &l->vtoc.v_slice[0] < UNIXWARE_NUMSLICE) { in parse_unixware()
508 if (state->next == state->limit) in parse_unixware()
511 if (p->s_label != UNIXWARE_FS_UNUSED) in parse_unixware()
512 put_partition(state, state->next++, in parse_unixware()
513 le32_to_cpu(p->start_sect), in parse_unixware()
514 le32_to_cpu(p->nr_sects)); in parse_unixware()
518 strlcat(state->pp_buf, " >\n", PAGE_SIZE); in parse_unixware()
530 sector_t offset, sector_t size, int origin) in parse_minix() argument
538 data = read_part_sector(state, offset, &sect); in parse_minix()
548 p->sys_ind == MINIX_PARTITION) { /* subpartition table present */ in parse_minix()
551 snprintf(tmp, sizeof(tmp), " %s%d: <minix:", state->name, origin); in parse_minix()
552 strlcat(state->pp_buf, tmp, PAGE_SIZE); in parse_minix()
554 if (state->next == state->limit) in parse_minix()
557 if (p->sys_ind == MINIX_PARTITION) in parse_minix()
558 put_partition(state, state->next++, in parse_minix()
561 strlcat(state->pp_buf, " >\n", PAGE_SIZE); in parse_minix()
591 sector_size = queue_logical_block_size(state->disk->queue) / 512; in msdos_partition()
594 return -1; in msdos_partition()
605 strlcat(state->pp_buf, " [AIX]", PAGE_SIZE); in msdos_partition()
617 * either the boot sector of a FAT filesystem or a DOS-type in msdos_partition()
618 * partition table. Reject this in case the boot indicator in msdos_partition()
623 if (p->boot_ind != 0 && p->boot_ind != 0x80) { in msdos_partition()
627 * without a partition table. in msdos_partition()
630 if (slot == 1 && fb->reserved && fb->fats in msdos_partition()
631 && fat_valid_media(fb->media)) { in msdos_partition()
632 strlcat(state->pp_buf, "\n", PAGE_SIZE); in msdos_partition()
646 if (p->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT) { in msdos_partition()
657 * Look for partitions in two passes: in msdos_partition()
658 * First find the primary and DOS-type extended partitions. in msdos_partition()
659 * On the second pass look inside *BSD, Unixware and Solaris partitions. in msdos_partition()
662 state->next = 5; in msdos_partition()
681 strlcat(state->pp_buf, " <", PAGE_SIZE); in msdos_partition()
683 strlcat(state->pp_buf, " >", PAGE_SIZE); in msdos_partition()
688 if (p->sys_ind == LINUX_RAID_PARTITION) in msdos_partition()
689 state->parts[slot].flags = ADDPART_FLAG_RAID; in msdos_partition()
690 if (p->sys_ind == DM6_PARTITION) in msdos_partition()
691 strlcat(state->pp_buf, "[DM]", PAGE_SIZE); in msdos_partition()
692 if (p->sys_ind == EZD_PARTITION) in msdos_partition()
693 strlcat(state->pp_buf, "[EZD]", PAGE_SIZE); in msdos_partition()
696 strlcat(state->pp_buf, "\n", PAGE_SIZE); in msdos_partition()
698 /* second pass - output for each on a separate line */ in msdos_partition()
701 unsigned char id = p->sys_ind; in msdos_partition()