interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / agent / path.om

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