Changeset 2799


Ignore:
Timestamp:
Jan 6, 2012, 5:31:11 PM (3 years ago)
Author:
wmb
Message:

EXT2/3/4 file systemsystem - OLPC trac #11184 - added the ability to delete extent-mapped files from an EXT4 filesystem.

Location:
ofw/fs/ext2fs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ofw/fs/ext2fs/dir.fth

    r2798 r2799  
    196196   \ Short symlinks hold no blocks, but have a string in the direct block list,
    197197   \ so we must not interpret that string as a block list.
    198    d.#blks-held d0<>  if  delete-blocks  then
     198   d.#blks-held d0<>  if
     199      extent?  if  delete-extents  else  delete-blocks  then
     200   then
    199201
    200202   \ clear d.#blks-held, link-count, etc.
  • ofw/fs/ext2fs/extent.fth

    r2798 r2799  
    1 \ EXT4 extents
     1\ See license at end of file
     2purpose: EXT4 extent handling
     3
    24d# 12 constant /extent-header
    35d# 12 constant /extent-record
     
    6062;
    6163
     64: get-extent-block  ( 'extent-index -- 'eh )
     65   d.block                   ( 'eh )
     66
     67   \ Error check
     68   dup ext-magic? 0=  if     ( 'eh )
     69      ." EXT4 bad index block" cr
     70      debug-me
     71   then                      ( 'eh )
     72;
     73
    6274: extent->pblk#  ( logical-block# -- d.physical-block# )
    6375   direct0                      ( logical-block# 'eh )
     
    6577      ext-binsearch             ( logical-block# 'extent-index )
    6678      index-block@              ( logical-block# d.block# )
    67       d.block                   ( logical-block# 'eh' )
    68 
    69       \ Error check
    70       dup ext-magic? 0=  if     ( logical-block# 'eh' )
    71          ." EXT4 bad index block" cr
    72          debug-me
    73       then                      ( logical-block# 'eh' )
    74 
     79      get-extent-block          ( logical-block# 'eh' )
    7580   loop                         ( logical-block# 'eh )
    7681
     
    8691   u>d  r> extent-block@  d+       ( d.block# )
    8792;
     93
     94: free-extent-blocks  ( 'extent -- )
     95   dup extent-block@             ( 'extent d.block# )
     96   rot >ee_len short@  0  ?do    ( d.block# )
     97      2dup d.free-block          ( d.block# )
     98      1. d+                      ( d.block#' )
     99   loop                          ( d.block#' )
     100   2drop                         ( )
     101;
     102
     103: (delete-extents)  ( 'eh level -- )  recursive
     104   ?dup  if                      ( 'eh level )
     105      \ Level nonzero means 'eh is an index, so recursively free its blocks.
     106      1-                         ( 'eh level' )
     107      over >eh_entries short@    ( 'eh level #entries )
     108      0  ?do                     ( 'eh level )
     109         i third >extent         ( 'eh level 'extent-index )
     110         index-block@ 2>r        ( 'eh level r: d.block# )
     111         2r@ get-extent-block    ( 'eh level 'subordinate-eh  r: d.block# )
     112         over (delete-extents)   ( 'eh level  r: d.block# )
     113         2r> d.free-block        ( 'eh level )
     114      loop                       ( 'eh level )
     115      2drop                      ( )
     116   else                                       ( 'eh )
     117      \ Level 0 means 'eh is an extent list
     118      \ For each extent in the list ...
     119      dup >eh_entries short@  0  ?do          ( 'eh )
     120         \ Free all the blocks in that extent
     121         i over >extent free-extent-blocks    ( 'eh )
     122      loop                                    ( 'eh )
     123      drop                                    ( )
     124   then                          ( )
     125;
     126
     127\ Delete blocks listed in the current set of extents
     128: delete-extents  ( -- )
     129   direct0                      ( 'eh )
     130   dup >eh_depth short@         ( 'eh depth )
     131   (delete-extents)             ( )
     132;
     133
     134\ LICENSE_BEGIN
     135\ Copyright (c) 2012 FirmWorks
     136\
     137\ Permission is hereby granted, free of charge, to any person obtaining
     138\ a copy of this software and associated documentation files (the
     139\ "Software"), to deal in the Software without restriction, including
     140\ without limitation the rights to use, copy, modify, merge, publish,
     141\ distribute, sublicense, and/or sell copies of the Software, and to
     142\ permit persons to whom the Software is furnished to do so, subject to
     143\ the following conditions:
     144\
     145\ The above copyright notice and this permission notice shall be
     146\ included in all copies or substantial portions of the Software.
     147\
     148\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     149\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     150\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     151\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     152\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     153\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     154\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     155\
     156\ LICENSE_END
  • ofw/fs/ext2fs/layout.fth

    r2798 r2799  
    196196;
    197197: delete-blocks   ( -- )
     198   extent?  if  delete-extents exit  then
    198199   delete-directs
    199200   indirect1 del-blk1  if  0 indirect1 int! update  then
Note: See TracChangeset for help on using the changeset viewer.