Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-bridge/blob/main/tests/native/v2/host/hcall.c # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-bridge / tests / native / v2 / host / hcall.c` 39 lines ยท 1640 bytes Raw Blame History 1 /* hcall.c: the C oracle for hfile.om through the --host library (tests/native/v2/run.sh, section 11). 2 * hcall FILE MISSING LINK: FILE holds 5 bytes, MISSING does not exist, LINK is a symlink to FILE. 3 * Each expectation is computed here by libc, independently of the Omega unit. */ 4 #define _GNU_SOURCE 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include "omega_native.h" 12 13 static int bad; 14 static void check(const char *what, int ok) { 15 printf("%s %s\n", ok ? "PASS" : "FAIL", what); 16 if (!ok) bad = 1; 17 } 18 19 static int64_t peek(const char *p) { 20 uint64_t r = 0; 21 if (omega2_peek(&r, (const uint8_t *)p, strlen(p)) != OMEGA_OK) return INT64_MIN; 22 return (int64_t)r; 23 } 24 25 int main(int argc, char **argv) { 26 if (argc != 4) { fprintf(stderr, "usage: hcall FILE MISSING LINK\n"); return 2; } 27 uint64_t r = 0; 28 uint64_t want = (uint64_t)getuid() + geteuid() + getgid() + getegid(); 29 check("ids == getuid+geteuid+getgid+getegid", omega2_ids(&r) == OMEGA_OK && r == want); 30 check("peek FILE reads its 5 bytes", peek(argv[1]) == 5); 31 check("peek MISSING = -ENOENT", peek(argv[2]) == -ENOENT); 32 check("peek LINK = -ELOOP (fopen with O_NOFOLLOW)", peek(argv[3]) == -ELOOP); 33 struct stat st; 34 check("size FILE == st_size", stat(argv[1], &st) == 0 && omega2_size(&r, (const uint8_t *)argv[1], strlen(argv[1])) == OMEGA_OK 35 && (int64_t)r == (int64_t)st.st_size); 36 check("ident carries host=", strstr(omega2_ident_hfile(), " host=") != NULL 37 && strcmp(omega2_ident_hfile(), OMEGA2_IDENT_hfile) == 0); 38 return bad; 39 }