From 2971bd66df63a8cf8d011abf6126c7bddc90f5ff Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] fs_block_size -> fs_blocksize, and int to make it consistent --- lib/diskimage.mli | 4 ++-- lib/diskimage_ext2.ml | 7 +++++-- lib/diskimage_linux_swap.ml | 5 +++-- lib/diskimage_utils.ml | 4 ++-- lib/diskimage_utils.mli | 4 ++-- virt-df/virt_df_main.ml | 32 +++++++++++++++++--------------- 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/lib/diskimage.mli b/lib/diskimage.mli index 09d791e..7d51e93 100644 --- a/lib/diskimage.mli +++ b/lib/diskimage.mli @@ -194,9 +194,9 @@ and partition_content = ] and filesystem = { - fs_dev : device; (** Device containing the filesystem. *) fs_plugin_id : fs_plugin_id; (** Filesystem type. *) - fs_block_size : int64; (** Block size (bytes). *) + fs_dev : device; (** Device containing the filesystem. *) + fs_blocksize : int; (** Block size (bytes). *) fs_blocks_total : int64; (** Total blocks. *) fs_is_swap : bool; (** If swap, following not valid. *) fs_blocks_reserved : int64; (** Blocks reserved for super-user. *) diff --git a/lib/diskimage_ext2.ml b/lib/diskimage_ext2.ml index f9913ca..2226255 100644 --- a/lib/diskimage_ext2.ml +++ b/lib/diskimage_ext2.ml @@ -120,11 +120,14 @@ let probe dev = let fs_dev = new blocksize_overlay (Int64.to_int block_size) dev in { - fs_dev = fs_dev; fs_plugin_id = plugin_id; - fs_block_size = block_size; + fs_dev = fs_dev; + + fs_blocksize = Int64.to_int block_size; fs_blocks_total = Int64.of_int32 s_blocks_count -^ overhead; + fs_is_swap = false; + fs_blocks_reserved = Int64.of_int32 s_r_blocks_count; fs_blocks_avail = Int64.of_int32 s_free_blocks_count; fs_blocks_used = diff --git a/lib/diskimage_linux_swap.ml b/lib/diskimage_linux_swap.ml index ae8c405..c5aff63 100644 --- a/lib/diskimage_linux_swap.ml +++ b/lib/diskimage_linux_swap.ml @@ -40,9 +40,10 @@ let probe dev = let fs_dev = new blocksize_overlay blocksize dev in { - fs_dev = fs_dev; fs_plugin_id = plugin_id; - fs_block_size = blocksize64; + fs_dev = fs_dev; + + fs_blocksize = blocksize; fs_blocks_total = fs_dev#size /^ blocksize64; (* The remaining fields are ignored when fs_is_swap is true. *) diff --git a/lib/diskimage_utils.ml b/lib/diskimage_utils.ml index 84eec94..cbd809f 100644 --- a/lib/diskimage_utils.ml +++ b/lib/diskimage_utils.ml @@ -203,9 +203,9 @@ and partition_content = (* Filesystems (also swap devices). *) and filesystem = { - fs_dev : device; (* Device containing the filesystem. *) fs_plugin_id : fs_plugin_id; (* Filesystem. *) - fs_block_size : int64; (* Block size (bytes). *) + fs_dev : device; (* Device containing the filesystem. *) + fs_blocksize : int; (* Block size (bytes). *) fs_blocks_total : int64; (* Total blocks. *) fs_is_swap : bool; (* If swap, following not valid. *) fs_blocks_reserved : int64; (* Blocks reserved for super-user. *) diff --git a/lib/diskimage_utils.mli b/lib/diskimage_utils.mli index bc67474..d44f038 100644 --- a/lib/diskimage_utils.mli +++ b/lib/diskimage_utils.mli @@ -104,9 +104,9 @@ and partition_content = ] and filesystem = { - fs_dev : device; fs_plugin_id : fs_plugin_id; - fs_block_size : int64; + fs_dev : device; + fs_blocksize : int; fs_blocks_total : int64; fs_is_swap : bool; fs_blocks_reserved : int64; diff --git a/virt-df/virt_df_main.ml b/virt-df/virt_df_main.ml index 84d7cc2..cfe40e2 100644 --- a/virt-df/virt_df_main.ml +++ b/virt-df/virt_df_main.ml @@ -339,7 +339,7 @@ OPTIONS" in let { Diskimage.fs_plugin_id = fs_plugin_id; - fs_block_size = fs_block_size; + fs_blocksize = fs_blocksize; fs_blocks_total = fs_blocks_total; fs_is_swap = fs_is_swap; fs_blocks_reserved = fs_blocks_reserved; @@ -350,6 +350,7 @@ OPTIONS" in fs_inodes_avail = fs_inodes_avail; fs_inodes_used = fs_inodes_used } = fs in + let fs_blocksize = Int64.of_int fs_blocksize in let fs_name = Diskimage.name_of_filesystem fs_plugin_id in @@ -357,10 +358,10 @@ OPTIONS" in (* Swap partition. *) if not !human then printf "%10Ld %s\n" - (fs_block_size *^ fs_blocks_total /^ 1024L) fs_name + (fs_blocksize *^ fs_blocks_total /^ 1024L) fs_name else printf "%10s %s\n" - (printable_size (fs_block_size *^ fs_blocks_total)) fs_name + (printable_size (fs_blocksize *^ fs_blocks_total)) fs_name ) else ( (* Ordinary filesystem. *) if not !inodes then ( (* Block display. *) @@ -371,15 +372,15 @@ OPTIONS" in if not !human then ( (* Display 1K blocks. *) printf "%10Ld %10Ld %10Ld %s\n" - (blocks_total *^ fs_block_size /^ 1024L) - (fs_blocks_used *^ fs_block_size /^ 1024L) - (blocks_avail *^ fs_block_size /^ 1024L) + (blocks_total *^ fs_blocksize /^ 1024L) + (fs_blocks_used *^ fs_blocksize /^ 1024L) + (blocks_avail *^ fs_blocksize /^ 1024L) fs_name ) else ( (* Human-readable blocks. *) printf "%10s %10s %10s %s\n" - (printable_size (blocks_total *^ fs_block_size)) - (printable_size (fs_blocks_used *^ fs_block_size)) - (printable_size (blocks_avail *^ fs_block_size)) + (printable_size (blocks_total *^ fs_blocksize)) + (printable_size (fs_blocks_used *^ fs_blocksize)) + (printable_size (blocks_avail *^ fs_blocksize)) fs_name ) ) else ( (* Inodes display. *) @@ -399,7 +400,7 @@ OPTIONS" in let { Diskimage.fs_plugin_id = fs_plugin_id; - fs_block_size = fs_block_size; + fs_blocksize = fs_blocksize; fs_blocks_total = fs_blocks_total; fs_is_swap = fs_is_swap; fs_blocks_reserved = fs_blocks_reserved; @@ -410,25 +411,26 @@ OPTIONS" in fs_inodes_avail = fs_inodes_avail; fs_inodes_used = fs_inodes_used } = fs in + let fs_blocksize = Int64.of_int fs_blocksize in let fs_name = Diskimage.name_of_filesystem fs_plugin_id in let row = if fs_is_swap then (* Swap partition. *) - [ Int64.to_string (fs_block_size *^ fs_blocks_total /^ 1024L); + [ Int64.to_string (fs_blocksize *^ fs_blocks_total /^ 1024L); ""; "" ] else ( (* Ordinary filesystem. *) - if not !inodes then ( (* Block display. *) + if not !inodes then ( (* 1K block display. *) (* 'df' doesn't count the restricted blocks. *) let blocks_total = fs_blocks_total -^ fs_blocks_reserved in let blocks_avail = fs_blocks_avail -^ fs_blocks_reserved in let blocks_avail = if blocks_avail < 0L then 0L else blocks_avail in - [ Int64.to_string (blocks_total *^ fs_block_size /^ 1024L); - Int64.to_string (fs_blocks_used *^ fs_block_size /^ 1024L); - Int64.to_string (blocks_avail *^ fs_block_size /^ 1024L) ] + [ Int64.to_string (blocks_total *^ fs_blocksize /^ 1024L); + Int64.to_string (fs_blocks_used *^ fs_blocksize /^ 1024L); + Int64.to_string (blocks_avail *^ fs_blocksize /^ 1024L) ] ) else ( (* Inodes display. *) [ Int64.to_string fs_inodes_total; Int64.to_string fs_inodes_used; -- 1.8.3.1