Revision: 5620
          http://jnode.svn.sourceforge.net/jnode/?rev=5620&view=rev
Author:   galatnm
Date:     2009-07-24 15:22:04 +0000 (Fri, 24 Jul 2009)

Log Message:
-----------
Print partition informations should now print number of blocks correctly.

Modified Paths:
--------------
    trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java

Modified: trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java      
2009-07-23 15:26:00 UTC (rev 5619)
+++ trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java      
2009-07-24 15:22:04 UTC (rev 5620)
@@ -162,7 +162,8 @@
         }
         BlockDeviceAPI api = dev.getAPI(BlockDeviceAPI.class);
         IDEDriveDescriptor descriptor = ideDev.getDescriptor();
-        ByteBuffer MBR = ByteBuffer.allocate(IDEConstants.SECTOR_SIZE);
+        int sectorSize = IDEConstants.SECTOR_SIZE;
+        ByteBuffer MBR = ByteBuffer.allocate(sectorSize);
         api.read(0, MBR);
         if (IBMPartitionTable.containsPartitionTable(MBR.array())) {
             IBMPartitionTable partitionTable = 
@@ -175,14 +176,25 @@
 
             int i = 0;
             for (IBMPartitionTableEntry entry : partitionTable) {
-                //IBMPartitionTableEntry entry = 
(IBMPartitionTableEntry)partitionTable.getEntry(i);
                 IBMPartitionTypes si = entry.getSystemIndicator();
                 if (si != IBMPartitionTypes.PARTTYPE_EMPTY) {
+                    // Calculate number of blocks
+                    long sectors = entry.getNrSectors();
+                    long blocks = sectors;
+                    long odd = 0;
+
+                    if (sectorSize < 1024) {
+                        blocks /= (1024 / sectorSize);
+                        odd = sectors % (1024 / sectorSize);
+                    } else {
+                        blocks *= (sectorSize / 1024);
+                    }
+                    
                     out.println("ID " + i  + " " +
                             (entry.getBootIndicator() ? "Boot" : "No") + "    
" +
                             entry.getStartLba() + "    " +
-                            (entry.getStartLba() + entry.getNrSectors()) + "   
 " +
-                            entry.getNrSectors() + "    " + si);
+                            (entry.getStartLba() + sectors) + "    " +
+                            blocks + ((odd!=0)?"+":"") + "    " + si);
                 }
                 if (entry.isExtended()) {
                     final List<IBMPartitionTableEntry> exPartitions = 
partitionTable.getExtendedPartitions();


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to