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 / seed / agent / path.om
| 1 | note seed/agent/path.om -- omagent's workspace path rule, shared by seed/agent/agent.om and the |
| 2 | note Omega Node tool adapter seed/node/tool.om (DRA-290). OM-2 unit, no globals; compose before its user. |
| 3 | note agpathok: relative, every part nonempty and not . or .., no control bytes, and no part |
| 4 | note (checked with lstat, prefix by prefix) is a symbolic link |
| 5 | note agcomp: the part p[s, i) is not empty, . or .., and the prefix p[0, i) is not a symbolic link |
| 6 | fn agcomp p view uchar * s ulong i ulong to bool |
| 7 | cl = sub i s |
| 8 | if eq cl 0 |
| 9 | ret false |
| 10 | end |
| 11 | if eq get p s 46 |
| 12 | if eq cl 1 |
| 13 | ret false |
| 14 | end |
| 15 | if eq cl 2 |
| 16 | if eq get p add s 1 46 |
| 17 | ret false |
| 18 | end |
| 19 | end |
| 20 | end |
| 21 | st = new uchar 128 0 |
| 22 | r = lstat p 0 i st 0 128 |
| 23 | if lt r 0 |
| 24 | ret true |
| 25 | end |
| 26 | md = or ulong get st 16 shl ulong get st 17 8 |
| 27 | ret ne and md 61440 40960 |
| 28 | end |
| 29 | |
| 30 | fn agpathok p view uchar * to bool |
| 31 | n = len p |
| 32 | if or eq n 0 gt n 4095 |
| 33 | ret false |
| 34 | end |
| 35 | if eq get p 0 47 |
| 36 | ret false |
| 37 | end |
| 38 | s = ulong 0 |
| 39 | for i ulong add n 1 |
| 40 | c = uchar 47 |
| 41 | if lt i n |
| 42 | c = get p i |
| 43 | if or lt c 32 eq c 127 |
| 44 | ret false |
| 45 | end |
| 46 | end |
| 47 | if eq c 47 |
| 48 | if not agcomp p s i |
| 49 | ret false |
| 50 | end |
| 51 | s = add i 1 |
| 52 | end |
| 53 | end |
| 54 | ret true |
| 55 | end |