fuchsia

cat-like functionality under Fuchsia OS command line


In the first command the > has the output of the ls command go to /data/result.txt. In the second command you see that size of the file is 229.

$ ls > /data/result.txt
$ ls /data/result.txt
-      229 /data/result.txt

Using the Fuchsia OS emulator there are a number of programs that are on the target system. See the reformatted list. ls gives a directory listing. hw is a modified version of hello_world_cpp. From the collection of programs on the system, is there one that can be used to display the contents of /data/result.txt?

$ ls /boot/bin                            -  1   286720 hid                      -  1    76176 ps
d  2        0 .                           -  1   201328 hw                       -  1   290832 ptysvc                                                                                                                             
-  1   221184 app                         -  1    53248 i2c                      -  1    70768 pwrbtn-monitor                                                                                                                             
-  1   314616 audio                       -  1   162024 i2cutil                  -  1   270272 run-vc                                                                                                                             
-  1   192024 backlight                   -  1   376848 ihda                     -  1  1142800 runtests                                                                                                                             
-  1    90128 biotime                     -  1  2871312 install-disk-image       -  1  3035736 rust_test_adapter                                                                                                                             
-  1     8280 blktest                     -  1  2035712 iochk                    -  1   320896 sdio                                                                                                                             
-  1  5353744 blobfs                      -  1  2012496 iotime                   -  1   212856 serial-test                                                                                                                                                     
-  1   331792 bootsvc                     -  1  1433896 isolated_devmgr          -  1   188840 sh                                                                                                                                                     
-  1    49984 clkctl                      -  1    16888 kcounter                 -  1    63800 signal                                                                                                                                                     
-  1    50208 clock                       -  1    63784 kill                     -  1     8264 spawn                                                                                                                                                     
-  1   892976 cmd                         -  1    65536 killall                  -  1   114192 spiutil                                                                                                                                                     
-  1  2681408 component_manager           -  1    45316 kilo                     -  1  2033040 storage-metrics                                                                                                                                                     
-  1   286736 console                     -  1    69632 kstats                   -  1   335912 svchost                                                                                                                                                                                     
-  1   880792 cpuctl                      -  1    53248 kstress                  -  1     8328 syscall-check                                                                                                                                                                                     
-  1    12624 crasher                     -  1    61456 ktrace                   -  1   278544 sysinfo                                                                                                                                                                                     
-  1   228240 dd                          -  1    16400 loadgen                  -  1  1315208 sysmem_connector                                                                                                                                                                                     
-  1   290832 ddk-schedule-work-perf      -  1  1220608 lsblk                    -  1     8280 tee-test                                                                                                                                                                                                                                  
-  1   274448 device-name-provider        -  1   842704 lsdev                    -  1    70368 thermal-cli                                                                                                                                                                                                                                  
-  1   217120 df                          -  1    55280 lspwr                    -  1    77824 threads                                                                                                                                                                                                                                  
-  1  2469904 disk-inspect                -  1    76512 lsusb                    -  1    73760 top                                                                                                                                                                                                                                  
-  1   880672 display-test                -  1   172400 lz4                      -  1    81920 trace-benchmark
-  1    63776 dlog                        -  1    82112 memgraph                 -  1    90112 trace-example
-  1  2908472 driver_host                 -  1  2494704 minfs                    -  1   131072 umount
-  1  4038384 driver_manager              -  1   565264 miscsvc                  -  1   842688 unbind
-  1   867040 driverctl                   -  1   132144 mkfs                     -  1   875448 usb-fwloader
-  1     8288 driverinfo                  -  1    21120 mkfs-msdosfs             -  1   258120 usbctl
-  1   131968 fsck                        -  1   135424 mount                    -  1  2581032 virtual-console
-  1    36864 fsck-msdosfs                -  1   126976 mutex_pi_exerciser       -  1    67928 vmaps
-  1   684048 fshost                      -  1   113432 nand-loader              -  1    72032 vmos
-  1  2052112 fvm-check                   -  1   909312 nand-util                -  1   917504 waitfor
-  1    98304 gpt                         -  1   210008 netsvc                   -  1     8264 watch
-  1    74016 handles                     -  1    16624 ping                     -  1    45568 xdc-test
-  1   149728 hello_world_rust

Solution

  • The cat program is provided by the //third_party/sbase:cat target.

    The bringup product creates a minimal image that does not include this target (list of products here). To use cat in the bringup product:

    For the other products from core upwards, the //bundles:tools target, and thus cat is included in the package universe by default, as can be seen in the declaration of core (link). Thus, it will be pulled on demand, as described here.