Author: wmb Date: 2007-07-24 21:02:06 +0200 (Tue, 24 Jul 2007) New Revision: 493
Added: ofw/fs/ext2fs/partition.fth Modified: ofw/disklabel/loadpkg.fth ofw/disklabel/methods.fth Log: Partition type decoder - handle mismatch between partition type code and actual filesystem. Warn of the mismatch, but use the actual filesystem. OLPC trac #635.
Modified: ofw/disklabel/loadpkg.fth =================================================================== --- ofw/disklabel/loadpkg.fth 2007-07-24 01:21:22 UTC (rev 492) +++ ofw/disklabel/loadpkg.fth 2007-07-24 19:02:06 UTC (rev 493) @@ -4,11 +4,15 @@ fload ${BP}/ofw/disklabel/common.fth fload ${BP}/ofw/fs/fatfs/partition.fth fload ${BP}/ofw/fs/cdfs/partition.fth +[ifdef] ufs-support fload ${BP}/ofw/fs/ufs/partition.fth +[then] +fload ${BP}/ofw/fs/ext2fs/partition.fth [ifdef] hfs-support fload ${BP}/ofw/fs/macfs/partition.fth [then] fload ${BP}/ofw/disklabel/methods.fth + \ LICENSE_BEGIN \ Copyright (c) 2006 FirmWorks \
Modified: ofw/disklabel/methods.fth =================================================================== --- ofw/disklabel/methods.fth 2007-07-24 01:21:22 UTC (rev 492) +++ ofw/disklabel/methods.fth 2007-07-24 19:02:06 UTC (rev 493) @@ -48,11 +48,13 @@ then then
+[ifdef] ufs-support \ If the partition type is UFS and a filename is specified, select \ one of the UFS sub-partitions. Otherwise use the raw partition. partition-type ufs-type = if filename nip if ufs-map then then +[then] ;
: select-partition ( -- ) @@ -83,6 +85,7 @@
iso-9660? if exit then
+[ifdef] ufs-support \ If this disk has a UFS partition map that is not subordinate to \ an FDISK map and either a UFS partition letter or a filename is \ specified, select one of the UFS sub-partitions. @@ -90,6 +93,7 @@ ufs? if ufs-partition 0<> filename nip 0<> or if ufs-map exit then then +[then]
\ Nothing we tried worked. abort @@ -106,15 +110,32 @@ \ ( change sector-offset and size.low,high ) ... [then]
+ 2 read-sector + ext2? if + partition-type ext2fs-type <> if + ." Warning: Filesystem is ext2/3, but partition type is 0x" + partition-type .x ." (should be 0x83)." cr + then + " ext2-file-system" exit + then + +[ifdef] ufs-support partition-type ufs-type = if " ufs-file-system" exit then - partition-type ext2fs-type = if " ext2-file-system" exit then - partition-type minix-type = if " minix-file-system" exit then +[then] + partition-type minix-type = if " minix-file-system" exit then
0 read-sector \ Get the first sector of the selected partition dropin? if " dropin-file-system" exit then zip? if " zip-file-system" exit then + fat? if + partition-type ext2fs-type = if + ." Warning: Filesystem is FAT, but partition type is 0x83 (ext2/3)." cr + then + " fat-file-system" exit + then
- " fat-file-system" + ." Error: Unknown file system" cr + abort ;
\ If the arguments include a filename, we determine the type of filesystem
Added: ofw/fs/ext2fs/partition.fth =================================================================== --- ofw/fs/ext2fs/partition.fth (rev 0) +++ ofw/fs/ext2fs/partition.fth 2007-07-24 19:02:06 UTC (rev 493) @@ -0,0 +1,33 @@ +\ See license at end of file +purpose: Ext2/3 partition map decoding support + +\ Returns true if the sector buffer appears to contain an ext2/3 super block +\ which signifies the beginning of a DOS "FAT" file system. +: ext2? ( -- flag ) + sector-buf h# 38 + w@ ( magic ) + dup h# ef53 = swap h# 53ef = or ( ext2? ) +; + +\ LICENSE_BEGIN +\ Copyright (c) 2007 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END