OSDN Git Service

cmfm: this is TOYBOX
authorGianmarco Reverberi <gianmarco.reverberi@gmail.com>
Tue, 17 Nov 2015 04:45:45 +0000 (22:45 -0600)
committerRaj Yengisetty <raj@cyngn.com>
Fri, 18 Dec 2015 02:56:08 +0000 (18:56 -0800)
* busybox is deprecated
* remove awk usage
* fix file system info

Change-Id: I7c2bcbd5024e3be283c9fd6ad699183b6fb5bf1a

res/values/overlay.xml
res/xml/command_list.xml
src/com/cyanogenmod/filemanager/util/ParseHelper.java

index 6b624ad..d5a4807 100644 (file)
         /system/bin/cat,
         /system/bin/chmod,
         /system/bin/chown,
+        /system/bin/cp,
+        /system/bin/cut,
         /system/bin/dd,
         /system/bin/df,
+        /system/bin/dirname,
+        /system/bin/echo,
+        /system/bin/find,
+        /system/bin/grep,
+        /system/bin/groups,
         /system/bin/gzip,
         /system/bin/id,
         /system/bin/kill,
         /system/bin/ln,
         /system/bin/ls,
+        /system/bin/md5sum,
         /system/bin/mkdir,
         /system/bin/mount,
         /system/bin/mv,
         /system/bin/ps,
+        /system/bin/pwd,
+        /system/bin/readlink,
         /system/bin/rm,
         /system/bin/sh,
-        /system/xbin/awk,
-        /system/xbin/bunzip2,
-        /system/xbin/busybox,
+        /system/bin/sha1sum,
+        /system/bin/stat,
+        /system/bin/tar,
+        /system/bin/toybox,
+        /system/bin/xargs,
         /system/xbin/bzip2,
-        /system/xbin/cp,
-        /system/xbin/cut,
-        /system/xbin/dirname,
-        /system/xbin/echo,
-        /system/xbin/find,
-        /system/xbin/grep,
-        /system/xbin/groups,
-        /system/xbin/gunzip,
-        /system/xbin/pwd,
-        /system/xbin/readlink,
-        /system/xbin/stat,
-        /system/xbin/tar,
-        /system/xbin/xargs,
-        /system/xbin/md5sum,
-        /system/xbin/sha1sum
+        /system/xbin/gunzip
     </string>
 
     <!-- The root command -->
index 874fd31..6b399a4 100644 (file)
 -->
 <CommandList xmlns="http://schemas.android.com/apk/res/com.cyanogenmod.filemanager">
   <!-- Start code (append to commands; for retrieve the exit code) -->
-  <startcode commandId="startcode" commandPath="/system/xbin/echo -n %1$s0%2$s ; " />
+  <startcode commandId="startcode" commandPath="/system/bin/echo -n %1$s0%2$s ; " />
   <!-- Exit code (append to commands; for retrieve the exit code) -->
-  <exitcode commandId="exitcode" commandPath=" ; /system/xbin/echo -n %1$s$?%2$s" />
+  <exitcode commandId="exitcode" commandPath=" ; /system/bin/echo -n %1$s$?%2$s" />
 
   <!-- Shell commands -->
   <command commandId="bash" commandPath="/system/bin/sh" commandArgs="" />
   <command commandId="su" commandPath="/system/xbin/su" commandArgs="" />
 
   <!-- Console info -->
-  <command commandId="groups" commandPath="/system/xbin/groups" commandArgs="" />
+  <command commandId="groups" commandPath="/system/bin/groups" commandArgs="" />
   <command commandId="id" commandPath="/system/bin/id" commandArgs="" />
 
   <!-- FileSystem -->
   <command commandId="mountpointinfo" commandPath="/system/bin/mount" commandArgs="" />
 
   <!-- List/Find/Info -->
-  <command commandId="ls" commandPath="/system/bin/ls" commandArgs="%1$s 1&gt; /dev/null &amp;&amp; /system/xbin/stat -t %1$s.* %1$s* 2&gt; /dev/null" />
-  <command commandId="fileinfo" commandPath="/system/xbin/stat" commandArgs="-t %1$s" />
-  <command commandId="find" commandPath="/system/xbin/find" commandArgs="%1$s \\( -name %2$s -o -name %3$s -o -name %4$s -o -name %5$s -o -name %6$s \\) -exec /system/xbin/stat -t {} 2&gt;&amp;1 \\;" />
-  <command commandId="quickfoldersearch" commandPath="/system/bin/ls" commandArgs="-aFd %1$s.* %1$s* 2&gt; /dev/null | /system/xbin/grep -e '^d' -e '^ld' | /system/xbin/cut -d&quot; &quot; -f2-" />
-  <command commandId="readlink" commandPath="/system/bin/ls" commandArgs="%1$s 1&gt; /dev/null &amp;&amp; /system/xbin/stat -tL %1$s 2&gt;&amp;1" />
+  <command commandId="ls" commandPath="/system/bin/ls" commandArgs="%1$s 1&gt; /dev/null &amp;&amp; /system/bin/stat -t %1$s.* %1$s* 2&gt; /dev/null" />
+  <command commandId="fileinfo" commandPath="/system/bin/stat" commandArgs="-t %1$s" />
+  <command commandId="find" commandPath="/system/bin/find" commandArgs="%1$s \\( -name %2$s -o -name %3$s -o -name %4$s -o -name %5$s -o -name %6$s \\) -exec /system/bin/stat -t {} 2&gt;&amp;1 \\;" />
+  <command commandId="quickfoldersearch" commandPath="/system/bin/ls" commandArgs="-aFd %1$s.* %1$s* 2&gt; /dev/null | /system/bin/grep -e '^d' -e '^ld' | /system/bin/cut -d&quot; &quot; -f2-" />
+  <command commandId="readlink" commandPath="/system/bin/ls" commandArgs="%1$s 1&gt; /dev/null &amp;&amp; /system/bin/stat -t -L %1$s 2&gt;&amp;1" />
 
   <!-- Operational -->
   <command commandId="chmod" commandPath="/system/bin/chmod" commandArgs="%1$s %2$s" />
   <command commandId="chown" commandPath="/system/bin/chown" commandArgs="%1$s.%2$s %3$s" />
-  <command commandId="cp" commandPath="/system/xbin/cp" commandArgs="-af %1$s %2$s" />
+  <command commandId="cp" commandPath="/system/bin/cp" commandArgs="-af %1$s %2$s" />
   <command commandId="link" commandPath="/system/bin/ln" commandArgs="-s %1$s %2$s" />
   <command commandId="mkdir" commandPath="/system/bin/mkdir" commandArgs="-p %1$s" />
-  <command commandId="mv" commandPath="/system/bin/mv" commandArgs="%1$s %2$s || ( /system/xbin/cp -af %1$s %2$s &amp;&amp; /system/bin/rm -R %1$s )" />
+  <command commandId="mv" commandPath="/system/bin/mv" commandArgs="%1$s %2$s || ( /system/bin/cp -af %1$s %2$s &amp;&amp; /system/bin/rm -R %1$s )" />
   <command commandId="rm" commandPath="/system/bin/rm" commandArgs="%1$s" />
   <command commandId="rmdir" commandPath="/system/bin/rm" commandArgs="-R %1$s" />
 
   <!-- Usage -->
-  <command commandId="diskusage" commandPath="/system/bin/df" commandArgs="%1$s" />
-  <command commandId="diskusageall" commandPath="/system/bin/df" commandArgs="" />
-  <command commandId="folderusage" commandPath="/system/xbin/busybox" commandArgs="ls -alR %1$s 2&gt; /dev/null" />
+  <command commandId="diskusage" commandPath="/system/bin/df" commandArgs="-h %1$s" />
+  <command commandId="diskusageall" commandPath="/system/bin/df" commandArgs="-h" />
+  <command commandId="folderusage" commandPath="/system/bin/ls" commandArgs="-alR %1$s 2&gt; /dev/null" />
 
   <!-- I/O -->
   <command commandId="read" commandPath="/system/bin/cat" commandArgs="%1$s" />
-  <command commandId="touch" commandPath="/system/xbin/echo" commandArgs="-n '' >> %1$s" />
+  <command commandId="touch" commandPath="/system/bin/echo" commandArgs="-n '' >> %1$s" />
   <command commandId="write" commandPath="/system/bin/dd" commandArgs="bs=4k of=%1$s" />
 
   <!-- Run -->
   <command commandId="exec" commandPath="/system/bin/sh" commandArgs="%1$s" />
 
   <!-- Misc -->
-  <command commandId="dirname" commandPath="/system/xbin/dirname" commandArgs="%1$s" />
-  <command commandId="echo" commandPath="/system/xbin/echo" commandArgs="%1$s" />
-  <command commandId="checksum" commandPath="/system/xbin/md5sum" commandArgs="%1$s &amp;&amp; /system/xbin/sha1sum %1$s" />
+  <command commandId="dirname" commandPath="/system/bin/dirname" commandArgs="%1$s" />
+  <command commandId="echo" commandPath="/system/bin/echo" commandArgs="%1$s" />
+  <command commandId="checksum" commandPath="/system/bin/md5sum" commandArgs="%1$s &amp;&amp; /system/bin/sha1sum %1$s" />
 
   <!-- Process control and info -->
-  <command commandId="pid_shell" commandPath="/system/xbin/echo" commandArgs="$$" />
-  <command commandId="pid_shell_cmds" commandPath="/system/bin/ps" commandArgs="| /system/xbin/grep -w %1$s | /system/xbin/awk '{print $2}' | /system/xbin/grep -v -w %1$s" />
-  <command commandId="pid_cmd" commandPath="/system/bin/ps" commandArgs="| /system/xbin/grep %1$s | /system/xbin/grep -w %2$s | /system/xbin/awk '{print $2}'" />
+  <command commandId="pid_shell" commandPath="/system/bin/echo" commandArgs="$$" />
+  <command commandId="pid_shell_cmds" commandPath="/system/bin/ps" commandArgs="| /system/bin/grep -w %1$s | /system/bin/cut -c 11-16 | /system/bin/grep -v -w %1$s" />
+  <command commandId="pid_cmd" commandPath="/system/bin/ps" commandArgs="| /system/bin/grep %1$s | /system/bin/grep -w %2$s | /system/bin/cut -c 11-16" />
   <command commandId="sendsignal" commandPath="/system/bin/kill" commandArgs="-%1$s %2$s" />
   <command commandId="terminate" commandPath="/system/bin/kill" commandArgs="%1$s" />
 
   <!-- Compress -->
-  <command commandId="tar" commandPath="/system/xbin/tar" commandArgs="-C%1$s -%2$scvf %3$s [@]" />
+  <command commandId="tar" commandPath="/system/bin/tar" commandArgs="-C%1$s -%2$scvf %3$s [@]" />
   <command commandId="gzip" commandPath="/system/bin/gzip" commandArgs="%1$s" />
   <command commandId="bzip" commandPath="/system/xbin/bzip2" commandArgs="-f %1$s" />
   <command commandId="zip" commandPath="cd" commandArgs="%1$s &amp;&amp; ( /system/xbin/zip -9 -r -y %2$s [@] || cd /)" />
 
   <!-- Uncompress -->
-  <command commandId="untar" commandPath="/system/bin/mkdir" commandArgs="-p %2$s &amp;&amp; /system/xbin/tar -C %2$s -%1$sxvf %3$s" />
+  <command commandId="untar" commandPath="/system/bin/mkdir" commandArgs="-p %2$s &amp;&amp; /system/bin/tar -C %2$s -%1$sxvf %3$s" />
   <command commandId="unzip" commandPath="/system/bin/mkdir" commandArgs="-p %1$s &amp;&amp; /system/xbin/unzip -o %2$s -d %1$s" />
   <command commandId="gunzip" commandPath="/system/xbin/gunzip" commandArgs="-f %1$s" />
-  <command commandId="bunzip" commandPath="/system/xbin/bunzip2" commandArgs="-f %1$s" />
+  <command commandId="bunzip" commandPath="/system/xbin/bzip2" commandArgs="-d -f %1$s" />
   <command commandId="unlzma" commandPath="/system/xbin/unlzma" commandArgs="-f %1$s" />
   <command commandId="uncompress" commandPath="/system/xbin/uncompress" commandArgs="-f %1$s" />
   <command commandId="unxz" commandPath="/system/xbin/unxz" commandArgs="-f %1$s" />
index ada51aa..7129af5 100644 (file)
@@ -254,13 +254,14 @@ public final class ParseHelper {
      */
     public static DiskUsage toDiskUsage(final String src) throws ParseException {
 
-        // Filesystem             Size   Used   Free   Blksize
-        // /dev                   414M    48K   414M   4096
-        // /mnt/asec              414M     0K   414M   4096
-        // /mnt/secure/asec: Permission denied
+        // Filesystem            Size  Used Avail Use% Mounted on
+        // tmpfs                 1.3G   88K  1.3G   1% /dev
+        // tmpfs                 1.3G     0  1.3G   0% /mnt
+        // /dev/block/mmcblk0p14 1.2G  966M  337M  75% /system
+        // /dev/fuse              55G   18G   37G  34% /storage/emulated
 
         try {
-            final int fields = 5;
+            final int fields = 6;
 
             //Permission denied or invalid statistics
             if (src.indexOf(":") != -1) { //$NON-NLS-1$
@@ -279,7 +280,7 @@ public final class ParseHelper {
             }
 
             //Return the disk usage
-            return new DiskUsage(data[0], toBytes(data[1]), toBytes(data[2]), toBytes(data[3]));
+            return new DiskUsage(data[5], toBytes(data[1]), toBytes(data[2]), toBytes(data[3]));
 
         } catch (Exception e) {
             throw new ParseException(e.getMessage(), 0);
@@ -295,34 +296,38 @@ public final class ParseHelper {
      */
     public static MountPoint toMountPoint(final String src) throws ParseException {
 
-        // rootfs / rootfs ro,relatime 0 0
-        // tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
-        // devpts /dev/pts devpts rw,relatime,mode=600 0 0
-        // /dev/block/vold/179:25 /mnt/emmc vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000, gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1, shortname=mixed,utf8,errors=remount-ro 0 0
+        // rootfs on / type rootfs (ro,seclabel,relatime)
+        // tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,size=1460476k,nr_inodes=142719,mode=755)
+        // devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
+        // /dev/block/mmcblk0p14 on /system type ext4 (rw,seclabel,relatime,data=ordered)
 
         try {
 
             //Extract all the info
             String line = src;
-            int pos = line.lastIndexOf(" "); //$NON-NLS-1$
-            int pass = Integer.parseInt(line.substring(pos + 1));
-            line = line.substring(0, pos).trim();
-            pos = line.lastIndexOf(" "); //$NON-NLS-1$
-            int dump = Integer.parseInt(line.substring(pos + 1));
-            line = line.substring(0, pos).trim();
-            pos = line.indexOf(" "); //$NON-NLS-1$
+            // Device
+            int pos = line.indexOf(" "); //$NON-NLS-1$
             String device = line.substring(0, pos).trim();
             line = line.substring(pos).trim();
-            pos = line.lastIndexOf(" "); //$NON-NLS-1$
-            String options = line.substring(pos + 1).trim();
-            line = line.substring(0, pos).trim();
-            pos = line.lastIndexOf(" "); //$NON-NLS-1$
-            String type = line.substring(pos + 1).trim();
+            // Skip "on"
+            pos = line.indexOf(" "); //$NON-NLS-1$
+            line = line.substring(pos).trim();
+            // Mount point
+            pos = line.indexOf(" "); //$NON-NLS-1$
             String mountPoint = line.substring(0, pos).trim();
-
+            line = line.substring(pos).trim();
+            // Skip "type"
+            pos = line.indexOf(" "); //$NON-NLS-1$
+            line = line.substring(pos).trim();
+            // Type
+            pos = line.indexOf(" "); //$NON-NLS-1$
+            String type = line.substring(0, pos).trim();
+            line = line.substring(pos).trim();
+            // Options
+            String options = line.substring(1, line.length() - 1).trim();
 
             //Return the mount point
-            return new MountPoint(mountPoint, device, type, options, dump, pass, false, false);
+            return new MountPoint(mountPoint, device, type, options, /*dump*/0, /*pass*/0, false, false);
 
         } catch (Exception e) {
             throw new ParseException(e.getMessage(), 0);