Bug#663540: finds MSDOS when there is none

2012-03-16 Thread Harald Dunkel
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 03/12/12 17:05, Joey Hess wrote:
 
 I added a check for autoexec.bat || config.sys , just to have an added check 
 and avoid the worse of the false positives. My gut feeling is that either a) 
 nobody cares if their DOS is not detected, or b) if they do care, they have 
 one of those files.
 

???

I understand that os-prober is some kind of heuristic, but wouldn't
it be more wise to delay the look at the first sector until the
file system has been examined? Obviously the information stored
in sector #0 is less reliable.

Anyway, many thanx for the fix. I just tried it on my laptop.
Seems to work.


Regards

Harri
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAk9jrLUACgkQUTlbRTxpHjdtEwCfbiPVBbtOmKjT9lU45V0ilGF6
ekIAnA5XlwUYG26SLLA5YyoG1q0Uucvg
=LusM
-END PGP SIGNATURE-



-- 
To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4f63acbd.9010...@afaics.de



Bug#663600: Bug#663540: finds MSDOS when there is none

2012-03-15 Thread Colin Watson
On Mon, Mar 12, 2012 at 12:11:29PM -0400, Joey Hess wrote:
 Colin Watson wrote:
  How about, if grub-mount is used, we use grub-probe to find out which
  GRUB filesystem driver is in use, and stash that somewhere so that
  individual tests can get at it?  That ought to be just as reliable as
  the existing OS filesystem type checks.
 
 Yes please. I've CCed the other bug I opened, since it appears there 
 are also several false negatives when grub-probe is used. Your method
 should solve it.
 
 Once we have a real FS type from grub-probe, the best thing would be to
 pass it into individual checks as $3 in place of fuse.

Thanks.  I've done that, and I think I've sorted out all the examples
you pointed out as a result.

qnx4 doesn't matter since AFAIK GRUB can't mount its filesystem, so
grub-mount will fail and we'll fall back to the OS driver.  If
grub-mount ever learns about it and calls its driver something other
than qnx4 then we can add that.

-- 
Colin Watson   [cjwat...@debian.org]



-- 
To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/20120315135115.gn3...@riva.dynamic.greenend.org.uk



Bug#663540: finds MSDOS when there is none

2012-03-12 Thread Michael Tokarev
On 12.03.2012 08:57, Harald Dunkel wrote:
 Package: os-prober
 Version: 1.49
 
 os-prober finds some MSDOS partition on my laptop:

[os-prober says /dev/sda2 is MSDOS,
 while parted and blkid identifies it as ext4]

I understand that, due to the fact that other utils correctly identifies
this filesystem as ext4, there's a bug in os-prober which can be corrected.

But anyway, this is a very minor situation which can be corrected on
your side once and forever.  I've no idea about level of your system
and technology knowlege, so I assume a beginner level, -- please
forgive me if you're not a beginner :)

All utils examine first few sectors of a filesystem to determine its
type based on some heuristics.

Ext* family (ext2, ext3, ext4) on purpose never, ever, touch first
512 bytes of the filesystem, these bytes are unused.  This place is
reserved for a bootloader.  So in order to detect ext* filesystem,
any tool should inspect subsequent sectors.

But MSDOS (FAT) filesystem, on the other hand, does use first 512
bytes and puts its signature there.

So a more naive approach at determining the filesystem type is to
check first 512 bytes, and if MS-DOS signature is found there,
report that it is MS-DOS.  This is, apparently, what os-prober is
currently doing.

I suspect you actually had ms-dos filesystem in this partition
before, but later installed linux and ext4 filesystem on it.
If this is the case, just zero out the first 512 bytes and no
tool, ever, even the ones who does not know anything about ext*,
will detect it as ms-dos filesystem.

How:

 dd if=/dev/zero bs=512 count=1 of=/dev/sda2

This will zero-out first 512 bytes on your sda2.  If you're
unsure, you may save it before doing so, to a file on _another_
filesystem, eg sda1 (root fs), like this:

 dd if=/dev/sda2 bs=512 count=1 of=/sda2-beginning.bin

It will create file named /sda2-beginning.bin, of length
512 bytes, and will save the start of your sda2 in it.
You can restore it back by doing

 dd if=/sda2-beginning.bin of=/dev/sda2

(or, in case you booted a rescue CD or something like that,
mount your regular root fs and specify corresponding path
there).

This may sound/smell/etc very dangerous, but if it really
_is_ ext4 (it appears to be) and if it is not a boot partition
(it is not), it is safe thing to do.

Thanks,

/mjt



-- 
To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4f5db5f2.5060...@msgid.tls.msk.ru



Bug#663540: finds MSDOS when there is none

2012-03-12 Thread Joey Hess
Michael Tokarev wrote:
 So a more naive approach at determining the filesystem type is to
 check first 512 bytes, and if MS-DOS signature is found there,
 report that it is MS-DOS.  This is, apparently, what os-prober is
 currently doing.

os-prober does not look at fragile magic numbers in filsystem headers. 
It mounts the actual filesystem, and looks for (fragile) specific
filenames indicating which OS is contained in it.

The particular OS string we see here comes from:

# MS-DOS
if [ -z $found ]  item_in_dir -q dos $2 
 [ -d $2/$(item_in_dir dos $2) ]; then
long=MS-DOS 5.x/6.x/Win3.1
short=MS-DOS

found=true
fi

Perhaps your filesystem has a /dos directory?
item_in_dir checks for any case, so /DOS or /Dos would also do.

These checks don't try to avoid false positives like a /dos or /windows,
because the code earlier checks that the mounted filesystem is one of ntfs,
vfat, or msdos. To which list was semi-recently added fuse, and I suspect
that might be the root of the problem. 

Colin, if grub-mount is being used, will *every* filesystem appear as fuse?
If so, this and other code has become much more prone to false positives
than it was when it was originally written.

(os-prober 1.42 didn't have this problem I think only because the
above code in it had a typo that made it never match anything!)

-- 
see shy jo


signature.asc
Description: Digital signature


Bug#663540: finds MSDOS when there is none

2012-03-12 Thread Samuel Thibault
Joey Hess, le Mon 12 Mar 2012 11:14:07 -0400, a écrit :
 The particular OS string we see here comes from:
 
 # MS-DOS
 if [ -z $found ]  item_in_dir -q dos $2 
  [ -d $2/$(item_in_dir dos $2) ]; then
 long=MS-DOS 5.x/6.x/Win3.1
 short=MS-DOS
 
 found=true
 fi
 
 item_in_dir checks for any case, so /DOS or /Dos would also do.
 Perhaps your filesystem has a /dos directory?
 
 These checks don't try to avoid false positives like a /dos or /windows,
 because the code earlier checks that the mounted filesystem is one of ntfs,
 vfat, or msdos.

Mmm, why not looking for io.sys at the root?  In all the versions of DOS
that I know there has to be one for the partition to be bootable.

Samuel



-- 
To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120312152118.gm4...@type.bordeaux.inria.fr



Bug#663540: finds MSDOS when there is none

2012-03-12 Thread Colin Watson
On Mon, Mar 12, 2012 at 11:14:07AM -0400, Joey Hess wrote:
 These checks don't try to avoid false positives like a /dos or /windows,
 because the code earlier checks that the mounted filesystem is one of ntfs,
 vfat, or msdos. To which list was semi-recently added fuse, and I suspect
 that might be the root of the problem. 
 
 Colin, if grub-mount is being used, will *every* filesystem appear as fuse?
 If so, this and other code has become much more prone to false positives
 than it was when it was originally written.

Hm, probably, yes.  (To some extent, you get to pick which kind of
fragility you want.)

How about, if grub-mount is used, we use grub-probe to find out which
GRUB filesystem driver is in use, and stash that somewhere so that
individual tests can get at it?  That ought to be just as reliable as
the existing OS filesystem type checks.

-- 
Colin Watson   [cjwat...@debian.org]



-- 
To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/20120312155052.gk3...@riva.dynamic.greenend.org.uk



Bug#663540: finds MSDOS when there is none

2012-03-12 Thread Joey Hess
Samuel Thibault wrote:
 Mmm, why not looking for io.sys at the root?  In all the versions of DOS
 that I know there has to be one for the partition to be bootable.

According to http://en.wikipedia.org/wiki/IO.SYS , some of the DOS
clones did not use io.sys, which may be why I don't remember it well.

I added a check for autoexec.bat || config.sys , just to have an added
check and avoid the worse of the false positives. My gut feeling is that
either a) nobody cares if their DOS is not detected,
or b) if they do care, they have one of those files.

-- 
see shy jo


signature.asc
Description: Digital signature


Bug#663600: Bug#663540: finds MSDOS when there is none

2012-03-12 Thread Joey Hess
Colin Watson wrote:
 How about, if grub-mount is used, we use grub-probe to find out which
 GRUB filesystem driver is in use, and stash that somewhere so that
 individual tests can get at it?  That ought to be just as reliable as
 the existing OS filesystem type checks.

Yes please. I've CCed the other bug I opened, since it appears there 
are also several false negatives when grub-probe is used. Your method
should solve it.

Once we have a real FS type from grub-probe, the best thing would be to
pass it into individual checks as $3 in place of fuse.

-- 
see shy jo


signature.asc
Description: Digital signature


Bug#663540: finds MSDOS when there is none

2012-03-11 Thread Harald Dunkel

Package: os-prober
Version: 1.49

os-prober finds some MSDOS partition on my laptop:

# os-prober
/dev/sda2:MS-DOS 5.x/6.x/Win3.1:MS-DOS:chain
# blkid | sort
/dev/sda1: UUID=063e2d53-7007-4112-822f-edcba00d2928 TYPE=ext4 LABEL=root
/dev/sda2: LABEL=debian UUID=af0b76b9-e91e-4bbd-a64c-b1a6199982bf 
TYPE=ext4
/dev/sda3: LABEL=swap UUID=55a05f9b-346d-46c8-87a6-b0b8b2f5ad37 TYPE=swap
/dev/sda4: LABEL=export UUID=e1f404ed-b77d-4c24-91d1-7ff69540fdfa 
TYPE=ext4
# parted /dev/sda u s p
Model: ATA ST9160823AS (scsi)
Disk /dev/sda: 312581808s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End SizeType File system Flags
 1  2048s   62492671s   62490624s   primary  ext4
 2  62492672s   96047103s   33554432s   primary  ext4
 3  96047104s   104435711s  8388608sprimary  linux-swap(v1)
 4  104435712s  312581807s  208146096s  primary  ext4


This makes /dev/sda2 unbootable. At boot time grub2 gives me

error: invalid signature.

os-prober 1.42 from Stable doesn't show this problem:

# os-prober
/dev/sda2:Debian GNU/Linux (wheezy/sid):Debian:linux


Regards

Harri



--
To UNSUBSCRIBE, email to debian-boot-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4f5d821e.8070...@afaics.de