2 * fs/partitions/check.c
4 * Code extracted from drivers/block/genhd.c
5 * Copyright (C) 1991-1998 Linus Torvalds
6 * Re-organised Feb 1998 Russell King
8 * We now have independent partition support from the
9 * block drivers, which allows all the partition code to
10 * be grouped in one location, and it to be mostly self
13 * Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl}
16 #include <linux/slab.h>
17 #include <linux/vmalloc.h>
18 #include <linux/ctype.h>
19 #include <linux/genhd.h>
39 int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
41 static int (*check_part[])(struct parsed_partitions *) = {
43 * Probe partition formats with tables at disk address 0
44 * that also have an ADFS boot block at 0xdc0.
46 #ifdef CONFIG_ACORN_PARTITION_ICS
49 #ifdef CONFIG_ACORN_PARTITION_POWERTEC
50 adfspart_check_POWERTEC,
52 #ifdef CONFIG_ACORN_PARTITION_EESOX
57 * Now move on to formats that only have partition info at
58 * disk address 0xdc0. Since these may also have stale
59 * PC/BIOS partition tables, they need to come before
62 #ifdef CONFIG_ACORN_PARTITION_CUMANA
63 adfspart_check_CUMANA,
65 #ifdef CONFIG_ACORN_PARTITION_ADFS
69 #ifdef CONFIG_CMDLINE_PARTITION
72 #ifdef CONFIG_EFI_PARTITION
73 efi_partition, /* this must come before msdos */
75 #ifdef CONFIG_SGI_PARTITION
78 #ifdef CONFIG_LDM_PARTITION
79 ldm_partition, /* this must come before msdos */
81 #ifdef CONFIG_MSDOS_PARTITION
84 #ifdef CONFIG_OSF_PARTITION
87 #ifdef CONFIG_SUN_PARTITION
90 #ifdef CONFIG_AMIGA_PARTITION
93 #ifdef CONFIG_ATARI_PARTITION
96 #ifdef CONFIG_MAC_PARTITION
99 #ifdef CONFIG_ULTRIX_PARTITION
102 #ifdef CONFIG_IBM_PARTITION
105 #ifdef CONFIG_KARMA_PARTITION
108 #ifdef CONFIG_SYSV68_PARTITION
111 #ifdef CONFIG_RK_PARTITION
118 static struct parsed_partitions *allocate_partitions(struct gendisk *hd)
120 struct parsed_partitions *state;
123 state = kzalloc(sizeof(*state), GFP_KERNEL);
127 nr = disk_max_parts(hd);
128 state->parts = vzalloc(nr * sizeof(state->parts[0]));
139 void free_partitions(struct parsed_partitions *state)
145 struct parsed_partitions *
146 check_partition(struct gendisk *hd, struct block_device *bdev)
148 struct parsed_partitions *state;
151 state = allocate_partitions(hd);
154 state->pp_buf = (char *)__get_free_page(GFP_KERNEL);
155 if (!state->pp_buf) {
156 free_partitions(state);
159 state->pp_buf[0] = '\0';
162 disk_name(hd, 0, state->name);
163 snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name);
164 if (isdigit(state->name[strlen(state->name)-1]))
165 sprintf(state->name, "p");
169 /* Rockchip partition table ONLY used by eMMC disk */
170 #ifdef CONFIG_RK_PARTITION
171 if ((179 == MAJOR(bdev->bd_dev) && (1 == hd->emmc_disk)))
172 i = sizeof(check_part) / sizeof(struct parsed_partitions *) - 2;
175 while (!res && check_part[i]) {
176 memset(state->parts, 0, state->limit * sizeof(state->parts[0]));
177 res = check_part[i++](state);
179 /* We have hit an I/O error which we don't report now.
180 * But record it, and let the others do their job.
188 printk(KERN_INFO "%s", state->pp_buf);
190 free_page((unsigned long)state->pp_buf);
193 if (state->access_beyond_eod)
196 /* The partition is unrecognized. So report I/O errors if there were any */
199 strlcat(state->pp_buf, " unknown partition table\n", PAGE_SIZE);
200 else if (warn_no_part)
201 strlcat(state->pp_buf, " unable to read partition table\n", PAGE_SIZE);
203 printk(KERN_INFO "%s", state->pp_buf);
205 free_page((unsigned long)state->pp_buf);
206 free_partitions(state);