Skip to content

Add storage service stdlib module in ylang#4

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/rewrite-storage-service-code
Draft

Add storage service stdlib module in ylang#4
Copilot wants to merge 3 commits into
masterfrom
copilot/rewrite-storage-service-code

Conversation

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Rewrites a C storage service (filesystem/persistent storage in userspace) into idiomatic ylang, following the same syscall-only patterns as fs.y and print.y.

API surface (lib/stdlib/fs/storage_service.y)

  • Memory: allocBuffer/freeBuffer — mmap/munmap wrappers
  • Path: buildPath(basePath, key) — shared path concatenation helper
  • Low-level I/O: storageOpen, storageClose, storageRead, storageWrite, storageSeek, storageFileSize
  • Key-value store: storageInit, storagePut, storageGet, storageDelete, storageList, storageRename, storageAppend

The KV store is flat-file backed — each key is a file under a base directory, all ops via Linux x86-64 syscalls with no C runtime dependency.

Example usage

import "stdlib/fs/storage_service";

main() -> {
    storageInit("/tmp/mystore");
    storagePut("/tmp/mystore", "session_id", "abc123", 6);

    let buf = allocBuffer(4096);
    let n = storageGet("/tmp/mystore", "session_id", buf, 4096);
    // buf now contains "abc123", n == 6

    storageList("/tmp/mystore");   // prints "session_id\n" to stdout
    storageDelete("/tmp/mystore", "session_id");
    freeBuffer(buf, 4096);
    return 0;
}

All 16 functions parse successfully against the existing lexer/parser. Existing tests unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants