[pve-devel] applied: [PATCH common 1/1] tools: add dev_t_major/minor

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Feb 4 11:42:00 CET 2019


Am 2/4/19 um 10:42 AM schrieb Wolfgang Bumiller:
> Extract major/minor from `dev_t` values as found in stat()
> calls, with support for the full 32 bit values.
> 
> The device value returned by stat() is 32 bits long and encoded as
> high 12 bit of the minor value as in the 12 MSBs, 12 bit major value,
> then the low 8 bit of the minor value in the low byte.

applied, thanks!

> 
> Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
>  src/PVE/Tools.pm | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> index cd236b5..189b552 100644
> --- a/src/PVE/Tools.pm
> +++ b/src/PVE/Tools.pm
> @@ -1632,4 +1632,16 @@ sub get_host_arch {
>      }
>  }
>  
> +# Devices are: [ (12 bits minor) (12 bits major) (8 bits minor) ]
> +sub dev_t_major($) {
> +    my ($dev_t) = @_;
> +    return (int($dev_t) & 0xfff00) >> 8;
> +}
> +
> +sub dev_t_minor($) {
> +    my ($dev_t) = @_;
> +    $dev_t = int($dev_t);
> +    return (($dev_t >> 12) & 0xfff00) | ($dev_t & 0xff);
> +}
> +
>  1;
> 





More information about the pve-devel mailing list