Re: [PATCH] partitions/msdos.c

2005-03-19 Thread Grzegorz Kulewski
On Sat, 19 Mar 2005, Werner Almesberger wrote:
Andries Brouwer wrote:
The two variants are: (i) partition tells the kernel
to do the partition table reading, and (ii) partition uses partx
to read the partition table and tells the kernel one-by-one
about the partitions found this way.
I guess, once you've reached the point where the kernel is
unable to find partitions without user-space help, you may
as well do everything in user space.
I agree. This is userspace job. This can be done very easily using 
device-mapper. I think EVMS does something similar.

I even asked on LKML some time ago about option for disabling kernel 
partition driver (maybe for some devices) from kernel command line to 
allow other tools do the job (because now I have unusable /dev/sda1 and 
usable /dev/evms/sda1 and this leads to stupid mistakes). But there were 
no replies.

Grzegorz Kulewski
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-03-19 Thread Werner Almesberger
Andries Brouwer wrote:
> In other words, we need the user space command `partition',
> where "partition -t dos /dev/sda" reads a DOS-type partition
> table.

So if you e.g. hotplug a new device, its partitions won't be
accessible before you (or some hotplug manager, etc.) run
"partition" ?

> The two variants are: (i) partition tells the kernel
> to do the partition table reading, and (ii) partition uses partx
> to read the partition table and tells the kernel one-by-one
> about the partitions found this way.

I guess, once you've reached the point where the kernel is
unable to find partitions without user-space help, you may
as well do everything in user space.

> Since this is a fundamental change,

Pretty much, yes. Except for a few embedded systems (*), this
would mark the end of kernels that can do anything useful
without initrd or initramfs.

(*) Oh, regarding the other exception, ceterum censeo nfsroot
esse delendam.

> a long transition period
> is needed, and that period could start with a kernel boot parameter
> telling the kernel not to do partition table parsing on a particular
> disk, or a particular type of disks, or all disks.

... and allow "partition" to override partitions previously
auto-detected by the kernel. That way, you can phase in
"partition" without needing to change your kernel setup.

Besides, the ability to correct past mistakes would also be
useful if auto-detection from user space yields garbage.

- Werner

-- 
  _
 / Werner Almesberger, Buenos Aires, Argentina [EMAIL PROTECTED] /
/_http://www.almesberger.net//
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-28 Thread Rogier Wolff
On Sun, Feb 27, 2005 at 12:40:53AM +0100, Andries Brouwer wrote:
> (Concerning the "size" version: it occurred to me that there is one
> very minor objection: For extended partitions so far the size did
> not normally play a role. Only the starting sector was significant.
> If, at some moment we decide also to check the size, then a weaker
> check, namely only checking for non-extended partitions, might be
> better at first.)

I recently encountered a disk that had clipping enabled. If you go
for the size implementation be careful that people can still run a 
program to unclip the disk after the disk has been detected and the
partition rejected 

Roger. 

-- 
** [EMAIL PROTECTED] ** http://www.BitWizard.nl/ ** +31-15-2600998 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement. 
Does it sit on the couch all day? Is it unemployed? Please be specific! 
Define 'it' and what it isn't doing. - Adapted from lxrbot FAQ
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-27 Thread Uwe Bonnes
> "Linus" == Linus Torvalds <[EMAIL PROTECTED]> writes:

Linus> On Sun, 27 Feb 2005, Uwe Bonnes wrote:
>>  on a Suse 9.2 System with Suse Hotplug, the phantom partition was
>> somehow recognized as Reiserfs, and then the Hotplug mechanism trying
>> to mount the bogus partition as a Reiser Filesystem ended in an
>> Oops...

Linus> Heh. That oops would be interesting in itself, since it implies
Linus> that reiserfs is not doing very well on the sanity-checking
Linus> front.

Linus> But yes, point taken.

I have to admit, I saw the oops only with a glimpse of the eye, trying to do
other tasks at that moment about a week ago. The oops also left no trace in
the syslog. As syslog is on a reiserfs partition, perhaps reiserfs refused
no write anything after the oops. Trying to reproduce by mounting the bogus
sda4 partition of the usb stick on two different setups, now reiserfs
clearly refuses to mount it. Perhaps the oops was unrelated. 

Find appended an oops happening yesterday, related to reiserfs too. Probably
totally useless, as run on a custom Suse kernel. A reiserfsck after the oops
corrected some errors, perhaps introduced by the oops one week earlier. I
don't understand what to do about the missing ksyms..

B.t.w.: While I have you attention, can I point you to 
http://www.ussg.iu.edu/hypermail/linux/kernel/0410.1/1246.html
where I reported a Linux missbehaviour and a possible patch. I tried to get
the attention of several kernel developpers, to no avail so long ...

Cheers
-- 
Uwe Bonnes[EMAIL PROTECTED]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
- Tel. 06151 162516  Fax. 06151 164321 --
==undecoded excerpt from the syslog===
Feb 26 18:47:40 r50 kernel: Unable to handle kernel paging request at virtual 
address 8a5e65b8
Feb 26 18:47:40 r50 kernel:  printing eip:
Feb 26 18:47:40 r50 kernel: c01d1482
Feb 26 18:47:40 r50 kernel: *pde = 
Feb 26 18:47:40 r50 kernel: Oops:  [#1]
Feb 26 18:47:40 r50 kernel: Modules linked in: usb_storage nvram usbserial 
parport_pc lp parport cpufreq_userspace speedstep_centrino freq_table thermal 
processor fan button battery ac edd snd_pcm_oss snd_mixer_oss snd_intel8x0 
snd_ac97_codec snd_pcm snd_timer snd soundcore snd_page_alloc ipv6 pcmcia 
joydev sg st sd_mod sr_mod scsi_mod ide_cd cdrom subfs nls_utf8 ntfs i2c_i801 
i2c_core cinergyT2 dvb_core e1000 ehci_hcd hw_random uhci_hcd ohci1394 ieee1394 
yenta_socket rsrc_nonstatic pcmcia_core intel_agp agpgart evdev dm_mod usbcore 
reiserfs
Feb 26 18:47:40 r50 kernel: CPU:0
Feb 26 18:47:40 r50 kernel: EIP:0060:[]Tainted: G U VLI
Feb 26 18:47:40 r50 kernel: EFLAGS: 00010202   (2.6.11-rc4-bk2) 
Feb 26 18:47:40 r50 kernel: EIP is at memcpy+0x12/0x30
Feb 26 18:47:40 r50 kernel: eax: 0004   ebx: df47b058   ecx: 0004   
edx: 0010
Feb 26 18:47:40 r50 kernel: esi: 8a5e65b8   edi: df47b058   ebp: c35d7b34   
esp: c35d7af4
Feb 26 18:47:40 r50 kernel: ds: 007b   es: 007b   ss: 0068
Feb 26 18:47:40 r50 kernel: Process xauth (pid: 30301, threadinfo=c35d6000 
task=c73d5aa0)
Feb 26 18:47:40 r50 kernel: Stack: dfb3c000 df451458 c35d7c94 e0a5acf4 7a5a 
c35d7c94 df6a9ad8 e0a70707 
Feb 26 18:47:40 r50 kernel:df6a9ad8 7a5a 0004 df451458 c35d7c94 
df6a9ad8 df451458 0005 
Feb 26 18:47:41 r50 kernel:c35d7c94 c15cf424 df451458 0004 c35d7ea8 
0027 0001 c35d7c94 
Feb 26 18:47:41 r50 kernel: Call Trace:
Feb 26 18:47:41 r50 kernel:  [] replace_key+0x34/0x70 [reiserfs]
Feb 26 18:47:41 r50 kernel:  [] internal_shift_left+0xa7/0xd0 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] 
balance_internal_when_delete+0x1ca/0x220 [reiserfs]
Feb 26 18:47:41 r50 kernel:  [] balance_internal+0x5bd/0x800 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] io_schedule+0xe/0x20
Feb 26 18:47:41 r50 kernel:  [] bh_lru_install+0x89/0xb0
Feb 26 18:47:41 r50 kernel:  [] mark_page_accessed+0x28/0x30
Feb 26 18:47:41 r50 kernel:  [] dc_check_balance_internal+0x37b/0x390 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] do_balance+0xc7/0xf0 [reiserfs]
Feb 26 18:47:41 r50 kernel:  [] fix_nodes+0x31c/0x360 [reiserfs]
Feb 26 18:47:41 r50 kernel:  [] reiserfs_cut_from_item+0x32e/0x4e0 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] reiserfs_do_truncate+0x2e3/0x540 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] reiserfs_delete_object+0x28/0x60 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] reiserfs_delete_inode+0x68/0xe0 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] truncate_inode_pages+0x9/0x10
Feb 26 18:47:41 r50 kernel:  [] reiserfs_delete_inode+0x0/0xe0 
[reiserfs]
Feb 26 18:47:41 r50 kernel:  [] generic_delete_inode+0xa4/0x130
Feb 26 18:47:41 r50 kernel:  [] iput+0x4d/0x70
Feb 26 18:47:41 r50 kernel:  [] sys_unlink+0xba/0x130
Feb 26 18:47:41 r50 kernel:  [] do_munmap+0xcd/0x100
Feb 26 18:47:41 r50 kernel:  [] sysenter_past_esp+0x52/0x79
Feb 26 18:47:41 r50 kernel: Code: e0 ff ff 21 e2 3b 42 18 73 06 8b 50 fd 31 c0 
c3 31 d2 b8 

Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Andries Brouwer
On Sun, Feb 27, 2005 at 01:47:43AM +0100, Uwe Bonnes wrote:

> on a Suse 9.2 System with Suse Hotplug, the phantom partition was somehow
> recognized as Reiserfs, and then the Hotplug mechanism trying to mount the 
> bogus partition as a Reiser Filesystem ended in an Oops...

Always report the oops. It is well-known that mounting garbage may crash
the kernel. Earlier the reply was "don't do that then". Nowadays we have
more layers of software trying to probe and do automatic things, and the
kernel must survive attempts to mount garbage.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Linus Torvalds


On Sun, 27 Feb 2005, Uwe Bonnes wrote:
> 
> on a Suse 9.2 System with Suse Hotplug, the phantom partition was somehow
> recognized as Reiserfs, and then the Hotplug mechanism trying to mount the 
> bogus partition as a Reiser Filesystem ended in an Oops...

Heh. That oops would be interesting in itself, since it implies that 
reiserfs is not doing very well on the sanity-checking front. 

But yes, point taken.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Uwe Bonnes
> "Linus" == Linus Torvalds <[EMAIL PROTECTED]> writes:

Linus> On Sun, 27 Feb 2005, Andries Brouwer wrote:
>>  (Concerning the "size" version: it occurred to me that there is one
>> very minor objection: For extended partitions so far the size did not
>> normally play a role. Only the starting sector was significant.  If,
>> at some moment we decide also to check the size, then a weaker check,
>> namely only checking for non-extended partitions, might be better at
>> first.)

Linus> Yes. I agree - checking the size is likely _more_ dangerous and
Linus> likely to break something silly than checking the ID for zero.

Linus> So your patch it is. I'll put it in immediately after doing a
Linus> 2.6.11 (no need to worry about getting into 2.6.11, since afaik
Linus> the worst problem right now is an extra partition that isn't
Linus> usable).

Well,

on a Suse 9.2 System with Suse Hotplug, the phantom partition was somehow
recognized as Reiserfs, and then the Hotplug mechanism trying to mount the 
bogus partition as a Reiser Filesystem ended in an Oops...

-- 
Uwe Bonnes[EMAIL PROTECTED]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
- Tel. 06151 162516  Fax. 06151 164321 --
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Andries Brouwer
On Sat, Feb 26, 2005 at 03:46:03PM -0800, Linus Torvalds wrote:

> We should probably do the same for the 
> extended partition case, just to be consistent.

True.

diff -uprN -X /linux/dontdiff a/fs/partitions/msdos.c b/fs/partitions/msdos.c
--- a/fs/partitions/msdos.c 2004-12-29 03:39:55.0 +0100
+++ b/fs/partitions/msdos.c 2005-02-27 01:10:06.0 +0100
@@ -114,6 +114,9 @@ parse_extended(struct parsed_partitions 
 */
for (i=0; i<4; i++, p++) {
u32 offs, size, next;
+
+   if (SYS_IND(p) == 0)
+   continue;
if (!NR_SECTS(p) || is_extended_partition(p))
continue;
 
@@ -430,6 +433,8 @@ int msdos_partition(struct parsed_partit
for (slot = 1 ; slot <= 4 ; slot++, p++) {
u32 start = START_SECT(p)*sector_size;
u32 size = NR_SECTS(p)*sector_size;
+   if (SYS_IND(p) == 0)
+   continue;
if (!size)
continue;
if (is_extended_partition(p)) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Linus Torvalds


On Sun, 27 Feb 2005, Andries Brouwer wrote:
> 
> (Concerning the "size" version: it occurred to me that there is one
> very minor objection: For extended partitions so far the size did
> not normally play a role. Only the starting sector was significant.
> If, at some moment we decide also to check the size, then a weaker
> check, namely only checking for non-extended partitions, might be
> better at first.)

Yes. I agree - checking the size is likely _more_ dangerous and likely to
break something silly than checking the ID for zero.

So your patch it is. I'll put it in immediately after doing a 2.6.11 
(no need to worry about getting into 2.6.11, since afaik the worst problem 
right now is an extra partition that isn't usable).

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Linus Torvalds


On Sun, 27 Feb 2005, Uwe Bonnes wrote:
>
> /dev/sda4 3512348 6003585   698791990+   0  Empty
> Partition 4 has different physical/logical beginnings (non-Linux?):
>  phys=(0, 0, 0) logical=(3512347, 6, 16)
> Partition 4 has different physical/logical endings:
>  phys=(0, 0, 0) logical=(6003584, 7, 6)
> Partition 4 does not end on cylinder boundary.

Yeah, your case could check for zero in the physical sector stuff too, but 
I'm not sure that matters, since nobody really cares about the physical 
values and they've long been too limited to matter. So I'm not at all 
convinced that adding a few more checks for zero would be any better than 
checking the one zero that Andries does.

I think Andries' patch is fine. We should probably do the same for the 
extended partition case, just to be consistent.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Andries Brouwer
On Sat, Feb 26, 2005 at 03:12:28PM -0800, Linus Torvalds wrote:

> > The default fdisk will assign type 83 to a newly created partition.
> 
> Ok. Is that a "it has done so for the last 5 years" thing? 

The last twelve years.

> > (About type 0: DOS has used type 0 as definition of unused. It is not
> > bad if Linux uses DOS-conventions for a DOS-type partition table.)
> 
> Agreed. At the same time, I could well imagine that some people might use 
> such a type exactly to make DOS ignore it (but I assume the same is true 
> of the regular 0x83 type too, so maybe I'm just being difficult).
> 
> There's certainly a good argument for fixing a known problem (Uwe) and a 
> small enough risk of it breaking anything else.

Yes.

Andries


(Concerning the "size" version: it occurred to me that there is one
very minor objection: For extended partitions so far the size did
not normally play a role. Only the starting sector was significant.
If, at some moment we decide also to check the size, then a weaker
check, namely only checking for non-extended partitions, might be
better at first.)

(Yes, disk capacity is not always known - see e.g. ll_rw_blk.c:
 /* Test device or partition size, when known. */
See also sd.c, with the strange
sdkp->capacity = 0x20; /* 1 GB - random */
In such cases we just access the blocks user space tells us to access.)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Uwe Bonnes
> "Linus" == Linus Torvalds <[EMAIL PROTECTED]> writes:

Linus> On Sat, 26 Feb 2005, Linus Torvalds wrote:
>>  Would it not make more sense to just sanity-check the size itself,
>> and throw it out if the partition size (plus start) is bigger than
>> the disk size?

Linus> Something like this (TOTALLY UNTESTED AS USUAL!)?

Yes, no phantom partitions also with your approach.

Linus> What does fdisk and other tools do on that disk? Just out of
Linus> interest..

To be honest:
r50:~ # fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 65 MB, 65536000 bytes
17 heads, 33 sectors/track, 228 cylinders
Units = cylinders of 561 * 512 = 287232 bytes

   Device Boot  Start End  Blocks   Id  System
/dev/sda1   1 229   63981+   6  FAT16
Partition 1 has different physical/logical beginnings (non-Linux?):
 phys=(0, 1, 1) logical=(0, 1, 5)
Partition 1 has different physical/logical endings:
 phys=(125, 16, 33) logical=(228, 2, 26)
/dev/sda4 3512348 6003585   698791990+   0  Empty
Partition 4 has different physical/logical beginnings (non-Linux?):
 phys=(0, 0, 0) logical=(3512347, 6, 16)
Partition 4 has different physical/logical endings:
 phys=(0, 0, 0) logical=(6003584, 7, 6)
Partition 4 does not end on cylinder boundary.


-- 
Uwe Bonnes[EMAIL PROTECTED]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
- Tel. 06151 162516  Fax. 06151 164321 --
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Linus Torvalds


On Sat, 26 Feb 2005, Andries Brouwer wrote:
> 
> The default fdisk will assign type 83 to a newly created partition.

Ok. Is that a "it has done so for the last 5 years" thing? 

> (About type 0: DOS has used type 0 as definition of unused. It is not
> bad if Linux uses DOS-conventions for a DOS-type partition table.)

Agreed. At the same time, I could well imagine that some people might use 
such a type exactly to make DOS ignore it (but I assume the same is true 
of the regular 0x83 type too, so maybe I'm just being difficult).

There's certainly a good argument for fixing a known problem (Uwe) and a 
small enough risk of it breaking anything else.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Andries Brouwer
On Sat, Feb 26, 2005 at 02:28:45PM -0800, Linus Torvalds wrote:

> Would it not make more sense to just sanity-check the size itself, and
> throw it out if the partition size (plus start) is bigger than the disk
> size?

I don't mind.

> There might well be people use use partition type 0, just because they
> just never _set_ the partition type.. I don't think Linux has ever cared
> about any type except for the "extended partition" type, so checking for 
> zero doesn't seem very safe..

The default fdisk will assign type 83 to a newly created partition.
One has to change it by hand to 0. So, I do not think testing against 0
is so bad. A heuristic, You give another heuristic. Probably there will
be a point in time where we need both.

(About type 0: DOS has used type 0 as definition of unused. It is not
bad if Linux uses DOS-conventions for a DOS-type partition table.)

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Linus Torvalds


On Sat, 26 Feb 2005, Linus Torvalds wrote:
> 
> Would it not make more sense to just sanity-check the size itself, and
> throw it out if the partition size (plus start) is bigger than the disk
> size?

Something like this (TOTALLY UNTESTED AS USUAL!)?

What does fdisk and other tools do on that disk? Just out of interest..

Linus

---
= fs/partitions/msdos.c 1.26 vs edited =
--- 1.26/fs/partitions/msdos.c  2004-11-09 12:43:17 -08:00
+++ edited/fs/partitions/msdos.c2005-02-26 14:33:33 -08:00
@@ -381,6 +381,7 @@
 int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
 {
int sector_size = bdev_hardsect_size(bdev) / 512;
+   sector_t nr_sectors;
Sector sect;
unsigned char *data;
struct partition *p;
@@ -426,11 +427,12 @@
 * On the second pass look inside *BSD, Unixware and Solaris partitions.
 */
 
+   nr_sectors = get_capacity(bdev->bd_disk);
state->next = 5;
for (slot = 1 ; slot <= 4 ; slot++, p++) {
u32 start = START_SECT(p)*sector_size;
u32 size = NR_SECTS(p)*sector_size;
-   if (!size)
+   if (!size || size > nr_sectors)
continue;
if (is_extended_partition(p)) {
/* prevent someone doing mkfs or mkswap on an
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Linus Torvalds


On Sat, 26 Feb 2005, Uwe Bonnes wrote:
> 
> Andrew,
> 
> Andries> I think nobody uses such partitions seriously, but nevertheless
> Andries> this should probably live in -mm for a while to see if anybody
> Andries> complains.
> 
> the partition table of the USB stick in question is valid:
> 
>  1B0:  00 00 00 00 00 00 00 00   53 3F 3C B9 00 00 00 01 S?<.
>  1C0:  01 00 06 10 21 7D 25 00   00 00 DB F3 01 00 00 00 !}%.
>  1D0:  00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00 
>*
>  1F0:  00 00 00 00 00 00 00 54   72 75 6D 70 4D 53 55 AA ...TrumpMSU.
> 
> Entry 1 is a FAT partition of exactly the size of the stick, and entries 2
> to 4 are empty, marked by id zero. However the manufacturer decided to put a
> name string  "Trump" ( /sbin/lsusb gives
> Bus 004 Device 012: ID 090a:1bc0 Trumpion Microelectronics, Inc.) just before
> the "55 AA" partition table magic and our code reads this string as a
> (bogus) size for the fourth entry, taking it for real.

Would it not make more sense to just sanity-check the size itself, and
throw it out if the partition size (plus start) is bigger than the disk
size?

We already do that within extended partitions, ie we do

if (offs + size > this_size)
continue;

to just ignore crap. For some reason we don't do this for the primary one 
(possibly because we don't trust disk size reporting, I guess).

There might well be people use use partition type 0, just because they
just never _set_ the partition type.. I don't think Linux has ever cared
about any type except for the "extended partition" type, so checking for 
zero doesn't seem very safe..

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] partitions/msdos.c

2005-02-26 Thread Uwe Bonnes
> "Andries" == Andries Brouwer <[EMAIL PROTECTED]> writes:

Andrew,

Andries> I think nobody uses such partitions seriously, but nevertheless
Andries> this should probably live in -mm for a while to see if anybody
Andries> complains.

the partition table of the USB stick in question is valid:

 1B0:  00 00 00 00 00 00 00 00   53 3F 3C B9 00 00 00 01 S?<.
 1C0:  01 00 06 10 21 7D 25 00   00 00 DB F3 01 00 00 00 !}%.
 1D0:  00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00 
   *
 1F0:  00 00 00 00 00 00 00 54   72 75 6D 70 4D 53 55 AA ...TrumpMSU.

Entry 1 is a FAT partition of exactly the size of the stick, and entries 2
to 4 are empty, marked by id zero. However the manufacturer decided to put a
name string  "Trump" ( /sbin/lsusb gives
Bus 004 Device 012: ID 090a:1bc0 Trumpion Microelectronics, Inc.) just before
the "55 AA" partition table magic and our code reads this string as a
(bogus) size for the fourth entry, taking it for real.

Please consider the patch for the main kernel distribution.

Cheers
-- 
Uwe Bonnes[EMAIL PROTECTED]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
- Tel. 06151 162516  Fax. 06151 164321 --
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] partitions/msdos.c

2005-02-26 Thread Andries Brouwer
A well-known kernel bug is that it guesses at the partition type
and the partitions on any disk it encounters. This is bad because
needless I/O is done, slowing down the boot, sometimes quite a lot,
especially when I/O errors occur. And it is bad because sometimes
we guess wrong.

In other words, we need the user space command `partition',
where "partition -t dos /dev/sda" reads a DOS-type partition
table. (And "partition /dev/sda" tries all known heuristics
to decide what type of partitioning might be present.)
The two variants are: (i) partition tells the kernel
to do the partition table reading, and (ii) partition uses partx
to read the partition table and tells the kernel one-by-one
about the partitions found this way.

Since this is a fundamental change, a long transition period
is needed, and that period could start with a kernel boot parameter
telling the kernel not to do partition table parsing on a particular
disk, or a particular type of disks, or all disks.

This could have been the intro to a patch doing that, but is not.
(It is just an RFC.)

The tiny patch below prompted the above - it was suggested by Uwe Bonnes
who encountered USB devices without partition table where our present
heuristics did not suffice to stop partition table parsing.
It causes the kernel to ignore partitions of type 0. A band-aid.

I think nobody uses such partitions seriously, but nevertheless this
should probably live in -mm for a while to see if anybody complains.

Andries

diff -uprN -X /linux/dontdiff a/fs/partitions/msdos.c b/fs/partitions/msdos.c
--- a/fs/partitions/msdos.c 2004-12-29 03:39:55.0 +0100
+++ b/fs/partitions/msdos.c 2005-02-26 22:21:06.0 +0100
@@ -430,6 +430,8 @@ int msdos_partition(struct parsed_partit
for (slot = 1 ; slot <= 4 ; slot++, p++) {
u32 start = START_SECT(p)*sector_size;
u32 size = NR_SECTS(p)*sector_size;
+   if (SYS_IND(p) == 0)
+   continue;
if (!size)
continue;
if (is_extended_partition(p)) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/