[libvirt-php][PATCH 12/14] examples: Better translate volume perms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 examples/libvirt.php | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/examples/libvirt.php b/examples/libvirt.php
index c30f06a..96aac6e 100644
--- a/examples/libvirt.php
+++ b/examples/libvirt.php
@@ -502,12 +502,13 @@ class Libvirt {
     }
 
     function translate_perms($mode) {
-        $mode = (string)((int)$mode);
+        $mode = (int)$mode;
 
         $tmp = '---------';
 
-        for ($i = 0; $i < 3; $i++) {
-            $bits = (int)$mode[$i];
+        for ($i = 2; $i >=0 ; $i--) {
+            $bits = $mode % 10;
+            $mode /= 10;
             if ($bits & 4)
                 $tmp[ ($i * 3) ] = 'r';
             if ($bits & 2)
-- 
2.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]