From e6cca10e5cf86b9bd280e371fb1195835a96bff0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 28 Mar 2008 17:12:47 +0000 Subject: Internationalize virt-df program. --- virt-df/virt_df_linux_swap.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) mode change 100755 => 100644 virt-df/virt_df_linux_swap.ml (limited to 'virt-df/virt_df_linux_swap.ml') diff --git a/virt-df/virt_df_linux_swap.ml b/virt-df/virt_df_linux_swap.ml old mode 100755 new mode 100644 index 4638828..04e22b9 --- a/virt-df/virt_df_linux_swap.ml +++ b/virt-df/virt_df_linux_swap.ml @@ -20,6 +20,8 @@ Support for Linux swap partitions. *) +open Virt_df_gettext.Gettext + (* Int64 operators for convenience. *) let (+^) = Int64.add let (-^) = Int64.sub @@ -28,7 +30,7 @@ let (/^) = Int64.div let probe_swap target part_type fd start size = Virt_df.Swap { - Virt_df.swap_name = "Linux swap"; + Virt_df.swap_name = s_ "Linux swap"; swap_block_size = 4096L; (* XXX *) swap_blocks_total = size *^ 512L /^ 4096L; } -- cgit From e6050cae9eee80791c3bb26f34c61f7dc89b142f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 14 Apr 2008 17:48:49 +0100 Subject: Complete rewrite of virt-df: - Uses pa_bitmatch for robust parsing of disk structures. - Completely modularized. --- virt-df/virt_df_linux_swap.ml | 46 +++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'virt-df/virt_df_linux_swap.ml') diff --git a/virt-df/virt_df_linux_swap.ml b/virt-df/virt_df_linux_swap.ml index 04e22b9..ad56149 100644 --- a/virt-df/virt_df_linux_swap.ml +++ b/virt-df/virt_df_linux_swap.ml @@ -21,22 +21,34 @@ *) open Virt_df_gettext.Gettext - -(* Int64 operators for convenience. *) -let (+^) = Int64.add -let (-^) = Int64.sub -let ( *^ ) = Int64.mul -let (/^) = Int64.div - -let probe_swap target part_type fd start size = - Virt_df.Swap { - Virt_df.swap_name = s_ "Linux swap"; - swap_block_size = 4096L; (* XXX *) - swap_blocks_total = size *^ 512L /^ 4096L; - } +open Virt_df + +let probe_swap (dev : device) = + (* Load the "superblock" (ie. first 0x1000 bytes). *) + let bits = dev#read_bitstring 0L 0x1000 in + + bitmatch bits with + (* Actually this isn't just padding. *) + | padding : 8*0x1000 - 10*8 : bitstring; + magic : 10*8 : bitstring + when Bitmatch.string_of_bitstring magic = "SWAPSPACE2" -> + { + fs_name = s_ "Linux swap"; + fs_block_size = 4096L; (* XXX *) + fs_blocks_total = dev#size /^ 4096L; + + (* The remaining fields are ignored when fs_is_swap is true. *) + fs_is_swap = true; + fs_blocks_reserved = 0L; + fs_blocks_avail = 0L; + fs_blocks_used = 0L; + fs_inodes_total = 0L; + fs_inodes_reserved = 0L; + fs_inodes_avail = 0L; + fs_inodes_used = 0L; + } + | _ -> + raise Not_found (* Not Linux swapspace. *) (* Register with main code. *) -let () = - Virt_df.fs_register - [ 0x82 ] (* Partition type. *) - probe_swap +let () = filesystem_type_register "linux_swap" probe_swap -- cgit From 0019c13c600d34f12778e849246711bb20ba4ee2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 15 Apr 2008 11:26:46 +0100 Subject: Don't need the ': device' typecasts any more. --- virt-df/virt_df_linux_swap.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'virt-df/virt_df_linux_swap.ml') diff --git a/virt-df/virt_df_linux_swap.ml b/virt-df/virt_df_linux_swap.ml index ad56149..afd671f 100644 --- a/virt-df/virt_df_linux_swap.ml +++ b/virt-df/virt_df_linux_swap.ml @@ -23,7 +23,7 @@ open Virt_df_gettext.Gettext open Virt_df -let probe_swap (dev : device) = +let probe_swap dev = (* Load the "superblock" (ie. first 0x1000 bytes). *) let bits = dev#read_bitstring 0L 0x1000 in -- cgit From 02f1c03c9f81e25353aae4900ce19e194b507f71 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 16 Apr 2008 13:51:14 +0100 Subject: Removed virt-ctrl, virt-df, ocaml-libvirt - now in separate repositories. --- virt-df/virt_df_linux_swap.ml | 54 ------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 virt-df/virt_df_linux_swap.ml (limited to 'virt-df/virt_df_linux_swap.ml') diff --git a/virt-df/virt_df_linux_swap.ml b/virt-df/virt_df_linux_swap.ml deleted file mode 100644 index afd671f..0000000 --- a/virt-df/virt_df_linux_swap.ml +++ /dev/null @@ -1,54 +0,0 @@ -(* 'df' command for virtual domains. - - (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc. - http://libvirt.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - Support for Linux swap partitions. -*) - -open Virt_df_gettext.Gettext -open Virt_df - -let probe_swap dev = - (* Load the "superblock" (ie. first 0x1000 bytes). *) - let bits = dev#read_bitstring 0L 0x1000 in - - bitmatch bits with - (* Actually this isn't just padding. *) - | padding : 8*0x1000 - 10*8 : bitstring; - magic : 10*8 : bitstring - when Bitmatch.string_of_bitstring magic = "SWAPSPACE2" -> - { - fs_name = s_ "Linux swap"; - fs_block_size = 4096L; (* XXX *) - fs_blocks_total = dev#size /^ 4096L; - - (* The remaining fields are ignored when fs_is_swap is true. *) - fs_is_swap = true; - fs_blocks_reserved = 0L; - fs_blocks_avail = 0L; - fs_blocks_used = 0L; - fs_inodes_total = 0L; - fs_inodes_reserved = 0L; - fs_inodes_avail = 0L; - fs_inodes_used = 0L; - } - | _ -> - raise Not_found (* Not Linux swapspace. *) - -(* Register with main code. *) -let () = filesystem_type_register "linux_swap" probe_swap -- cgit