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>
38 int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
40 static int (*check_part[])(struct parsed_partitions *) = {
42 * Probe partition formats with tables at disk address 0
43 * that also have an ADFS boot block at 0xdc0.
45 #ifdef CONFIG_ACORN_PARTITION_ICS
48 #ifdef CONFIG_ACORN_PARTITION_POWERTEC
49 adfspart_check_POWERTEC,
51 #ifdef CONFIG_ACORN_PARTITION_EESOX
56 * Now move on to formats that only have partition info at
57 * disk address 0xdc0. Since these may also have stale
58 * PC/BIOS partition tables, they need to come before
61 #ifdef CONFIG_ACORN_PARTITION_CUMANA
62 adfspart_check_CUMANA,
64 #ifdef CONFIG_ACORN_PARTITION_ADFS
68 #ifdef CONFIG_EFI_PARTITION
69 efi_partition, /* this must come before msdos */
71 #ifdef CONFIG_SGI_PARTITION
74 #ifdef CONFIG_LDM_PARTITION
75 ldm_partition, /* this must come before msdos */
77 #ifdef CONFIG_MSDOS_PARTITION
80 #ifdef CONFIG_OSF_PARTITION
83 #ifdef CONFIG_SUN_PARTITION
86 #ifdef CONFIG_AMIGA_PARTITION
89 #ifdef CONFIG_ATARI_PARTITION
92 #ifdef CONFIG_MAC_PARTITION
95 #ifdef CONFIG_ULTRIX_PARTITION
98 #ifdef CONFIG_IBM_PARTITION
101 #ifdef CONFIG_KARMA_PARTITION
104 #ifdef CONFIG_SYSV68_PARTITION
107 #ifdef CONFIG_RK_PARTITION
114 static struct parsed_partitions *allocate_partitions(struct gendisk *hd)
116 struct parsed_partitions *state;
119 state = kzalloc(sizeof(*state), GFP_KERNEL);
123 nr = disk_max_parts(hd);
124 state->parts = vzalloc(nr * sizeof(state->parts[0]));
135 void free_partitions(struct parsed_partitions *state)
141 struct parsed_partitions *
142 check_partition(struct gendisk *hd, struct block_device *bdev)
144 struct parsed_partitions *state;
147 state = allocate_partitions(hd);
150 state->pp_buf = (char *)__get_free_page(GFP_KERNEL);
151 if (!state->pp_buf) {
152 free_partitions(state);
155 state->pp_buf[0] = '\0';
158 disk_name(hd, 0, state->name);
159 snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name);
160 if (isdigit(state->name[strlen(state->name)-1]))
161 sprintf(state->name, "p");
165 /* Rockchip partition table ONLY used by eMMC disk */
166 #ifdef CONFIG_RK_PARTITION
167 if ((179 == MAJOR(bdev->bd_dev) && (1 == hd->emmc_disk)))
168 i = sizeof(check_part) / sizeof(struct parsed_partitions *) - 2;
171 while (!res && check_part[i]) {
172 memset(state->parts, 0, state->limit * sizeof(state->parts[0]));
173 res = check_part[i++](state);
175 /* We have hit an I/O error which we don't report now.
176 * But record it, and let the others do their job.
184 printk(KERN_INFO "%s", state->pp_buf);
186 free_page((unsigned long)state->pp_buf);
189 if (state->access_beyond_eod)
192 /* The partition is unrecognized. So report I/O errors if there were any */
195 strlcat(state->pp_buf, " unknown partition table\n", PAGE_SIZE);
196 else if (warn_no_part)
197 strlcat(state->pp_buf, " unable to read partition table\n", PAGE_SIZE);
199 printk(KERN_INFO "%s", state->pp_buf);
201 free_page((unsigned long)state->pp_buf);
202 free_partitions(state);