Changeset 2900


Ignore:
Timestamp:
Mar 19, 2012, 10:52:46 PM (3 years ago)
Author:
quozl
Message:

OLPC - add fs-resize, no change to fs-update, fs-resize enlarges the second partition to fill remaining space on eMMC or microSD, may be followed up with manual use of "resize2fs /dev/mmcblk0p2", does not require initramfs or olpc-os-builder support. #11690

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpu/x86/pc/olpc/via/fsupdate.fth

    r2872 r2900  
    9494;
    9595
     96h# 1be. 2value pt  \ device byte offset to start of partition table
     97h# 10 value /pe    \ size of a partition entry
     98/pe buffer: pe     \ partition entry buffer
     99
     100: pe-seek   ( partition# -- )
     101   1- /pe * 0 pt d+                  ( d.pos )
     102   " seek" nandih $call-method drop  ( )
     103;
     104
     105: pe-read   ( partition# -- )  pe-seek  pe /pe " read"  nandih $call-method drop  ;
     106: pe-write  ( partition# -- )  pe-seek  pe /pe " write" nandih $call-method drop  ;
     107
     108: pe-start@   ( pe -- start )   pe h# 08 + le-l@  ;
     109: pe-length@  ( pe -- length )  pe h# 0c + le-l@  ;
     110: pe-length!  ( length pe -- )  pe h# 0c + le-l!  ;
     111
     112: pe-is-set?  ( partition# -- flag )   pe-read  pe-start@ pe-length@ or  ;
     113
     114: (resize:)  ( -- )
     115   4 pe-is-set?  abort" partition 4 is non-zero"
     116   3 pe-is-set?  abort" partition 3 is non-zero"
     117   " size" nandih $call-method d# 512 um/mod swap drop
     118                              ( d-end )
     119   2 pe-read                  ( d-end )
     120   pe-start@  dup >r          ( d-end p-start )  ( r: p-start )
     121   pe-length@ + swap          ( p-end d-end )    ( r: p-start )
     122   2dup > abort" partition ends beyond device size"
     123   2dup < if                  ( p-end d-end )    ( r: p-start )
     124      nip r> - pe-length!     ( )                ( r: )
     125      2 pe-write              ( )                ( r: )
     126   else                       ( p-end d-end )    ( r: p-start )
     127      r> 3drop                ( )                ( r: )
     128   then                       ( )                ( r: )
     129;
     130
    96131: data:  ( "filename" -- )
    97132   safe-parse-word            ( filename$ )
     
    242277: fs-update  ( "devspec" -- )
    243278   safe-parse-word $fs-update
     279;
     280
     281: fs-resize  ( -- )
     282   open-nand
     283   [ also nand-commands ] (resize:) [ previous ]
     284   close-nand
    244285;
    245286
Note: See TracChangeset for help on using the changeset viewer.