omega-harness
Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories
Brought by drakestapleton
omega-harness / examples / pwrite_text.om
| 1 | note pwrite_text: pwrite only reads its array, so a text is a valid source (omega-mv #904, e2662fff). |
| 2 | note pread writes its array, so its destination must be writable: a global here (err20_pread_text.om |
| 3 | note is the text case). Up to omc 2c824805 (omega-mv e5b32567) the check sat on the wrong word and |
| 4 | note this program was error 20 at the pwrite line. Run in an empty scratch directory; Linux AArch64 |
| 5 | note O_RDWR|O_CREAT|O_EXCL = 194, mode 0600 = 384. |
| 6 | text fname "f.bin" |
| 7 | text body "pwrite\n" |
| 8 | global rb uchar 16 |
| 9 | fn main to int |
| 10 | fd = fopen fname 0 len fname 194 384 |
| 11 | if lt fd 0 |
| 12 | exit 90 |
| 13 | end |
| 14 | w = pwrite int fd body 0 len body 0 |
| 15 | if ne w long len body |
| 16 | exit 91 |
| 17 | end |
| 18 | r = pread int fd rb 0 len body 0 |
| 19 | if ne r long len body |
| 20 | exit 92 |
| 21 | end |
| 22 | k = write 1 rb 0 ulong r |
| 23 | c = fclose int fd |
| 24 | u = unlink fname 0 len fname |
| 25 | if ne u 0 |
| 26 | exit 93 |
| 27 | end |
| 28 | ret 0 |
| 29 | end |