[openfirmware] [commit] r2947 - ofw/fs/ext2fs

repository service svn at openfirmware.info
Fri Apr 20 09:07:04 CEST 2012


Author: quozl
Date: Fri Apr 20 09:07:04 2012
New Revision: 2947
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2947

Log:
ext2fs - fix inode reference count for directories on filesystems without DIR_NLINK, and maintain directory count in group descriptor, #11787

Modified:
   ofw/fs/ext2fs/bitmap.fth
   ofw/fs/ext2fs/dir.fth
   ofw/fs/ext2fs/sb.fth

Modified: ofw/fs/ext2fs/bitmap.fth
==============================================================================
--- ofw/fs/ext2fs/bitmap.fth	Thu Apr 19 21:05:54 2012	(r2946)
+++ ofw/fs/ext2fs/bitmap.fth	Fri Apr 20 09:07:04 2012	(r2947)
@@ -75,11 +75,32 @@
    then                     ( n     r: adr )
    r> h# 0e + le-w!         ( )
 ;
-: free-inodes+!  ( n inode# -- )
+: free-inodes+!  ( n group# -- )
    tuck free-inodes@  +   ( group# n' )
    over free-inodes!      ( group# )
    gd-update              ( )
 ;
+: used-dirs@   ( group# -- n )
+   group-desc  dup  h# 10 + le-w@   ( adr lo )
+   desc64?  if                      ( adr lo )
+      swap h# 30 + le-w@ wljoin     ( n )
+   else                             ( adr lo )
+      nip                           ( n )
+   then                             ( n )
+;
+: used-dirs!  ( n group# -- )
+   group-desc >r            ( n     r: adr )
+   desc64?  if              ( n     r: adr )
+      lwsplit               ( lo hi r: adr )
+      r@ h# 30 + le-w!      ( lo    r: adr )
+   then                     ( n     r: adr )
+   r> h# 10 + le-w!         ( )
+;
+: used-dirs+!  ( n group# -- )
+   tuck used-dirs@  +   ( group# n' )
+   over used-dirs!      ( group# )
+   gd-update            ( )
+;
 
 [ifdef] 386-assembler
 code find-low-zero  ( n -- bit# )

Modified: ofw/fs/ext2fs/dir.fth
==============================================================================
--- ofw/fs/ext2fs/dir.fth	Thu Apr 19 21:05:54 2012	(r2946)
+++ ofw/fs/ext2fs/dir.fth	Fri Apr 20 09:07:04 2012	(r2947)
@@ -78,7 +78,7 @@
 : +link-count  ( increment -- )
    \ link-count = 1 means that the directory has more links than can
    \ be represented in a 16-bit number; don't increment in that case.
-   dir?  if                ( increment )
+   dir? sb-nlink? and  if  ( increment )
       link-count 1 =  if   ( increment )
          drop exit         ( -- )
       then                 ( increment )
@@ -89,7 +89,7 @@
    \ If the incremented value exceeds the limit, store 1
    \ We should also set the RO_COMPAT_DIR_NLINK bit in the superblock,
    \ but we assume that OFW won't be used to create enormous directories
-   dir?  if                ( link-count )
+   dir? sb-nlink? and  if  ( link-count )
       dup d# 65000 >=  if  ( link-count )
          drop 1            ( link-count' )
       then                 ( link-count' )
@@ -106,6 +106,9 @@
    dup ctime!			( time ) \ set creation time
        mtime!			( )      \ set modification time
    0 link-count!		( )      \ link count will be incremented by new-dirent
+   dir?  if
+      1 inode# 1- ipg / used-dirs+!
+   then
    inode#			( inode# )
 ;
 
@@ -214,6 +217,10 @@
 
 \ Delete the currently selected inode. Does not affect the directory entry, if any.
 : idelete   ( -- )
+   dir? if
+      -1 inode# 1- ipg / used-dirs+!
+   then
+
    \ Short symlinks hold no blocks, but have a string in the direct block list,
    \ so we must not interpret that string as a block list.
    d.#blks-held d0<>  if
@@ -276,7 +283,7 @@
    new-inode		( name$ inode# )
 
    \ new-inode changed the value of inode#; we must restore it so
-   \ new-dirent can find info about the containing diretory 
+   \ new-dirent can find info about the containing directory
    wd-inum set-inode    ( name$ inode# )
 
    new-dirent		( error? )

Modified: ofw/fs/ext2fs/sb.fth
==============================================================================
--- ofw/fs/ext2fs/sb.fth	Thu Apr 19 21:05:54 2012	(r2946)
+++ ofw/fs/ext2fs/sb.fth	Fri Apr 20 09:07:04 2012	(r2947)
@@ -57,6 +57,7 @@
 : sb-64bit?    ( -- flag )  incompat-flags h# 80 and  0<>  ;
 : sb-extents?  ( -- flag )  incompat-flags h# 40 and  0<>  ;
 : sb-gd-csum?  ( -- flag )  ro-flags       h# 10 and  0<>  ;
+: sb-nlink?    ( -- flag )  ro-flags       h# 20 and  0<>  ;
 
 \ Don't write to a disk that uses extensions we don't understand
 : unknown-extensions?   ( -- unsafe? )



More information about the openfirmware mailing list