module C = Libvirt.Connect
module D = Libvirt.Domain
+open Int63.Operators
+
open Virt_df_gettext.Gettext
open Virt_df
-let ( +* ) = Int32.add
-let ( -* ) = Int32.sub
-let ( ** ) = Int32.mul
-let ( /* ) = Int32.div
-
-let ( +^ ) = Int64.add
-let ( -^ ) = Int64.sub
-let ( *^ ) = Int64.mul
-let ( /^ ) = Int64.div
-
let () =
(* Command line argument parsing. *)
let set_uri = function "" -> uri := None | u -> uri := Some u in
csv_write [ "Filesystem"; total; used; avail; "Type" ] in
let printable_size bytes =
- if bytes < 1024L *^ 1024L then
- sprintf "%Ld bytes" bytes
- else if bytes < 1024L *^ 1024L *^ 1024L then
- sprintf "%.1f MiB" (Int64.to_float (bytes /^ 1024L) /. 1024.)
+ if bytes < ~^1024 *^ ~^1024 then
+ sprintf "%s bytes" (Int63.to_string bytes)
+ else if bytes < ~^1024 *^ ~^1024 *^ ~^1024 then
+ sprintf "%.1f MiB" (Int63.to_float (bytes /^ ~^1024) /. 1024.)
else
- sprintf "%.1f GiB" (Int64.to_float (bytes /^ 1024L /^ 1024L) /. 1024.)
+ sprintf "%.1f GiB" (Int63.to_float (bytes /^ ~^1024 /^ ~^1024) /. 1024.)
in
(* HOF to iterate over filesystems. *)
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
if fs_is_swap then (
(* Swap partition. *)
if not !human then
- printf "%10Ld %s\n"
- (fs_blocksize *^ fs_blocks_total /^ 1024L) fs_name
+ printf "%10s %s\n"
+ (Int63.to_string (fs_blocksize *^ fs_blocks_total /^ ~^1024))
+ fs_name
else
printf "%10s %s\n"
- (printable_size (fs_blocksize *^ fs_blocks_total)) fs_name
+ (printable_size (fs_blocksize *^ fs_blocks_total))
+ fs_name
) else (
(* Ordinary filesystem. *)
if not !inodes then ( (* 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
+ let blocks_avail = if blocks_avail < ~^0 then ~^0 else blocks_avail in
if not !human then ( (* Display 1K blocks. *)
- printf "%10Ld %10Ld %10Ld %s\n"
- (blocks_total *^ fs_blocksize /^ 1024L)
- (fs_blocks_used *^ fs_blocksize /^ 1024L)
- (blocks_avail *^ fs_blocksize /^ 1024L)
+ printf "%10s %10s %10s %s\n"
+ (Int63.to_string (blocks_total *^ fs_blocksize /^ ~^1024))
+ (Int63.to_string (fs_blocks_used *^ fs_blocksize /^ ~^1024))
+ (Int63.to_string (blocks_avail *^ fs_blocksize /^ ~^1024))
fs_name
) else ( (* Human-readable blocks. *)
printf "%10s %10s %10s %s\n"
fs_name
)
) else ( (* Inodes display. *)
- printf "%10Ld %10Ld %10Ld %s\n"
- fs_inodes_total fs_inodes_used fs_inodes_avail
+ printf "%10s %10s %10s %s\n"
+ (Int63.to_string fs_inodes_total)
+ (Int63.to_string fs_inodes_used)
+ (Int63.to_string fs_inodes_avail)
fs_name
)
)
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_blocksize *^ fs_blocks_total /^ 1024L);
+ [ Int63.to_string (fs_blocksize *^ fs_blocks_total /^ ~^1024);
""; "" ]
else (
(* Ordinary filesystem. *)
(* '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
+ let blocks_avail = if blocks_avail < ~^0 then ~^0 else blocks_avail in
- [ 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) ]
+ [ Int63.to_string (blocks_total *^ fs_blocksize /^ ~^1024);
+ Int63.to_string (fs_blocks_used *^ fs_blocksize /^ ~^1024);
+ Int63.to_string (blocks_avail *^ fs_blocksize /^ ~^1024) ]
) else ( (* Inodes display. *)
- [ Int64.to_string fs_inodes_total;
- Int64.to_string fs_inodes_used;
- Int64.to_string fs_inodes_avail ]
+ [ Int63.to_string fs_inodes_total;
+ Int63.to_string fs_inodes_used;
+ Int63.to_string fs_inodes_avail ]
)
) in