File tree Expand file tree Collapse file tree 6 files changed +13
-12
lines changed
Expand file tree Collapse file tree 6 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -529,9 +529,9 @@ exception Not_a_device
529529
530530let of_device ctx path =
531531 let stat = Unix. stat path in
532+ let module Stat = Unixext. Stat in
532533 if stat.Unix. st_kind <> Unix. S_BLK then raise Not_a_device ;
533- let major = stat.Unix. st_rdev / 256 in
534- let minor = stat.Unix. st_rdev mod 256 in
534+ let Stat. {major; minor} = Stat. decode_st_dev stat.Unix. st_rdev in
535535 if driver_of_major major <> " tapdev" then raise Not_blktap ;
536536 match List. filter (fun (tapdev , _ , _ ) -> tapdev.minor = minor) (list ctx) with
537537 | [t] ->
Original file line number Diff line number Diff line change 1919 vhd-format-lwt
2020 xapi-idl
2121 xapi-log
22+ xapi-stdext-unix
2223 xenstore_transport.unix
2324 ezxenstore
2425 )
Original file line number Diff line number Diff line change @@ -213,10 +213,11 @@ let after f g =
213213let find_backend_device path =
214214 try
215215 let open Ezxenstore_core.Xenstore in
216+ let module Stat = Xapi_stdext_unix.Unixext. Stat in
216217 (* If we're looking at a xen frontend device, see if the backend
217218 is in the same domain. If so check if it looks like a .vhd *)
218219 let rdev = (Unix.LargeFile. stat path).Unix.LargeFile. st_rdev in
219- let major = rdev / 256 and minor = rdev mod 256 in
220+ let Stat. { major; minor} = Stat. decode_st_dev rdev in
220221 let link =
221222 Unix. readlink (Printf. sprintf " /sys/dev/block/%d:%d/device" major minor)
222223 in
Original file line number Diff line number Diff line change 1+ module Stat = Xapi_stdext_unix.Unixext. Stat
2+
13let get_device_numbers path =
2- let rdev = (Unix.LargeFile. stat path).Unix.LargeFile. st_rdev in
3- let major = rdev / 256 and minor = rdev mod 256 in
4- (major, minor)
4+ Unix.LargeFile. ((stat path).st_rdev) |> Stat. decode_st_dev
55
66let is_nbd_device path =
77 let nbd_device_num = 43 in
8- let major, _ = get_device_numbers path in
8+ let Stat. { major; _} = get_device_numbers path in
99 major = nbd_device_num
1010
1111type t = [`Vhd of string | `Raw of string | `Nbd of string * string ]
Original file line number Diff line number Diff line change @@ -132,13 +132,11 @@ let write_block ~__context filename buffer ofd len =
132132 raise e
133133
134134let get_device_numbers path =
135- let rdev = (Unix.LargeFile. stat path).Unix.LargeFile. st_rdev in
136- let major = rdev / 256 and minor = rdev mod 256 in
137- (major, minor)
135+ Unix.LargeFile. ((stat path).st_rdev) |> Unixext.Stat. decode_st_dev
138136
139137let is_nbd_device path =
140138 let nbd_device_num = 43 in
141- let major, _ = get_device_numbers path in
139+ let Unixext.Stat. { major; _} = get_device_numbers path in
142140 major = nbd_device_num
143141
144142type nbd_connect_info = {path : string ; exportname : string } [@@ deriving rpc ]
Original file line number Diff line number Diff line change @@ -118,10 +118,11 @@ let receive progress_cb format protocol (s : Unix.file_descr)
118118let find_backend_device path =
119119 try
120120 let open Ezxenstore_core.Xenstore in
121+ let module Stat = Xapi_stdext_unix.Unixext. Stat in
121122 (* If we're looking at a xen frontend device, see if the backend
122123 is in the same domain. If so check if it looks like a .vhd *)
123124 let rdev = (Unix. stat path).Unix. st_rdev in
124- let major = rdev / 256 and minor = rdev mod 256 in
125+ let Stat. { major; minor} = Stat. decode_st_dev rdev in
125126 let link =
126127 Unix. readlink (Printf. sprintf " /sys/dev/block/%d:%d/device" major minor)
127128 in
You can’t perform that action at this time.
0 commit comments