{"id":13805108,"url":"https://github.com/dantecatalfamo/9p-zig","last_synced_at":"2025-05-13T18:33:16.014Z","repository":{"id":147935390,"uuid":"613205693","full_name":"dantecatalfamo/9p-zig","owner":"dantecatalfamo","description":"9P2000 protocol implemented in zig","archived":false,"fork":false,"pushed_at":"2023-04-06T01:47:47.000Z","size":41,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-06T06:08:34.571Z","etag":null,"topics":["9p","9p2000","filesystem","plan9","protocol","zig","zig-library","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dantecatalfamo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-13T05:37:27.000Z","updated_at":"2025-02-19T06:18:06.000Z","dependencies_parsed_at":"2023-05-28T01:00:13.948Z","dependency_job_id":null,"html_url":"https://github.com/dantecatalfamo/9p-zig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2F9p-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2F9p-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2F9p-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantecatalfamo%2F9p-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantecatalfamo","download_url":"https://codeload.github.com/dantecatalfamo/9p-zig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254003495,"owners_count":21997896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["9p","9p2000","filesystem","plan9","protocol","zig","zig-library","zig-package"],"created_at":"2024-08-04T01:00:57.636Z","updated_at":"2025-05-13T18:33:15.708Z","avatar_url":"https://github.com/dantecatalfamo.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 9p-zig\n9P2000 protocol client/server implemented in zig\n\n# Files\n* `src/main.zig` - Test case\n* `src/9p.zig` - Library\n* `u9fs-server.sh` - Test server script\n\n# Example\n## Client\n```zig\nconst std = @import(\"std\");\nconst debug = std.debug;\nconst z9p = @import(\"9p.zig\");\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer _ = gpa.deinit();\n    var allocator = gpa.allocator();\n\n    // Open connection\n    const stream = try std.net.tcpConnectToHost(allocator, \"127.0.0.1\", 5640);\n    defer stream.close();\n\n    std.debug.print(\"Connected\\n\", .{});\n\n    // Initialize client\n    var client = z9p.simpleClient(allocator, stream.reader(), stream.writer());\n    defer client.deinit();\n\n    // Setup protocol\n    try client.connect(std.math.maxInt(u32));\n\n    // Login to the server with name at endpoint, returning a handle\n    const root = try client.attach(null, \"dante\", \"\");\n    defer root.clunk() catch unreachable;\n    std.debug.print(\"root: {any}\\n\", .{ root });\n\n    // Return a directory handle associated with the root\n    const top_dir = try root.walk(\u0026.{ \"\" });\n    std.debug.print(\"top_dir: {any}\\n\", .{ top_dir });\n\n    // Open the directory for reading\n    try top_dir.open(.{});\n    std.debug.print(\"opened: {any}\\n\", .{ top_dir });\n\n    // Get directory information\n    const stat = try top_dir.stat();\n    defer stat.deinit();\n    std.debug.print(\"stat: {any}\\n\", .{ stat });\n    std.debug.print(\"size: {d}\\n\", .{ stat.length });\n\n    // Example of reading a directory (or file)\n    const buf = try top_dir.reader().readAllAlloc(allocator, 99999);\n    defer allocator.free(buf);\n    std.debug.print(\"reader: {any}\\n\", .{ buf });\n\n    // List files and directories in a directory\n    const files = try top_dir.files();\n    defer files.deinit();\n    for (files.stats) |s| {\n        std.debug.print(\"{s} {s:6} {s:6} {d:8} {s}\\n\", .{ s.mode, s.uid, s.gid, s.length, s.name });\n    }\n\n    // Close a handle, deallocate it\n    try top_dir.clunk();\n\n    // Open another directory\n    const tmp = try root.walk(\u0026.{ \"tmp\" });\n    // Create a file, handle is now associated with the file\n    try tmp.create(\"testing\", .{ .user_read = true, .user_write = true, .group_read = true, .world_read = true }, .{});\n    // Delete the file associated with the handle, deallocate it\n    try tmp.remove();\n\n    const passwd = try root.walk(\u0026.{ \"etc\", \"passwd\" });\n    defer passwd.clunk() catch unreachable;\n    try passwd.open(.{});\n    const pass_data = try passwd.reader().readAllAlloc(allocator, 99999);\n    defer allocator.free(pass_data);\n    std.debug.print(\"/etc/passwd:\\n{s}\\n\", .{ pass_data });\n\n    const new_file = try root.walk(\u0026.{ \"tmp\" });\n    defer new_file.remove() catch unreachable;\n    // Create a file and write to it\n    try new_file.create(\"new_thing.txt\", .{ .user_write = true, .user_read = true }, .{ .perm = .write });\n    const tons_of_data = [_]u8{'a'} ** 10000;\n    try new_file.writer().print(\u0026tons_of_data, .{});\n}\n```\n\n## Server\n\nWIP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantecatalfamo%2F9p-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantecatalfamo%2F9p-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantecatalfamo%2F9p-zig/lists"}