[parted-devel] [ PATCH ] extended attributes support on ext2 and ext3 filesystem

Christian mail.kristian at yahoo.it
Thu Apr 9 19:58:00 UTC 2009


Hi! 

	I'm Christian Brunello, the co-maintainer of GNU fdisk package.

As described in some bug reports (both in bug-parted at gnu.org and
bug-fdisk at gnu.org) libparted does not support second extended file
system very well so I'm working to make it support most important s
features like ext_attr, resize_inode and dir_index.  

With this mail there is a patch to make libparted support user extended
attributes on ext2 and ext3 file system. 

To apply this patch people need to download the parted-1.8.8 package and
the file `parted-1.8.8_ext2_ext_attr_support.patch'. When ready simple
type those commands:

        user at host:~$ ls
        parted-1.8.8.tar.bz2	parted-1.8.8_ext2_ext_attr_support.patch
        user at host:~$ tar -xf parted-1.8.8.tar.bz2
        user at host:~$ patch -p0 < parted-1.8.8_ext2_ext_attr_support.patch
        patching file parted-1.8.8/libparted/fs/ext2/ext2_block_relocator.c
        patching file parted-1.8.8/libparted/fs/ext2/ext2.c
        patching file parted-1.8.8/libparted/fs/ext2/ext2_fs.h
        patching file parted-1.8.8/libparted/fs/ext2/ext2.h
        patching file parted-1.8.8/tests/t3100-resize-ext2-partion.sh
        user at host:~$ cd parted-1.8.8

Now we can configure, compile, test and install parted.

My patch also modify `tests/t3100-resize-ext2-partition.sh' because
before ext_attr support there is a test expected to fail. 

By the way, I think that this script is not enough to make sure
libparted resize a second extended filesystem in a right way, without
lost data or info. To make sure my ext_attr code work well I had write
some simple functions that make some tests on a ext2 resized file
system. The behaviour of this test is:

      * Create an image from /dev/zero, with a size decided from user;
      * Create a second extended file system with ext_attr feature
        enabled;
      * Mount the file system and create files on it. Files have random
        size, random data (from /dev/urandom), random number of extended
        attributes, random extended attributes names (but all on `user'
        namespace) and random extended attributes values. 
        
        Files are created in different steps, for each of those steps
        the script create files until the file system is full and delete
        random number of random entryes.
        
      * Umount the filesystem and make a backup of the image.
      * Resize the filesystem with parted (the size is random).
      * Mount the resized file system in a directory and the backup in
        another directory.
      * Compare files in the backup with those in the resized file
        system,  using md5sum for data and a simple string compare for
        the user extended attributes.
      * If the test exit successfully try to resize a file system more
        than once, and compare images using diff.
      * repeat all this stuff 3 times, with different (random) size for
        each run.

The following output is a summary of a test with 250000 byte of data:


        ####
        # TESTING WITH IMAGE OF 250000 BYTES (total 750000 bytes)
        ####
        
        
        # CREATED DIRECTORY: EXT2_FS/D86SFORcB4bsAkLHK
        attribute user.KJCsppRal set to nc1oIELigHEgdI6LB for EXT2_FS/D86SFORcB4bsAkLHK
        attribute user.jNqnR9bWF set to w0C3FIRgHO1NWC3T2 for EXT2_FS/D86SFORcB4bsAkLHK
        attribute user.WwzOmm1ft set to 4IJtaOGzvhCoTHjzd for EXT2_FS/D86SFORcB4bsAkLHK
        attribute user.NeiZnDoTA set to 3osDcd77JaAT8WUrj for EXT2_FS/D86SFORcB4bsAkLHK
        attribute user.Z2UCkHuR9 set to 2JuNaGIINBb72DGgk for EXT2_FS/D86SFORcB4bsAkLHK
        
        # CREATED FILE: EXT2_FS/D86SFORcB4bsAkLHK/sD44OWjb0O6Z80FeH (1862)
        
        # CREATED FILE: EXT2_FS/D86SFORcB4bsAkLHK/bndSDAbi1Nkuro9fM (713)
        attribute user.5BmSsL2et set to jLFzhlHwEnW2l4T9a for EXT2_FS/D86SFORcB4bsAkLHK/bndSDAbi1Nkuro9fM
        attribute user.en1EpP7c4 set to h7BJfOc3IOzdfJMWb for EXT2_FS/D86SFORcB4bsAkLHK/bndSDAbi1Nkuro9fM
        
        # CREATED FILE: EXT2_FS/D86SFORcB4bsAkLHK/kITHojBG8TkGhHf5e (1080)
        attribute user.OLPaNGJoc set to UW2OBgwBl32esiMzp for EXT2_FS/D86SFORcB4bsAkLHK/kITHojBG8TkGhHf5e
        attribute user.0qkMKKOmK set to 6CurwdEAManLdcJIP for EXT2_FS/D86SFORcB4bsAkLHK/kITHojBG8TkGhHf5e
        attribute user.tbrffQEGA set to 5igBAB5e14liwrlJW for EXT2_FS/D86SFORcB4bsAkLHK/kITHojBG8TkGhHf5e
        attribute user.WB87KtQvT set to A3t45PRwOtZRuvDn9 for EXT2_FS/D86SFORcB4bsAkLHK/kITHojBG8TkGhHf5e
        attribute user.uEO2djhc7 set to JI1G2M0ugDjpfqAvz for EXT2_FS/D86SFORcB4bsAkLHK/kITHojBG8TkGhHf5e
        
        # CREATED FILE: EXT2_FS/D86SFORcB4bsAkLHK/C1JccMLMb2lwqaZcl (32)
        attribute user.F7HbH7IFb set to LhRPCAp0kFfE1v2fH for EXT2_FS/D86SFORcB4bsAkLHK/C1JccMLMb2lwqaZcl
        attribute user.ebo6hO2rt set to klBK6oOEEWIANOmep for EXT2_FS/D86SFORcB4bsAkLHK/C1JccMLMb2lwqaZcl
        
        # CREATED FILE: EXT2_FS/D86SFORcB4bsAkLHK/nP3IeS7p4au4PLWlC (1773)
        attribute user.igv6ARusM set to vrHKnrdMWFSA5t7NK for EXT2_FS/D86SFORcB4bsAkLHK/nP3IeS7p4au4PLWlC
        
        # CREATED FILE: EXT2_FS/D86SFORcB4bsAkLHK/rW2IvWCqlRG47qzUN (235)
        attribute user.fgOMgquNb set to lq1k52j9jIk7gIwU5 for EXT2_FS/D86SFORcB4bsAkLHK/rW2IvWCqlRG47qzUN
        attribute user.lIJPfT8if set to 0b8Lz92qaa5zlNOAg for EXT2_FS/D86SFORcB4bsAkLHK/rW2IvWCqlRG47qzUN
        attribute user.TFqKOCp6z set to 2PCoDd7oIip76HLIF for EXT2_FS/D86SFORcB4bsAkLHK/rW2IvWCqlRG47qzUN
        attribute user.5s5nLHu48 set to bvf4AhdmapMEHCI16 for EXT2_FS/D86SFORcB4bsAkLHK/rW2IvWCqlRG47qzUN
        
        ...
        ...
        ...
        
        ###
        # CREATED 1 directory, 20 files
        
        removed `EXT2_FS/D86SFORcB4bsAkLHK/rdMjBjokdcujIdifl'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/FtZpqmmhckz7Djs6B'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/bndSDAbi1Nkuro9fM'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/b0fhLDzTMM1Qigknu'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/PcntzA6QFalj9NgnZ'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/rWKUj4Spip7t0oz96'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/stRbJGItdRCGj0UTC'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/BpuuWZgreRDsHfeK7'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/sD44OWjb0O6Z80FeH'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/CIiRiJGpodpeoOROG'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/rUKssJfZWdN5qv0A2'
        removed `EXT2_FS/D86SFORcB4bsAkLHK/IEkMTpkktZo8QL96D'
        
        # CREATED DIRECTORY: EXT2_FS/1Kh9ZWapmo3vif9FQ
        attribute user.PP7GtKQIR set to sitCN0RQMCcrdTGfv for EXT2_FS/1Kh9ZWapmo3vif9FQ
        attribute user.sre901F2I set to AEoGLrmlQTME7Bz4p for EXT2_FS/1Kh9ZWapmo3vif9FQ
        attribute user.ugPL4WL1h set to Jj2qPvsji4acQtudZ for EXT2_FS/1Kh9ZWapmo3vif9FQ
        attribute user.FUlo12QZI set to L7v5MBGhQbuJBoklm for EXT2_FS/1Kh9ZWapmo3vif9FQ
        
        ...
        ...
        ...
        
        # TEST_IMAGE RESIZED TO 19%
        
        # CHECKING MD5SUM OF FILES
        
        ./1Kh9ZWapmo3vif9FQ/TTmsnCzd1EIUPzklh: OK
        ./1Kh9ZWapmo3vif9FQ/JmCw18P94zKRIutBI: OK
        ./aUbFiuLBUwbrRCrpJ/4NaCHBcwQfUkssoSc: OK
        ./aUbFiuLBUwbrRCrpJ/KuDsOERnrNWmHkwND: OK
        ./O84R1MiNJBZRa7q5Q/ni7g7rivE4vrsQjrv: OK
        
        # CHECKING EXTENDED ATTRIBUTES OF FILES
        
        Comparing EXT2_FS_BACKUP/./D86SFORcB4bsAkLHK
            user.KJCsppRal OK
            user.NeiZnDoTA OK
            user.WwzOmm1ft OK
            user.Z2UCkHuR9 OK
            user.jNqnR9bWF OK
        Comparing EXT2_FS_BACKUP/./1Kh9ZWapmo3vif9FQ
            user.FUlo12QZI OK
            user.PP7GtKQIR OK
            user.sre901F2I OK
            user.ugPL4WL1h OK
        Comparing EXT2_FS_BACKUP/./1Kh9ZWapmo3vif9FQ/TTmsnCzd1EIUPzklh
            user.r26imn2lj OK
        Comparing EXT2_FS_BACKUP/./1Kh9ZWapmo3vif9FQ/JmCw18P94zKRIutBI
            user.10MP91D2i OK
            user.tfFuELNHr OK
        Comparing EXT2_FS_BACKUP/./Ob1a21FoPgc3SIAZa
            user.DfjhmOQoQ OK
            user.MTOTqSWmp OK
            user.iE5mU8LFf OK
        Comparing EXT2_FS_BACKUP/./aUbFiuLBUwbrRCrpJ/4NaCHBcwQfUkssoSc
            user.UShu2zdcC OK
        Comparing EXT2_FS_BACKUP/./O84R1MiNJBZRa7q5Q
            user.R1eK1uqEJ OK
        # TEST_IMAGE RESIZED TO 19%
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 1 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 2 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 3 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 4 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 5 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 6 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 7 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 8 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 9 [ OK ]
        # TEST_IMAGE-BACKUP RESIZED TO 19%
        IMAGE COPY TEST 10 [ OK ]
        
        ###
        # ALL TEST PASSED

I think this test is more safe ,so please, can anyone integrate it on
parted package? All scripts are in the attached tarball.


Many thanks!

Christian


-------------- next part --------------
A non-text attachment was scrubbed...
Name: parted-1.8.8_ext2_ext_attr_support.patch
Type: text/x-patch
Size: 8286 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20090409/b099334c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scripts.tar.bz2
Type: application/x-bzip-compressed-tar
Size: 2966 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20090409/b099334c/attachment-0001.bin>


More information about the parted-devel mailing list