{"id":13439428,"url":"https://github.com/pop-os/sys-mount","last_synced_at":"2025-04-05T23:09:18.027Z","repository":{"id":48430285,"uuid":"151261854","full_name":"pop-os/sys-mount","owner":"pop-os","description":"High level FFI binding around the sys mount \u0026 umount2 calls, for Rust","archived":false,"fork":false,"pushed_at":"2024-02-05T18:19:31.000Z","size":61,"stargazers_count":45,"open_issues_count":5,"forks_count":23,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-29T22:05:57.982Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/pop-os.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-02T13:47:47.000Z","updated_at":"2025-03-28T17:42:32.000Z","dependencies_parsed_at":"2024-06-19T13:33:16.500Z","dependency_job_id":null,"html_url":"https://github.com/pop-os/sys-mount","commit_stats":{"total_commits":39,"total_committers":9,"mean_commits":4.333333333333333,"dds":0.5384615384615384,"last_synced_commit":"d7ca304e8ebe2cc66f2cd68737a8591b3530c819"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pop-os%2Fsys-mount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pop-os%2Fsys-mount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pop-os%2Fsys-mount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pop-os%2Fsys-mount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pop-os","download_url":"https://codeload.github.com/pop-os/sys-mount/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411234,"owners_count":20934653,"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":[],"created_at":"2024-07-31T03:01:13.841Z","updated_at":"2025-04-05T23:09:18.004Z","avatar_url":"https://github.com/pop-os.png","language":"Rust","funding_links":[],"categories":["Libraries","库 Libraries","库"],"sub_categories":["Filesystem","文件系统 Filesystem","文件系统"],"readme":"# sys-mount\n\n![Rust Compatibility](https://img.shields.io/badge/rust-1.24.1%20tested-green.svg)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://gitlab.com/evertiro/maco/blob/master/LICENSE)\n\nHigh level FFI bindings to the `mount` and `umount2` system calls, for Rust.\n\n## Examples\n\n### Mount\n\nThis is how the `mount` command could be written with this API.\n\n```rust\nextern crate clap;\nextern crate sys_mount;\n\nuse clap::{App, Arg};\nuse sys_mount::{Mount, MountFlags, SupportedFilesystems};\nuse std::process::exit;\n\nfn main() {\n    let matches = App::new(\"mount\")\n        .arg(Arg::with_name(\"source\").required(true))\n        .arg(Arg::with_name(\"directory\").required(true))\n        .get_matches();\n\n    let src = matches.value_of(\"source\").unwrap();\n    let dir = matches.value_of(\"directory\").unwrap();\n\n    // Fetch a listed of supported file systems on this system. This will be used\n    // as the fstype to `Mount::new`, as the `Auto` mount parameter.\n    let supported = match SupportedFilesystems::new() {\n        Ok(supported) =\u003e supported,\n        Err(why) =\u003e {\n            eprintln!(\"failed to get supported file systems: {}\", why);\n            exit(1);\n        }\n    };\n\n    // The source block will be mounted to the target directory, and the fstype is likely\n    // one of the supported file systems.\n    let result = Mount::builder()\n        .fstype(FilesystemType::from(\u0026supported))\n        .mount(src, dir);\n\n    match result {\n        Ok(mount) =\u003e {\n            println!(\"mounted {} ({}) to {}\", src, mount.get_fstype(), dir);\n        }\n        Err(why) =\u003e {\n            eprintln!(\"failed to mount {} to {}: {}\", src, dir, why);\n            exit(1);\n        }\n    }\n}\n```\n\n### Umount\n\nThis is how the `umount` command could be implemented.\n\n```rust\nextern crate clap;\nextern crate sys_mount;\n\nuse clap::{App, Arg};\nuse sys_mount::{unmount, UnmountFlags};\nuse std::process::exit;\n\nfn main() {\n    let matches = App::new(\"umount\")\n        .arg(Arg::with_name(\"lazy\")\n            .short(\"l\")\n            .long(\"lazy\"))\n        .arg(Arg::with_name(\"source\").required(true))\n        .get_matches();\n\n    let src = matches.value_of(\"source\").unwrap();\n\n    let flags = if matches.is_present(\"lazy\") {\n        UnmountFlags::DETACH\n    } else {\n        UnmountFlags::empty()\n    };\n\n    match unmount(src, flags) {\n        Ok(()) =\u003e (),\n        Err(why) =\u003e {\n            eprintln!(\"failed to unmount {}: {}\", src, why);\n            exit(1);\n        }\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpop-os%2Fsys-mount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpop-os%2Fsys-mount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpop-os%2Fsys-mount/lists"}