2
* Copyright (C) 2006-2009 Citrix Systems Inc.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation; version 2.1 only. with the special
7
* exception on linking described in file LICENSE.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Lesser General Public License for more details.
18
(** Represents the configuration of a static (ie attached on boot) vdi *)
20
uuid: string; (* VDI.uuid *)
21
reason: string; (* describes why this disk was attached for debugging *)
22
delete_next_boot: bool; (* indicates this disk configuration will be forgotten on reboot *)
23
currently_attached: bool; (* indicates this disk is attached now in dom0 *)
24
path: string option; (* path in dom0 *)
27
(** Returns a list of vdi records, one for each VDI statically configured on this host *)
29
(* Read the filesystem structure directly *)
30
let main_dir = "/etc/xensource/static-vdis" in
31
let all = try Array.to_list (Sys.readdir main_dir) with Sys_error _ -> [] in
33
let path = Filename.concat main_dir x in
34
let uuid = Unixext.string_of_file (Filename.concat path "vdi-uuid") in
35
let reason = Unixext.string_of_file (Filename.concat path "reason") in
36
(* let bool_of_string x = String.lowercase x = "true" in *)
37
let delete_next_boot =
38
try ignore(Unix.stat (Filename.concat path "delete-next-boot")); true
40
let currently_attached =
41
try ignore(Unix.stat (Filename.concat path "disk")); true
44
try Some (Unix.readlink (Filename.concat path "disk"))
46
{ uuid = uuid; reason = reason; delete_next_boot = delete_next_boot;
47
currently_attached = currently_attached; path = path }) all