omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / gpu / runtime / inventory.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/runtime/inventory.om: the inventory of CUDApp src/ against this repository, in seeded Omega (OM-2 program |
| 3 | note mode, Linux AArch64). Build from the repository root (seed/ng/sha256.om supplies sh_dat, sh_blk, sh_out; |
| 4 | note gpu/runtime/zsha.om the streaming hash): |
| 5 | note { printf 'om2\n'; cat seed/ng/sha256.om gpu/runtime/zsha.om gpu/runtime/inventory.om; } | seed/out/omc > inventory |
| 6 | note Run from the repository root: inventory [DIR] (DIR defaults to gpu/runtime) |
| 7 | note Inputs, all in DIR, made outside the tree by the commands in gpu/runtime/README.md: |
| 8 | note cudapp-src.sha256.txt sha256sum lines (64 hex, two spaces, path) of every file under CUDApp src/ |
| 9 | note omega-base.sha256.txt sha256sum lines of every file under src/ and gpu/ of this repository at the base |
| 10 | note cudapp-ident.txt every CUDApp src/*.ident record, concatenated: the Omega Bridge provenance lines |
| 11 | note pathmap.tsv FROM TAB TO: a CUDApp Omega path starting FROM lives in this tree at TO then the rest |
| 12 | note rewrites.tsv CUDAPP-PATH TAB OMEGA-PATH: a CUDApp file without an ident record rewritten in Omega here |
| 13 | note A line of pathmap.tsv or rewrites.tsv starting with # is a comment; an empty line is skipped. |
| 14 | note Output on stdout, one row per CUDApp file in list order: PATH KIND OMEGA_SRC ORIGIN OMEGA DETAIL, tab separated. |
| 15 | note KIND the file name's extension (c, h, inc, ident, ...) |
| 16 | note OMEGA_SRC identical | diverged | cudapp-only: this repository's file at the same path, from the base list; |
| 17 | note the file in the tree is hashed and must still match the base list (cudapp-only: must not exist) |
| 18 | note ORIGIN record (an .ident file) | bridge (its sha256 is the c= or h= of an ident record, so the Omega |
| 19 | note Bridge emitted it from Omega source) | unrecorded (no ident record names it: written by hand, |
| 20 | note or emitted by a CUDApp generator that writes no ident record) |
| 21 | note OMEGA bridge: same (every source part is in this tree and the parts compose to the record's src= |
| 22 | note sha256), changed (all parts here, another composition), absent (a part is not here); |
| 23 | note unrecorded: rewritten (rewrites.tsv names an Omega file that exists here), rewrite-missing, none; |
| 24 | note record: - |
| 25 | note An omega-ident record composes its parts each followed by a newline (CUDApp om/units.sh); an |
| 26 | note omega-native-ident record (parts joined by +) composes them with nothing between. |
| 27 | note Then summary lines starting with #. Exit 0, 2 bad usage, 3 an input is malformed, a tree file differs from the |
| 28 | note base list or a cudapp-only path exists in the tree (the list is stale: regenerate it), 4 the host refused memory. |
| 29 | note Every input is length-checked. |
| 30 | note Memory grows with the input (run-time pools); the one fixed buffer is a path of PATH_MAX (4096) bytes. |
| 31 | text iv_dflt "gpu/runtime" |
| 32 | text iv_fsrc "/cudapp-src.sha256.txt" |
| 33 | text iv_fbase "/omega-base.sha256.txt" |
| 34 | text iv_fid "/cudapp-ident.txt" |
| 35 | text iv_fmap "/pathmap.tsv" |
| 36 | text iv_frw "/rewrites.tsv" |
| 37 | text iv_hdr "path\tkind\tomega_src\torigin\tomega\tdetail\n" |
| 38 | text iv_kid "ident" |
| 39 | text iv_kc "c" |
| 40 | text iv_kh "h" |
| 41 | text iv_kinc "inc" |
| 42 | text iv_knat "omega-native-ident " |
| 43 | text iv_kunit "unit=" |
| 44 | text iv_ksrc "src=" |
| 45 | text iv_kpath "path=" |
| 46 | text iv_identical "identical" |
| 47 | text iv_diverged "diverged" |
| 48 | text iv_conly "cudapp-only" |
| 49 | text iv_record "record" |
| 50 | text iv_bridge "bridge" |
| 51 | text iv_unrec "unrecorded" |
| 52 | text iv_same "same" |
| 53 | text iv_changed "changed" |
| 54 | text iv_absent "absent" |
| 55 | text iv_rewritten "rewritten" |
| 56 | text iv_rwmiss "rewrite-missing" |
| 57 | text iv_none "none" |
| 58 | text iv_dash "-" |
| 59 | text iv_s_rows "# rows=" |
| 60 | text iv_s_rec " record=" |
| 61 | text iv_s_br " bridge=" |
| 62 | text iv_s_bs " bridge_same=" |
| 63 | text iv_s_bc " bridge_changed=" |
| 64 | text iv_s_ba " bridge_absent=" |
| 65 | text iv_s_hd " unrecorded=" |
| 66 | text iv_s_hr " unrecorded_rewritten=" |
| 67 | text iv_s_hm " unrecorded_rewrite_missing=" |
| 68 | text iv_s_hn " unrecorded_none=" |
| 69 | text iv_s_id "# omega_src identical=" |
| 70 | text iv_s_dv " diverged=" |
| 71 | text iv_s_co " cudapp_only=" |
| 72 | text iv_s_rem "# unrecorded_none by kind c=" |
| 73 | text iv_s_rh " h=" |
| 74 | text iv_s_ri " inc=" |
| 75 | text iv_s_ro " other=" |
| 76 | text iv_s_rd "# unrecorded_none by omega_src identical=" |
| 77 | text iv_e_usage "usage: inventory [DIR] (run from the repository root)\n" |
| 78 | text iv_e_read "inventory: cannot read " |
| 79 | text iv_e_list "inventory: malformed sha256 list line in " |
| 80 | text iv_e_tab "inventory: malformed row (FROM TAB TO) in " |
| 81 | text iv_e_drift "inventory: tree file differs from omega-base.sha256.txt (regenerate the list): " |
| 82 | text iv_e_new "inventory: tree file is not in omega-base.sha256.txt (regenerate the list): " |
| 83 | text iv_e_part "inventory: cannot read Omega source part " |
| 84 | text iv_e_mem "inventory: the host refused memory\n" |
| 85 | text iv_e_long "inventory: a path is longer than 4095 bytes\n" |
| 86 | text iv_e_rec "inventory: an ident record has no unit=, src= or path= value of the expected form\n" |
| 87 | global iv_t uchar * |
| 88 | global iv_o uchar * |
| 89 | global iv_x ulong * |
| 90 | global iv_bl ulong * |
| 91 | global iv_pa uchar 4096 |
| 92 | global iv_dir uchar 4096 |
| 93 | global iv_n ulong 64 |
| 94 | note iv_n: 0 path length, 1 dir length, 2 iv_t used, 3 iv_o used, 4..13 input ranges [s,e) of src, base, ident, |
| 95 | note pathmap, rewrites; 14 hash fill, 15 hash total; 16, 17 a token value [s,e); 18 a part is absent; |
| 96 | note 19 iv_x entries, 20 rows, 21 record, 22 bridge, 23 same, 24 changed, 25 absent, 26 unrecorded, 27 rewritten, |
| 97 | note 28 rewrite-missing, 29 unrecorded none, 30 identical, 31 diverged, 32 cudapp-only, 33..36 unrecorded none c h |
| 98 | note inc other, 37..39 unrecorded none identical diverged cudapp-only, 40 iv_bl entries, 41 parts emitted |
| 99 | const IV_NONE ulong 9223372036854775808 |
| 100 | note ---- failure |
| 101 | fn die t view uchar * code int to void |
| 102 | r = write 2 t 0 len t |
| 103 | exit code |
| 104 | end |
| 105 | note die naming the path in iv_pa |
| 106 | fn diepa t view uchar * to void |
| 107 | r = write 2 t 0 len t |
| 108 | r = write 2 iv_pa 0 get iv_n 0 |
| 109 | q = new uchar 1 10 |
| 110 | r = write 2 q 0 1 |
| 111 | exit 3 |
| 112 | end |
| 113 | note ---- output pool |
| 114 | fn oc c ulong to void |
| 115 | n = get iv_n 3 |
| 116 | if ge n len iv_o |
| 117 | r = enlarge iv_o add mul n 2 65536 |
| 118 | if ne r 0 |
| 119 | die iv_e_mem 4 |
| 120 | end |
| 121 | end |
| 122 | put iv_o n uchar c |
| 123 | put iv_n 3 add n 1 |
| 124 | end |
| 125 | fn ot t view uchar * to void |
| 126 | for i ulong len t bound 4096 |
| 127 | oc ulong get t i |
| 128 | end |
| 129 | end |
| 130 | fn otr a ulong b ulong to void |
| 131 | for i ulong sub b a bound 9223372036854775807 |
| 132 | oc ulong get iv_t add a i |
| 133 | end |
| 134 | end |
| 135 | fn opa to void |
| 136 | for i ulong get iv_n 0 bound 4096 |
| 137 | oc ulong get iv_pa i |
| 138 | end |
| 139 | end |
| 140 | fn onum v ulong to void |
| 141 | if ge v 10 |
| 142 | onum div v 10 |
| 143 | end |
| 144 | oc add 48 rem v 10 |
| 145 | end |
| 146 | fn oflush to void |
| 147 | n = get iv_n 3 |
| 148 | o = ulong 0 |
| 149 | while lt o n bound 9223372036854775807 |
| 150 | x = write 1 iv_o o sub n o |
| 151 | if le x 0 |
| 152 | exit 3 |
| 153 | end |
| 154 | o = add o ulong x |
| 155 | end |
| 156 | put iv_n 3 0 |
| 157 | end |
| 158 | note ---- paths: iv_pa[0, iv_n 0) |
| 159 | fn pclr to void |
| 160 | put iv_n 0 0 |
| 161 | end |
| 162 | fn pc c ulong to void |
| 163 | n = get iv_n 0 |
| 164 | if ge n 4095 |
| 165 | die iv_e_long 3 |
| 166 | end |
| 167 | put iv_pa n uchar c |
| 168 | put iv_n 0 add n 1 |
| 169 | end |
| 170 | fn pt t view uchar * to void |
| 171 | for i ulong len t bound 4096 |
| 172 | pc ulong get t i |
| 173 | end |
| 174 | end |
| 175 | fn ptr a ulong b ulong to void |
| 176 | for i ulong sub b a bound 9223372036854775807 |
| 177 | pc ulong get iv_t add a i |
| 178 | end |
| 179 | end |
| 180 | note DIR then a file name |
| 181 | fn pdir t view uchar * to void |
| 182 | pclr |
| 183 | for i ulong get iv_n 1 bound 4096 |
| 184 | pc ulong get iv_dir i |
| 185 | end |
| 186 | pt t |
| 187 | end |
| 188 | fn popen to int |
| 189 | r = fopen iv_pa 0 get iv_n 0 int 524288 int 0 |
| 190 | if lt r 0 |
| 191 | ret -1 |
| 192 | end |
| 193 | ret int r |
| 194 | end |
| 195 | note ---- input pool: append the file at iv_pa to iv_t; slot k gets its start, k+1 its end |
| 196 | fn tload k ulong to void |
| 197 | fd = popen |
| 198 | if lt fd 0 |
| 199 | diepa iv_e_read |
| 200 | end |
| 201 | s = get iv_n 2 |
| 202 | n = s |
| 203 | while true bound 9223372036854775807 |
| 204 | if ge add n 65536 len iv_t |
| 205 | r = enlarge iv_t add mul len iv_t 2 131072 |
| 206 | if ne r 0 |
| 207 | die iv_e_mem 4 |
| 208 | end |
| 209 | end |
| 210 | x = read fd iv_t n sub len iv_t n |
| 211 | if lt x 0 |
| 212 | diepa iv_e_read |
| 213 | end |
| 214 | if eq x 0 |
| 215 | break |
| 216 | end |
| 217 | n = add n ulong x |
| 218 | end |
| 219 | r = fclose fd |
| 220 | put iv_n 2 n |
| 221 | put iv_n k s |
| 222 | put iv_n add k 1 n |
| 223 | end |
| 224 | note ---- bytes of iv_t |
| 225 | fn eol p ulong e ulong to ulong |
| 226 | q = p |
| 227 | while lt q e bound 9223372036854775807 |
| 228 | if eq get iv_t q 10 |
| 229 | ret q |
| 230 | end |
| 231 | q = add q 1 |
| 232 | end |
| 233 | ret e |
| 234 | end |
| 235 | note first index of byte c in [p, e), or e |
| 236 | fn tfind p ulong e ulong c ulong to ulong |
| 237 | q = p |
| 238 | while lt q e bound 9223372036854775807 |
| 239 | if eq ulong get iv_t q c |
| 240 | ret q |
| 241 | end |
| 242 | q = add q 1 |
| 243 | end |
| 244 | ret e |
| 245 | end |
| 246 | fn teq a ulong b ulong n ulong to bool |
| 247 | for i ulong n bound 9223372036854775807 |
| 248 | if ne get iv_t add a i get iv_t add b i |
| 249 | ret false |
| 250 | end |
| 251 | end |
| 252 | ret true |
| 253 | end |
| 254 | note iv_t[a, a+n) equals the text t |
| 255 | fn tteq a ulong n ulong t view uchar * to bool |
| 256 | if ne n len t |
| 257 | ret false |
| 258 | end |
| 259 | for i ulong n bound 4096 |
| 260 | if ne get iv_t add a i get t i |
| 261 | ret false |
| 262 | end |
| 263 | end |
| 264 | ret true |
| 265 | end |
| 266 | note iv_t at a starts with the text t, inside [a, e) |
| 267 | fn tpre a ulong e ulong t view uchar * to bool |
| 268 | if lt sub e a len t |
| 269 | ret false |
| 270 | end |
| 271 | ret tteq a len t t |
| 272 | end |
| 273 | note iv_t[a, a+n) equals iv_pa |
| 274 | fn tpaeq a ulong n ulong to bool |
| 275 | if ne n get iv_n 0 |
| 276 | ret false |
| 277 | end |
| 278 | for i ulong n bound 4096 |
| 279 | if ne get iv_t add a i get iv_pa i |
| 280 | ret false |
| 281 | end |
| 282 | end |
| 283 | ret true |
| 284 | end |
| 285 | fn ishex c uchar to bool |
| 286 | if and ge c 48 le c 57 |
| 287 | ret true |
| 288 | end |
| 289 | ret and ge c 97 le c 102 |
| 290 | end |
| 291 | note ---- sha256sum lists: a line is 64 lowercase hex, two spaces, a path of at least one byte |
| 292 | fn lineok p ulong q ulong to bool |
| 293 | if lt sub q p 67 |
| 294 | ret false |
| 295 | end |
| 296 | for i ulong 64 |
| 297 | if not ishex get iv_t add p i |
| 298 | ret false |
| 299 | end |
| 300 | end |
| 301 | ret and eq get iv_t add p 64 32 eq get iv_t add p 65 32 |
| 302 | end |
| 303 | note check every line of list k (slots k, k+1); a list that is not newline-terminated is malformed |
| 304 | fn listok k ulong nm view uchar * to void |
| 305 | p = get iv_n k |
| 306 | e = get iv_n add k 1 |
| 307 | while lt p e bound 9223372036854775807 |
| 308 | q = eol p e |
| 309 | if or eq q e not lineok p q |
| 310 | pdir nm |
| 311 | diepa iv_e_list |
| 312 | end |
| 313 | p = add q 1 |
| 314 | end |
| 315 | end |
| 316 | note index the base list: iv_bl holds line starts |
| 317 | fn blindex to void |
| 318 | p = get iv_n 6 |
| 319 | e = get iv_n 7 |
| 320 | n = ulong 0 |
| 321 | while lt p e bound 9223372036854775807 |
| 322 | if ge n len iv_bl |
| 323 | r = enlarge iv_bl add mul n 2 4096 |
| 324 | if ne r 0 |
| 325 | die iv_e_mem 4 |
| 326 | end |
| 327 | end |
| 328 | put iv_bl n p |
| 329 | n = add n 1 |
| 330 | p = add eol p e 1 |
| 331 | end |
| 332 | put iv_n 40 n |
| 333 | end |
| 334 | note the base-list line whose path is iv_t[a, b), or IV_NONE |
| 335 | fn bfind a ulong b ulong to ulong |
| 336 | e = get iv_n 7 |
| 337 | for j ulong get iv_n 40 bound 9223372036854775807 |
| 338 | p = get iv_bl j |
| 339 | q = eol p e |
| 340 | if eq sub q add p 66 sub b a |
| 341 | if teq add p 66 a sub b a |
| 342 | ret p |
| 343 | end |
| 344 | end |
| 345 | end |
| 346 | ret IV_NONE |
| 347 | end |
| 348 | note the base-list line whose path is iv_pa, or IV_NONE |
| 349 | fn bfindpa to ulong |
| 350 | e = get iv_n 7 |
| 351 | for j ulong get iv_n 40 bound 9223372036854775807 |
| 352 | p = get iv_bl j |
| 353 | q = eol p e |
| 354 | if tpaeq add p 66 sub q add p 66 |
| 355 | ret p |
| 356 | end |
| 357 | end |
| 358 | ret IV_NONE |
| 359 | end |
| 360 | note ---- ident records: iv_x holds (hash offset, record line start) for every c= and h= value |
| 361 | fn xadd h ulong ls ulong to void |
| 362 | n = get iv_n 19 |
| 363 | if ge add n 1 len iv_x |
| 364 | r = enlarge iv_x add mul n 2 4096 |
| 365 | if ne r 0 |
| 366 | die iv_e_mem 4 |
| 367 | end |
| 368 | end |
| 369 | put iv_x n h |
| 370 | put iv_x add n 1 ls |
| 371 | put iv_n 19 add n 2 |
| 372 | end |
| 373 | note a token at q (up to the next space or e) that is c= or h= then 64 hex |
| 374 | fn xtok q ulong e ulong ls ulong to void |
| 375 | c = get iv_t q |
| 376 | if not or eq c 99 eq c 104 |
| 377 | ret |
| 378 | end |
| 379 | if lt sub e q 66 |
| 380 | ret |
| 381 | end |
| 382 | if ne get iv_t add q 1 61 |
| 383 | ret |
| 384 | end |
| 385 | t = tfind q e 32 |
| 386 | if ne sub t q 66 |
| 387 | ret |
| 388 | end |
| 389 | xadd add q 2 ls |
| 390 | end |
| 391 | fn xindex to void |
| 392 | p = get iv_n 8 |
| 393 | e = get iv_n 9 |
| 394 | while lt p e bound 9223372036854775807 |
| 395 | q = eol p e |
| 396 | a = p |
| 397 | while lt a q bound 9223372036854775807 |
| 398 | b = tfind a q 32 |
| 399 | xtok a b p |
| 400 | a = add b 1 |
| 401 | end |
| 402 | p = add q 1 |
| 403 | end |
| 404 | end |
| 405 | note the record line whose c= or h= is iv_t[h, h+64), or IV_NONE |
| 406 | fn xfind h ulong to ulong |
| 407 | for j ulong div get iv_n 19 2 bound 9223372036854775807 |
| 408 | if teq get iv_x mul j 2 h 64 |
| 409 | ret get iv_x add mul j 2 1 |
| 410 | end |
| 411 | end |
| 412 | ret IV_NONE |
| 413 | end |
| 414 | note the value of the token KEY... in the record line [ls, le) into slots 16, 17; false when absent |
| 415 | fn tokval ls ulong lz ulong kw view uchar * to bool |
| 416 | a = ls |
| 417 | while lt a lz bound 9223372036854775807 |
| 418 | b = tfind a lz 32 |
| 419 | if tpre a b kw |
| 420 | put iv_n 16 add a len kw |
| 421 | put iv_n 17 b |
| 422 | ret true |
| 423 | end |
| 424 | a = add b 1 |
| 425 | end |
| 426 | ret false |
| 427 | end |
| 428 | note ---- hash the file at iv_pa into the gpu/runtime/zsha.om stream; false when unreadable |
| 429 | fn zfile to bool |
| 430 | fd = popen |
| 431 | if lt fd 0 |
| 432 | ret false |
| 433 | end |
| 434 | ok = zfd fd |
| 435 | r = fclose fd |
| 436 | ret ok |
| 437 | end |
| 438 | note sh_dig equals the hex at iv_t[p, p+64) |
| 439 | fn digeq p ulong to bool |
| 440 | for j ulong 32 |
| 441 | b = get sh_dig j |
| 442 | if ne get iv_t add p mul j 2 sh_hexd uint shr b 4 |
| 443 | ret false |
| 444 | end |
| 445 | if ne get iv_t add p add mul j 2 1 sh_hexd uint and b 15 |
| 446 | ret false |
| 447 | end |
| 448 | end |
| 449 | ret true |
| 450 | end |
| 451 | note ---- tables (pathmap, rewrites): FROM TAB TO rows |
| 452 | fn rowskip p ulong q ulong to bool |
| 453 | if eq p q |
| 454 | ret true |
| 455 | end |
| 456 | ret eq get iv_t p 35 |
| 457 | end |
| 458 | note check every row of table k: a tab with bytes on both sides, newline-terminated |
| 459 | fn tabok k ulong nm view uchar * to void |
| 460 | p = get iv_n k |
| 461 | e = get iv_n add k 1 |
| 462 | while lt p e bound 9223372036854775807 |
| 463 | q = eol p e |
| 464 | if eq q e |
| 465 | pdir nm |
| 466 | diepa iv_e_tab |
| 467 | end |
| 468 | if not rowskip p q |
| 469 | t = tfind p q 9 |
| 470 | if or or eq t q eq t p eq add t 1 q |
| 471 | pdir nm |
| 472 | diepa iv_e_tab |
| 473 | end |
| 474 | end |
| 475 | p = add q 1 |
| 476 | end |
| 477 | end |
| 478 | note map the CUDApp Omega path iv_t[a, b) into iv_pa by the first pathmap row whose FROM it starts with |
| 479 | fn pmap a ulong b ulong to void |
| 480 | pclr |
| 481 | p = get iv_n 10 |
| 482 | e = get iv_n 11 |
| 483 | while lt p e bound 9223372036854775807 |
| 484 | q = eol p e |
| 485 | if not rowskip p q |
| 486 | t = tfind p q 9 |
| 487 | if le sub t p sub b a |
| 488 | if teq p a sub t p |
| 489 | ptr add t 1 q |
| 490 | ptr add a sub t p b |
| 491 | ret |
| 492 | end |
| 493 | end |
| 494 | end |
| 495 | p = add q 1 |
| 496 | end |
| 497 | ptr a b |
| 498 | end |
| 499 | note ---- one bridge record: its parts |
| 500 | note the parts of record [ls, le) into slots 16, 17 (after unit=... or as is); false for a malformed record |
| 501 | fn partsof ls ulong lz ulong to bool |
| 502 | if not tokval ls lz iv_kpath |
| 503 | ret false |
| 504 | end |
| 505 | if tpre ls lz iv_knat |
| 506 | ret true |
| 507 | end |
| 508 | s = get iv_n 16 |
| 509 | e = get iv_n 17 |
| 510 | q = tfind s e 61 |
| 511 | if lt q e |
| 512 | put iv_n 16 add q 1 |
| 513 | end |
| 514 | ret true |
| 515 | end |
| 516 | note one part [a, b), mode 0 check presence and the base digest, 1 hash, 2 print |
| 517 | fn part1 a ulong b ulong mode ulong nat bool to void |
| 518 | pmap a b |
| 519 | if eq mode 0 |
| 520 | f = bfindpa |
| 521 | if eq f IV_NONE |
| 522 | put iv_n 18 1 |
| 523 | ret |
| 524 | end |
| 525 | zbeg |
| 526 | if not zfile |
| 527 | diepa iv_e_part |
| 528 | end |
| 529 | zend |
| 530 | if not digeq f |
| 531 | diepa iv_e_drift |
| 532 | end |
| 533 | ret |
| 534 | end |
| 535 | if eq mode 1 |
| 536 | if not zfile |
| 537 | diepa iv_e_part |
| 538 | end |
| 539 | if not nat |
| 540 | zbyte 10 |
| 541 | end |
| 542 | ret |
| 543 | end |
| 544 | if ne get iv_n 41 0 |
| 545 | oc 44 |
| 546 | end |
| 547 | opa |
| 548 | put iv_n 41 add get iv_n 41 1 |
| 549 | end |
| 550 | note every part of record [ls, le) in mode |
| 551 | fn parts ls ulong lz ulong mode ulong to void |
| 552 | if not partsof ls lz |
| 553 | die iv_e_rec 3 |
| 554 | end |
| 555 | nat = tpre ls lz iv_knat |
| 556 | sep = ulong 44 |
| 557 | if nat |
| 558 | sep = 43 |
| 559 | end |
| 560 | s = get iv_n 16 |
| 561 | e = get iv_n 17 |
| 562 | if eq s e |
| 563 | die iv_e_rec 3 |
| 564 | end |
| 565 | put iv_n 41 0 |
| 566 | a = s |
| 567 | while lt a e bound 9223372036854775807 |
| 568 | b = tfind a e sep |
| 569 | part1 a b mode nat |
| 570 | a = add b 1 |
| 571 | end |
| 572 | end |
| 573 | note OMEGA and DETAIL of a bridge file whose record line starts at ls |
| 574 | fn bridge ls ulong to void |
| 575 | e = get iv_n 9 |
| 576 | lz = eol ls e |
| 577 | put iv_n 18 0 |
| 578 | parts ls lz 0 |
| 579 | st = ulong 0 |
| 580 | if eq get iv_n 18 0 |
| 581 | zbeg |
| 582 | parts ls lz 1 |
| 583 | zend |
| 584 | if not tokval ls lz iv_ksrc |
| 585 | die iv_e_rec 3 |
| 586 | end |
| 587 | if or ne sub get iv_n 17 get iv_n 16 64 not digeq get iv_n 16 |
| 588 | st = 1 |
| 589 | end |
| 590 | else |
| 591 | st = 2 |
| 592 | end |
| 593 | if eq st 0 |
| 594 | ot iv_same |
| 595 | put iv_n 23 add get iv_n 23 1 |
| 596 | end |
| 597 | if eq st 1 |
| 598 | ot iv_changed |
| 599 | put iv_n 24 add get iv_n 24 1 |
| 600 | end |
| 601 | if eq st 2 |
| 602 | ot iv_absent |
| 603 | put iv_n 25 add get iv_n 25 1 |
| 604 | end |
| 605 | oc 9 |
| 606 | if not tokval ls lz iv_kunit |
| 607 | die iv_e_rec 3 |
| 608 | end |
| 609 | otr get iv_n 16 get iv_n 17 |
| 610 | oc 58 |
| 611 | parts ls lz 2 |
| 612 | end |
| 613 | note ---- files without an ident record |
| 614 | note OMEGA and DETAIL of an unrecorded file at path [a, b), kind slot ks, omega_src slot os |
| 615 | fn unrec a ulong b ulong ks ulong os ulong to void |
| 616 | p = get iv_n 12 |
| 617 | e = get iv_n 13 |
| 618 | while lt p e bound 9223372036854775807 |
| 619 | q = eol p e |
| 620 | if not rowskip p q |
| 621 | t = tfind p q 9 |
| 622 | if eq sub t p sub b a |
| 623 | if teq p a sub t p |
| 624 | pclr |
| 625 | ptr add t 1 q |
| 626 | fd = popen |
| 627 | if lt fd 0 |
| 628 | ot iv_rwmiss |
| 629 | put iv_n 28 add get iv_n 28 1 |
| 630 | else |
| 631 | r = fclose fd |
| 632 | ot iv_rewritten |
| 633 | put iv_n 27 add get iv_n 27 1 |
| 634 | end |
| 635 | oc 9 |
| 636 | opa |
| 637 | ret |
| 638 | end |
| 639 | end |
| 640 | end |
| 641 | p = add q 1 |
| 642 | end |
| 643 | ot iv_none |
| 644 | oc 9 |
| 645 | ot iv_dash |
| 646 | put iv_n 29 add get iv_n 29 1 |
| 647 | put iv_n ks add get iv_n ks 1 |
| 648 | put iv_n os add get iv_n os 1 |
| 649 | end |
| 650 | note ---- the tree file at path [a, b) against its base digest at iv_t f (IV_NONE: the base has no such file) |
| 651 | fn treeok a ulong b ulong f ulong to void |
| 652 | pclr |
| 653 | ptr a b |
| 654 | if eq f IV_NONE |
| 655 | fd = popen |
| 656 | if ge fd 0 |
| 657 | r = fclose fd |
| 658 | diepa iv_e_new |
| 659 | end |
| 660 | ret |
| 661 | end |
| 662 | zbeg |
| 663 | if not zfile |
| 664 | diepa iv_e_drift |
| 665 | end |
| 666 | zend |
| 667 | if not digeq f |
| 668 | diepa iv_e_drift |
| 669 | end |
| 670 | end |
| 671 | note ---- one CUDApp file: the list line [p, q) |
| 672 | fn bump k ulong to void |
| 673 | put iv_n k add get iv_n k 1 |
| 674 | end |
| 675 | note the kind of path [a, b): the bytes after the last dot of the file name, into slots 16, 17 |
| 676 | fn kindof a ulong b ulong to void |
| 677 | d = b |
| 678 | q = a |
| 679 | while lt q b bound 9223372036854775807 |
| 680 | c = get iv_t q |
| 681 | if eq c 47 |
| 682 | d = b |
| 683 | end |
| 684 | if eq c 46 |
| 685 | d = q |
| 686 | end |
| 687 | q = add q 1 |
| 688 | end |
| 689 | if eq d b |
| 690 | put iv_n 16 b |
| 691 | else |
| 692 | put iv_n 16 add d 1 |
| 693 | end |
| 694 | put iv_n 17 b |
| 695 | end |
| 696 | fn kslot ks ulong ke ulong to ulong |
| 697 | if tteq ks sub ke ks iv_kc |
| 698 | ret 33 |
| 699 | end |
| 700 | if tteq ks sub ke ks iv_kh |
| 701 | ret 34 |
| 702 | end |
| 703 | if tteq ks sub ke ks iv_kinc |
| 704 | ret 35 |
| 705 | end |
| 706 | ret 36 |
| 707 | end |
| 708 | fn row p ulong q ulong to void |
| 709 | a = add p 66 |
| 710 | bump 20 |
| 711 | otr a q |
| 712 | oc 9 |
| 713 | kindof a q |
| 714 | ks = get iv_n 16 |
| 715 | ke = get iv_n 17 |
| 716 | otr ks ke |
| 717 | oc 9 |
| 718 | f = bfind a q |
| 719 | treeok a q f |
| 720 | os = ulong 39 |
| 721 | if eq f IV_NONE |
| 722 | ot iv_conly |
| 723 | bump 32 |
| 724 | else |
| 725 | if teq f p 64 |
| 726 | ot iv_identical |
| 727 | bump 30 |
| 728 | os = 37 |
| 729 | else |
| 730 | ot iv_diverged |
| 731 | bump 31 |
| 732 | os = 38 |
| 733 | end |
| 734 | end |
| 735 | oc 9 |
| 736 | if tteq ks sub ke ks iv_kid |
| 737 | ot iv_record |
| 738 | oc 9 |
| 739 | ot iv_dash |
| 740 | oc 9 |
| 741 | ot iv_dash |
| 742 | bump 21 |
| 743 | oc 10 |
| 744 | ret |
| 745 | end |
| 746 | ls = xfind p |
| 747 | if ne ls IV_NONE |
| 748 | ot iv_bridge |
| 749 | oc 9 |
| 750 | bump 22 |
| 751 | bridge ls |
| 752 | oc 10 |
| 753 | ret |
| 754 | end |
| 755 | ot iv_unrec |
| 756 | oc 9 |
| 757 | bump 26 |
| 758 | unrec a q kslot ks ke os |
| 759 | oc 10 |
| 760 | end |
| 761 | note ---- summary |
| 762 | fn okv t view uchar * k ulong to void |
| 763 | ot t |
| 764 | onum get iv_n k |
| 765 | end |
| 766 | fn summary to void |
| 767 | okv iv_s_rows 20 |
| 768 | okv iv_s_rec 21 |
| 769 | okv iv_s_br 22 |
| 770 | okv iv_s_bs 23 |
| 771 | okv iv_s_bc 24 |
| 772 | okv iv_s_ba 25 |
| 773 | okv iv_s_hd 26 |
| 774 | okv iv_s_hr 27 |
| 775 | okv iv_s_hm 28 |
| 776 | okv iv_s_hn 29 |
| 777 | oc 10 |
| 778 | okv iv_s_id 30 |
| 779 | okv iv_s_dv 31 |
| 780 | okv iv_s_co 32 |
| 781 | oc 10 |
| 782 | okv iv_s_rem 33 |
| 783 | okv iv_s_rh 34 |
| 784 | okv iv_s_ri 35 |
| 785 | okv iv_s_ro 36 |
| 786 | oc 10 |
| 787 | okv iv_s_rd 37 |
| 788 | okv iv_s_dv 38 |
| 789 | okv iv_s_co 39 |
| 790 | oc 10 |
| 791 | end |
| 792 | fn main to int |
| 793 | if gt argcnt 2 |
| 794 | die iv_e_usage 2 |
| 795 | end |
| 796 | if eq argcnt 2 |
| 797 | r = argread 1 iv_dir 0 4000 |
| 798 | if lt r 1 |
| 799 | die iv_e_usage 2 |
| 800 | end |
| 801 | put iv_n 1 ulong r |
| 802 | else |
| 803 | for i ulong len iv_dflt |
| 804 | put iv_dir i get iv_dflt i |
| 805 | end |
| 806 | put iv_n 1 len iv_dflt |
| 807 | end |
| 808 | pdir iv_fsrc |
| 809 | tload 4 |
| 810 | pdir iv_fbase |
| 811 | tload 6 |
| 812 | pdir iv_fid |
| 813 | tload 8 |
| 814 | pdir iv_fmap |
| 815 | tload 10 |
| 816 | pdir iv_frw |
| 817 | tload 12 |
| 818 | listok 4 iv_fsrc |
| 819 | listok 6 iv_fbase |
| 820 | tabok 10 iv_fmap |
| 821 | tabok 12 iv_frw |
| 822 | blindex |
| 823 | xindex |
| 824 | ot iv_hdr |
| 825 | p = get iv_n 4 |
| 826 | e = get iv_n 5 |
| 827 | while lt p e bound 9223372036854775807 |
| 828 | q = eol p e |
| 829 | row p q |
| 830 | p = add q 1 |
| 831 | if ge get iv_n 3 1048576 |
| 832 | oflush |
| 833 | end |
| 834 | end |
| 835 | summary |
| 836 | oflush |
| 837 | ret 0 |
| 838 | end |