Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mcp/blob/main/src/boot.om # omega-mcp aien-dev/omega-mcp Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mcp / src / boot.om` 152 lines ยท 2659 bytes Raw Blame History 1 note omega-mcp: start-up. Resolves this executable, the pinned compiler and the data directory, 2 note checks the compiler's sha256 against the pin and the presence of /usr/bin/bwrap. 3 4 text kself "/proc/self/exe" 5 text k_omc "--omc" 6 text k_dat "--data" 7 text k_noiso "--test-only-no-isolation" 8 text kdomc "/omc" 9 text kddat "/data/" 10 11 note argeq: argument i equals t 12 fn argeq i ulong t view uchar * to bool 13 r = argread i pa 0 4096 14 if ne r long len t 15 ret false 16 end 17 for j ulong len t 18 if ne get pa j get t j 19 ret false 20 end 21 end 22 ret true 23 end 24 25 fn hexof v ulong to uchar 26 ret get khex v 27 end 28 29 note sha_fd: sha256 of everything readable from fd into bsha (globals cannot be arguments, so the 30 note digest is computed in locals and copied); gv gbinn gets the byte count; false on a read error 31 fn sha_fd fd int to bool 32 c = new uchar 104 0 33 b = new uchar 65536 0 34 o = new uchar 32 0 35 sha256_init c 36 t = ulong 0 37 for i ulong 999999 38 r = read fd b 0 65536 39 if lt r 0 40 ret false 41 end 42 if eq r 0 43 break 44 end 45 sha256_update c part b 0 ulong r 46 t = add t ulong r 47 end 48 sha256_final c o 49 for i ulong 32 50 put bsha i get o i 51 end 52 put gv gbinn t 53 ret true 54 end 55 56 note sha_file: sha256 of the compiler at omcp into bsha 57 fn sha_file to bool 58 f = fopen omcp 0 get gv gomcl ofrd 0 59 if lt f 0 60 ret false 61 end 62 ok = sha_fd int f 63 z = fclose int f 64 ret ok 65 end 66 67 note pinok: bsha equals the pinned digest 68 fn pinok to bool 69 for i ulong 32 70 b = get bsha i 71 if ne hexof ulong shr b 4 get kpin mul i 2 72 ret false 73 end 74 if ne hexof ulong and b 15 get kpin add mul i 2 1 75 ret false 76 end 77 end 78 ret true 79 end 80 81 note boot: returns 0 ready, 2 bad arguments, 3 compiler missing or not the pin, 5 sandbox tools missing 82 fn boot to int 83 put gv gnoiso 0 84 n = readlnk kself 0 len kself sx 0 4095 85 if le n 0 86 ret 2 87 end 88 put gv gsxl ulong n 89 d = ulong n 90 while gt d 0 bound 4096 91 if eq get sx sub d 1 47 92 break 93 end 94 d = sub d 1 95 end 96 for i ulong d 97 put omcp i get sx i 98 put datp i get sx i 99 end 100 for i ulong sub len kdomc 1 101 put omcp add d i get kdomc add i 1 102 end 103 put gv gomcl add d sub len kdomc 1 104 for i ulong sub len kddat 1 105 put datp add d i get kddat add i 1 106 end 107 put gv gdatl add d sub len kddat 1 108 a = ulong argcnt 109 i = ulong 1 110 while lt i a bound 64 111 if argeq i k_noiso 112 put gv gnoiso 1 113 i = add i 1 114 continue 115 end 116 if and argeq i k_omc lt add i 1 a 117 r = argread add i 1 omcp 0 4000 118 if le r 0 119 ret 2 120 end 121 if ne get omcp 0 47 122 ret 2 123 end 124 put gv gomcl ulong r 125 i = add i 2 126 continue 127 end 128 if and argeq i k_dat lt add i 1 a 129 r = argread add i 1 datp 0 3000 130 if le r 0 131 ret 2 132 end 133 put datp ulong r 47 134 put gv gdatl add ulong r 1 135 i = add i 2 136 continue 137 end 138 ret 2 139 end 140 if not sha_file 141 ret 3 142 end 143 if not pinok 144 ret 3 145 end 146 if eq get gv gnoiso 0 147 if ne faccess kbwrap 0 len kbwrap 1 0 148 ret 5 149 end 150 end 151 ret 0 152 end