Changeset 2947


Ignore:
Timestamp:
Apr 20, 2012, 7:07:04 AM (3 years ago)
Author:
quozl
Message:

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

Location:
ofw/fs/ext2fs
Files:
3 edited

Legend:

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

    r2815 r2947  
    7676   r> h# 0e + le-w!         ( )
    7777;
    78 : free-inodes+!  ( n inode# -- )
     78: free-inodes+!  ( n group# -- )
    7979   tuck free-inodes@  +   ( group# n' )
    8080   over free-inodes!      ( group# )
    8181   gd-update              ( )
     82;
     83: used-dirs@   ( group# -- n )
     84   group-desc  dup  h# 10 + le-w@   ( adr lo )
     85   desc64?  if                      ( adr lo )
     86      swap h# 30 + le-w@ wljoin     ( n )
     87   else                             ( adr lo )
     88      nip                           ( n )
     89   then                             ( n )
     90;
     91: used-dirs!  ( n group# -- )
     92   group-desc >r            ( n     r: adr )
     93   desc64?  if              ( n     r: adr )
     94      lwsplit               ( lo hi r: adr )
     95      r@ h# 30 + le-w!      ( lo    r: adr )
     96   then                     ( n     r: adr )
     97   r> h# 10 + le-w!         ( )
     98;
     99: used-dirs+!  ( n group# -- )
     100   tuck used-dirs@  +   ( group# n' )
     101   over used-dirs!      ( group# )
     102   gd-update            ( )
    82103;
    83104
  • ofw/fs/ext2fs/dir.fth

    r2946 r2947  
    7979   \ link-count = 1 means that the directory has more links than can
    8080   \ be represented in a 16-bit number; don't increment in that case.
    81    dir?  if                ( increment )
     81   dir? sb-nlink? and  if  ( increment )
    8282      link-count 1 =  if   ( increment )
    8383         drop exit         ( -- )
     
    9090   \ We should also set the RO_COMPAT_DIR_NLINK bit in the superblock,
    9191   \ but we assume that OFW won't be used to create enormous directories
    92    dir?  if                ( link-count )
     92   dir? sb-nlink? and  if  ( link-count )
    9393      dup d# 65000 >=  if  ( link-count )
    9494         drop 1            ( link-count' )
     
    107107       mtime!                   ( )      \ set modification time
    108108   0 link-count!                ( )      \ link count will be incremented by new-dirent
     109   dir?  if
     110      1 inode# 1- ipg / used-dirs+!
     111   then
    109112   inode#                       ( inode# )
    110113;
     
    215218\ Delete the currently selected inode. Does not affect the directory entry, if any.
    216219: idelete   ( -- )
     220   dir? if
     221      -1 inode# 1- ipg / used-dirs+!
     222   then
     223
    217224   \ Short symlinks hold no blocks, but have a string in the direct block list,
    218225   \ so we must not interpret that string as a block list.
     
    277284
    278285   \ new-inode changed the value of inode#; we must restore it so
    279    \ new-dirent can find info about the containing diretory
     286   \ new-dirent can find info about the containing directory
    280287   wd-inum set-inode    ( name$ inode# )
    281288
  • ofw/fs/ext2fs/sb.fth

    r2817 r2947  
    5858: sb-extents?  ( -- flag )  incompat-flags h# 40 and  0<>  ;
    5959: sb-gd-csum?  ( -- flag )  ro-flags       h# 10 and  0<>  ;
     60: sb-nlink?    ( -- flag )  ro-flags       h# 20 and  0<>  ;
    6061
    6162\ Don't write to a disk that uses extensions we don't understand
Note: See TracChangeset for help on using the changeset viewer.