Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c867fbe authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds
Browse files

partitions: fix sometimes unreadable partition strings



Fix this garbage happening quite often:

==>	 sda:
	scsi 3:0:0:0: CD-ROM            TOSHIBA
==>	 sda1 sda2 sda3 sda4 <sr0: scsi3-mmc drive: 24x/24x writer dvd-ram cd/rw xa/form2 cdda tray
			    ^^^
	Uniform CD-ROM driver Revision: 3.20
	sr 3:0:0:0: Attached scsi CD-ROM sr0
==>	 sda5 sda6 sda7 >

Make "sda: sda1 ..." lines actually lines.

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ecd62691
Loading
Loading
Loading
Loading
+20 −15
Original line number Original line Diff line number Diff line
@@ -45,8 +45,11 @@ adfs_partition(struct parsed_partitions *state, char *name, char *data,
	nr_sects = (le32_to_cpu(dr->disc_size_high) << 23) |
	nr_sects = (le32_to_cpu(dr->disc_size_high) << 23) |
		   (le32_to_cpu(dr->disc_size) >> 9);
		   (le32_to_cpu(dr->disc_size) >> 9);


	if (name)
	if (name) {
		printk(" [%s]", name);
		strlcat(state->pp_buf, " [", PAGE_SIZE);
		strlcat(state->pp_buf, name, PAGE_SIZE);
		strlcat(state->pp_buf, "]", PAGE_SIZE);
	}
	put_partition(state, slot, first_sector, nr_sects);
	put_partition(state, slot, first_sector, nr_sects);
	return dr;
	return dr;
}
}
@@ -81,14 +84,14 @@ static int riscix_partition(struct parsed_partitions *state,
	if (!rr)
	if (!rr)
		return -1;
		return -1;


	printk(" [RISCiX]");
	strlcat(state->pp_buf, " [RISCiX]", PAGE_SIZE);




	if (rr->magic == RISCIX_MAGIC) {
	if (rr->magic == RISCIX_MAGIC) {
		unsigned long size = nr_sects > 2 ? 2 : nr_sects;
		unsigned long size = nr_sects > 2 ? 2 : nr_sects;
		int part;
		int part;


		printk(" <");
		strlcat(state->pp_buf, " <", PAGE_SIZE);


		put_partition(state, slot++, first_sect, size);
		put_partition(state, slot++, first_sect, size);
		for (part = 0; part < 8; part++) {
		for (part = 0; part < 8; part++) {
@@ -97,11 +100,13 @@ static int riscix_partition(struct parsed_partitions *state,
				put_partition(state, slot++,
				put_partition(state, slot++,
					le32_to_cpu(rr->part[part].start),
					le32_to_cpu(rr->part[part].start),
					le32_to_cpu(rr->part[part].length));
					le32_to_cpu(rr->part[part].length));
				printk("(%s)", rr->part[part].name);
				strlcat(state->pp_buf, "(", PAGE_SIZE);
				strlcat(state->pp_buf, rr->part[part].name, PAGE_SIZE);
				strlcat(state->pp_buf, ")", PAGE_SIZE);
			}
			}
		}
		}


		printk(" >\n");
		strlcat(state->pp_buf, " >\n", PAGE_SIZE);
	} else {
	} else {
		put_partition(state, slot++, first_sect, nr_sects);
		put_partition(state, slot++, first_sect, nr_sects);
	}
	}
@@ -131,7 +136,7 @@ static int linux_partition(struct parsed_partitions *state,
	struct linux_part *linuxp;
	struct linux_part *linuxp;
	unsigned long size = nr_sects > 2 ? 2 : nr_sects;
	unsigned long size = nr_sects > 2 ? 2 : nr_sects;


	printk(" [Linux]");
	strlcat(state->pp_buf, " [Linux]", PAGE_SIZE);


	put_partition(state, slot++, first_sect, size);
	put_partition(state, slot++, first_sect, size);


@@ -139,7 +144,7 @@ static int linux_partition(struct parsed_partitions *state,
	if (!linuxp)
	if (!linuxp)
		return -1;
		return -1;


	printk(" <");
	strlcat(state->pp_buf, " <", PAGE_SIZE);
	while (linuxp->magic == cpu_to_le32(LINUX_NATIVE_MAGIC) ||
	while (linuxp->magic == cpu_to_le32(LINUX_NATIVE_MAGIC) ||
	       linuxp->magic == cpu_to_le32(LINUX_SWAP_MAGIC)) {
	       linuxp->magic == cpu_to_le32(LINUX_SWAP_MAGIC)) {
		if (slot == state->limit)
		if (slot == state->limit)
@@ -149,7 +154,7 @@ static int linux_partition(struct parsed_partitions *state,
				 le32_to_cpu(linuxp->nr_sects));
				 le32_to_cpu(linuxp->nr_sects));
		linuxp ++;
		linuxp ++;
	}
	}
	printk(" >");
	strlcat(state->pp_buf, " >", PAGE_SIZE);


	put_dev_sector(sect);
	put_dev_sector(sect);
	return slot;
	return slot;
@@ -294,7 +299,7 @@ int adfspart_check_ADFS(struct parsed_partitions *state)
			break;
			break;
		}
		}
	}
	}
	printk("\n");
	strlcat(state->pp_buf, "\n", PAGE_SIZE);
	return 1;
	return 1;
}
}
#endif
#endif
@@ -367,7 +372,7 @@ int adfspart_check_ICS(struct parsed_partitions *state)
		return 0;
		return 0;
	}
	}


	printk(" [ICS]");
	strlcat(state->pp_buf, " [ICS]", PAGE_SIZE);


	for (slot = 1, p = (const struct ics_part *)data; p->size; p++) {
	for (slot = 1, p = (const struct ics_part *)data; p->size; p++) {
		u32 start = le32_to_cpu(p->start);
		u32 start = le32_to_cpu(p->start);
@@ -401,7 +406,7 @@ int adfspart_check_ICS(struct parsed_partitions *state)
	}
	}


	put_dev_sector(sect);
	put_dev_sector(sect);
	printk("\n");
	strlcat(state->pp_buf, "\n", PAGE_SIZE);
	return 1;
	return 1;
}
}
#endif
#endif
@@ -461,7 +466,7 @@ int adfspart_check_POWERTEC(struct parsed_partitions *state)
		return 0;
		return 0;
	}
	}


	printk(" [POWERTEC]");
	strlcat(state->pp_buf, " [POWERTEC]", PAGE_SIZE);


	for (i = 0, p = (const struct ptec_part *)data; i < 12; i++, p++) {
	for (i = 0, p = (const struct ptec_part *)data; i < 12; i++, p++) {
		u32 start = le32_to_cpu(p->start);
		u32 start = le32_to_cpu(p->start);
@@ -472,7 +477,7 @@ int adfspart_check_POWERTEC(struct parsed_partitions *state)
	}
	}


	put_dev_sector(sect);
	put_dev_sector(sect);
	printk("\n");
	strlcat(state->pp_buf, "\n", PAGE_SIZE);
	return 1;
	return 1;
}
}
#endif
#endif
@@ -543,7 +548,7 @@ int adfspart_check_EESOX(struct parsed_partitions *state)


		size = get_capacity(state->bdev->bd_disk);
		size = get_capacity(state->bdev->bd_disk);
		put_partition(state, slot++, start, size - start);
		put_partition(state, slot++, start, size - start);
		printk("\n");
		strlcat(state->pp_buf, "\n", PAGE_SIZE);
	}
	}


	return i ? 1 : 0;
	return i ? 1 : 0;
+15 −5
Original line number Original line Diff line number Diff line
@@ -69,7 +69,13 @@ int amiga_partition(struct parsed_partitions *state)
	/* blksize is blocks per 512 byte standard block */
	/* blksize is blocks per 512 byte standard block */
	blksize = be32_to_cpu( rdb->rdb_BlockBytes ) / 512;
	blksize = be32_to_cpu( rdb->rdb_BlockBytes ) / 512;


	printk(" RDSK (%d)", blksize * 512);	/* Be more informative */
	{
		char tmp[7 + 10 + 1 + 1];

		/* Be more informative */
		snprintf(tmp, sizeof(tmp), " RDSK (%d)", blksize * 512);
		strlcat(state->pp_buf, tmp, PAGE_SIZE);
	}
	blk = be32_to_cpu(rdb->rdb_PartitionList);
	blk = be32_to_cpu(rdb->rdb_PartitionList);
	put_dev_sector(sect);
	put_dev_sector(sect);
	for (part = 1; blk>0 && part<=16; part++, put_dev_sector(sect)) {
	for (part = 1; blk>0 && part<=16; part++, put_dev_sector(sect)) {
@@ -106,23 +112,27 @@ int amiga_partition(struct parsed_partitions *state)
		{
		{
			/* Be even more informative to aid mounting */
			/* Be even more informative to aid mounting */
			char dostype[4];
			char dostype[4];
			char tmp[42];

			__be32 *dt = (__be32 *)dostype;
			__be32 *dt = (__be32 *)dostype;
			*dt = pb->pb_Environment[16];
			*dt = pb->pb_Environment[16];
			if (dostype[3] < ' ')
			if (dostype[3] < ' ')
				printk(" (%c%c%c^%c)",
				snprintf(tmp, sizeof(tmp), " (%c%c%c^%c)",
					dostype[0], dostype[1],
					dostype[0], dostype[1],
					dostype[2], dostype[3] + '@' );
					dostype[2], dostype[3] + '@' );
			else
			else
				printk(" (%c%c%c%c)",
				snprintf(tmp, sizeof(tmp), " (%c%c%c%c)",
					dostype[0], dostype[1],
					dostype[0], dostype[1],
					dostype[2], dostype[3]);
					dostype[2], dostype[3]);
			printk("(res %d spb %d)",
			strlcat(state->pp_buf, tmp, PAGE_SIZE);
			snprintf(tmp, sizeof(tmp), "(res %d spb %d)",
				be32_to_cpu(pb->pb_Environment[6]),
				be32_to_cpu(pb->pb_Environment[6]),
				be32_to_cpu(pb->pb_Environment[4]));
				be32_to_cpu(pb->pb_Environment[4]));
			strlcat(state->pp_buf, tmp, PAGE_SIZE);
		}
		}
		res = 1;
		res = 1;
	}
	}
	printk("\n");
	strlcat(state->pp_buf, "\n", PAGE_SIZE);


rdb_done:
rdb_done:
	return res;
	return res;
+6 −6
Original line number Original line Diff line number Diff line
@@ -62,7 +62,7 @@ int atari_partition(struct parsed_partitions *state)
	}
	}


	pi = &rs->part[0];
	pi = &rs->part[0];
	printk (" AHDI");
	strlcat(state->pp_buf, " AHDI", PAGE_SIZE);
	for (slot = 1; pi < &rs->part[4] && slot < state->limit; slot++, pi++) {
	for (slot = 1; pi < &rs->part[4] && slot < state->limit; slot++, pi++) {
		struct rootsector *xrs;
		struct rootsector *xrs;
		Sector sect2;
		Sector sect2;
@@ -81,7 +81,7 @@ int atari_partition(struct parsed_partitions *state)
#ifdef ICD_PARTS
#ifdef ICD_PARTS
		part_fmt = 1;
		part_fmt = 1;
#endif
#endif
		printk(" XGM<");
		strlcat(state->pp_buf, " XGM<", PAGE_SIZE);
		partsect = extensect = be32_to_cpu(pi->st);
		partsect = extensect = be32_to_cpu(pi->st);
		while (1) {
		while (1) {
			xrs = read_part_sector(state, partsect, &sect2);
			xrs = read_part_sector(state, partsect, &sect2);
@@ -120,14 +120,14 @@ int atari_partition(struct parsed_partitions *state)
				break;
				break;
			}
			}
		}
		}
		printk(" >");
		strlcat(state->pp_buf, " >", PAGE_SIZE);
	}
	}
#ifdef ICD_PARTS
#ifdef ICD_PARTS
	if ( part_fmt!=1 ) { /* no extended partitions -> test ICD-format */
	if ( part_fmt!=1 ) { /* no extended partitions -> test ICD-format */
		pi = &rs->icdpart[0];
		pi = &rs->icdpart[0];
		/* sanity check: no ICD format if first partition invalid */
		/* sanity check: no ICD format if first partition invalid */
		if (OK_id(pi->id)) {
		if (OK_id(pi->id)) {
			printk(" ICD<");
			strlcat(state->pp_buf, " ICD<", PAGE_SIZE);
			for (; pi < &rs->icdpart[8] && slot < state->limit; slot++, pi++) {
			for (; pi < &rs->icdpart[8] && slot < state->limit; slot++, pi++) {
				/* accept only GEM,BGM,RAW,LNX,SWP partitions */
				/* accept only GEM,BGM,RAW,LNX,SWP partitions */
				if (!((pi->flg & 1) && OK_id(pi->id)))
				if (!((pi->flg & 1) && OK_id(pi->id)))
@@ -137,13 +137,13 @@ int atari_partition(struct parsed_partitions *state)
						be32_to_cpu(pi->st),
						be32_to_cpu(pi->st),
						be32_to_cpu(pi->siz));
						be32_to_cpu(pi->siz));
			}
			}
			printk(" >");
			strlcat(state->pp_buf, " >", PAGE_SIZE);
		}
		}
	}
	}
#endif
#endif
	put_dev_sector(sect);
	put_dev_sector(sect);


	printk ("\n");
	strlcat(state->pp_buf, "\n", PAGE_SIZE);


	return 1;
	return 1;
}
}
+18 −4
Original line number Original line Diff line number Diff line
@@ -164,10 +164,16 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
	state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
	state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
	if (!state)
	if (!state)
		return NULL;
		return NULL;
	state->pp_buf = (char *)__get_free_page(GFP_KERNEL);
	if (!state->pp_buf) {
		kfree(state);
		return NULL;
	}
	state->pp_buf[0] = '\0';


	state->bdev = bdev;
	state->bdev = bdev;
	disk_name(hd, 0, state->name);
	disk_name(hd, 0, state->name);
	printk(KERN_INFO " %s:", state->name);
	snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name);
	if (isdigit(state->name[strlen(state->name)-1]))
	if (isdigit(state->name[strlen(state->name)-1]))
		sprintf(state->name, "p");
		sprintf(state->name, "p");


@@ -185,17 +191,25 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
		}
		}


	}
	}
	if (res > 0)
	if (res > 0) {
		printk(KERN_INFO "%s", state->pp_buf);

		free_page((unsigned long)state->pp_buf);
		return state;
		return state;
	}
	if (state->access_beyond_eod)
	if (state->access_beyond_eod)
		err = -ENOSPC;
		err = -ENOSPC;
	if (err)
	if (err)
	/* The partition is unrecognized. So report I/O errors if there were any */
	/* The partition is unrecognized. So report I/O errors if there were any */
		res = err;
		res = err;
	if (!res)
	if (!res)
		printk(" unknown partition table\n");
		strlcat(state->pp_buf, " unknown partition table\n", PAGE_SIZE);
	else if (warn_no_part)
	else if (warn_no_part)
		printk(" unable to read partition table\n");
		strlcat(state->pp_buf, " unable to read partition table\n", PAGE_SIZE);

	printk(KERN_INFO "%s", state->pp_buf);

	free_page((unsigned long)state->pp_buf);
	kfree(state);
	kfree(state);
	return ERR_PTR(res);
	return ERR_PTR(res);
}
}
+5 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ struct parsed_partitions {
	int next;
	int next;
	int limit;
	int limit;
	bool access_beyond_eod;
	bool access_beyond_eod;
	char *pp_buf;
};
};


static inline void *read_part_sector(struct parsed_partitions *state,
static inline void *read_part_sector(struct parsed_partitions *state,
@@ -32,9 +33,12 @@ static inline void
put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
{
{
	if (n < p->limit) {
	if (n < p->limit) {
		char tmp[1 + BDEVNAME_SIZE + 10 + 1];

		p->parts[n].from = from;
		p->parts[n].from = from;
		p->parts[n].size = size;
		p->parts[n].size = size;
		printk(" %s%d", p->name, n);
		snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
		strlcat(p->pp_buf, tmp, PAGE_SIZE);
	}
	}
}
}


Loading