[OpenBIOS] r735 - dev/olpc/cafenand ofw/fs/jffs2

svn at openbios.org svn at openbios.org
Fri Nov 16 23:29:19 CET 2007


Author: wmb
Date: 2007-11-16 23:29:19 +0100 (Fri, 16 Nov 2007)
New Revision: 735

Modified:
   dev/olpc/cafenand/cafenand.fth
   ofw/fs/jffs2/jffs2.fth
Log:
OLPC trac #4982 - Discard cached JFFS2 scan info if the data changes
on the NAND FLASH, so JFFS2 operations work correctly after copy-nand.
Also added a couple of JFFS2 debugging tools - .dirinum and .finum ;
nothing calls them.  They display the nodes for a given inum.


Modified: dev/olpc/cafenand/cafenand.fth
===================================================================
--- dev/olpc/cafenand/cafenand.fth	2007-11-16 22:02:01 UTC (rev 734)
+++ dev/olpc/cafenand/cafenand.fth	2007-11-16 22:29:19 UTC (rev 735)
@@ -129,6 +129,7 @@
 \ : read-id  ( -- )  0 0 set-page read-id-cmd 0 cmd  wait-cmd  h# 30 cl@  ;
 : dma-off  ( -- )  0 h# 40 cl!  ;
 
+0 value #writes
 : wait-write-done  ( -- error? )
    0               ( status )
    begin           ( status )
@@ -139,6 +140,7 @@
    \ If the value is completely 0 I think it means write protect     
    1 and  0<>      ( error? )
    write-disable
+   #writes 1+ to #writes
 ;
 
 \ Assumes that the range doesn't straddle a page boundary

Modified: ofw/fs/jffs2/jffs2.fth
===================================================================
--- ofw/fs/jffs2/jffs2.fth	2007-11-16 22:02:01 UTC (rev 734)
+++ ofw/fs/jffs2/jffs2.fth	2007-11-16 22:29:19 UTC (rev 735)
@@ -86,6 +86,7 @@
 
 true value first-time?
 -1 value partition#
+-1 value #writes
 
 \ This is a run-time cache of the parent inums for the directory inums we
 \ have seen, used for resolving "..".
@@ -512,28 +513,26 @@
    dirent-offset !                      ( )
 ;
 
-: c at +  ( adr -- c adr' )  dup c@ swap ca1+  ;
-: w at +  ( adr -- w adr' )  dup w@ swap wa1+  ;
-: l at +  ( adr -- l adr' )  dup l@ swap la1+  ;
+: w at +  ( adr -- w adr' )  dup wa1+ swap w@  ;
+: l at +  ( adr -- adr' l )  dup la1+ swap l@  ;
 
-: decode-dirent  ( adr -- false | adr' offset pino true )
+: decode-dirent  ( adr -- false | adr' offset true )
    dup  next-dirent  >=  if  drop false exit  then
    dup c@  dup 1 and  if           ( adr c )   \ 1-byte form
       2/  /l* dirent-offset +!     ( adr )
       ca1+                         ( adr' )
       dirent-offset @              ( adr offset )
-      cur-pino @                   ( adr offset pino )
    else                            ( adr c )   \ Longer form
+      drop                         ( adr )
       w at +  ?dup  if                ( adr' w )   \ 2-byte form
          /w* dirent-offset +!      ( adr )
          dirent-offset @           ( adr offset )
-         cur-pino @                ( adr offset pino )
       else                         ( adr )     \ Long form
-         l at + over cur-pino !       ( pino adr' )
-         l at + over dirent-offset !  ( pino offset adr' )
-         swap rot                  ( adr offset pino )
-      then                         ( adr offset pino )
-   then                            ( adr offset pino )
+         l at + cur-pino !            ( adr' )
+         l at + dirent-offset !       ( adr' )
+         dirent-offset @           ( adr offset )
+      then                         ( adr offset )
+   then                            ( adr offset )
    true
 ;
 
@@ -618,7 +617,7 @@
    4 #     sp  add          \ clean stack
    ax ax xor  0 # 0 [sp] mov  \ return false
 c;
-: next-pino-match  ( adr -- false | pino adr' offset true )
+: next-pino-match  ( adr -- false | adr' offset true )
    next-dirent wd-inum cur-pino dirent-offset (next-pino-match)
 ;
 [then]
@@ -650,11 +649,11 @@
       dup c@  dup 1 and  if          ( adr b )
          2/ /l* dirent-offset +!     ( adr )
          ca1+                        ( adr' )
-      w at + swap ?dup  if              ( adr' w )
+      w at + ?dup  if                   ( adr' w )
          /w* dirent-offset +!        ( adr' )
       else                           ( adr' )
-         l at + swap cur-pino !         ( adr' )
-         l at + swap dirent-offset !    ( adr' )
+         l at + cur-pino !              ( adr' )
+         l at + dirent-offset !         ( adr' )
          wd-inum cur-pino @ =  if    ( adr' )
             dirent-offset @          ( adr' offset )
             true                     ( adr' offset true )
@@ -827,7 +826,11 @@
 ;
 
 : scan-occupied  ( -- )
-   " partition#" $call-parent partition# =  first-time? 0= and  if  exit  then
+   " partition#" $call-parent partition# =
+   first-time? 0= and
+   " #writes" $call-parent #writes =  and
+   if  exit  then
+
    init-curvars
    dirents 'next-dirent !
    inodes  'next-inode  !
@@ -838,6 +841,9 @@
          i possible-nodes?  if  i scan-raw-nodes  then
       then
    pages/eblock +loop
+
+   " partition#" $call-parent to partition#
+   " #writes"    $call-parent to #writes
 ;
 
 0 [if]
@@ -1195,7 +1201,37 @@
    to wd-inum
    false
 ;
+: .finum  ( inum -- )
+   init-curvars
+   inodes  begin  next-inode curinum  amatch-inode  while    ( inum inode' offset version )
+      drop  get-node                  ( inum inode' adr )
+      ." Vers: " dup riversion@ .     ( inum inode' len adr )
+      ." Floc: " dup rioffset@ .      ( inum inode' len adr )
+      ." Dlen: " dup ridsize@ .       ( inum inode' len adr )
+      ." Mode: " dup rimode@ .        ( inum inode' len adr )
+      drop cr                         ( inum inode' len )
+   repeat                             ( inum )
+   drop
+;
 
+: .dirinum  ( inum -- )
+   >r
+   dirents  begin  decode-dirent  while  ( adr' offset pino r: )
+      get-node dup rdinode@              ( adr' node-adr this-inum r: inum )
+      r@ =  if
+         dup rdname$ type
+         ."  Vers: "  dup rdversion@ .
+         ."   Pino: " dup rdpino@ .
+\ Inum is known since we searched for it, and type is always "directory"
+\ since we searched the dirent list.
+\         ."  Inum: "  dup rdinode@ .
+         cr
+      then                               ( adr' node-adr r: inum )
+      drop                               ( adr' r: inum )
+   repeat                                ( r: inum )
+   r> drop
+;
+
 : $find-name  ( name$ -- error? )
    -1 to my-vers                         ( name$ )
 
@@ -1469,7 +1505,6 @@
 
    scan-occupied                                ( )
 
-   " partition#" $call-parent to partition#
    false to first-time?
 
    my-args " <NoFile>"  $=  if  true exit  then




More information about the OpenBIOS mailing list