当前位置: 首页>>代码示例>>C#>>正文


C# Partition.Read方法代码示例

本文整理汇总了C#中Partition.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Partition.Read方法的具体用法?C# Partition.Read怎么用?C# Partition.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Partition的用法示例。


在下文中一共展示了Partition.Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Ext

        public Ext( Device device, MBRPartitionEntry mbr_entry )
        {
            partition = new Partition( device, mbr_entry );
            Byte[] sector = new Byte[ device.SectorSize ];
            partition.Read( sector, 1024, device.SectorSize );

            if ( sector[ 56 ] != 0x53 || sector[ 57 ] != 0xef ) throw new Exception( "Partition is not Ext2/3/4" );

            Utils.LoadLE32( out inode_count,            sector, 0 );
            Utils.LoadLE32( out total_block_count,      sector, 4 );
            Utils.LoadLE32( out reserved_block_count,   sector, 8 );
            Utils.LoadLE32( out free_block_count,       sector, 12 );
            Utils.LoadLE32( out free_inode_count,       sector, 16 );
            Utils.LoadLE32( out first_data_block,       sector, 20 );
            Utils.LoadLE32( out block_size_pow,         sector, 24 );
            Utils.LoadLE32( out blocks_per_group,       sector, 32 );
            Utils.LoadLE32( out inodes_per_group,       sector, 40 );
            Utils.LoadLE16( out minor_revision,         sector, 62 );
            Utils.LoadLE32( out revision,               sector, 76 );
            Utils.LoadLE32( out first_useable_inode,    sector, 84 );
            Utils.LoadLE16( out inode_size,             sector, 88 );
            Utils.LoadLE32( out features_compatible,    sector, 92 );
            Utils.LoadLE32( out features_incompatible,  sector, 96 );
            Utils.LoadLE32( out features_ro_compatible, sector, 100 );
            Utils.LoadLE32( out volume_id[0],           sector, 104 );
            Utils.LoadLE32( out volume_id[1],           sector, 108 );
            Utils.LoadLE32( out volume_id[2],           sector, 112 );
            Utils.LoadLE32( out volume_id[3],           sector, 116 );
            Utils.LoadString( out volume_name, 16,      sector, 120 );
            prealloc_file   = sector[204];
            prealloc_dir    = sector[205];
            Utils.LoadString( out journal_uuid, 16,     sector, 208 );
            Utils.LoadLE32( out journal_inode,          sector, 224 );
            Utils.LoadLE32( out journal_last_orphan,    sector, 232 );
            Utils.LoadLE32( out hash_seed[0],           sector, 236 );
            Utils.LoadLE32( out hash_seed[1],           sector, 240 );
            Utils.LoadLE32( out hash_seed[2],           sector, 244 );
            Utils.LoadLE32( out hash_seed[3],           sector, 248 );
            hash_version    = sector[252];
            Utils.LoadLE32( out first_meta_block_group, sector, 260 );

            ext4 =  ( ( features_ro_compatible & 0x0008 ) != 0 ) ||
                    ( ( features_ro_compatible & 0x0010 ) != 0 ) ||
                    ( ( features_ro_compatible & 0x0020 ) != 0 ) ||
                    ( ( features_ro_compatible & 0x0040 ) != 0 ) ||
                    ( ( features_incompatible & 0x0040 ) != 0 ) ||
                    ( ( features_incompatible & 0x0080 ) != 0 ) ||
                    ( ( features_incompatible & 0x0100 ) != 0 ) ||
                    ( ( features_incompatible & 0x0200 ) != 0 ) ||
                    ( ( features_incompatible & 0x0400 ) != 0 ) ||
                    ( ( features_incompatible & 0x1000 ) != 0 );

            uint block_group_count = ( total_block_count + blocks_per_group-1 )/blocks_per_group;
            for ( uint i=0; i<block_group_count; ++i )
            {
                bg_descriptors.Add( GetGroupDescriptor( i ) );
            }
        }
开发者ID:pbalint,项目名称:Playground,代码行数:58,代码来源:Ext.cs


注:本文中的Partition.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。