LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andries Brouwer <Andries.Brouwer@cwi.nl>
To: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Cc: linux-kernel@vger.kernel.org, Andries.Brouwer@cwi.nl
Subject: Re: rfc: test whether a device has a partition table
Date: Sat, 22 May 2004 14:56:33 +0200 [thread overview]
Message-ID: <20040522125633.GA4777@apps.cwi.nl> (raw)
In-Reply-To: <16559.14090.6623.563810@hertz.ikp.physik.tu-darmstadt.de>
On Sat, May 22, 2004 at 01:18:34PM +0200, Uwe Bonnes wrote:
> around last september there was a discussion about the linux kernel
> recognizing "supperfloppys" as disks with bogus partition tables.
Yes - already had forgotten about that - thanks for reviving
> Linux Torvalds wrote at one point in the discussion:
> >I don't mind the 0x00/0x80 "boot flag" checks - those look fairly
> > obvious and look reasonably safe to add to the partitioning code.
>
> The discussion seemed to fade out with no visible result, and for example my
> USB stick "ID 0d7d:1420 Apacer" with a floppy as second partition gets
> recognized as:
> SCSI device sdc: 2880 512-byte hdwr sectors (1 MB)
> sdc: Write Protect is off
> sdc: sdc1 sdc2 sdc3 sdc4
What do you mean by "floppy as second partition"?
> Find appended a patch that does the 0x00/0x80 "boot flag" checks. Please
> discuss and consider for inclusion into the kernel.
> +#define BOOT_IND(p) (get_unaligned(&p->boot_ind))
> #define SYS_IND(p) (get_unaligned(&p->sys_ind))
Hmm. get_unaligned() for a single byte?
I see no reason for these two macros.
Also, it is a good habit to parenthesize macro parameters.
> + /*
> + Some consistancy check for a valid partition table
consistency
> + Boot indicator must either be 0x80 or 0x0 on all primary partitions
> + Only one partition may be marked bootable (0x80)
> + */
> + p = (struct partition *) (data + 0x1be);
> + for (slot = 1 ; slot <= 4 ; slot++, p++) {
> + if ((BOOT_IND(p) != 0x80) && (BOOT_IND(p) != 0x0))
> + return 0;
> + if (BOOT_IND(p) == 0x80)
> + nr_bootable++;
> + }
> + if (nr_bootable > 1)
> + return 0;
I have no objections.
Does it in your case suffice to check for 0 / 0x80 only
(without testing nr_bootable)?
I would prefer to omit that test, until there is at least one
person who shows a boot sector where it is needed.
Andries
next prev parent reply other threads:[~2004-05-22 12:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-22 11:18 Uwe Bonnes
2004-05-22 12:37 ` John Bradford
2004-05-22 12:56 ` Andries Brouwer [this message]
2004-05-22 15:14 ` Uwe Bonnes
2004-05-22 17:45 ` [PATCH] " Andries Brouwer
-- strict thread matches above, loose matches on Subject: below --
2003-09-24 20:29 Andries.Brouwer
2003-09-24 21:54 ` Linus Torvalds
2003-09-24 23:50 ` Andries Brouwer
2003-09-25 0:05 ` viro
2003-09-25 12:14 ` Andries Brouwer
2003-09-25 0:18 ` Linus Torvalds
2003-09-25 6:53 ` Xavier Bestel
2003-09-25 10:57 ` Andries Brouwer
2003-09-25 4:47 ` Linus Torvalds
2003-09-25 4:56 ` Linus Torvalds
2003-09-25 11:42 ` Andries Brouwer
2003-10-05 9:00 ` Meelis Roos
2003-09-25 0:42 ` Douglas Gilbert
2003-09-25 1:00 ` viro
2003-09-25 1:27 ` Douglas Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040522125633.GA4777@apps.cwi.nl \
--to=andries.brouwer@cwi.nl \
--cc=bon@elektron.ikp.physik.tu-darmstadt.de \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: rfc: test whether a device has a partition table' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).