{"id":23124076,"url":"https://github.com/othiym23/find_mountpoint","last_synced_at":"2025-08-17T03:32:02.888Z","repository":{"id":57629520,"uuid":"90575124","full_name":"othiym23/find_mountpoint","owner":"othiym23","description":"find the mountpoint (or prefix, on Windows) for a provided path","archived":false,"fork":false,"pushed_at":"2017-05-28T00:10:47.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T23:24:00.661Z","etag":null,"topics":["filesystem","libc","mountpoint","rust","statfs"],"latest_commit_sha":null,"homepage":"https://docs.rs/find_mountpoint","language":"Rust","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/othiym23.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}},"created_at":"2017-05-08T01:42:40.000Z","updated_at":"2023-03-10T10:23:47.000Z","dependencies_parsed_at":"2022-09-26T20:11:07.519Z","dependency_job_id":null,"html_url":"https://github.com/othiym23/find_mountpoint","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/othiym23/find_mountpoint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othiym23%2Ffind_mountpoint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othiym23%2Ffind_mountpoint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othiym23%2Ffind_mountpoint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othiym23%2Ffind_mountpoint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/othiym23","download_url":"https://codeload.github.com/othiym23/find_mountpoint/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othiym23%2Ffind_mountpoint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270802982,"owners_count":24648682,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["filesystem","libc","mountpoint","rust","statfs"],"created_at":"2024-12-17T07:37:31.726Z","updated_at":"2025-08-17T03:32:02.613Z","avatar_url":"https://github.com/othiym23.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# find_mountpoint\n\nThe documentation is [here][docs].\n\nThis started as a simple crate to simplify getting at one field returned from\n`statfs(2)` on macOS. It takes care of all of the unsafe stuff and reflects my\nbest understanding as a Rust newbie of how to deal with `libc` memory\nmanagement efficiently. It has since grown a bit and should work on all\nplatforms supported by Rust.\n\nIts error handling is pretty conservative. It doesn't use `.unwrap()` and\nshould therefore never panic unless you fail to handle the `Result` in your own\ncode. I created a new `find_mountpoint::Error` that's a sum type over the error\ntypes returned by the calls I make, which was presented as idiomatic by the\nRust book.\n\nAlthough the macOS version makes unsafe calls, I've tried to keep it all in a\nsingle critical section to minimize the amount of weirdness that can happen.\nBecause one of my goals was to minimize memory overhead, I thought about using\na static variable for the buffer passed to `statfs(2)`, but then realized that\nwould make it unsafe for use in threaded code or with Tokio, so each call\nresults in a new allocation for a `statfs` structure.\n\nSince developing the macOS version, I've written a (slower) version that\ndoesn't rely on libc and should work on all other variants of UNIX.  There's\nalso an even simpler version for Windows, which passes its (pretty simple)\ntests on AppVeyor, so maybe it will work for you, friendly Windows developer,\nas well. Sample code for the API I'm using on Windows is [thin on the\nground][lol].\n\nThat said, It took me less than half an hour to get the project up and tests\npassing on AppVeyor, thanks to [this configuration][appveyor-rust] and\n`rustup`. It's pretty impressive how quickly everything came together.  Thanks,\nRust!  Thust!\n\nThis is my first published Rust crate, so I'm sure even this short chunk of\ncode has problems that I would love help in fixing. There aren't a lot of\nexamples out there of [`libc::statfs`][statfs] in use, and pretty much\neverybody does some variant of what I do, but bugs and PRs are welcome.\n\n## justification\n\nDealing with `libc` calls is fiddly (`\u0026str` → `Path` → `OsStr` → `CStr` and\nback again, just for strings!). nix doesn't expose the field I want in its\n`Statfs` structure. None of the filesystem crates I could find exposed this\nfunction. If somebody wants to assimilate this into their library, or work with\nme to get this function merged into their crate (including nix), that would be\nfantastic!\n\nUntil then, I needed this for my own nefarious purposes, so here it is.\n\n[appveyor-rust]: https://github.com/starkat99/appveyor-rust/\n[docs]: https://docs.rs/find_mountpoint\n[lol]: https://github.com/search?utf8=%E2%9C%93\u0026q=PrefixComponent+extension%3Ars\u0026type=Code\u0026ref=advsearch\u0026l=\u0026l=\n[statfs]: https://doc.rust-lang.org/libc/x86_64-apple-darwin/libc/fn.statfs.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fothiym23%2Ffind_mountpoint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fothiym23%2Ffind_mountpoint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fothiym23%2Ffind_mountpoint/lists"}