File tree Expand file tree Collapse file tree 5 files changed +12
-13
lines changed
Expand file tree Collapse file tree 5 files changed +12
-13
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 @@ -304,13 +304,11 @@ let read_raw ~__context ~vdi =
304304type nbd_connect_info = {path : string ; exportname : string } [@@ deriving rpc ]
305305
306306let get_device_numbers path =
307- let rdev = (Unix.LargeFile. stat path).Unix.LargeFile. st_rdev in
308- let major = rdev / 256 and minor = rdev mod 256 in
309- (major, minor)
307+ Unix.LargeFile. ((stat path).st_rdev) |> Unixext.Stat. decode_st_dev
310308
311309let is_nbd_device path =
312310 let nbd_device_num = 43 in
313- let major, _ = get_device_numbers path in
311+ let Unixext.Stat. { major; _} = get_device_numbers path in
314312 major = nbd_device_num
315313
316314let get_nbd_device path =
@@ -365,8 +363,7 @@ let find_backend_device path =
365363 let open Ezxenstore_core.Xenstore in
366364 (* If we're looking at a xen frontend device, see if the backend
367365 is in the same domain. If so check if it looks like a .vhd *)
368- let rdev = (Unix. stat path).Unix. st_rdev in
369- let major = rdev / 256 and minor = rdev mod 256 in
366+ let Unixext.Stat. {major; minor} = get_device_numbers path in
370367 let link =
371368 Unix. readlink (Printf. sprintf " /sys/dev/block/%d:%d/device" major minor)
372369 in
You can’t perform that action at this time.
0 commit comments