interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / site / copy.om

181 lines · 3579 bytes Raw Blame History
1note Checked public-tree copy and emitted-file inventory. No symlinks, private crumbs, or stale HTML.
2note Linux ARM64 stat mode at byte 16; getdents64 record length at 16 and filename at 19.
3note WolframLanguageEvaluator: {256*11,FromDigits["170000",8],FromDigits["040000",8],FromDigits["100000",8],FromDigits["200000",8]} -> {2816,61440,16384,32768,65536}.
4global sxmode uchar 1
5text sxcrumb ".crumb"
6text sxlocal ".crumb.local"
7text sxsuf ".html"
8text sxindex "index.html"
9text sxinv "inventory.txt"
10
11text SX0001 ".well-known"
12text SX0002 ".nojekyll"
13text SX0003 "\n"
14text SX0004 "site: public HTML absent from canonical registry\n"
15text SX0005 "site: public assets must be regular files or directories\n"
16text SX0006 "site: cannot read asset directory\n"
17
18fn sx_private name view uchar * to bool
19if eq len name 0
20ret true
21end
22if sr_equal name sxcrumb
23ret true
24end
25if sr_equal name sxlocal
26ret true
27end
28if eq get name 0 46
29if sr_equal name SX0001
30ret false
31end
32if sr_equal name SX0002
33ret false
34end
35ret true
36end
37ret false
38end
39
40fn sx_html path view uchar * to bool
41if lt len path len sxsuf
42ret false
43end
44ret sr_equal part path sub len path len sxsuf len sxsuf sxsuf
45end
46
47fn sx_registered path view uchar * to bool
48buf = new uchar 8192 0
49routebuf = new uchar 1024 0
50for i ulong get stcount 0
51if st_match i 5 path
52ret true
53end
54n = st_html_path i routebuf
55m = st_append buf stpub 0
56m = st_append buf part routebuf 0 n m
57if sr_equal path part buf 0 m
58ret true
59end
60end
61ret false
62end
63
64fn sx_file path view uchar * to void
65dest = new uchar 8192 0
66if eq get sxmode 0 1
67n = add get stoutn 0 1
68sr_raw part path n sub len path n
69sr_raw SX0003
70ret
71end
72if sx_html path
73if not sx_registered path
74st_fail SX0004
75end
76ret
77end
78if lt len path 7
79trap 10
80end
81dn = st_append dest part path 7 sub len path 7 0
82if si_generated part dest 0 dn
83ret
84end
85if eq get sxmode 0 2
86si_line part dest 0 dn
87ret
88end
89st_copy path part dest 0 dn
90end
91
92fn sx_entry parent view uchar * name view uchar * depth ulong to void
93pathbuf = new uchar 8192 0
94statbuf = new uchar 128 0
95n = st_append pathbuf parent 0
96n = st_append pathbuf stslash n
97n = st_append pathbuf name n
98r = lstat pathbuf 0 n statbuf 0 len statbuf
99if lt r 0
100trap 10
101end
102mode = and or uint get statbuf 16 shl uint get statbuf 17 8 61440
103if eq mode 16384
104sx_tree part pathbuf 0 n add depth 1
105else
106if ne mode 32768
107st_fail SX0005
108end
109sx_file part pathbuf 0 n
110end
111end
112
113fn sx_record parent view uchar * entry view uchar * depth ulong to void
114if lt len entry 20
115trap 10
116end
117n = ulong 19
118while lt n len entry bound 4096
119if eq get entry n 0
120break
121end
122n = add n 1
123end
124if eq n len entry
125trap 10
126end
127if not sx_private part entry 19 sub n 19
128sx_entry parent part entry 19 sub n 19 depth
129end
130end
131
132fn sx_tree path view uchar * depth ulong to void
133entries = new uchar 65536 0
134if gt depth 16
135trap 3
136end
137note arm64 O_DIRECTORY is octal 040000 (16384); generic 0200000 is O_DIRECT here.
138fd = fopen path 0 len path 16384 0
139if lt fd 0
140st_fail SX0006
141end
142while true bound 65536
143n = getdnts int fd entries 0 len entries
144if lt n 0
145trap 10
146end
147if eq n 0
148break
149end
150p = ulong 0
151while lt p ulong n bound 4096
152if lt sub ulong n p 20
153trap 10
154end
155size = ulong get entries add p 16
156size = or size shl ulong get entries add p 17 8
157if or lt size 20 gt size sub ulong n p
158trap 10
159end
160sx_record path part entries p size depth
161p = add p size
162end
163end
164r = fclose int fd
165if ne r 0
166trap 10
167end
168end
169
170fn sx_inventory to void
171pathbuf = new uchar 8192 0
172n = get stoutn 0
173for i ulong n
174put pathbuf i get stout i
175end
176st_open sxinv
177put sxmode 0 1
178sx_tree part pathbuf 0 n 0
179sr_close
180put sxmode 0 0
181end