Posts

Plan 9: Emoji

Image
  Noto Emoji Font Note:  Noto Color emoji needs Color Bitmap Data (CBDT) support.   Four independent bugs, spanning truetypefs.c , hint.c , and head.c : 1. assert(gs[i] != nil) crash in compilesub ( truetypefs.c ) ttffindchar returning glyph 0 for a rune inside a declared cmap segment (a genuine gap, not just the NUL special-case) skipped the retry-via-notdef path entirely. If the font's own .notdef then also failed to rasterize, the assert took the whole fileserver down. Fixed by replacing the assert with a synthesized blank placeholder as the last resort in the fallback chain. 2. No bounds checking on glyph geometry before blit() ( truetypefs.c ) blit() has zero validation of its own; compilesub sized the destination strip from the font's declared ascentpx + descentpx but never checked that an individual glyph's actual rendered width/height/vertical position fit inside that buffer. A decorative font ( architectsdaughter ) reporting ink extents past its dec...

Plan 9: Dynamic HTML

Image
  Render Dynamic HTML using plot and qjs. Render a simple website   Font zoom   E-Book Reader eBook is a collection of HTML files in a ZIP archive. Follow same steps for Comic Book reader which are collection of JPG/PNG images in a ZIP/RAR archive. For columns, pure HTML solution involves column-count CSS property. However, this works only for designed screen sizes. For non-standard sizes, the first column might span multiple pages before continuing in the second column. Hence, the page mode manages the split without relying on the column-count.   Keymap t                          Table of Content -/=                     Font zoom 1,2,3                  Column s                         Toggle scroll/page mode  ...

Plan 9 Plumber

Image
Plumb Zip file   View files inside a zip compressed file via Plumber without extraction. Zip file contents are accessible at /n/tapefs. (Note: sam displays the UTF Byte-Order-Mark (BOM) as is - the garbage in the beginning of the first line). #zip file content in a new window type    is    text data    matches    '([a-zA-Z¡-ï¿¿0-9_\-.,/]+)\.zip' arg    isfile    $0 plumb    start    window fs/zipfs $file; cd /n/tapefs; ls; rc   Plumber process, usually running in the parent process, does not have visibility into the folders mounted by the child process because of namespace isolation. Hence, you need the following changes: zipfs (or 32vfs, cpiofs, tapfs, tarfs, tpfs, v6fs, v10fs etc.) must expose a service in the /srv directory. ( fs.c ) plumber must mount the zipfs for paths starting with /n/tapefs before checking for file existence. ( match.c )   

Plan 9: Tiled Map

Image
  Use plot(1) to display tiled maps. The zoom factor decides the grid dimension. osm.js: Download tile images from OpenStreetMaps using hget. Cache the images. Convert the PNG image into Plan 9 format using png. Display the images using plot. Plot script   ra 0 0 200 200 m 0 100 im /file :Note - must end the script with a newline     Plot tries to center the drawing. Hence the origin is at the bottom with a slight offset from the left. However, image uses origin at the top left.     Interactive Plotting and Maps Use plot command in server mode (-s option). plot -s a.plt  mount /srv/plot /mnt/plot echo li 0 0 100 100 > /mnt/plot/ctl echo erase > /mnt/plot/ctl Usage as an interactive map.   OSM API Tiles https://tile.openstreetmap.org/zoom/x/y.png   The World map at zoom 0 https://tile.openstreetmap.org/0/0/0.png     Geocoding (Name to geographical co-ordinates) https://nominatim.openstreetmap.org/search?q=hebba...

Browser in Javascript

Image
  A Proof-of-Concept Browser written in Javascript for minimal Web 2.0 browsing experience. This DOES NOT depend on any browser engine like Blink, Gecko or Webkit. Use an existing HTML rendering engine like netsurf or roll-out your own . This uses QuickJS-ng for JS runtime, Linkedom for DOM API and curl for network downloads. Font decoration uses Terminal ANSI escape codes . Since linkedom is an npm module, it needs to be converted to ES6 module for use with quickjs.  sudo apt install npm  npm install linkedom npx esbuild node_modules/linkedom/esm/index.js \     --bundle \     --format=esm \     --outfile= linkedom.bundle.js \     --platform=neutral \     -- main-fields = module,main           Code https://gitlab.com/atamariya/quickjs/-/blob/dev/ldom.js https://gitlab.com/atamariya/quickjs/-/blob/dev/net.js https://gitlab.com/atamariya/quickjs/-/blob/dev/render.js   Lessons Learnt st...

Plan 9: Network Printer (HP Deskjet Ink Advantage 3545)

Image
Internet Printing Protocol Printing with  Internet Printing Protocol (IPP)  involves sending a Unirast   Format (URF) image with appropriate protocol headers to port 631. It is the basis for standards like  Windows Mopria Alliance , Apple   AirPrint , and IPP Everywhere .  It is also called  Driverless Printing   since this doesn't involve installing any printer specific driver. On Plan 9, printing involves three steps: Convert the document to PDF using lp Convert the PDF to URF using  gs  (use urfgray, urfrgb or urfcmyk device) Send the request to the printer using hget IPP header ( req.bin in the below script) contains page output options like paper size, margins etc. This is generated   using ippenc.c .        #!/bin/rc HOST=$1 FILE=$2 TFILE=/tmp/a.pdf URL=( http://$HOST:631/ipp/print/ ) if (! ~ $#* 2)    echo 'Usage: $0 <printer-ip> <file>'     lp -d stdout $FILE > $TFILE...

Plan 9: Audio-Video Pipeline

Image
Video pipeline in action Two important points about videos: A video is a series of images. RGB format is used for display. YUV format is used for storage and transmission.  Recording   ──────────────────────────────────────────────────────── [Video Source] → [Frame Processing] → [Video Encode] ┐                                                                                                      ├→ [Mux] → [Container Stream] [Audio Source] → [Audio Processing] → [Audio Encode] ┘ Playback   ──────────────────────────────────────────────────────── [Container Stream] → [Demux] → [Video Decode] → [Video Sink]                                   ...

Plan 9: Real Time Streaming

Image
Stream a single window or the whole screen via Real Time Streaming Protocol (RTSP). This uses MJPEG stream over TCP-interleave . Plan 9 /dev/screen and /dev/window produces RGBA byte stream with Plan 9 headers. This is converted to JPEG using tojpg and streamed using RTSP. In the video, host port 12554 port is being forwarded to 554 in the Plan 9 VM.  ffplay -rtsp_transport tcp rtsp://localhost:12554/ stream1       Code https://gitlab.com/atamariya/plan9front/-/blob/dev/sys/src/cmd/rtsp/server.c https://gitlab.com/atamariya/plan9front/-/blob/dev/sys/src/cmd/jpg/tojpg.c https://gitlab.com/atamariya/plan9front/-/blob/dev/sys/src/cmd/jpg/writejpg.c ( Update 16/03/2026 : server.c is moved to /sys/src/cmd/stream/rtsp/)   Youtube Live Use Real-Time Messaging Protocol ( RTMP ) to feed into Youtube / Twitch Live. video/hj264 -f 25 /dev/screen | video/rtmp -a /dev/audio rtmp://.... rtmp://...         Note:   The encoder and the publisher pr...

Plan 9: WiFi Protected Setup

Image
  Demo of Wifi router connection using WiFi Protected Setup (WPS). WiFi Protected Setup (WPS) allows you to connect to an Access Point (router) via Push Button Control (PBC) or a temporary PIN.   Authentication Flow   Direction Message / Contents Phase / Purpose Supplicant → AP Authentication Request 802.11 Authentication Supplicant ← AP Authentication Response Supplicant → AP Association Request 802.11 Association Supplicant ← AP Association Response Supplicant → AP EAPOL-Start EAP Initiation Supplicant ← AP EAP-Request Identity Supplicant → AP EAP-Response Identity (Identity: “WFA-SimpleConfig-Registrar-1-0”) Supplicant ← AP WSC Start Enrollee → Registrar (M1) N1 || Descripti...

Plan 9: Share Media Content with TV via UPnP

Image
  Share media content with UPnP / DLNA capable players. This is a proof-of-concept of network programming  (TCP and UDP)  in Plan 9. For information, man udp is a useful place to get started.   Device Quirks VLC VLC looks for "urn:schemas-upnp-org:service:ContentDirectory:1" instead of "urn:schemas-upnp-org:device:MediaServer:1" during M-SEARCH.   LG WebOS TV   LG WebOS TV needs the services "urn:schemas-upnp-org:service:ConnectionManager:1" and "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1" in addition to "urn:schemas-upnp-org:service:ContentDirectory:1" in device.xml.   It also seems to remember the UUIDs for a particular IP address. If you change the UUID of our application and it doesn't appear in the TV, restarting the TV might help.  Code https://gitlab.com/atamariya/plan9front/-/blob/dev/sys/src/cmd/upnp/server.c  

Plan 9: Password Management

Image
 An authentication server manages users credentials in a Plan 9 grid. However, if you are just getting started, probably it would be a better idea to directly use factotum for managing credentials for various services. Create a file keys  with the following content.  key proto=pass        service= ftp server=10.0.2.2 user=anand !password=<password> key proto= wpapsk service= wpa essid=Tomato24 !password=<password>   Load the keys in factotum.  read -m keys > /mnt/factotum/ctl   # Verify cat  /mnt/factotum/ctl   Now you can log into the services without manually entering the password. ftpfs 10.0.2.2 aux/wpa -s Tomato24 /net/ether1  Finally, you can add the command to $home/lib/profile so that it will be executed automatically during bootup. If you have the authentication server configured, you can use the following commands to manage your credentials. (Secstore files are stored at "/adm/secstore/use...

Plan 9: Intel Wireless 3165

Intel Wireless 3165 internal PCI card works with Plan 9. You'll need firmware blob /lib/firmware/ iwlwifi-7265D-29 .ucode from Linux as /lib/firmware/ iwlwifi-7265D-29  in Plan 9. Detect hardware on Linux  lspci -nn 02:00.0 Network controller [0280]: Intel Corporation Wireless 3165 [ 8086:3165 ] (rev 81)      # slot_info=0000:02:00.0 # vendor_id=8086 # device_code=3165   Detect firmware on Linux  sudo dmesg | grep -i iwlwifi | grep -i firmware [    6.062085] iwlwifi 0000:02:00.0: loaded firmware version 29.f2390aa8.0 7265D-29.ucode op_mode iwlmvm Apply the following patch to etheriwl.c and rebuild kernel (cd  /sys/src/9/pc64 && mk install). The kernel should be copied to /n/9fat (9fat partition - use 9fs 9fat ) . @@ -4509,6 +4512,10 @@ iwlpci(void)              family = 9000;              fwname = "iwm-9260-34";           ...

Plan 9: Quick Boot with UEFI

Image
 UEFI ( Unified Extensible Firmware Interface) provides a quick way to set up a Plan 9 terminal  on modern hardware .  EFI System Partition (ESP) is a FAT32 partition. You should be able to modify it in most of the operating systems.     Run mk in /sys/src/boot/efi . aux/aout2efi converts an a.out file to an EFI executable.  For x86_64 hardware,  copy over the files bootx64.efi (EFI application) , 9pc64 (kernel) , plan9.ini  (configuration file) to \EFI\plan9\ directory in the ESP. If you want it be the default OS , you can create a symlink \EFI\boot to \EFI\plan9. Remember to include the full path to the kernel in plan9.ini. ( Note:  ESP is a FAT32 partition. Hence you must use backward slashes.) bootfile=\EFI\plan9\9pc64       When bootx64.efi fails to find the bootfile (e.g. kernel is missing, plan9.ini is missing or path is incorrect), you can provide the arguments at > prompt   followed by a boot command . Y...

Lisp on Plan 9

Image
  Compile and run Tinylisp in under 2 minutes on Plan 9 ( 9front ). Both are modified versions.   Code https://gitlab.com/atamariya/tinylisp (plan9 branch) https://gitlab.com/atamariya/plan9front (dev branch)    

Plan 9 : The Infinity Notebook

Image
  Plan 9 is an Operating System (OS) from Bell Labs which is a successor to UNIX. It builds on the learnings from the previous Operating systems. Network computing and graphics is an integral part of the OS rather than an afterthought. It is modular and portable - it comes with a cross compiler . It is available, under MIT License , which anybody can use, learn and tweak. Features Everything is a file. Small Kernel:  Around 5MB size which can be built in under 2 minutes.  Singular Grid: All the computers running Plan 9 OS and connected together act like a singular grid. So there's no need for remote access solutions like VNC or RDP. This cool video shows a small glimpse of the possibilities. Process Isolation: Processes run within their own namespaces and are isolated from each other. So you can run rio (the window manager) within rio. Applications like Browsers don't need complicated sandboxing. And a crashing program is unlikely to bring down the OS. No DLL Hell : ...