udisks2-0.3.1/.cargo_vcs_info.json0000644000000001610000000000100124170ustar { "git": { "sha1": "964d639f85dc437247b4399502c79fb5c10002fb", "dirty": true }, "path_in_vcs": "" }udisks2-0.3.1/.github/workflows/ci.yaml000064400000000000000000000033241046102023000160670ustar 00000000000000on: push: branches: [master] pull_request: name: Continuous Integration concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: check: name: Check #format does not need to run on all platforms runs-on: ubuntu-latest timeout-minutes: 15 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable - name: Run check run: cargo check clippy: name: Clippy runs-on: ubuntu-latest timeout-minutes: 15 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable with: components: clippy - name: Run clippy run: cargo clippy -- -Dwarnigns test: name: Test Suite strategy: matrix: platform: [ubuntu-latest] # test only on ubuntu, testing on every platform would take too much time and fail too often due to a few flaky test rust: - 1.80.0 # MSRV - stable - beta - nightly #tests should pass on all platforms runs-on: ${{ matrix.platform }} timeout-minutes: 25 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Install ${{ matrix.rust }} toolchain uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - name: Install udisks2 run: sudo apt-get install -y udisks2 - name: Build continue-on-error: false run: cargo build - name: Run tests continue-on-error: false run: cargo test --locked --verbose udisks2-0.3.1/.gitignore000064400000000000000000000002371046102023000132030ustar 00000000000000udisks/target/ udisks/udisks-sys/target/ # Added by cargo /target # Added by cargo # # already existing elements were commented out #/target /Cargo.lock udisks2-0.3.1/Cargo.lock0000644000000727210000000000100104050ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] name = "adler2" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "async-broadcast" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" dependencies = [ "event-listener", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-channel" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" dependencies = [ "concurrent-queue", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" dependencies = [ "async-task", "concurrent-queue", "fastrand", "futures-lite", "slab", ] [[package]] name = "async-fs" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" dependencies = [ "async-lock", "blocking", "futures-lite", ] [[package]] name = "async-io" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" dependencies = [ "async-lock", "cfg-if", "concurrent-queue", "futures-io", "futures-lite", "parking", "polling", "rustix", "slab", "tracing", "windows-sys 0.59.0", ] [[package]] name = "async-lock" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ "event-listener", "event-listener-strategy", "pin-project-lite", ] [[package]] name = "async-process" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" dependencies = [ "async-channel", "async-io", "async-lock", "async-signal", "async-task", "blocking", "cfg-if", "event-listener", "futures-lite", "rustix", "tracing", ] [[package]] name = "async-recursion" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "async-signal" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" dependencies = [ "async-io", "async-lock", "atomic-waker", "cfg-if", "futures-core", "futures-io", "rustix", "signal-hook-registry", "slab", "windows-sys 0.59.0", ] [[package]] name = "async-task" version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", "windows-targets", ] [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "blocking" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" dependencies = [ "async-channel", "async-task", "futures-io", "futures-lite", "piper", ] [[package]] name = "bytes" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" dependencies = [ "shlex", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "concurrent-queue" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "endi" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" [[package]] name = "enumflags2" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" dependencies = [ "enumflags2_derive", "serde", ] [[package]] name = "enumflags2_derive" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", "windows-sys 0.59.0", ] [[package]] name = "event-listener" version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", "pin-project-lite", ] [[package]] name = "event-listener-strategy" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ "event-listener", "pin-project-lite", ] [[package]] name = "fastrand" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" dependencies = [ "fastrand", "futures-core", "futures-io", "parking", "pin-project-lite", ] [[package]] name = "futures-task" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-io", "futures-task", "memchr", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "gettext-rs" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44e92f7dc08430aca7ed55de161253a22276dfd69c5526e5c5e95d1f7cf338a" dependencies = [ "gettext-sys", "locale_config", ] [[package]] name = "gettext-sys" version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb45773f5b8945f12aecd04558f545964f943dacda1b1155b3d738f5469ef661" dependencies = [ "cc", "temp-dir", ] [[package]] name = "gimli" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "hermit-abi" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "indexmap" version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "locale_config" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934" dependencies = [ "lazy_static", "objc", "objc-foundation", "regex", "winapi", ] [[package]] name = "lock_api" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", ] [[package]] name = "malloc_buf" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" dependencies = [ "libc", ] [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] [[package]] name = "miniz_oxide" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] [[package]] name = "mio" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "wasi", "windows-sys 0.52.0", ] [[package]] name = "nix" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags", "cfg-if", "cfg_aliases", "libc", "memoffset", ] [[package]] name = "objc" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ "malloc_buf", ] [[package]] name = "objc-foundation" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" dependencies = [ "block", "objc", "objc_id", ] [[package]] name = "objc_id" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" dependencies = [ "objc", ] [[package]] name = "object" version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "ordered-stream" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" dependencies = [ "futures-core", "pin-project-lite", ] [[package]] name = "parking" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", "windows-targets", ] [[package]] name = "pin-project-lite" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" dependencies = [ "atomic-waker", "fastrand", "futures-io", ] [[package]] name = "polling" version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi", "pin-project-lite", "rustix", "tracing", "windows-sys 0.59.0", ] [[package]] name = "proc-macro-crate" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ "bitflags", ] [[package]] name = "regex" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", "windows-sys 0.59.0", ] [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_repr" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" version = "2.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "temp-dir" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc1ee6eef34f12f765cb94725905c6312b6610ab2b0940889cfe58dae7bc3c72" [[package]] name = "tempfile" version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", "once_cell", "rustix", "windows-sys 0.59.0", ] [[package]] name = "tokio" version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", "libc", "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", "winnow", ] [[package]] name = "tracing" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing-core" version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", ] [[package]] name = "udisks2" version = "0.3.1" dependencies = [ "enumflags2", "gettext-rs", "serde", "serde_repr", "tokio", "zbus", ] [[package]] name = "uds_windows" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" dependencies = [ "memoffset", "tempfile", "winapi", ] [[package]] name = "unicode-ident" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] [[package]] name = "xdg-home" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" dependencies = [ "libc", "windows-sys 0.59.0", ] [[package]] name = "zbus" version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb67eadba43784b6fb14857eba0d8fc518686d3ee537066eb6086dc318e2c8a1" dependencies = [ "async-broadcast", "async-executor", "async-fs", "async-io", "async-lock", "async-process", "async-recursion", "async-task", "async-trait", "blocking", "enumflags2", "event-listener", "futures-core", "futures-util", "hex", "nix", "ordered-stream", "serde", "serde_repr", "static_assertions", "tracing", "uds_windows", "windows-sys 0.59.0", "winnow", "xdg-home", "zbus_macros", "zbus_names", "zvariant", ] [[package]] name = "zbus_macros" version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c9d49ebc960ceb660f2abe40a5904da975de6986f2af0d7884b39eec6528c57" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn", "zbus_names", "zvariant", "zvariant_utils", ] [[package]] name = "zbus_names" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "856b7a38811f71846fd47856ceee8bccaec8399ff53fb370247e66081ace647b" dependencies = [ "serde", "static_assertions", "winnow", "zvariant", ] [[package]] name = "zvariant" version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1200ee6ac32f1e5a312e455a949a4794855515d34f9909f4a3e082d14e1a56f" dependencies = [ "endi", "enumflags2", "serde", "static_assertions", "winnow", "zvariant_derive", "zvariant_utils", ] [[package]] name = "zvariant_derive" version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "687e3b97fae6c9104fbbd36c73d27d149abf04fb874e2efbd84838763daa8916" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn", "zvariant_utils", ] [[package]] name = "zvariant_utils" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20d1d011a38f12360e5fcccceeff5e2c42a8eb7f27f0dcba97a0862ede05c9c6" dependencies = [ "proc-macro2", "quote", "serde", "static_assertions", "syn", "winnow", ] udisks2-0.3.1/Cargo.toml0000644000000032050000000000100104170ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.80" name = "udisks2" version = "0.3.1" build = false autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = " Unofficial crate for interacting with the UDisks2 API" readme = "README.md" keywords = [ "udisks", "udisks2", "manipulating-disk", "storage", ] categories = [ "api-bindings", "hardware-support", "os::linux-apis", ] license = "LGPL-2.1" repository = "https://github.com/FineFindus/udisks-rs" [lib] name = "udisks2" path = "src/lib.rs" [[example]] name = "bug" path = "examples/bug.rs" [[example]] name = "dev" path = "examples/dev.rs" [[example]] name = "disk_sizes" path = "examples/disk_sizes.rs" [[example]] name = "loop" path = "examples/loop.rs" [[example]] name = "unmount-udisks" path = "examples/unmount-udisks.rs" [dependencies.enumflags2] version = "0.7" features = ["serde"] [dependencies.gettext-rs] version = "0.7" features = ["gettext-system"] [dependencies.serde] version = "1.0" features = ["derive"] [dependencies.serde_repr] version = "0.1" [dependencies.zbus] version = "5.2" [dev-dependencies.tokio] version = "1.42" features = ["full"] udisks2-0.3.1/Cargo.toml.orig000064400000000000000000000012411046102023000140760ustar 00000000000000[package] name = "udisks2" version = "0.3.1" edition = "2021" rust-version = "1.80" description = " Unofficial crate for interacting with the UDisks2 API" readme = "README.md" license = "LGPL-2.1" repository = "https://github.com/FineFindus/udisks-rs" keywords = ["udisks", "udisks2", "manipulating-disk", "storage"] categories = ["api-bindings", "hardware-support", "os::linux-apis"] [dependencies] zbus = "5.2" serde = { version = "1.0", features = ["derive"] } serde_repr = "0.1" enumflags2 = { version = "0.7", features = ["serde"] } gettext-rs = { version = "0.7", features = ["gettext-system"] } [dev-dependencies] tokio = { version = "1.42", features = ["full"] } udisks2-0.3.1/LICENSE000064400000000000000000000636261046102023000122330ustar 00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 2023 FineFindus This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! udisks2-0.3.1/README.md000064400000000000000000000025211046102023000124700ustar 00000000000000# Udisks An unofficial Rust client crate for [`udisks2`](https://github.com/storaged-project/udisks). Udisks allows accessing and manipulating disks, storages devices and similar technologies. ## Version Based on https://github.com/storaged-project/udisks/commit/4b1250cdf5897391e449ca0ad3836598c3b00dad for the client and https://github.com/storaged-project/udisks/commit/3e499ea0248ee73043aedab834f32501019830a8 for the generated interfaces. ## Example ```rust // we use tokio in this example, but you can use any runtime #[tokio::main] async fn main() -> udisks2::Result<()> { let client = udisks2::Client::new().await?; let object = client .object("/org/freedesktop/UDisks2/block_devices/sda") .expect("No sda device found"); let block = object.block().await?; let drive = client.drive_for_block(&block).await?; println!( "Size: {}", client.size_for_display(drive.size().await?, true, true) ); Ok(()) } ``` ## Documentation While this crate provides documentation for the handwritten code, the generated types may be lacking. In this case it is recommended to use the official [documentation](https://storaged.org/doc/udisks2-api/latest/). ### Internationalization This crate uses the same localization as `UDisks2`, which uses gettext. If the locale is left unset, English will be used. udisks2-0.3.1/examples/bug.rs000064400000000000000000000010411046102023000141460ustar 00000000000000#[tokio::main] async fn main() -> udisks2::Result<()> { let client = udisks2::Client::new().await.unwrap(); let block = client .object("/org/freedesktop/UDisks2/block_devices/loop0") // has no Drive (the Drive property is '/') .unwrap() .block() .await .expect("can not create BlockProxy for loop0 block"); assert!(block.drive().await.unwrap().as_ref() == "/"); client .drive_for_block(&block) .await .expect("can not create Drive for loop0 block"); Ok(()) } udisks2-0.3.1/examples/dev.rs000064400000000000000000000041031046102023000141510ustar 00000000000000use std::collections::HashMap; use zbus::Connection; #[tokio::main] async fn main() -> udisks2::Result<()> { gettextrs::setlocale(gettextrs::LocaleCategory::LcAll, "de_DE.UTF-8"); gettextrs::textdomain(GETTEXT_PACKAGE).expect("Failed to set textdomain"); let client = udisks2::Client::new().await?; let version = client.manager().version().await?; println!("Version: {}", version); let object = client .object("/org/freedesktop/UDisks2/block_devices/sda") .expect("No sda device found"); let block = object.block().await?; let drive = client.drive_for_block(&block).await?; println!( "Size: {}", client.size_for_display(drive.size().await?, true, true) ); println!("Block: {}", block.inner().path()); let drive = client.object("/org/freedesktop/UDisks2/drives/SanDisk_SSD_PLUS_1000GB_1926FP462112")?; println!( "Drive: {:?}", drive.drive().await.unwrap().can_power_off().await ); println!("{:?}", block.device().await); let swap = client.object("/org/freedesktop/UDisks2/block_devices/zram0")?; println!("Swap: {:?}", swap.swapspace().await?.active().await?); //println!( // "Object: {:?}", // client.object(drive.drive().await?.inner().path().to_owned()) //); const GETTEXT_PACKAGE: &str = "udisks2"; // println!( "{}", gettextrs::dgettext(GETTEXT_PACKAGE, "Mount a filesystem on a system device") ); // println!("{:?}", client.partition_table_type_for_display("apm")); // println!( // "{:?}", // client.job_description_from_operation("md-raid-creates") // ); // println!("{:?}", block.symlinks().await); let fs = client .object("/org/freedesktop/UDisks2/block_devices/sdb2") .expect("No sda device found") .filesystem() .await?; println!("MountPoints: {:?}", fs.mount_points().await?); let connection = zbus::Connection::session().await?; let job = udisks2::job::JobProxy::new(&connection).await.unwrap(); dbg!(&job.rate().await); Ok(()) } udisks2-0.3.1/examples/disk_sizes.rs000064400000000000000000000012001046102023000155350ustar 00000000000000#[tokio::main] async fn main() -> udisks2::Result<()> { let client = udisks2::Client::new().await?; for object in client .object_manager() .get_managed_objects() .await? .into_iter() .filter_map(|(object_path, _)| client.object(object_path).ok()) { //only use objects that have a drive let Ok(drive) = object.drive().await else { continue; }; // print model and size println!( "{}: {}", drive.model().await?, client.size_for_display(drive.size().await?, false, false) ); } Ok(()) } udisks2-0.3.1/examples/loop.rs000064400000000000000000000015401046102023000143460ustar 00000000000000use std::ffi::CString; #[tokio::main] async fn main() -> udisks2::Result<()> { let client = udisks2::Client::new().await?; for object in client .object_manager() .get_managed_objects() .await? .into_iter() .filter_map(|(object_path, _)| client.object(object_path).ok()) { //only use objects that have a drive let Ok(fs) = object.filesystem().await else { continue; }; // print path and mount point for mount_point in fs .mount_points() .await .unwrap() .iter() .filter_map(|p| CString::from_vec_with_nul(p.to_vec()).ok()) .filter_map(|p| p.to_str().map(|p| p.to_string()).ok()) { println!("{}:{:?}", object.object_path(), mount_point); } } Ok(()) } udisks2-0.3.1/examples/unmount-udisks.rs000064400000000000000000000052511046102023000164050ustar 00000000000000use std::{ collections::HashMap, fs, os::{linux::fs::MetadataExt, unix::fs::FileTypeExt}, process::ExitCode, }; // https://github.com/storaged-project/udisks/blob/master/tools/umount-udisks.c #[tokio::main] async fn main() -> ExitCode { let mut args = std::env::args(); let bin_name = args.next().unwrap(); let Some(path) = args.next() else { eprintln!( "{}: this program is only supposed to be invoked by umount(8).", bin_name ); return ExitCode::FAILURE; }; let block_device = match fs::metadata(&path) { Ok(data) if data.file_type().is_block_device() => data.st_rdev(), Ok(data) => data.st_dev(), Err(err) => { eprintln!("{}: error calling stat on {}: {}).", bin_name, path, err); return ExitCode::FAILURE; } }; let Ok(client) = udisks2::Client::new().await else { eprintln!("Error connecting to the udisks daemon"); return ExitCode::FAILURE; }; let Some(object) = lookup_object_for_block(&client, block_device).await else { eprintln!( "Error finding object for block device {}:{}", major(block_device), minor(block_device) ); return ExitCode::FAILURE; }; let Ok(filesystem) = object.filesystem().await else { eprintln!( "Block device {}:{} is not a mountable filesystem", major(block_device), minor(block_device) ); return ExitCode::FAILURE; }; if let Err(err) = filesystem.unmount(HashMap::new()).await { eprintln!( "Error unmounting block device {}:{}: {}", major(block_device), minor(block_device), err ); return ExitCode::FAILURE; } return ExitCode::SUCCESS; } async fn lookup_object_for_block( client: &udisks2::Client, block_device: u64, ) -> Option { for object in client .object_manager() .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| client.object(object_path).ok()) { if let Ok(block) = object.block().await { if Ok(block_device) == block.device_number().await { return Some(object); } }; } None } pub fn major(dev: u64) -> u32 { let mut major = 0; major |= (dev & 0x00000000000fff00) >> 8; major |= (dev & 0xfffff00000000000) >> 32; major as u32 } pub fn minor(dev: u64) -> u32 { let mut minor = 0; minor |= (dev & 0x00000000000000ff) >> 0; minor |= (dev & 0x00000ffffff00000) >> 12; minor as u32 } udisks2-0.3.1/org.freedesktop.UDisks2.xml000064400000000000000000005005061046102023000163250ustar 00000000000000 udisks2-0.3.1/src/ata.rs000064400000000000000000000125451046102023000131220ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Drive.Ata` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Drive.Ata", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Drive" )] pub trait Ata { /// PmGetState method fn pm_get_state( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// PmStandby method fn pm_standby( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// PmWakeup method fn pm_wakeup( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SecurityEraseUnit method fn security_erase_unit( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SmartGetAttributes method #[allow(clippy::type_complexity)] fn smart_get_attributes( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result< Vec<( u8, String, u16, i32, i32, i32, i64, i32, std::collections::HashMap, )>, >; /// SmartSelftestAbort method fn smart_selftest_abort( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SmartSelftestStart method fn smart_selftest_start( &self, type_: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SmartSetEnabled method fn smart_set_enabled( &self, value: bool, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SmartUpdate method fn smart_update( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// AamEnabled property #[zbus(property)] fn aam_enabled(&self) -> error::Result; /// AamSupported property #[zbus(property)] fn aam_supported(&self) -> error::Result; /// AamVendorRecommendedValue property #[zbus(property)] fn aam_vendor_recommended_value(&self) -> error::Result; /// ApmEnabled property #[zbus(property)] fn apm_enabled(&self) -> error::Result; /// ApmSupported property #[zbus(property)] fn apm_supported(&self) -> error::Result; /// PmEnabled property #[zbus(property)] fn pm_enabled(&self) -> error::Result; /// PmSupported property #[zbus(property)] fn pm_supported(&self) -> error::Result; /// ReadLookaheadEnabled property #[zbus(property)] fn read_lookahead_enabled(&self) -> error::Result; /// ReadLookaheadSupported property #[zbus(property)] fn read_lookahead_supported(&self) -> error::Result; /// SecurityEnhancedEraseUnitMinutes property #[zbus(property)] fn security_enhanced_erase_unit_minutes(&self) -> error::Result; /// SecurityEraseUnitMinutes property #[zbus(property)] fn security_erase_unit_minutes(&self) -> error::Result; /// SecurityFrozen property #[zbus(property)] fn security_frozen(&self) -> error::Result; /// SmartEnabled property #[zbus(property)] fn smart_enabled(&self) -> error::Result; /// SmartFailing property #[zbus(property)] fn smart_failing(&self) -> error::Result; /// SmartNumAttributesFailedInThePast property #[zbus(property)] fn smart_num_attributes_failed_in_the_past(&self) -> error::Result; /// SmartNumAttributesFailing property #[zbus(property)] fn smart_num_attributes_failing(&self) -> error::Result; /// SmartNumBadSectors property #[zbus(property)] fn smart_num_bad_sectors(&self) -> error::Result; /// SmartPowerOnSeconds property #[zbus(property)] fn smart_power_on_seconds(&self) -> error::Result; /// SmartSelftestPercentRemaining property #[zbus(property)] fn smart_selftest_percent_remaining(&self) -> error::Result; /// SmartSelftestStatus property #[zbus(property)] fn smart_selftest_status(&self) -> error::Result; /// SmartSupported property #[zbus(property)] fn smart_supported(&self) -> error::Result; /// SmartTemperature property #[zbus(property)] fn smart_temperature(&self) -> error::Result; /// SmartUpdated property #[zbus(property)] fn smart_updated(&self) -> error::Result; /// WriteCacheEnabled property #[zbus(property)] fn write_cache_enabled(&self) -> error::Result; /// WriteCacheSupported property #[zbus(property)] fn write_cache_supported(&self) -> error::Result; } udisks2-0.3.1/src/block.rs000064400000000000000000000562671046102023000134600ustar 00000000000000//! Interface to represent a block device. //! //! This interface should not to be confused with the //! [`org.freedesktop.UDisks2.Drive`](crate::drive) that is used to represent drives. //! For example, the [`org.freedesktop.UDisks2.Block`](crate::block) interface //! is also used for block devices that do not correspond to drives at all //! (e.g. [Loop Devices](https://en.wikipedia.org/wiki/Loop_device)). use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Block", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Block" )] pub trait Block { /// Adds a new configuration item. /// /// See [`Self::configuration`] for details. /// Some fields can be omitted and will then receive default values. This is useful when passing configuration items to Format, /// for example, because the proper values are not known before the formatting is done. /// /// * If `fsname` is omitted in a `fstab` entry, or `device` is omitted in a `crypttab` entry, /// it defaults to `UUID=...` when the block device has a filesystem UUID, /// or to the name of the device in the filesystem. /// /// * If `name` is omitted in a `crypttab` entry, it defaults to `luks-`. /// /// * If `passphrase-path` is omitted, it defaults to `/etc/luks-keys/`. /// /// * If `track-parents` is set to true in item, /// then the `opts` and `options` fields will be augmented with `x-parent` elements, /// as appropriate. This will make item appear in the ChildConfiguration properties, /// and will allow the `tear-down` option of Format, DeletePartition, /// and other methods to remove this item reliably. fn add_configuration_item( &self, //TODO: use struct item: &( &str, std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ), options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; //TODO: use enum for type /// Formats the device with a file system, partition table or other well-known content. /// /// Known values for type includes `empty` (to just zero out areas of the device known to host file system signatures) and `swap` (Linux swap space) /// and most file systems supported by the mkfs(8) program through its `-t` option. /// /// Known partition table formats includes `dos` and `gpt`. /// /// If `type` supports it, you can specify a label with the `label` option in the `options` parameter; however, /// note that this may not be supported on all file systems and, if supported, the maximum allowed length may vary. /// Similarly, you can specify filesystem UUID with the `uuid` option in the options parameter given that the particular filesystem type supports this feature. /// The format of the UUID string should match the [`Self::uuid`] property. /// /// If the file system in question supports owners and the option `take-ownership` is set to `true` then the root directory of the created file system will be owned by the caller of this method. /// /// If the option `encrypt.passphrase` is given then a LUKS device is created with the given passphrase and the file system is created on the unlocked `device`. /// The unlocked device will be left open. This parameter can be used to supply the binary contents of an arbitrary keyfile by passing a value of type `ay`. /// Option `encrypt.type` can be used to specify encryption "technology" that will be used. /// Currently only “luks1” and “luks2” are supported. /// Following additional options for LUKS key derivation function can be used: /// - `encrypt.pbkdf`: key derivation function, one of "pbkdf2", "argon2i", "argon2id" /// - `encrypt.iterations`: number of iterations for PBKDF /// - `encrypt.memory`: memory cost in KiB for Argon2 /// - `encrypt.time`: time cost for PBKDF in ms /// - `encrypt.threads`: parallel cost for PBKDF (number of threads, up to 4) /// /// If the option `erase` is used then the underlying device will be erased. /// Valid values include “zero” to write zeroes over the entire device before formatting, /// “ata-secure-erase” to perform a secure erase or “ata-secure-erase-enhanced” to perform an enhanced secure erase. /// /// If the option `update-partition-type` is set to `true` and the object in question is a partition, then its type (cf. the "Type" property) /// will be set to the natural partition type matching type, if any. /// For example, if formatting a GPT partition with a FAT filesystem, the “Microsoft Basic Data” partition type will be chosen; /// similar, if formatting a DOS partition with a Ext4 filesystem then partition type 0x83 is chosen. /// /// If the option `no-block` is set to `true` then the method returns just before the actual formatting takes place /// but after authorization and other checks are done. This is useful for applications that want to format several devices in parallel. /// /// If the option `dry-run-first` is set to `true` then a dry run of the formatting command is performed first, /// if UDisks knows how to do that. The idea is that this allows a deeper check of the parameters even when `no-block` is `true`. /// Note that the block device has already been modified (wiped) when the dry run check is called. /// /// If the option `mkfs-args` is set then the caller can provide a list of additional command-line arguments that will be passed to the mkfs program. /// The arguments specified in this way are not validated by UDisks, and the user is responsible for making sure that the available mkfs program /// for that filesystem supports them and that they work for the intended purpose. /// Note that UDisks can also pass its own additional arguments to mkfs, and they may vary between releases, with no guarantees of stability in this regard. /// The position in which the user-provided arguments are appended to the final mkfs command line is also not defined. /// Because of all this, `mkfs-args` should only be used as a last resort when no other dedicated option is available. /// /// If the option `no-discard` is set to `true` then Udisks tells the formatting utility not to issue `BLKDISCARD` ioctls. /// /// If the option `config-items` is set, it should be an array of configuration items suitable for [`Self::add_configuration_item`]. /// They will all be added after the formatting is done. /// /// If the option `tear-down` is set to `true`, then the block device and all its children will be cleaned up before formatting. /// This cleanup consists of removing entries from `/etc/fstab` and `/etc/crypttab`, and locking of encrypted block devices. /// Entries in `/etc/fstab` and `/etc/crypttab` that have been created with the 'track-parents' options to [`Self::add_configuration_item`] /// will be removed even if their block device is currently unavailable. /// /// Note that if the operation fails the block device may be left in an inconsistent state. /// In cases of removing partition table and failed operation it's advised to validate the device e.g. /// by re-reading the partition table or force-wiping it before performing further operations. /// /// In case the `tear-down` option is not set and the block device being formatted is partitioned and contains mounted filesystem /// or an active layered structure inside then the Format operation may not fail, yet could still overwrite nested foreign data regions. /// It is the caller responsibility to ensure the device is ready for destructive operations. This may be subject to further restrictions in the future. fn format( &self, type_: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Returns the same value as [`Self::configuration`], but without secret information filtered out. fn get_secret_configuration( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result< Vec<( String, std::collections::HashMap, )>, >; /// Returns a file desciptor to the device. /// /// Set option `flags` for additional flags. See man 2 open for list of supported flags. /// `O_RDONLY`, `O_WRONLY` and `O_RDWR` are not allowed, use `mode` instead. /// /// `mode` specifies the mode that the file can be opened, can be `r`(read-only), /// `w`(write-only) and `rw`(read-write). fn open_device( &self, //TODO: use enum/struct mode: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Returns a read-only file descriptor for the device intended for a byte-by-byte imaging of the device. /// This can only be done if the device is not already in use. #[deprecated = "Use OpenDevice with O_EXCL and O_CLOEXEC flags instead."] fn open_for_backup( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Returns a file descriptor for the device that is suitable to be used for benchmarking the device /// (transfer rate, access time etc.). /// /// Note that the file descriptor may be opened with the O_DIRECT and O_SYNC flags so care must be taken to /// only perform block-aligned I/O. /// /// If the `writable` in options is `true` then the returned file descriptor will be writable. /// This only works if the device is not already in use. #[deprecated = "Use OpenDevice with O_DIRECT, O_SYNC and O_CLOEXEC flags instead."] fn open_for_benchmark( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Returns a writable file descriptor for the device intended for a byte-by-byte restore /// of a disk image onto the device. /// /// This can only be done if the device is not already in use. #[deprecated = "Use OpenDevice with O_EXCL and O_CLOEXEC flags instead."] fn open_for_restore( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Removes an existing configuration item. /// /// See the [`Self::configuration`] property for details about valid configuration items. fn remove_configuration_item( &self, item: &( &str, std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ), options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Request that the kernel and core OS rescans the contents of the device and update their state to reflect this /// (including things such as the `/dev/disk/` hierarchy of symlinks). /// /// This includes requesting that the kernel re-reads the partition table, if appropriate. /// This is usually not needed since the OS automatically does this when the last process /// with a writable file descriptor for the device closes it. fn rescan( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Removes a configuration item and adds a new one. /// /// This is equivalent to calling [`Self::remove_configuration_item`] followed by [`Self::add_configuration_item`] /// with the change that only one PolicyKit check is made and that `new_item` can be validated against `old_item`. /// /// See the [`Self::configuration`] property for details about valid configuration items. fn update_configuration_item( &self, old_item: &( &str, std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ), new_item: &( &str, std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ), options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// The configuration for the device. /// /// This is an array of tuples `(type, details)` where type is a string identifying the configuration source /// (e.g. `fstab`) and details contains the actual configuration data. /// /// Use the [`Self::add_configuration_item`], [`Self::remove_configuration_item`] and [`Self::update_configuration_item`] /// methods to add, remove and update configuration items. /// /// Use [`Self::get_secret_configuration`] to get the secrets (e.g. `passphrases`) that may be part of the configuration /// but isn't exported in this property for security reasons. /// /// For entries of type `fstab`, it means that the block device is referenced in the system-wide `/etc/fstab` file. /// Known configuration items for type `fstab` are: //TODO: link to zbus types /// - `fsname` (type `ay`): The special device /// - `dir` (type `ay`): The mount point /// - `type` (type `ay`): The filesystem point /// - `opts` (type `ay`): Options /// - `freq` (type `i`): Dump frequency in days /// - `passno` (type `i`): Pass number of parallel `fsck` /// /// For entries of type `crypttab`, it means that the block device is referenced in the system-wide `/etc/crypttab` file. /// Known configuration items for type crypttab are: /// - `name` (type `ay`): The name to set the device up as /// - `device` (type `ay`): The special device /// - `passphrase-path` (type `ay`): Either empty to specify that no password is set, otherwise a path to a file containing the encryption password. /// This may also point to a special device file in `/dev` such as `/dev/random`. /// - `passphrase-contents` (type `ay`): The contents of the file containing the encryption password, if applicable. This is only available via the [`Self::get_secret_configuration`] method. /// - `options` (type `ay`): Options /// /// For security reasons, when creating a new `crypttab` entry (via the [`Self::add_configuration_item`] method), then the `passphrase-path` /// must reference an unexisting file in the `/etc/luks-keys` directory. #[zbus(property)] fn configuration( &self, ) -> error::Result< Vec<( String, std::collections::HashMap, )>, >; /// The [org.freedesktop.UDisks2.Block](crate::block) object that is backing the device /// or `/` if unknown or if the block device is not the cleartext device for an encrypted device. #[zbus(property)] fn crypto_backing_device(&self) -> error::Result; ///The special device file for the block device e.g. `/dev/sda2`. #[zbus(property)] fn device(&self) -> error::Result>; /// The `dev_t` of the block device. #[zbus(property)] fn device_number(&self) -> error::Result; /// The [`org.freedesktop.UDisks2.Drive `](crate::drive) object that the block device belongs to. /// Returns '/' if no such object exists. #[zbus(property)] fn drive(&self) -> error::Result; /// Whether the device should be automatically started (e.g. mounted, unlocked etc.). /// /// See [udisks(8)](https://storaged.org/doc/udisks2-api/latest/udisks.8.html) for how to influence the value of this property. #[zbus(property)] fn hint_auto(&self) -> error::Result; /// If not blank, the icon name to use when presenting the device. /// /// The name must adhere to the [freedesktop.org icon theme specification](http://www.freedesktop.org/wiki/Specifications/icon-theme-spec). /// /// See [udisks(8)](https://storaged.org/doc/udisks2-api/latest/udisks.8.html) for how to influence the value of this property. #[zbus(property)] fn hint_icon_name(&self) -> error::Result; /// Whether the device should be hidden from users. /// /// See [udisks(8)](https://storaged.org/doc/udisks2-api/latest/udisks.8.html) for how to influence the value of this property. #[zbus(property)] fn hint_ignore(&self) -> error::Result; ///If not blank, the name to use when presenting the device. /// /// See [udisks(8)](https://storaged.org/doc/udisks2-api/latest/udisks.8.html) for how to influence the value of this property. //TODO: is it possible to use NONE instead of a blank string #[zbus(property)] fn hint_name(&self) -> error::Result; /// Whether the device is normally expected to be partitionable. /// Devices for which this is not the case include floppy drives, optical drives and LVM logical volumes. #[zbus(property)] fn hint_partitionable(&self) -> error::Result; /// If not blank, the icon name to use when presenting the device using a symbolic icon. /// /// The name must adhere to the [freedesktop.org icon theme specification](http://www.freedesktop.org/wiki/Specifications/icon-theme-spec). /// /// See [udisks(8)](https://storaged.org/doc/udisks2-api/latest/udisks.8.html) for how to influence the value of this property. #[zbus(property)] fn hint_symbolic_icon_name(&self) -> error::Result; /// Whether the device is considered a system device. /// System devices are devices that require additional permissions to access. /// /// See [udisks(8)](https://storaged.org/doc/udisks2-api/latest/udisks.8.html) for how to influence the value of this property. #[zbus(property)] fn hint_system(&self) -> error::Result; /// A unique and persistent identifier for the device. /// Empty if no such identifier is available. /// /// For devices with fixed media, this identifier is derived from vital product data / UUIDs / serial numbers /// of the drive or construct (e.g. LVM or MD-RAID) the block device is part of. /// For devices with removable media, this identifier is derived from the medium currently inserted. /// This identifier is guaranteed to not include the slash character '/' (U+002F SOLIDUS) which means it /// can be used as a filename. /// /// # Examples /// /// * `by-id-ata-INTEL_SSDSA2MH080G1GC_CVEM842101HD080DGN` /// * `by-id-ata-ST1000LM024_HN-M101MBB_S2TBJA0C230233-part3` /// * `by-id-usb-Kingston_DataTraveler_2.0_0013729940C4F9A166250D3E-0:0` /// * `by-id-dm-name-luks-6d81fe85-26b1-4f8b-b834-405454c1cd46` /// * `by-id-dm-name-vg_thinkpad-lv_swap` /// * `by-label-HARRY_POTTER_SORCERERS_STONE-` /// * `by-uuid-D22D-08B8` #[zbus(property)] fn id(&self) -> error::Result; /// The label of the filesystem or other structured data on the block device. /// /// Returns an empty string if there is no label or the label is unknown. #[zbus(property)] fn id_label(&self) -> error::Result; /// This property contains more information about the result of probing the block device. /// /// The value depends of the value of [`Self::id_usage`]: /// /// * `filesystem`: The mountable file system that was detected (e.g. `vfat`). /// * `crypto`: Encrypted data. Known values include `crypto_LUKS`. /// * `raid`: RAID or similar. Known values include `LVM2_member` (for LVM2 components), /// `linux_raid_member` (for MD-RAID components.) /// * `other`: Something else. Known values include `swap` (for swap space), /// `suspend` (data used when resuming from suspend-to-disk). /// /// See the note for the "IdUsage" property about usage. //TODO: what? #[zbus(property)] fn id_type(&self) -> error::Result; /// The [UUID](https://en.wikipedia.org/wiki/UUID) of the filesystem or other structured data on the block device. /// Do not make any assumptions about the UUID as its format depends on what kind of data is on the device. /// /// Returns an empty string if there is no label or the label is unknown. #[zbus(property, name = "IdUUID")] fn id_uuid(&self) -> error::Result; /// A result of probing for signatures on the block device. Known values include: /// /// * `filesystem`: Used for mountable filesystems /// * `crypto`: Used for e.g. LUKS devices /// * `raid`: Used for e.g. RAID members and LVM PVs /// * `other`: Something else was detected. /// /// If blank, no known signature was detected. This doesn't necessarily mean the device contains no /// structured data; it only means that no signature known to the probing code was detected. /// /// Applications should not rely on the value, or the value of [`Self::id_type`] /// - instead, applications should check for whether the object in question implements interfaces /// such as e.g. [`org.freedesktop.UDisks2.Filesystem`](crate::filesystem), /// [`org.freedesktop.UDisks2.Swapspace`](crate::swapspace) or [`org.freedesktop.UDisks2.Encrypted`](crate::encrypted). //TODO: use enum #[zbus(property)] fn id_usage(&self) -> error::Result; /// The version of the filesystem or other structured data on the block device. /// Do not make any assumptions about the format. /// /// Returns an empty string if there is no version or the version is unknown. #[zbus(property)] fn id_version(&self) -> error::Result; /// If the block device is a running MD-RAID array, /// this is set to the [`org.freedesktop.UDisks2.MDRaid`](crate::mdraid) object that it correspond to. /// Returns '/' if no such object exists. #[zbus(property, name = "MDRaid")] fn mdraid(&self) -> error::Result; /// If the block device is a member of a MD-RAID array, /// this is set to the [`org.freedesktop.UDisks2.MDRaid`](crate::mdraid) object that it correspond to. /// Returns '/' if no such object exists. #[zbus(property, name = "MDRaidMember")] fn mdraid_member(&self) -> error::Result; //TODO: a lot of functions return Strings as c type strings (i.e. vec of u8 with \0 bytes) //they should be updated to return rust strings /// The special device file to present in the UI instead of the value of the [`Self::device`] property. /// /// For example this could be e.g. `/dev/mapper/mpathk` for a multipath device with special /// device file `/dev/dm-9`. #[zbus(property)] fn preferred_device(&self) -> error::Result>; /// If `true`, the device can not be written to, only read from. #[zbus(property)] fn read_only(&self) -> error::Result; /// The size of the block device. #[zbus(property)] fn size(&self) -> error::Result; /// Known symlinks in `/dev` that points to the device file in the "Device" property. /// /// For example, this array could include symlinks such as `/dev/disk/by-id/ata-INTEL_SSDSA2MH080G1GC_CVEM842101HD080DGN` /// and `/dev/disk/by-id/wwn-0x5001517387d61905`. #[zbus(property)] fn symlinks(&self) -> error::Result>>; /// List of userspace mount options. #[zbus(property)] fn userspace_mount_options(&self) -> error::Result>; } udisks2-0.3.1/src/client.rs000064400000000000000000001151461046102023000136340ustar 00000000000000use gettextrs::pgettext; use zbus::{fdo::ObjectManagerProxy, zvariant::OwnedObjectPath}; use crate::{ block::{self, BlockProxy}, drive, error, gettext::{dpgettext, pgettext_f}, id::ID_TYPES, job, manager, mdraid, object::Object, object_info::ObjectInfo, partition, partition_subtypes, partition_types::{self, PartitionTypeInfo, PARTITION_TYPES}, partitiontable, r#loop, }; const KILOBYTE_FACTOR: f64 = 1000.0; const MEGABYTE_FACTOR: f64 = 1000.0 * 1000.0; const GIGABYTE_FACTOR: f64 = 1000.0 * 1000.0 * 1000.0; const TERABYTE_FACTOR: f64 = 1000.0 * 1000.0 * 1000.0 * 1000.0; const KIBIBYTE_FACTOR: f64 = 1024.0; const MEBIBYTE_FACTOR: f64 = 1024.0 * 1024.0; const GIBIBYTE_FACTOR: f64 = 1024.0 * 1024.0 * 1024.0; const TEBIBYTE_FACTOR: f64 = 1024.0 * 1024.0 * 1024.0 * 10242.0; /// Utility routines for accessing the UDisks service. /// /// It should be used for accessing the UDisks service from a client program. #[derive(Debug, Clone)] pub struct Client { connection: zbus::Connection, object_manager: zbus::fdo::ObjectManagerProxy<'static>, manager: manager::ManagerProxy<'static>, } impl Client { /// Create a new client. pub async fn new() -> error::Result { let connection = zbus::Connection::system().await?; Self::new_for_connection(connection).await } /// Creates a new client based on the given [`zbus::Connection`]. pub async fn new_for_connection(connection: zbus::Connection) -> error::Result { let object_manager = ObjectManagerProxy::builder(&connection) .destination("org.freedesktop.UDisks2")? .path("/org/freedesktop/UDisks2")? .build() .await?; let manager = manager::ManagerProxy::new(&connection).await?; Ok(Self { connection, object_manager, manager, }) } /// Returns the [`zbus::fdo::ObjectManagerProxy`] used by the [Client]. pub fn object_manager(&self) -> &zbus::fdo::ObjectManagerProxy<'_> { &self.object_manager } /// Returns a reference to the manager interface. pub fn manager(&self) -> &manager::ManagerProxy<'_> { &self.manager } /// Convenience function for looking up an [Object] for `object_path`. /// /// # Errors /// Returns an error if the given object path cannot be converted to an [zbus::zvariant::OwnedObjectPath] pub fn object>(&self, object_path: P) -> Result { let path = object_path.try_into()?; Ok(Object::new( path, self.object_manager.clone(), self.connection.clone(), )) } /// Gets all the [`job::JobProxy`] instances for the given object. /// /// If no instances are found, the returned vector is empty. pub async fn jobs_for_object(&self, object: &Object) -> Vec { //TODO: maybe this should be moved to object directly? let object_path = object.object_path(); let mut blocks = Vec::new(); for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(job) = object.job().await else { continue; }; blocks.extend( job.objects() .await .into_iter() .flatten() .filter(|job_object_path| job_object_path == object_path), ); } blocks } /// Gets a human-readable and localized text string describing the operation of job. /// /// For known job types, see the documentation for [`job::JobProxy::operation`]. pub fn job_description_from_operation(&self, operation: &str) -> String { match operation { "ata-smart-selftest" => pgettext("job", "SMART self-test"), "drive-eject" => pgettext("job", "Ejecting Medium"), "encrypted-unlock" => pgettext("job", "Unlocking Device"), "encrypted-lock" => pgettext("job", "Locking Device"), "encrypted-modify" => pgettext("job", "Modifying Encrypted Device"), "encrypted-resize" => pgettext("job", "Resizing Encrypted Device"), "swapspace-start" => pgettext("job", "Starting Swap Device"), "swapspace-stop" => pgettext("job", "Stopping Swap Device"), "swapspace-modify" => pgettext("job", "Modifying Swap Device"), "filesystem-check" => pgettext("job", "Checking Filesystem"), "filesystem-mount" => pgettext("job", "Mounting Filesystem"), "filesystem-unmount" => pgettext("job", "Unmounting Filesystem"), "filesystem-modify" => pgettext("job", "Modifying Filesystem"), "filesystem-repair" => pgettext("job", "Repairing Filesystem"), "filesystem-resize" => pgettext("job", "Resizing Filesystem"), "format-erase" => pgettext("job", "Erasing Device"), "format-mkfs" => pgettext("job", "Creating Filesystem"), "loop-setup" => pgettext("job", "Setting Up Loop Device"), "partition-modify" => pgettext("job", "Modifying Partition"), "partition-delete" => pgettext("job", "Deleting Partition"), "partition-create" => pgettext("job", "Creating Partition"), "cleanup" => pgettext("job", "Cleaning Up"), "ata-secure-erase" => pgettext("job", "ATA Secure Erase"), "ata-enhanced-secure-erase" => pgettext("job", "ATA Enhanced Secure Erase"), "md-raid-stop" => pgettext("job", "Stopping RAID Array"), "md-raid-start" => pgettext("job", "Starting RAID Array"), "md-raid-fault-device" => pgettext("job", "Marking Device as Faulty"), "md-raid-remove-device" => pgettext("job", "Removing Device from Array"), "md-raid-add-device" => pgettext("job", "Adding Device to Array"), "md-raid-set-bitmap" => pgettext("job", "Setting Write-Intent Bitmap"), "md-raid-create" => pgettext("job", "Creating RAID Array"), _ => pgettext_f("unknown-job", "Unknown ({})", [operation]), } } /// Gets a human-readable and localized text string describing the operation of job. /// /// For known job types, see the documentation for [`job::JobProxy::operation`]. pub async fn job_description(&self, job: &job::JobProxy<'_>) -> error::Result { Ok(self.job_description_from_operation(&job.operation().await?)) } /// Gets the [`block::BlockProxy`] for the given `block_device_number`. /// /// If no block is found, [`None`] is returned, pub async fn block_for_dev(&self, block_device_number: u64) -> Option { for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(block) = object.block().await else { continue; }; if Ok(block_device_number) == block.device_number().await { return Some(block); } } None } /// Gets all the [`block::BlockProxy`] instances with the given label. /// /// If no instances are found, the returned vector is empty. pub async fn block_for_label(&self, label: &str) -> Vec { //TODO refactor once it is possible to use iterators with async let mut blocks = Vec::new(); for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(block) = object.block().await else { continue; }; if Ok(label) == block.id_label().await.as_deref() { blocks.push(block); } } blocks } /// Gets all the [`block::BlockProxy`]s for the given `uuid`. /// /// If no blocks are found, the returned vector is empty. pub async fn block_for_uuid(&self, uuid: &str) -> Vec { let mut blocks = Vec::new(); for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(block) = object.block().await else { continue; }; if Ok(uuid) == block.id_uuid().await.as_deref() { blocks.push(block); } } blocks } /// Returns all top-level [`Object`]s for the given drive. /// /// Top-level blocks are blocks that do not have a partition associated with it. async fn top_level_blocks_for_drive(&self, drive_object_path: &OwnedObjectPath) -> Vec { let mut blocks = Vec::new(); for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(block) = object.block().await else { continue; }; if block.drive().await.as_deref() == Ok(drive_object_path) && object.partition().await.is_err() { blocks.push(object); } } blocks } /// Gets the [`block::BlockProxy`], if exists, for the given [`drive::DriveProxy`] /// /// The returned block is for the whole disk drive, so [`partition::PartitionProxy`] is never /// returned. /// /// If `physical` is set to true, a block that is able to send low-level SCSI commands is /// returned. If `physical` is set to false, a block device that can read/write data is /// returned. pub async fn block_for_drive( &self, drive: &drive::DriveProxy<'_>, _physical: bool, ) -> Option { let object = self.object(drive.inner().path().clone()).ok()?; for object in self .top_level_blocks_for_drive(object.object_path()) .await .iter() { if let Ok(block) = object.block().await { return Some(block); }; } None } /// Gets the [`drive::DriveProxy`] for the given [`block::BlockProxy`], if any. /// /// # Errors /// If no drive is found, [`zbus::Error::InterfaceNotFound`] is returned. pub async fn drive_for_block( &self, block: &block::BlockProxy<'_>, ) -> error::Result> { let drive = block.drive().await?; self.object(drive)?.drive().await } /// If the given [`block::BlockProxy`] is an encrypted device, returns the cleartext device. /// /// If no block is found, [`None`] is returned. pub async fn cleartext_block( &self, block: &block::BlockProxy<'_>, ) -> Option> { let object_path = block.inner().path().to_owned().into(); for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(block) = object.block().await else { continue; }; if block.crypto_backing_device().await.as_ref() == Ok(&object_path) { return Some(block); } } None } /// Returns the [`partitiontable::PartitionTableProxy`] for the given partition. /// /// # Errors /// Returns an error if it is unable to get the table or the [`Object`] for the table. pub async fn partition_table( &self, partition: &partition::PartitionProxy<'_>, ) -> error::Result> { self.object(partition.table().await?)? .partition_table() .await } /// Returns the [`loop::LoopProxy`] for the given [`block::BlockProxy`]. /// /// This only works if the block is a loop device, or a partition of a loop device. /// /// # Errors /// Returns an error if it is unable to get the loop interface. pub async fn loop_for_block( &self, block: &block::BlockProxy<'_>, ) -> error::Result { let object = self.object(block.inner().path().clone())?; if let Ok(loop_proxy) = object.r#loop().await { return Ok(loop_proxy); } // possibly partition of a loop device let partition = object.partition().await?; let partitiontable = self.partition_table(&partition).await?; let partitiontable_object = self.object(partitiontable.inner().path().clone())?; partitiontable_object.r#loop().await } /// Returns all [`partition::PartitionProxy`] of the given [`partitiontable::PartitionTableProxy`]. pub async fn partitions( &self, table: &partitiontable::PartitionTableProxy<'_>, ) -> Vec> { let mut partitions = Vec::new(); // safe to unwrap as the table's object path does not need to be converted let table_object = self.object(table.inner().path().clone()).unwrap(); let table_object_path = table_object.object_path(); for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(partition) = object.partition().await else { continue; }; if partition.table().await.as_ref() == Ok(table_object_path) { partitions.push(partition); } } partitions } /// Returns all [`partition::PartitionProxy`] of the given [`partitiontable::PartitionTableProxy`]. pub async fn drive_siblings( &self, drive: &drive::DriveProxy<'_>, ) -> Vec> { let mut drive_siblings = Vec::new(); let sibling_id = drive.sibling_id().await; if sibling_id.is_err() || sibling_id.as_ref().unwrap().is_empty() { return drive_siblings; } for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(iter_drive) = object.drive().await else { continue; }; if // TODO: C version checks if we're the same drive // rust version doesn't implement partial_cmp // iter_drive != drive && iter_drive.sibling_id().await.as_ref() == sibling_id.as_ref() { drive_siblings.push(iter_drive); } } drive_siblings } async fn block_or_blocks_for_mdraid( &self, mdraid: &mdraid::MDRaidProxy<'_>, //TODO: pass in a function // member_get: impl Fn(&block::BlockProxy<'a>) -> Future> + 'a, members: bool, only_first_one: bool, skip_partitions: bool, ) -> Vec { let mut blocks = Vec::new(); // safe to unwrap as the table's object path does not need to be converted let raid_object = self.object(mdraid.inner().path().clone()).unwrap(); let raid_objpath = raid_object.object_path(); for object in self .object_manager .get_managed_objects() .await .into_iter() .flatten() .filter_map(|(object_path, _)| self.object(object_path).ok()) { let Ok(block) = object.block().await else { continue; }; // skip partitions if skip_partitions && object.partition().await.is_ok() { continue; } // if member_get(&block).await.as_ref() == Ok(raid_objpath) { let block_objpath = if members { block.mdraid().await } else { block.mdraid_member().await }; if block_objpath.as_ref() == Ok(raid_objpath) { blocks.push(block); if only_first_one { break; } } } blocks } /// Returns the RAID device (e.g. `/dev/md0`) for the given mdraid. /// /// In the case of a [split-brain syndrome](https://en.wikipedia.org/wiki/Split-brain_(computing)), /// it is undefined which RAID device is returned. For example this can happen if `/dev/sda` and `/dev/sdb` /// are components of a two-disk RAID-1 and `/dev/md0` and `/dev/md1` are two degraded arrays, /// each one using exactly one of the two devices. Use [`Client::all_blocks_for_mdraid`] to get all RAID devices. /// /// If no RAID device is running, [`Option::None`] is returned. pub async fn block_for_mdraid( &self, mdraid: &mdraid::MDRaidProxy<'_>, ) -> Option> { self.block_or_blocks_for_mdraid(mdraid, false, true, true) .await .first() .cloned() } /// Returns all RAID devices (e.g. `/dev/md0` and `/dev/md1`) for the given mdraid. /// /// This is usually only useful [split-brain syndrome](https://en.wikipedia.org/wiki/Split-brain_(computing)), /// and is normally used only to convey the problem in an user interface. See [`Client::block_for_mdraid`] for an example. pub async fn all_blocks_for_mdraid( &self, mdraid: &mdraid::MDRaidProxy<'_>, ) -> Vec> { self.block_or_blocks_for_mdraid(mdraid, false, false, true) .await } /// returns the physical block devices that are part of the given raid. pub async fn members_for_mdraid( &self, mdraid: &mdraid::MDRaidProxy<'_>, ) -> Vec> { self.block_or_blocks_for_mdraid(mdraid, true, false, false) .await } /// Returns the [`mdraid::MDRaidProxy`] that the given block is the block device for. /// /// # Errors /// Returns an error if no [`mdraid::MDRaidProxy`] for the block is found, or the block is not /// a MD-RAID block device. pub async fn mdraid_for_block( &self, block: &block::BlockProxy<'_>, ) -> error::Result> { let object = self.object(block.mdraid().await?)?; object.mdraid().await } /// Returns information about the given object for presentation in a user information. /// /// The returned information is localized. pub async fn object_info<'a>(&self, object: &'a Object) -> ObjectInfo<'a> { let mut object_info = ObjectInfo::new(object); //populate object_info if let Ok(drive) = object.drive().await { object_info.info_for_drive(self, &drive, None).await; } else if let Ok(mdraid) = object.mdraid().await { object_info.info_for_mdraid(self, mdraid, None).await; } else if let Ok(block) = object.block().await { let partition = object.partition().await; let drive = self.drive_for_block(&block); if let Ok(drive) = drive.await { object_info .info_for_drive(self, &drive, partition.ok()) .await; return object_info; } let mdraid = self.mdraid_for_block(&block); if let Ok(mdraid) = mdraid.await { object_info .info_for_mdraid(self, mdraid, partition.ok()) .await; return object_info; } if let Ok(loop_proxy) = object.r#loop().await { object_info .info_for_loop(self, loop_proxy, block, partition.ok()) .await; } else { object_info .info_for_block(self, block, partition.ok()) .await; } } object_info } /// Returns informating about the given partition that is suitable for presentation in an user /// interface in a single line of text. /// /// The returned string is localized and includes things like the partition type, flags (if /// any) and name (if any). /// /// # Errors /// Returns an errors if it fails to read any of the aforementioned information. pub async fn partition_info( &self, partition: &partition::PartitionProxy<'_>, ) -> error::Result { let flags = partition.flags().await?; let table = self.partition_table(partition).await?; let mut flags_str = String::new(); match table.type_().await.as_deref() { Ok("dos") if flags.contains(partition::PartitionFlags::Bootable) => { // Translators: Corresponds to the DOS/Master-Boot-Record "bootable" flag for a partition flags_str.push_str(&format!(", {}", pgettext("dos-part-flag", "Bootable"))) } Ok("gpt") => { let flag_map = [ ( partition::PartitionFlags::SystemPartition, // Translators: Corresponds to the GPT "system" flag for a partition, // see http://en.wikipedia.org/wiki/GUID_Partition_Table pgettext("gpt-part-flag", "System"), ), ( partition::PartitionFlags::LegacyBIOSBootable, // Translators: Corresponds to the GPT "legacy bios bootable" flag for a partition, // see http://en.wikipedia.org/wiki/GUID_Partition_Table pgettext("gpt-part-flag", "Legacy BIOS Bootable"), ), ( partition::PartitionFlags::ReadOnly, // Translators: Corresponds to the GPT "read-only" flag for a partition, // see http://en.wikipedia.org/wiki/GUID_Partition_Table pgettext("gpt-part-flag", "Read-only"), ), ( partition::PartitionFlags::Hidden, // Translators: Corresponds to the GPT "hidden" flag for a partition, // see http://en.wikipedia.org/wiki/GUID_Partition_Table pgettext("gpt-part-flag", "Hidden"), ), ( partition::PartitionFlags::NoAutoMount, // Translators: Corresponds to the GPT "no automount" flag for a partition, // see http://en.wikipedia.org/wiki/GUID_Partition_Table pgettext("gpt-part-flag", "No Automaount"), ), ]; for (flag, info) in flag_map { if flags.contains(flag) { flags_str.push_str(&format!(", {}", info)); } } } _ => {} }; let type_str = match self .partition_type_for_display(&table.type_().await?, &partition.type_().await?) { Some(val) => val.to_owned(), _ => partition.type_().await?, }; let partition_info; if !flags_str.is_empty() { // Translators: Partition info. First {} is the type, second {} is a list of flags partition_info = pgettext_f("partition-info", "{} ({})", [type_str, flags_str]) } else if type_str.is_empty() { // Translators: The Partition info when unknown partition_info = pgettext("partition-info", "Unknown") } else { partition_info = type_str; } Ok(partition_info) } fn pow2_size(&self, size: u64) -> String { //TODO: refactor let size = size as f64; let display_size; let unit; if size < MEBIBYTE_FACTOR { display_size = size / KIBIBYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow2", "KiB"); } else if size < GIBIBYTE_FACTOR { display_size = size / MEBIBYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow2", "MiB"); } else if size < TEBIBYTE_FACTOR { display_size = size / GIBIBYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow2", "GiB"); } else { display_size = size / TEBIBYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow2", "TiB"); } let digits = if display_size < 10.0 { 1 } else { 0 }; format!("{:.digits$} {}", display_size, unit) } fn pow10_size(&self, size: u64) -> String { let size = size as f64; let display_size; let unit; if size < MEGABYTE_FACTOR { display_size = size / KILOBYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow10", "KB"); } else if size < GIGABYTE_FACTOR { display_size = size / MEGABYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow10", "MB"); } else if size < TERABYTE_FACTOR { display_size = size / GIGABYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow10", "GB"); } else { display_size = size / TERABYTE_FACTOR; /* Translators: SI prefix and standard unit symbol, translate cautiously (or not at all) */ unit = pgettext("byte-size-pow10", "TB"); } let digits = if display_size < 10.0 { 1 } else { 0 }; format!("{:.digits$} {}", display_size, unit) } /// Utility function to get a human-readable string that represents the given size. /// /// When `use_pow2` is set to true power-of-two units are used instead of power-of-ten /// units. /// Set `long_str` to true, to produce a long string. pub fn size_for_display(&self, size: u64, use_pow2: bool, long_str: bool) -> String { let pow_size = if use_pow2 { self.pow2_size(size) } else { self.pow10_size(size) }; if !long_str { return pow_size; } if use_pow2 { // Translators: The first %s is the size in power-of-2 units, e.g. '64 KiB' // the second %s is the size as a number e.g. '65,536' (always > 1) pgettext_f( "byte-size-pow2", "{} ({} bytes)", [pow_size, size.to_string()], ) } else { // Translators: The first %s is the size in power-of-10 units, e.g. '100 kB' // the second %s is the size as a number e.g. '100,000' (always > 1) pgettext_f( "byte-size-pow10", "{} ({} bytes)", [pow_size, size.to_string()], ) } } /// Returns a human readable localized string for `usage`, `type` and `version`. pub fn id_for_display(&self, usage: &str, ty: &str, version: &str, long_str: bool) -> String { ID_TYPES .iter() .filter(|id| id.usage == usage && id.ty == ty) .find_map(|id| { if id.version.is_none() && version.is_empty() { return Some(if long_str { dpgettext("fs-type", id.long_name) } else { dpgettext("fs-type", id.short_name) }); } else if !version.is_empty() && (id.version == Some(version) || id.version == Some("*")) { return Some(if long_str { dpgettext("fs-type", id.long_name).replace("%s", version) } else { dpgettext("fs-type", id.short_name).replace("%s", version) }); } None }) .unwrap_or_else(|| { let id_type; if long_str { if !version.is_empty() { // Translators: Shown for unknown filesystem types. // First %s is the raw filesystem type obtained from udev, second %s is version. id_type = pgettext_f("fs-type", "Unknown ({} {})", [ty, version]); } else if !ty.is_empty() { // Translators: Shown for unknown filesystem types. // First %s is the raw filesystem type obtained from udev. id_type = pgettext_f("fs-type", "Unknown ({})", [ty]); } else { // Translators: Shown for unknown filesystem types. id_type = pgettext("fs-type", "Unknown"); } } else if !ty.is_empty() { id_type = ty.to_string(); } else { // Translators: Shown for unknown filesystem types. id_type = pgettext("fs-type", "Unknown"); } id_type }) } /// Returns a human-readable, localized string of the media described by the given `media_compat`. /// /// If the media is unknown, [`Option::None`] is returned. pub fn media_compat_for_display(&self, media_compat: &[&str]) -> Option { let mut optical_cd = false; let mut optical_dvd = false; let mut optical_bd = false; let mut optical_hddvd = false; let mut media_desc: String = media_compat .iter() .filter_map(|&media| match media { "flash_cf" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "CompactFlash")) } "flash_ms" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "MemoryStick")) } "flash_sm" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "SmartMedia")) } "flash_sd" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "SecureDigital")) } "flash_sdhc" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "SD High Capacity")) } "floppy" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "Floppy")) } "floppy_zip" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "Zip")) } "floppy_jaz" => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "Jaz")) } val if val.starts_with("flash") => { // Translators: This word is used to describe the media inserted into a device Some(pgettext("media", "Flash")) } val => { if val.starts_with("optical_cd") { optical_cd = true; } else if val.starts_with("optical_dvd") { optical_dvd = true; } else if val.starts_with("optical_bd") { optical_bd = true; } else if val.starts_with("optical_hddvd") { optical_hddvd = true; } None } }) //TODO: replace with intersperse .collect::>() .join(","); let add_separator = |str: &mut String| { if !str.is_empty() { str.push('/'); } }; if optical_cd { add_separator(&mut media_desc); //Translators: This word is used to describe the optical disc type, it may appear // in a slash-separated list e.g. 'CD/DVD/Blu-Ray' media_desc.push_str(&pgettext("disc-type", "CD")); } if optical_dvd { add_separator(&mut media_desc); //Translators: This word is used to describe the optical disc type, it may appear // in a slash-separated list e.g. 'CD/DVD/Blu-Ray' media_desc.push_str(&pgettext("disc-type", "DVD")); } if optical_bd { add_separator(&mut media_desc); //Translators: This word is used to describe the optical disc type, it may appear // in a slash-separated list e.g. 'CD/DVD/Blu-Ray' media_desc.push_str(&pgettext("disc-type", "Blu-Ray")); } if optical_hddvd { add_separator(&mut media_desc); //Translators: This word is used to describe the optical disc type, it may appear // in a slash-separated list e.g. 'CD/DVD/Blu-Ray' media_desc.push_str(&pgettext("disc-type", "HDDVD")); } //return none, if the string is empty, to clearly indicate that the media is unknown //it is also closer to the C API if media_desc.is_empty() { None } else { Some(media_desc) } } /// Returns information about all known partition types for `partition_table_type` (e.g. `dos` or `gpt`) and `partition_table_subtype`. /// /// If `partition_table_subtype` is [`None`], it is equivalent to all known types. pub fn partition_type_infos( &self, partition_table_type: &str, partition_table_subtype: Option<&str>, ) -> Vec<&PartitionTypeInfo> { //TODO: use enum for table type? //TODO: C version uses a custom type, which appears to be the same as `PartitionTypeInfo`, //but without the name //https://github.com/storaged-project/udisks/blob/4f24c900383d3dc28022f62cab3eb434d19b6b82/udisks/udisksclient.c#L2604 PARTITION_TYPES .iter() .filter(|pti| { pti.table_type == partition_table_type && (partition_table_subtype.is_none() || Some(pti.table_subtype) == partition_table_subtype) }) .collect() } /// Returns information about all known subtypes for `partition_table_type` (e.g. `dos` or `gpt`) and `partition_table_subtype`. pub fn partition_table_subtypes(&self, partition_table_type: &str) -> Vec<&str> { partition_subtypes::PARTITION_TABLE_SUBTYPES .iter() .filter(|pt| pt.ty == partition_table_type) .map(|pt| pt.subtype) .collect() } /// Returns, if exists, the human-readable localized name of the [PartitionTypeInfo]. pub fn partition_type_for_display( &self, partition_table_type: &str, partition_type: &str, ) -> Option { partition_types::PARTITION_TYPES .iter() .find(|pt| pt.table_type == partition_table_type && pt.ty == partition_type) .map(|partition_type| dpgettext("part-type", partition_type.name)) } /// Returns, if existing, the human-readable localized name of the [`PartitionTypeInfo`]. /// /// It is similar to [`Client::partition_type_for_display`], but also accounts for the `partition_table_subtype`, if available. /// This can be useful for scenarios, where different subtypes are using the same partition /// type. pub fn partition_type_and_subtype_for_display( &self, partition_table_type: &str, partition_table_subtype: &str, partition_type: &str, ) -> Option { PARTITION_TYPES .iter() .filter(|pt| pt.table_type == partition_table_type && pt.ty == partition_type) .filter(|pt| partition_table_subtype == pt.table_subtype) .map(|pt| dpgettext("part-type", pt.name)) .next() } /// Returns, if exists, the human-readable localized string for `partition_table_type` (e.g. /// `dos` or `gpt`). pub fn partition_table_type_for_display(&self, partition_table_type: &str) -> Option { //TODO: use enum [ // Translators: name of partition table format ("dos", pgettext("dos", "Master Boot Record")), // Translators: name of partition table format ("gpt", pgettext("gpt", "GUID Partition Table")), // Translators: name of partition table format ("apm", pgettext("apm", "Apple Partition Map")), ] .iter() .find(|(ty, _)| ty == &partition_table_type) .map(|(_, name)| name.to_string()) } /// Returns a human-readable localized description for `partition_table_type` (e.g. `dos` or `gpt`) /// and `partition_table_subtype` (e.g. `dos` or `gpt`). pub fn partition_table_subtype_for_display( &self, partition_table_type: &str, partition_table_subtype: &str, ) -> Option { //TODO: C version docs for subtype and type are identical, bug? partition_subtypes::PARTITION_TABLE_SUBTYPES .iter() .find(|pt| pt.ty == partition_table_type && pt.subtype == partition_table_subtype) .map(|pt| dpgettext("partition-subtype", pt.name)) } } udisks2-0.3.1/src/drive.rs000064400000000000000000000323451046102023000134660ustar 00000000000000//! Interface to represent both hard disks and disk drives //! (with or without removable media). //! //! This interface should not to be confused with the `org.freedesktop.UDisks2.Block` //! interface that is used for low-level block devices the OS knows about. //! For example, if `/dev/sda` and `/dev/sdb` are block devices for two paths //! to the same drive, there will be only one `org.freedesktop.UDisks2.Drive` //! object but two `org.freedesktop.UDisks2.Block` objects. use std::str::FromStr; use serde::{de::IntoDeserializer, Deserialize, Serialize}; use zbus::{ proxy, zvariant::{OwnedValue, Type, Value}, }; use crate::error; /// Rotational rate of a drive. #[derive(Debug, Default, PartialEq, Eq)] pub enum RotationRate { /// The drive is known to be rotating media but rotation rate isn't known. Unknown, /// The drive is known to be non-rotating media. #[default] NonRotating, /// The rotation rate in rounds per minute. Rotating(i32), } impl TryFrom for RotationRate { type Error = >::Error; fn try_from(v: OwnedValue) -> Result { Ok(match v.try_into()? { -1 => RotationRate::Unknown, 0 => RotationRate::NonRotating, v => RotationRate::Rotating(v), }) } } /// The physical kind of media a drive uses or the type of the drive. #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Eq, Type)] #[zvariant(signature = "s")] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub enum MediaCompatibility { /// The device is a thumb-drive with non-removable media (e.g. a USB stick) Thumb, /// Flash Card Flash, /// CompactFlash FlashCf, /// MemoryStick FlashMs, /// SmartMedia FlashSm, /// Secure Digital FlashSd, /// Secure Digital High Capacity FlashSdhc, /// Secure Digital eXtended Capacity FlashSdxc, /// Secure Digital Input Output FlashSdio, /// Secure Digital Input Output combo card with storage and I/O functionality FlashSdCombo, /// MultiMediaCard FlashMmc, /// Floppy Disk Floppy, /// Zip Disk FloppyZip, /// Jaz Disk FloppyJaz, /// Optical Disc Optical, /// Compact Disc OpticalCd, /// Compact Disc Recordable OpticalCdR, /// Compact Disc Rewritable OpticalCdRw, /// Digital Versatile Disc OpticalDvd, /// DVD-R OpticalDvdR, /// DVD-RW OpticalDvdRw, /// DVD-RAM OpticalDvdRam, /// DVD+R OpticalDvdPlusR, /// DVD+RW OpticalDvdPlusRw, /// DVD+R Dual Layer OpticalDvdPlusRDl, /// DVD+RW Dual Layer OpticalDvdPlusRwDl, /// Blu-ray Disc OpticalBd, /// Blu-ray Recordable OpticalBdR, /// Blu-ray Rewritable OpticalBdRe, /// HD-DVD OpticalHddvd, /// HD-DVD Recordable OpticalHddvdR, /// HD-DVD Rewritable OpticalHddvdRw, /// Magneto Optical OpticalMo, /// Can read Mount Rainer media OpticalMrw, /// Can write Mount Rainer media OpticalMrwW, /// Media is unknown #[serde(rename(deserialize = ""))] // unknow types are blank Unknown, } impl FromStr for MediaCompatibility { type Err = serde::de::value::Error; fn from_str(s: &str) -> Result { let res: Result<_, Self::Err> = Self::deserialize(s.into_deserializer()); Ok(res.unwrap_or(Self::Unknown)) } } //TODO: use macro when this is used for multiple types impl TryFrom> for MediaCompatibility { type Error = >>::Error; fn try_from(value: Value<'_>) -> Result { let val: String = value.downcast_ref()?; Ok(Self::from_str(&val).unwrap_or(Self::Unknown)) } } impl TryFrom for MediaCompatibility { type Error = >::Error; fn try_from(v: OwnedValue) -> Result { Self::try_from(Into::>::into(v)) } } #[proxy( interface = "org.freedesktop.UDisks2.Drive", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Drive" )] pub trait Drive { /// Ejects media from the drive. This is only meaningful to do on drives with removable media. /// There are not a lot of guarantees associated with this method so it should only be called in response to an user action. /// /// On some hardware the media may be physically ejected while on other hardware may simply eject the disc. On some hardware it may not do anything physical but it may cause e.g. a display on the hardware to show e.g. “It is now safe to remove the device”. fn eject( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Arranges for the drive to be safely removed and powered off. /// On the OS side this includes ensuring that no process is using the drive, /// then requesting that in-flight buffers and caches are committed to stable storage. /// The exact steps for powering off the drive depends on the drive itself and the interconnect used. /// For drives connected through USB, the effect is that the USB device will be deconfigured followed by disabling the upstream hub port it is connected to. /// /// Note that as some physical devices contain multiple drives (for example 4-in-1 flash card reader USB devices) powering off one drive may affect other drives. Applications can examine the "SiblingId" property to determine such relationships. /// /// There are not a lot of guarantees associated with this method so it should only be called in response to an user action. Usually the effect is that the drive disappears as if it was unplugged. /// /// This method only works if the [`Self::can_power_off`] property is set to `true`. fn power_off( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Sets the configuration for the drive. /// This will store the configuration in the file-system and also apply it to the drive. /// /// See the [Self::configuration] property for details about valid values and the location of the configuration file that value will be written to. fn set_configuration( &self, value: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Whether the drive can be safely removed / powered off. See the [Self::power_off] function for more information. /// /// See [udisks(8)](http://storaged.org/doc/udisks2-api/latest/udisks.8.html) for how to influence the value of this property. #[zbus(property)] fn can_power_off(&self) -> error::Result; /// Configuration directives that are applied to the drive /// when it's connected (i.e. start-up, hotplug or resume). //TODO: since the confi. are known, use a struct? #[zbus(property)] fn configuration( &self, ) -> error::Result>; /// Physical connection bus used for the drive as seen by the user. /// This is typically used to draw a USB or /// Firewire emblem on top of an icon in an user interface. /// /// Note that this property has _nothing_ to do with the low-level /// command-set used (such as ATA-8) or what low-level connection bus /// (such as SATA, eSATA, PATA, SAS2 etc) is used. #[zbus(property)] fn connection_bus(&self) -> error::Result; /// Whether the media can be ejected from the drive or the drive accepts an eject command to switch its state so it displays e.g. a "Safe To Remove" message to the user. /// /// Note that this is only a _guess_. #[zbus(property)] fn ejectable(&self) -> error::Result; /// Unique and persistent identifier for the device or blank if no identifier is available. /// This identifier is guaranteed to not include the slash character `/` (U+002F SOLIDUS) which means it can be used as a filename. /// /// # Examples /// - `ST32000542AS-6XW00W51` /// - `HITACHI-HTS723232A7A364-E3834563KRG2HN` /// - `INTEL-SSDSA2MH080G1GC-CVEM842101HD080DGN` #[zbus(property)] fn id(&self) -> error::Result; /// Media currently in the drive or black if unknown. #[zbus(property)] fn media(&self) -> error::Result; /// If the medium is available. /// /// Will always be `true` if [`Self::media_change_detected`] is `false` #[zbus(property)] fn media_available(&self) -> error::Result; /// If media changes are detected. /// /// Media changes are detected on all modern disk drives through /// either polling or an asynchronous notification mechanism. /// The only known disk drives that cannot report /// media changes are PC floppy drives. #[zbus(property)] fn media_change_detected(&self) -> error::Result; /// The physical kind of media the drive uses or the type of the drive. /// Blank if unknown. #[zbus(property)] fn media_compatibility(&self) -> error::Result>; /// Hint whether the drive and/or its media is considered removable by the user. /// /// This includes drives with removable media (cf. the [`Self::media_removable`] property), /// Flash media such as SD cards and drives on hotpluggable buses such as USB or Firewire (cf. the [`Self::connection_bus`] property). /// /// Note that this is only a guess. #[zbus(property)] fn media_removable(&self) -> error::Result; /// Name for the model of the drive or blank if unknown. #[zbus(property)] fn model(&self) -> error::Result; /// Whether the drive contains an optical disc. #[zbus(property)] fn optical(&self) -> error::Result; /// Whether the disc is blank. /// /// This is only valid if the property [Self::optical] is true`. #[zbus(property)] fn optical_blank(&self) -> error::Result; /// Number of audio tracks. /// /// This is only valid if the property [Self::optical] is `true`. #[zbus(property)] fn optical_num_audio_tracks(&self) -> error::Result; /// Number of data tracks. /// /// This is only valid if the property [Self::optical] is `true`. #[zbus(property)] fn optical_num_data_tracks(&self) -> error::Result; /// Number of sessions. /// /// This is only valid if the property [Self::optical] is `true`. #[zbus(property)] fn optical_num_sessions(&self) -> error::Result; /// Number of of tracks. /// /// This is only valid if the property [Self::optical] is `true`. #[zbus(property)] fn optical_num_tracks(&self) -> error::Result; /// Hint whether the drive and/or its media is considered removable by the user. /// /// This includes drives with removable media (cf. the [Self::media_removable] property), /// Flash media such as SD cards and drives on hotpluggable buses /// such as USB or Firewire (cf. the [Self::connection_bus] property). /// /// Note that this is only a guess. #[zbus(property)] fn removable(&self) -> error::Result; /// Firmware Revision /// /// Blank if unknown. #[zbus(property)] fn revision(&self) -> error::Result; /// Rotational rate of the drive. #[zbus(property)] fn rotation_rate(&self) -> error::Result; /// String identifying what seat the drive is plugged into, if any. #[zbus(property)] fn seat(&self) -> error::Result; /// Serial number of the drive. /// /// Blank if unknown. #[zbus(property)] fn serial(&self) -> error::Result; /// Opaque token that, if non-blank, /// is used to group drives that are part of the same physical device. #[zbus(property)] fn sibling_id(&self) -> error::Result; /// Size of the drive (or the media currently in the drive). /// /// In case of NVMe this value indicates the total NVM capacity that is accessible by the NVMe controller. /// This is always `0` if [`Self::media_change_detected`] is `false`. #[zbus(property)] fn size(&self) -> error::Result; /// String that can be used for sorting drive objects. #[zbus(property)] fn sort_key(&self) -> error::Result; /// The time the drive was first detected. /// /// This is expressed in micro-seconds since [std::time::UNIX_EPOCH]. #[zbus(property)] fn time_detected(&self) -> error::Result; /// The earliest time media was last detected or 0 if media is not available. /// /// This is expressed in micro-seconds since [std::time::UNIX_EPOCH]. #[zbus(property)] fn time_media_detected(&self) -> error::Result; /// Name for the vendor of the drive or blank if unknown. #[zbus(property)] fn vendor(&self) -> error::Result; /// [World Wide Name](http://en.wikipedia.org/wiki/World_Wide_Name) of the drive or blank if unknown. /// /// In case of NVMe drives please refer to namespace-level WWN properties. #[zbus(property, name = "WWN")] fn wwn(&self) -> error::Result; } udisks2-0.3.1/src/encrypted.rs000064400000000000000000000040011046102023000143360ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Encrypted` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Encrypted", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Encrypted" )] pub trait Encrypted { /// ChangePassphrase method fn change_passphrase( &self, passphrase: &str, new_passphrase: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Lock method fn lock( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Resize method fn resize( &self, size: u64, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Unlock method fn unlock( &self, passphrase: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// ChildConfiguration property #[zbus(property)] fn child_configuration( &self, ) -> error::Result< Vec<( String, std::collections::HashMap, )>, >; /// CleartextDevice property #[zbus(property)] fn cleartext_device(&self) -> error::Result; /// HintEncryptionType property #[zbus(property)] fn hint_encryption_type(&self) -> error::Result; /// MetadataSize property #[zbus(property)] fn metadata_size(&self) -> error::Result; } udisks2-0.3.1/src/error.rs000064400000000000000000000153401046102023000135020ustar 00000000000000use std::{convert::Infallible, fmt::Display}; /// Alias for a `Result` with the error type [`Error`]. pub type Result = std::result::Result; /// The error type for `UDisks2`. /// /// Possible errors and their corresponding D-Bus error names. #[derive(Debug, PartialEq, Clone)] pub enum Error { /// The operation failed. Failed, /// The operation was cancelled. Cancelled, /// The operation has already been cancelled. AlreadyCancelled, /// Not authorized to perform the requested operation. NotAuthorized, /// Like [`Error::NotAuthorized`] but authorization can be obtained through e.g. authentication. NotAuthorizedCanObtain, /// Like [`Error::NotAuthorized`] but an authentication was shown and the user dismissed it. NotAuthorizedDismissed, /// The device is already mounted. AlreadyMounted, /// The device is not mounted. NotMounted, /// Not permitted to use the requested option. OptionNotPermitted, /// The device is mounted by another user. MountedByOtherUser, /// The device is already unmounting. AlreadyUnmounting, /// The operation is not supported due to missing driver/tool support. NotSupported, /// The operation timed out. TimedOut, /// The operation would wake up a disk that is in a deep-sleep state. WouldWakeup, /// Attempting to unmount a device that is busy. DeviceBusy, Iscsi(Iscsi), /// The operation failed due to an [`zbus::Error`]. Zbus(zbus::Error), } #[derive(Debug, PartialEq, Clone)] pub enum Iscsi { DaemonTransportFailed, HostNotFound, Idmb, LoginFailed, LoginAuthFailed, LoginFatal, LogoutFailed, NoFirmware, NoObjectsFound, NotConnected, TransportFailed, UnknownDiscoveryType, } impl std::error::Error for Error {} impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Error::Failed => write!(f, "The operation failed"), Error::Cancelled => write!(f, "The operation was cancelled."), Error::AlreadyCancelled => write!(f, "The operation has already been cancelled."), Error::NotAuthorized => write!(f, "Not authorized to perform the requested operation."), Error::NotAuthorizedCanObtain => write!(f, "Like `Error::NotAuthorized` but authorization can be obtained through e.g. authentication."), Error::NotAuthorizedDismissed => write!(f, "Like `Error::NotAuthorized` but an authentication was shown and the user dismissed it."), Error::AlreadyMounted => write!(f, "The device is already mounted."), Error::NotMounted => write!(f, "The device is not mounted."), Error::OptionNotPermitted => write!(f, "Not permitted to use the requested option."), Error::MountedByOtherUser => write!(f, "The device is mounted by another user."), Error::AlreadyUnmounting => write!(f, "The device is already unmounting."), Error::NotSupported => write!(f, "The operation is not supported due to missing driver/tool support."), Error::TimedOut => write!(f, "The operation timed out."), Error::WouldWakeup => write!(f, "The operation would wake up a disk that is in a deep-sleep state."), Error::DeviceBusy => write!(f, "Attempting to unmount a device that is busy."), Error::Iscsi(_) => write!(f, "An ISCSI error occured."), Error::Zbus(err) => err.fmt(f), } } } impl From for Error { fn from(value: zbus::Error) -> Self { let zbus::Error::MethodError(ref name, ref _msg, ref _info) = value else { return Error::Zbus(value); }; match name.as_str() { "org.freedesktop.UDisks2.Error.Failed" => Error::Failed, "org.freedesktop.UDisks2.Error.Cancelled" => Error::Cancelled, "org.freedesktop.UDisks2.Error.AlreadyCancelled" => Error::AlreadyCancelled, "org.freedesktop.UDisks2.Error.NotAuthorized" => Error::NotAuthorized, "org.freedesktop.UDisks2.Error.NotAuthorizedCanObtain" => Error::NotAuthorizedCanObtain, "org.freedesktop.UDisks2.Error.NotAuthorizedDismissed" => Error::NotAuthorizedDismissed, "org.freedesktop.UDisks2.Error.AlreadyMounted" => Error::AlreadyMounted, "org.freedesktop.UDisks2.Error.NotMounted" => Error::NotMounted, "org.freedesktop.UDisks2.Error.OptionNotPermitted" => Error::OptionNotPermitted, "org.freedesktop.UDisks2.Error.MountedByOtherUser" => Error::MountedByOtherUser, "org.freedesktop.UDisks2.Error.AlreadyUnmounting" => Error::AlreadyUnmounting, "org.freedesktop.UDisks2.Error.NotSupported" => Error::NotSupported, "org.freedesktop.UDisks2.Error.Timedout" => Error::TimedOut, "org.freedesktop.UDisks2.Error.WouldWakeup" => Error::WouldWakeup, "org.freedesktop.UDisks2.Error.DeviceBusy" => Error::DeviceBusy, "org.freedesktop.UDisks2.Error.ISCSI.DaemonTransportFailed" => { Error::Iscsi(Iscsi::DaemonTransportFailed) } "org.freedesktop.UDisks2.Error.ISCSI.HostNotFound" => Error::Iscsi(Iscsi::HostNotFound), "org.freedesktop.UDisks2.Error.ISCSI.IDMB" => Error::Iscsi(Iscsi::Idmb), "org.freedesktop.UDisks2.Error.ISCSI.LoginFailed" => Error::Iscsi(Iscsi::LoginFailed), "org.freedesktop.UDisks2.Error.ISCSI.LoginAuthFailed" => { Error::Iscsi(Iscsi::LoginAuthFailed) } "org.freedesktop.UDisks2.Error.ISCSI.LoginFatal" => Error::Iscsi(Iscsi::LoginFatal), "org.freedesktop.UDisks2.Error.ISCSI.LogoutFailed" => Error::Iscsi(Iscsi::LogoutFailed), "org.freedesktop.UDisks2.Error.ISCSI.NoFirmware" => Error::Iscsi(Iscsi::NoFirmware), "org.freedesktop.UDisks2.Error.ISCSI.NoObjectsFound" => { Error::Iscsi(Iscsi::NoObjectsFound) } "org.freedesktop.UDisks2.Error.ISCSI.NotConnected" => Error::Iscsi(Iscsi::NotConnected), "org.freedesktop.UDisks2.Error.ISCSI.TransportFailed" => { Error::Iscsi(Iscsi::TransportFailed) } "org.freedesktop.UDisks2.Error.ISCSI.UnknownDiscoveryType" => { Error::Iscsi(Iscsi::UnknownDiscoveryType) } _ => Error::Zbus(value), } } } impl From for Error { fn from(value: zbus::fdo::Error) -> Self { Error::Zbus(value.into()) } } impl From for Error { fn from(value: zbus::zvariant::Error) -> Self { Error::Zbus(value.into()) } } impl From for Error { fn from(i: Infallible) -> Self { match i {} } } udisks2-0.3.1/src/filesystem.rs000064400000000000000000000042771046102023000145440ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Filesystem` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Filesystem", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Filesystem" )] pub trait Filesystem { /// Check method fn check( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Mount method fn mount( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Repair method fn repair( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Resize method fn resize( &self, size: u64, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SetLabel method fn set_label( &self, label: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SetUUID method #[zbus(name = "SetUUID")] fn set_uuid( &self, uuid: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// TakeOwnership method fn take_ownership( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Unmount method fn unmount( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// MountPoints property #[zbus(property)] fn mount_points(&self) -> error::Result>>; /// Size property #[zbus(property)] fn size(&self) -> error::Result; } udisks2-0.3.1/src/gettext.rs000064400000000000000000000041561046102023000140400ustar 00000000000000/// gettext package pub(crate) const GETTEXT_PACKAGE: &str = "udisks2"; /// Translate msgid to localized message from the specified domain (with context support). /// /// For more information, see [`dpgettext2`](https://docs.gtk.org/glib/func.dpgettext2.html) pub(crate) fn dpgettext(msgctxt: T, msgid: U) -> String where T: Into, U: Into, { const MSG_SEPARATOR: char = '\u{004}'; gettextrs::dgettext( GETTEXT_PACKAGE, format!("{}{MSG_SEPARATOR}{}", msgctxt.into(), msgid.into()), ) } /// Similar to [`gettextrs::pgettext`], but with support for formatted strings. /// /// Unlike the provided macro, this function is compatible with gettext string extraction tools. /// /// # Example /// /// ```rust,ignore /// # use crate::gettext::pgettext_f; /// let formatted_string = pgettext_f("hello-world", "Hello, {}!", ["world"]); /// assert_eq!(formatted_string, "Hello, world!"); /// ``` //TODO: add function name to gettext keywords for extraction pub(crate) fn pgettext_f( msgctxt: &str, format: &str, args: impl IntoIterator>, ) -> String { // map Rust style string formatting to C style formatting let s = gettextrs::pgettext(msgctxt, format.replace("{}", "%s")); arg_replace(s, args) } /// Similar to [`gettextrs::gettext`], but with support for formatted strings. /// /// Unlike the provided macro, this function is compatible with gettext string extraction tools. /// /// # Example /// /// ```rust,ignore /// # use crate::gettext::gettext_f; /// let formatted_string = gettext_f("Hello, {}!", ["world"]); /// assert_eq!(formatted_string, "Hello, world!"); /// ``` //TODO: add function name to gettext keywords for extraction pub(crate) fn gettext_f(format: &str, args: impl IntoIterator>) -> String { // map Rust style string formatting to C style formatting let s = gettextrs::gettext(format.replace("{}", "%s")); arg_replace(s, args) } fn arg_replace(mut s: String, args: impl IntoIterator>) -> String { for arg in args { s = s.replacen("%s", arg.as_ref(), 1); } s } udisks2-0.3.1/src/id.rs000064400000000000000000000124211046102023000127420ustar 00000000000000#[derive(Debug, Clone, Copy)] pub(crate) struct Id { pub usage: &'static str, pub ty: &'static str, pub version: Option<&'static str>, pub long_name: &'static str, pub short_name: &'static str, } impl Id { pub(crate) const fn new( usage: &'static str, ty: &'static str, version: Option<&'static str>, long_name: &'static str, short_name: &'static str, ) -> Self { //TODO: use gettext //https://github.com/storaged-project/udisks/blob/4f24c900383d3dc28022f62cab3eb434d19b6b82/udisks/udisksclient.c#L2025 Self { usage, ty, version, long_name, short_name, } } } pub(crate) const ID_TYPES: [Id; 46] = [ Id::new( "filesystem", "vfat", Some("FAT12"), "FAT (12-bit version)", "FAT", ), Id::new( "filesystem", "vfat", Some("FAT16"), "FAT (16-bit version)", "FAT", ), Id::new( "filesystem", "vfat", Some("FAT32"), "FAT (32-bit version)", "FAT", ), Id::new("filesystem", "vfat", Some("*"), "FAT (version %s)", "FAT"), Id::new("filesystem", "vfat", None, "FAT", "FAT"), Id::new("filesystem", "ntfs", Some("*"), "NTFS (version %s)", "NTFS"), Id::new("filesystem", "ntfs", None, "NTFS", "NTFS"), Id::new("filesystem", "hfs", None, "HFS", "HFS"), Id::new("filesystem", "hfsplus", None, "HFS+", "HFS+"), Id::new("filesystem", "apfs", None, "APFS", "APFS"), Id::new("filesystem", "ext2", Some("*"), "Ext2 (version %s)", "Ext2"), Id::new("filesystem", "ext2", None, "Ext2", "Ext2"), Id::new("filesystem", "ext3", Some("*"), "Ext3 (version %s)", "Ext3"), Id::new("filesystem", "ext3", None, "Ext3", "Ext3"), Id::new("filesystem", "ext4", Some("*"), "Ext4 (version %s)", "Ext4"), Id::new("filesystem", "ext4", None, "Ext4", "Ext4"), Id::new( "filesystem", "jdb", Some("*"), "Journal for Ext (version %s)", "JDB", ), Id::new("filesystem", "jdb", Some("*"), "Journal for Ext", "JDB"), Id::new("filesystem", "xfs", Some("*"), "XFS (version %s)", "XFS"), Id::new("filesystem", "xfs", None, "XFS", "XFS"), //TODO: No ID_FS_VERSION yet for btrfs... //https://github.com/storaged-project/udisks/blob/4f24c900383d3dc28022f62cab3eb434d19b6b82/udisks/udisksclient.c#L2045C6-L2045C45 Id::new("filesystem", "btrfs", None, "Btrfs", "Btrfs"), Id::new( "filesystem", "iso9660", Some("*"), "ISO 9660 (version %s)", "ISO9660", ), Id::new("filesystem", "iso9660", None, "ISO 9660", "ISO9660"), Id::new("filesystem", "udf", Some("*"), "UDF (version %s)", "UDF"), Id::new("filesystem", "udf", None, "UDF", "UDF"), Id::new("filesystem", "exfat", None, "exFAT", "exFAT"), Id::new( "filesystem", "exfat", Some("*"), "exFAT (version %s)", "exFAT", ), Id::new("other", "swap", Some("*"), "Swap (version %s)", "Swap"), Id::new("other", "swap", None, "Swap", "Swap"), Id::new( "raid", "LVM2_member", Some("*"), "LVM2 Physical Volume (%s)", "LVM2 PV", ), Id::new( "raid", "LVM2_member", None, "LVM2 Physical Volume", "LVM2 PV", ), Id::new( "raid", "linux_raid_member", Some("*"), "Linux RAID Member (version %s)", "Linux RAID Member", ), Id::new( "raid", "linux_raid_member", None, "Linux RAID Member", "Linux RAID Member", ), Id::new( "raid", "zfs_member", Some("*"), "ZFS Device (ZPool version %s)", "ZFS (v%s)", ), Id::new("raid", "zfs_member", None, "ZFS Device", "ZFS"), Id::new( "raid", "isw_raid_member", Some("*"), "Intel Rapid Storage Technology enterprise RAID Member (version %s)", "Intel RSTe RAID Member (%s)", ), Id::new( "raid", "isw_raid_member", None, "Intel Rapid Storage Technology enterprise RAID Member", "Intel RSTe RAID Member", ), Id::new( "crypto", "crypto_unknown", None, "Possibly Encrypted", "Encrypted?", ), Id::new( "crypto", "crypto_LUKS", Some("*"), "LUKS Encryption (version %s)", "LUKS", ), Id::new("crypto", "crypto_LUKS", None, "LUKS Encryption", "LUKS"), Id::new( "crypto", "crypto_TCRYPT", None, "VeraCrypt/TrueCrypt Encryption", "VeraCrypt/TrueCrypt", ), Id::new( "crypto", "BitLocker", None, "BitLocker Encryption", "BitLocker", ), Id::new( "filesystem", "VMFS", Some("*"), "VMFS (version %s)", "VMFS (v%s)", ), Id::new("filesystem", "VMFS", None, "VMFS", "VMFS"), Id::new( "raid", "VMFS_volume_member", Some("*"), "VMFS Volume Member (version %s)", "VMFS Member (v%s)", ), Id::new( "raid", "VMFS_volume_member", None, "VMFS Volume Member", "VMFS Member", ), ]; udisks2-0.3.1/src/job.rs000064400000000000000000000036371046102023000131310ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Job` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Job", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Jop" )] pub trait Job { /// Cancel method fn cancel( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Completed signal #[zbus(signal)] fn completed(&self, success: bool, message: &str) -> error::Result<()>; /// Bytes property #[zbus(property)] fn bytes(&self) -> error::Result; /// Cancelable property #[zbus(property)] fn cancelable(&self) -> error::Result; /// ExpectedEndTime property #[zbus(property)] fn expected_end_time(&self) -> error::Result; /// Objects property #[zbus(property)] fn objects(&self) -> error::Result>; /// Operation property #[zbus(property)] fn operation(&self) -> error::Result; /// Progress property #[zbus(property)] fn progress(&self) -> error::Result; /// ProgressValid property #[zbus(property)] fn progress_valid(&self) -> error::Result; /// Rate property #[zbus(property)] fn rate(&self) -> error::Result; /// StartTime property #[zbus(property)] fn start_time(&self) -> error::Result; /// StartedByUID property #[zbus(property, name = "StartedByUID")] fn started_by_uid(&self) -> error::Result; } udisks2-0.3.1/src/lib.rs000064400000000000000000000021471046102023000131200ustar 00000000000000#![doc = include_str!("../README.md")] #[cfg(not(target_os = "linux"))] compile_error!("UDisks only supports Linux"); use std::collections::HashMap; //re-eport zbus pub use zbus; pub mod ata; pub mod block; mod client; pub mod drive; pub mod encrypted; mod error; pub mod filesystem; pub(crate) mod gettext; mod id; pub mod job; pub mod r#loop; pub mod manager; pub mod mdraid; mod media; pub mod nvme; mod object; mod object_info; mod partition_subtypes; pub mod partition_types; pub use object::Object; pub use object_info::ObjectInfo; pub mod partition; pub mod partitiontable; pub mod swapspace; pub use client::Client; pub use error::{Error, Iscsi, Result}; /// Standard Options. /// /// Many functions inlude a parameter `options`, which includes the following options: /// - `no_user_auth_interaction` if set to `true`, no user interaction will happen, /// when checking if the called function is authorized pub fn standard_options( no_user_auth_interaction: bool, ) -> HashMap<&'static str, zbus::zvariant::Value<'static>> { HashMap::from([("auth.no_user_interaction", no_user_auth_interaction.into())]) } udisks2-0.3.1/src/loop.rs000064400000000000000000000024361046102023000133240ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Loop` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Loop", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Loop" )] pub trait Loop { /// Delete method fn delete( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SetAutoclear method fn set_autoclear( &self, value: bool, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Autoclear property #[zbus(property)] fn autoclear(&self) -> error::Result; /// BackingFile property #[zbus(property)] fn backing_file(&self) -> error::Result>; /// SetupByUID property #[zbus(property, name = "SetupByUID")] fn setup_by_uid(&self) -> error::Result; } udisks2-0.3.1/src/manager.rs000064400000000000000000000054461046102023000137710ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Manager` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Manager", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Manager" )] pub trait Manager { /// CanCheck method fn can_check(&self, type_: &str) -> error::Result<(bool, String)>; /// CanFormat method fn can_format(&self, type_: &str) -> error::Result<(bool, String)>; /// CanRepair method fn can_repair(&self, type_: &str) -> error::Result<(bool, String)>; /// CanResize method fn can_resize(&self, type_: &str) -> error::Result<(bool, u64, String)>; /// EnableModule method fn enable_module(&self, name: &str, enable: bool) -> error::Result<()>; /// EnableModules method #[deprecated(note = "Use EnableModule instead")] fn enable_modules(&self, enable: bool) -> error::Result<()>; /// GetBlockDevices method fn get_block_devices( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result>; /// LoopSetup method fn loop_setup( &self, fd: zbus::zvariant::Fd<'_>, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// MDRaidCreate method #[zbus(name = "MDRaidCreate")] fn mdraid_create( &self, blocks: &[zbus::zvariant::ObjectPath<'_>], level: &str, name: &str, chunk: u64, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// ResolveDevice method fn resolve_device( &self, devspec: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result>; /// DefaultEncryptionType property #[zbus(property)] fn default_encryption_type(&self) -> error::Result; /// SupportedEncryptionTypes property #[zbus(property)] fn supported_encryption_types(&self) -> error::Result>; /// SupportedFilesystems property #[zbus(property)] fn supported_filesystems(&self) -> error::Result>; /// Version property #[zbus(property)] fn version(&self) -> error::Result; } udisks2-0.3.1/src/mdraid.rs000064400000000000000000000074361046102023000136200ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.MDRaid` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.MDRaid", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/MDRaid" )] pub trait MDRaid { /// AddDevice method fn add_device( &self, device: &zbus::zvariant::ObjectPath<'_>, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Delete method fn delete( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// RemoveDevice method fn remove_device( &self, device: &zbus::zvariant::ObjectPath<'_>, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// RequestSyncAction method fn request_sync_action( &self, sync_action: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SetBitmapLocation method fn set_bitmap_location( &self, value: &[u8], options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Start method fn start( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Stop method fn stop( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// ActiveDevices property #[zbus(property)] #[allow(clippy::type_complexity)] fn active_devices( &self, ) -> error::Result< Vec<( zbus::zvariant::OwnedObjectPath, i32, Vec, u64, std::collections::HashMap, )>, >; /// BitmapLocation property #[zbus(property)] fn bitmap_location(&self) -> error::Result>; /// ChildConfiguration property #[zbus(property)] fn child_configuration( &self, ) -> error::Result< Vec<( String, std::collections::HashMap, )>, >; /// ChunkSize property #[zbus(property)] fn chunk_size(&self) -> error::Result; /// Degraded property #[zbus(property)] fn degraded(&self) -> error::Result; /// Level property #[zbus(property)] fn level(&self) -> error::Result; /// Name property #[zbus(property)] fn name(&self) -> error::Result; /// NumDevices property #[zbus(property)] fn num_devices(&self) -> error::Result; /// Running property #[zbus(property)] fn running(&self) -> error::Result; /// Size property #[zbus(property)] fn size(&self) -> error::Result; /// SyncAction property #[zbus(property)] fn sync_action(&self) -> error::Result; /// SyncCompleted property #[zbus(property)] fn sync_completed(&self) -> error::Result; /// SyncRate property #[zbus(property)] fn sync_rate(&self) -> error::Result; /// SyncRemainingTime property #[zbus(property)] fn sync_remaining_time(&self) -> error::Result; /// UUID property #[zbus(property, name = "UUID")] fn uuid(&self) -> error::Result; } udisks2-0.3.1/src/media.rs000064400000000000000000000234461046102023000134360ustar 00000000000000use crate::drive::MediaCompatibility; #[derive(Debug, Clone, Copy)] pub(crate) enum DriveType { Drive, Disk, Card, Disc, } pub(crate) struct MediaData { pub id: MediaCompatibility, pub media_name: &'static str, pub media_family: &'static str, pub media_icon: &'static str, pub media_icon_symbolic: &'static str, pub media_type: DriveType, pub drive_icon: &'static str, pub drive_icon_symbolic: &'static str, } impl MediaData { //just used to generate a nicer interface for the `MEDIA_DATA` below, no need for builder //pattern or secondary struct #[allow(clippy::too_many_arguments)] const fn new( id: MediaCompatibility, media_name: &'static str, media_family: &'static str, media_icon: &'static str, media_icon_symbolic: &'static str, media_type: DriveType, drive_icon: &'static str, drive_icon_symbolic: &'static str, ) -> Self { //TODO: translate //https://github.com/storaged-project/udisks/blob/0b3879ab1d429b8312eaad0deb1b27e5545e39c1/udisks/udisksobjectinfo.c#L159 //Translators: 'Thumb' here refers to "USB thumb drive", see http://en.wikipedia.org/wiki/Thumb_drive Self { id, media_name, media_family, media_icon, media_icon_symbolic, media_type, drive_icon, drive_icon_symbolic, } } } pub(crate) const MEDIA_DATA: [MediaData; 32] = [ /* Translators: 'Thumb' here refers to "USB thumb drive", see http://en.wikipedia.org/wiki/Thumb_drive */ MediaData::new( MediaCompatibility::Thumb, "Thumb", "Thumb", "media-removable", "media-removable-symbolic", DriveType::Drive, "media-removable", "media-removable-symbolic", ), MediaData::new( MediaCompatibility::Floppy, "Floppy", "Floppy", "media-floppy", "media-floppy-symbolic", DriveType::Disk, "drive-removable-media-floppy", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FloppyZip, "Zip", "Zip", "media-floppy-jaz", "media-floppy-symbolic", DriveType::Disk, "drive-removable-media-floppy-jaz", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FloppyJaz, "Jaz", "Jaz", "media-floppy-zip", "media-floppy-symbolic", DriveType::Disk, "drive-removable-media-floppy-zip", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::Flash, "Flash", "Flash", "media-flash", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FlashMs, "MemoryStick", "MemoryStick", "media-flash-ms", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash-ms", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FlashSm, "SmartMedia", "SmartMedia", "media-flash-sm", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash-sm", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FlashCf, "CompactFlash", "CompactFlash", "media-flash-cf", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash-cf", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FlashMmc, "MMC", "SD", "media-flash-mmc", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash-mmc", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FlashSd, "SD", "SD", "media-flash-sd", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash-sd", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FlashSdxc, "SDXC", "SD", "media-flash-sd-xc", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash-sd-xc", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::FlashSdhc, "SDHC", "SD", "media-flash-sd-hc", "media-flash-symbolic", DriveType::Card, "drive-removable-media-flash-sd-hc", "drive-removable-media-symbolic", ), MediaData::new( MediaCompatibility::OpticalCd, "CD-ROM", "CD", "media-optical-cd-rom", "media-optical-symbolic", DriveType::Disc, "drive-optical", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalCdR, "CD-R", "CD", "media-optical-cd-r", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalCdRw, "CD-RW", "CD", "media-optical-cd-rw", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvd, "DVD", "DVD", "media-optical-dvd-rom", "media-optical-symbolic", DriveType::Disc, "drive-optical", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvdR, "DVD-R", "DVD", "media-optical-dvd-r", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvdRw, "DVD-RW", "DVD", "media-optical-dvd-rw", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvdRam, "DVD-RAM", "DVD", "media-optical-dvd-ram", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvdPlusR, "DVD+R", "DVD", "media-optical-dvd-r-plus", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvdPlusRw, "DVD+RW", "DVD", "media-optical-dvd-rw-plus", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvdPlusRDl, "DVD+R DL", "DVD", "media-optical-dvd-dl-r-plus", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalDvdPlusRwDl, "DVD+RW DL", "DVD", "media-optical-dvd-dl-r-plus", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalBd, "BD-ROM", "Blu-Ray", "media-optical-bd-rom", "media-optical-symbolic", DriveType::Disc, "drive-optical", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalBdR, "BD-R", "Blu-Ray", "media-optical-bd-r", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalBdRe, "BD-RE", "Blu-Ray", "media-optical-bd-re", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalHddvd, "HDDVD", "HDDVD", "media-optical-hddvd-rom", "media-optical-symbolic", DriveType::Disc, "drive-optical", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalHddvdR, "HDDVD-R", "HDDVD", "media-optical-hddvd-r", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalHddvdRw, "HDDVD-RW", "HDDVD", "media-optical-hddvd-rw", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalMo, "MO", "CD", "media-optical-mo", "media-optical-symbolic", DriveType::Disc, "drive-optical", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalMrw, "MRW", "CD", "media-optical-mrw", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), MediaData::new( MediaCompatibility::OpticalMrwW, "MRW-W", "CD", "media-optical-mrw-w", "media-optical-symbolic", DriveType::Disc, "drive-optical-recorder", "drive-optical-symbolic", ), ]; udisks2-0.3.1/src/nvme/controller.rs000064400000000000000000000063771046102023000155130ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.NVMe.Controller` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.NVMe.Controller", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/NVMe" )] pub trait Controller { /// SanitizeStart method fn sanitize_start( &self, action: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SmartGetAttributes method fn smart_get_attributes( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result>; /// SmartSelftestAbort method fn smart_selftest_abort( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SmartSelftestStart method fn smart_selftest_start( &self, type_: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SmartUpdate method fn smart_update( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// ControllerID property #[zbus(property, name = "ControllerID")] fn controller_id(&self) -> error::Result; /// FGUID property #[zbus(property, name = "FGUID")] fn fguid(&self) -> error::Result; /// NVMeRevision property #[zbus(property, name = "NVMeRevision")] fn nvme_revision(&self) -> error::Result; /// SanitizePercentRemaining property #[zbus(property)] fn sanitize_percent_remaining(&self) -> error::Result; /// SanitizeStatus property #[zbus(property)] fn sanitize_status(&self) -> error::Result; /// SmartCriticalWarning property #[zbus(property)] fn smart_critical_warning(&self) -> error::Result>; /// SmartPowerOnHours property #[zbus(property)] fn smart_power_on_hours(&self) -> error::Result; /// SmartSelftestPercentRemaining property #[zbus(property)] fn smart_selftest_percent_remaining(&self) -> error::Result; /// SmartSelftestStatus property #[zbus(property)] fn smart_selftest_status(&self) -> error::Result; /// SmartTemperature property #[zbus(property)] fn smart_temperature(&self) -> error::Result; /// SmartUpdated property #[zbus(property)] fn smart_updated(&self) -> error::Result; /// State property #[zbus(property)] fn state(&self) -> error::Result; /// SubsystemNQN property #[zbus(property, name = "SubsystemNQN")] fn subsystem_nqn(&self) -> error::Result>; /// UnallocatedCapacity property #[zbus(property)] fn unallocated_capacity(&self) -> error::Result; } udisks2-0.3.1/src/nvme/fabrics.rs000064400000000000000000000023601046102023000147250ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.NVMe.Fabrics` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.NVMe.Fabrics", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/NVMe" )] pub trait Fabrics { /// Disconnect method fn disconnect( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// HostID property #[zbus(property, name = "HostID")] fn host_id(&self) -> error::Result>; /// HostNQN property #[zbus(property, name = "HostNQN")] fn host_nqn(&self) -> error::Result>; /// Transport property #[zbus(property)] fn transport(&self) -> error::Result; /// TransportAddress property #[zbus(property)] fn transport_address(&self) -> error::Result>; } udisks2-0.3.1/src/nvme/mod.rs000064400000000000000000000031671046102023000141010ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Manager.NVMe` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; pub mod controller; pub mod fabrics; pub mod namespace; #[proxy( interface = "org.freedesktop.UDisks2.Manager.NVMe", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Manager" )] pub trait NVMe { /// Connect method fn connect( &self, subsysnqn: &[u8], transport: &str, transport_addr: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// SetHostID method #[zbus(name = "SetHostID")] fn set_host_id( &self, hostid: &[u8], options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SetHostNQN method #[zbus(name = "SetHostNQN")] fn set_host_nqn( &self, hostnqn: &[u8], options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// HostID property #[zbus(property, name = "HostID")] fn host_id(&self) -> error::Result>; /// HostNQN property #[zbus(property, name = "HostNQN")] fn host_nqn(&self) -> error::Result>; } udisks2-0.3.1/src/nvme/namespace.rs000064400000000000000000000041001046102023000152420ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.NVMe.Namespace` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.NVMe.Namespace", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/NVMe" )] pub trait Namespace { /// FormatNamespace method fn format_namespace( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// EUI64 property #[zbus(property, name = "EUI64")] fn eui64(&self) -> error::Result; /// FormatPercentRemaining property #[zbus(property)] fn format_percent_remaining(&self) -> error::Result; /// FormattedLBASize property #[zbus(property, name = "FormattedLBASize")] fn formatted_lbasize(&self) -> error::Result<(u16, u16, u8)>; /// LBAFormats property #[zbus(property, name = "LBAFormats")] fn lbaformats(&self) -> error::Result>; /// NGUID property #[zbus(property, name = "NGUID")] fn nguid(&self) -> error::Result; /// NSID property #[zbus(property, name = "NSID")] fn nsid(&self) -> error::Result; /// NamespaceCapacity property #[zbus(property)] fn namespace_capacity(&self) -> error::Result; /// NamespaceSize property #[zbus(property)] fn namespace_size(&self) -> error::Result; /// NamespaceUtilization property #[zbus(property)] fn namespace_utilization(&self) -> error::Result; /// UUID property #[zbus(property, name = "UUID")] fn uuid(&self) -> error::Result; /// WWN property #[zbus(property, name = "WWN")] fn wwn(&self) -> error::Result; } udisks2-0.3.1/src/object.rs000064400000000000000000000064121046102023000136170ustar 00000000000000use zbus::fdo::ObjectManagerProxy; use zbus::zvariant::OwnedObjectPath; use crate::{ ata, block, drive, encrypted, filesystem, job, mdraid, partition, partitiontable, r#loop, swapspace, }; use crate::{error, nvme}; /// Utility struct for easily accessing interfaces. #[derive(Debug, Clone)] pub struct Object { connection: zbus::Connection, path: OwnedObjectPath, object_manager: ObjectManagerProxy<'static>, } /// Generate functions to get the interfaces of the given paths. /// /// # Examples /// /// ```skip /// # fn main() { /// impl_get_interface!( /// block, block::BlockProxy<'static>, "org.freedesktop.UDisks2.Block"; /// ); /// /// # } /// ``` macro_rules! impl_get_interface { ($($name:ident, $type:ty, $key:literal);+) => { $( #[doc = "Returns the `"] #[doc = $key] #[doc = "` interface."] /// /// # Errors /// Returns [zbus::Error::InterfaceNotFound] if the interface could not be acquired. pub async fn $name(&self) -> error::Result<$type> { let objects = self.object_manager.get_managed_objects().await?; let interfaces = objects .get(&self.path) .ok_or(zbus::Error::InterfaceNotFound)?; if !interfaces.contains_key($key) { return Err(zbus::Error::InterfaceNotFound.into()); } Ok(<$type>::builder(&self.connection) .path(self.path.clone())? .build() .await?) })+ }; } impl Object { pub(crate) fn new( path: OwnedObjectPath, object_manager: ObjectManagerProxy<'static>, connection: zbus::Connection, ) -> Self { Self { connection, path, object_manager, } } /// Returns the [OwnedObjectPath] used by the object. pub fn object_path(&self) -> &OwnedObjectPath { &self.path } impl_get_interface!( block, block::BlockProxy<'static>, "org.freedesktop.UDisks2.Block"; drive, drive::DriveProxy<'static>, "org.freedesktop.UDisks2.Drive"; drive_ata, ata::AtaProxy<'static>, "org.freedesktop.UDisks2.Drive.Ata"; filesystem, filesystem::FilesystemProxy<'static>, "org.freedesktop.UDisks2.Filesystem"; job, job::JobProxy<'static>, "org.freedesktop.UDisks2.Job"; swapspace, swapspace::SwapspaceProxy<'static>, "org.freedesktop.UDisks2.Swapspace"; encrypted, encrypted::EncryptedProxy<'static>, "org.freedesktop.UDisks2.Encrypted"; r#loop, r#loop::LoopProxy<'static>, "org.freedesktop.UDisks2.Loop"; manager_nvme, nvme::NVMeProxy<'static>, "org.freedesktop.UDisks2.Manager.Nvme"; partition, partition::PartitionProxy<'static>, "org.freedesktop.UDisks2.Partition"; partition_table, partitiontable::PartitionTableProxy<'static>, "org.freedesktop.UDisks2.PartitionTable"; mdraid, mdraid::MDRaidProxy<'static>, "org.freedesktop.UDisks2.Mdraid"; nvme_controller, nvme::controller::ControllerProxy<'static>, "org.freedesktop.UDisks2.NVMe.Controller"; nvme_namespace, nvme::namespace::NamespaceProxy<'static>, "org.freedesktop.UDisks2.NVMe.Namespace"; nvme_fabrics, nvme::fabrics::FabricsProxy<'static>, "org.freedesktop.UDisks2.Nvme.Fabrics" ); } udisks2-0.3.1/src/object_info.rs000064400000000000000000000761601046102023000146410ustar 00000000000000use std::ffi::CString; use gettextrs::{gettext, pgettext}; use crate::{ block, drive::{self, RotationRate}, error, mdraid, gettext::{dpgettext, gettext_f, pgettext_f}, media::{self, DriveType}, partition, r#loop, Client, Object, }; /// Icon /// /// Represents an icon that can be looked up from an icon theme. /// An icon may have an symbolic version as well. #[derive(Debug, Default, Clone)] pub struct Icon { name: Option, name_symbolic: Option, } impl Icon { fn new(name: Option, name_symbolic: Option) -> Self { Self { name, name_symbolic, } } fn set_if_none(&mut self, icon: String, icon_symbolic: String) { self.name.get_or_insert(icon); self.name_symbolic.get_or_insert(icon_symbolic); } /// Name of the icon. /// /// If the [`Object`] has no associated icon, None is returned. pub fn name(&self) -> Option<&String> { self.name.as_ref() } /// Name of the symbolic icon. /// /// If the [`Object`] has no associated symbolic icon, None is returned. pub fn name_symbolic(&self) -> Option<&String> { self.name_symbolic.as_ref() } } /// Detailed information about the D-Bus interfaces (such as [`block::BlockProxy`] and [`drive::DriveProxy`]) /// on a [`Object`] that is suitable to display in an user interface. #[derive(Debug, Clone)] pub struct ObjectInfo<'a> { /// The [`Object`] that the info is about pub object: &'a Object, /// Name of the object pub name: Option, /// Description of the object pub description: Option, /// Icon associated with the object /// /// The returned icon may be influenced by [`block::BlockProxy::hint_name()`]. pub icon: Icon, /// Description of media associated with the object pub media_description: Option, /// Icon associated with media /// /// The returned icon may be influenced by [`block::BlockProxy::hint_name()`]. pub media_icon: Icon, /// Single-line description /// /// A single line string, containing enough detail to be used as a comprehensive /// representation of the `object`. For instance, in the case of block devices /// or drives, it includes critical information like the device's special file /// path, such as `/dev/sda`. pub one_liner: Option, /// Sort key /// /// This can be used to sort objects. pub sort_key: Option, } impl<'a> ObjectInfo<'a> { pub(crate) fn new(object: &'a Object) -> Self { Self { object, name: None, description: None, icon: Icon::default(), media_description: None, media_icon: Icon::default(), one_liner: None, sort_key: None, } } pub(crate) async fn info_for_block( &mut self, client: &Client, block: block::BlockProxy<'_>, partition: Option>, ) { self.icon = Icon::new( Some("drive-removable-media".to_owned()), Some("drive-removable-media-symbolic".to_owned()), ); self.name = block .preferred_device() .await .ok() .and_then(|dev| CString::from_vec_with_nul(dev).ok()) .and_then(|dev| dev.to_str().map(|p| p.to_string()).ok()); let size = block.size().await; if let Ok(size) = size { let size = client.size_for_display(size, false, false); self.description = Some(gettext_f("{} Block Device", [size])); } else { self.description = Some(gettext("Block Device")); } let mut partition_number = None; if let Some(partition) = partition { //TODO: we're expecting it here to to be fine to load, //but further down we handle the error??? partition_number = partition.number().await.ok(); // Translators: Used to describe a partition of a block device. // The %u is the partition number. // The %s is the description for the block device (e.g. "5 GB Block Device"). //TODO: pgettext_f does not support non-string C placeholders, so we replace it //manually to maintain compatibilty self.description = Some( pgettext_f( "part-block", "Partition %u of {}", [ //Safe to unwrap, we have previously set this self.description.as_ref().unwrap(), ], ) .replace( "%u", &partition_number .expect("Failed to read partition number") .to_string(), ), ); } // Translators: String used for one-liner description of a block device. // The first %s is the description of the object (e.g. "50 GB Block Device"). // The second %s is the special device file (e.g. "/dev/sda2"). //TODO: C version calls preferred_device again, instead of using name, why? self.one_liner = Some(pgettext_f( "one-liner-block", "{} ({})", [ self.description.as_ref().unwrap(), self.name.as_ref().unwrap(), ], )); self.sort_key = Some(format!( "02_block_{}_{}", // safe to unwrap, object path always have at least one `/` self.object.object_path().split('/').last().unwrap(), //TODO: use async closure when stable partition_number.unwrap_or(0) )) } pub(crate) async fn info_for_loop( &mut self, client: &Client, loop_proxy: r#loop::LoopProxy<'_>, block: block::BlockProxy<'_>, partition: Option>, ) { self.icon = Icon::new( Some("drive-removable-media".to_owned()), Some("drive-removable-media-symbolic".to_owned()), ); self.name = loop_proxy .backing_file() .await .ok() .and_then(|dev| CString::from_vec_with_nul(dev).ok()) .and_then(|dev| dev.to_str().map(|p| p.to_string()).ok()); let size = block.size().await; if let Ok(size) = size { let size = client.size_for_display(size, false, false); self.description = Some(gettext_f("{} Loop Device", [size])); } else { self.description = Some(gettext("Loop Device")); } let mut partition_number = None; if let Some(partition) = partition { //TODO: we're expecting it here to to be fine to load, //but further down we handle the error??? partition_number = partition.number().await.ok(); // Translators: Used to describe a partition of a loop device. // The %u is the partition number. // The %s is the description for the block device (e.g. "5 GB Loop Device"). //TODO: pgettext_f does not support non-string C placeholders, so we replace it //manually to maintain compatibilty self.description = Some( pgettext_f( "part-loop", "Partition %u of {}", [ //Safe to unwrap, we have previously set this self.description.as_ref().unwrap(), ], ) .replace( "%u", &partition_number .expect("Failed to read partition number") .to_string(), ), ); } // Translators: String used for one-liner description of a loop device. // The first %s is the description of the object (e.g. "2 GB Loop Device"). // The second %s is the name of the backing file (e.g. "/home/davidz/file.iso"). // The third %s is the special device file (e.g. "/dev/loop2"). self.one_liner = Some(pgettext_f( "one-liner-loop", "{} — {} ({})", [ self.description.as_ref().unwrap(), //safe to unwrap, has been set previously self.name.as_ref().unwrap(), &block .preferred_device() .await .ok() .and_then(|dev| CString::from_vec_with_nul(dev).ok()) .and_then(|dev| dev.to_str().map(|p| p.to_string()).ok()) .unwrap_or_default(), ], )); self.sort_key = Some(format!( "03_loop_{}_{}", // safe to unwrap, object path always have at least one `/` self.object.object_path().split('/').last().unwrap(), //TODO: use async closure when stable partition_number.unwrap_or(0) )); } pub(crate) async fn info_for_mdraid( &mut self, client: &Client, mdraid: mdraid::MDRaidProxy<'_>, partition: Option>, ) { let name = mdraid.name().await.unwrap_or_default(); self.name = Some(name.split(':').last().unwrap_or_else(|| &name).to_string()); self.icon = Icon::new( Some("drive-multidisk".to_owned()), Some("drive-multidisk-symbolic".to_owned()), ); let level = mdraid.level().await; let size = mdraid.size().await; if let Ok(size) = size { let size = client.size_for_display(size, false, false); // Translators: Used to format the description for a RAID array. // The first %s is the size (e.g. '42.0 GB'). // The second %s is the level (e.g. 'RAID-5 Array'). self.description = Some(pgettext_f( "mdraid-desc", "{} {}", [size, self.format_level(level)], )); } else { self.description = Some(self.format_level(level)); } let mut partition_number = None; if let Some(partition) = partition { //TODO: we're expecting it here to to be fine to load, //but further down we handle the error??? partition_number = partition.number().await.ok(); // Translators: Used to describe a partition of a RAID Array. // The %u is the partition number. // The %s is the description for the drive (e.g. "2 TB RAID-5"). //TODO: pgettext_f does not support non-string C placeholders, so we replace it //manually to maintain compatibilty self.description = Some( pgettext_f( "part-raid", "Partition %u of {}", [ &partition_number .expect("Failed to read partition number") .to_string(), //Safe to unwrap, we have previously set this self.description.as_ref().unwrap(), ], ) .replace( "%u", &partition_number .expect("Failed to read partition number") .to_string(), ), ); } let block = client.block_for_mdraid(&mdraid).await; if self.name.as_deref().is_some_and(|name| !name.is_empty()) { if let Some(block) = block { let preferred_device = block .preferred_device() .await .ok() .and_then(|dev| CString::from_vec_with_nul(dev).ok()) .and_then(|dev| dev.to_str().map(|p| p.to_string()).ok()) .expect("Failed to get preferred device"); // Translators: String used for one-liner description of running RAID array. // The first %s is the array name (e.g. "AlphaGo"). // The second %s is the size and level (e.g. "2 TB RAID-5"). // The third %s is the special device file (e.g. "/dev/sda"). self.one_liner = Some(pgettext_f( "one-liner-mdraid-running", "{} — {} ({})", [ self.name.as_deref().unwrap(), self.description.as_deref().unwrap_or_default(), &preferred_device, ], )); } else { // Translators: String used for one-liner description of non-running RAID array. // The first %s is the array name (e.g. "AlphaGo"). // The second %s is the size and level (e.g. "2 TB RAID-5"). self.one_liner = Some(pgettext_f( "one-liner-mdraid-not-running", "{} — {}", [ self.name.as_deref().unwrap_or_default(), self.description.as_deref().unwrap_or_default(), ], )); } } else if let Some(block) = block { let preferred_device = block .preferred_device() .await .ok() .and_then(|dev| CString::from_vec_with_nul(dev).ok()) .and_then(|dev| dev.to_str().map(|p| p.to_string()).ok()) .expect("Failed to get preferred device"); // Translators: String used for one-liner description of running RAID array. // The first %s is the array name (e.g. "AlphaGo"). // The second %s is the size and level (e.g. "2 TB RAID-5"). // The third %s is the special device file (e.g. "/dev/sda"). self.one_liner = Some(pgettext_f( "one-liner-mdraid-no-name-running", "{} — {}", [ self.description.as_deref().unwrap_or_default(), &preferred_device, ], )); } else { // Translators: String used for one-liner description of non-running RAID array. // The first %s is the array name (e.g. "AlphaGo"). // The second %s is the size and level (e.g. "2 TB RAID-5"). self.one_liner = Some(pgettext_f( "one-liner-mdraid-no-name-not-running", "{}", [self.description.as_deref().unwrap_or_default()], )); } self.sort_key = Some(format!( "01_mdraid_{}_{}", mdraid.uuid().await.expect("Failed to get mdraid uuid"), //TODO: use async closure when stable partition_number.unwrap_or(0) )); } pub(crate) async fn info_for_drive( &mut self, client: &Client, drive: &drive::DriveProxy<'_>, partition: Option>, ) { let vendor = drive.vendor().await.unwrap_or_default(); // "%vendor $model" self.name = Some(format!( "{}{}{}", vendor, if vendor.is_empty() { "" } else { " " }, drive.model().await.unwrap_or_default() )); let media_removable = drive.media_removable().await.unwrap_or_default(); let media_available = drive.media_available().await.unwrap_or_default(); let media = drive.media().await.unwrap(); let media_compat = drive.media_compatibility().await.unwrap_or_default(); let mut desc = String::new(); let mut desc_type = None; for media_data in media::MEDIA_DATA { if media_compat.contains(&media_data.id) { self.icon.set_if_none( media_data.drive_icon.to_owned(), media_data.drive_icon_symbolic.to_owned(), ); if !desc.contains(media_data.media_family) { if !desc.is_empty() { desc.push('/'); } desc.push_str(&pgettext("media-type", media_data.media_family)); } desc_type = Some(media_data.media_type); } if media_removable && media_available { //media if media == media_data.id { if self.media_description.is_none() { self.media_description = Some(match media_data.media_type { media::DriveType::Drive => { //Translators: Used to describe drive without removable media. The %s is the type, e.g. 'Thumb' pgettext_f( "drive-with-fixed-media", "{} Drive", [dpgettext("media-type", media_data.media_name)], ) } media::DriveType::Disk => { //Translators: Used to describe generic media. The %s is the type, e.g. 'Zip' or 'Floppy' pgettext_f( "drive-with-generic-media", "{} Disk", [dpgettext("media-type", media_data.media_name)], ) } media::DriveType::Card => { //Translators: Used to describe flash media. The %s is the type, e.g. 'SD' or 'CompactFlash' pgettext_f( "flash-media", "{} Card", [dpgettext("media-type", media_data.media_name)], ) } media::DriveType::Disc => { //Translators: Used to describe optical discs. The %s is the type, e.g. 'CD-R' or 'DVD-ROM' pgettext_f( "optical-media", "{} Disc", [dpgettext("media-type", media_data.media_name)], ) } }); } self.media_icon.set_if_none( media_data.media_icon.to_owned(), media_data.media_icon_symbolic.to_owned(), ); } } } let size = drive .size() .await .ok() .map(|size| client.size_for_display(size, false, false)); let rotation_rate = drive.rotation_rate().await.unwrap_or_default(); self.description = Some(match desc_type { None => { if media_removable { if let Some(size) = size { // Translators: Used to describe a drive. The %s is the size, e.g. '20 GB' pgettext_f("drive-with-size", "{} Drive", [size]) } else { //Translators: Used to describe a drive we know very little about (removable media or size not known) pgettext("generic-drive", "Drive") } } else if rotation_rate == RotationRate::NonRotating { if let Some(size) = size { // Translators: Used to describe a non-rotating drive (rotation rate either unknown // or it's a solid-state drive). The %s is the size, e.g. '20 GB'. pgettext_f("disk-non-rotational", "{} Disk", [size]) } else { // Translators: Used to describe a non-rotating drive (rotation rate either unknown // or it's a solid-state drive). The drive is either using removable media or its // size not known. pgettext("disk-non-rotational", "Disk") } } else if let Some(size) = size { // Translators: Used to describe a hard-disk drive (HDD). The %s is the size, e.g. '20 GB'. pgettext_f("disk-hdd", "{} Hard Disk", [size]) } else { // Translators: Used to describe a hard-disk drive (HDD) (removable media or size not known) pgettext("disk-hdd", "Hard Disk") } } Some(DriveType::Card) => { // Translators: Used to describe a card reader. The %s is the card type e.g. 'CompactFlash'. pgettext_f("drive-card-reader", "{} Card Reader", [desc]) } Some(DriveType::Drive) | Some(DriveType::Disk) | Some(DriveType::Disc) => { if size.as_ref().is_some_and(|_| !media_removable) { // Translators: Used to describe drive. The first %s is the size e.g. '20 GB' and the // second %s is the drive type e.g. 'Thumb'. pgettext_f( "drive-with-size-and-type", "{} {} Drive", [size.unwrap(), desc], ) } else { //Translators: Used to describe drive. The first %s is the drive type e.g. 'Thumb'. pgettext_f("drive-with-type", "{} Drive", [desc]) } } }); let hyphenated_connection_bus = drive .connection_bus() .await .ok() .filter(|bus| !bus.is_empty()) .map(|bus| format!("-{}", bus)) .unwrap_or_default(); //fallback for icon let icon_fallback = if media_removable { format!("drive-removable-media{}", hyphenated_connection_bus) } else if rotation_rate == RotationRate::NonRotating { format!("drive-harddisk-solidstate{}", hyphenated_connection_bus) } else { format!("drive-harddisk{}", hyphenated_connection_bus) }; let icon_symbolic_fallback = if media_removable { format!( "drive-removable-media{}-symbolic", hyphenated_connection_bus ) } else if rotation_rate == RotationRate::NonRotating { format!( "drive-harddisk-solidstate{}-symbolic", hyphenated_connection_bus ) } else { format!("drive-harddisk{}-symbolic", hyphenated_connection_bus) }; self.icon.set_if_none(icon_fallback, icon_symbolic_fallback); //fallback for media_icon if media_available { let media_icon_fallback = if media_removable { format!("drive-removable-media{}", hyphenated_connection_bus) } else if rotation_rate == RotationRate::NonRotating { format!("drive-harddisk-solidstate{}", hyphenated_connection_bus) } else { format!("drive-harddisk{}", hyphenated_connection_bus) }; let media_icon_symbolic_fallback = if media_removable { format!( "drive-removable-media{}-symbolic", hyphenated_connection_bus ) } else if rotation_rate == RotationRate::NonRotating { format!( "drive-harddisk-solidstate{}-symbolic", hyphenated_connection_bus ) } else { format!("drive-harddisk{}-symbolic", hyphenated_connection_bus) }; self.media_icon .set_if_none(media_icon_fallback, media_icon_symbolic_fallback); } //TODO: refactor //prepend a qualifier to the media description, based on the disc state if drive.optical_blank().await.unwrap_or_default() { // Translators: String used for a blank disc. The %s is the disc type e.g. "CD-RW Disc" self.media_description = Some(pgettext_f( "optical-media", "Blank {}", [self.media_description.as_deref().unwrap_or_default()], )); } else if drive .optical_num_audio_tracks() .await .is_ok_and(|tracks| tracks > 0) && drive .optical_num_data_tracks() .await .is_ok_and(|tracks| tracks > 0) { // Translators: String used for a mixed disc. The %s is the disc type e.g. "CD-ROM Disc" self.media_description = Some(pgettext_f( "optical-media", "Mixed {}", [self.media_description.as_deref().unwrap_or_default()], )); } else if drive .optical_num_audio_tracks() .await .is_ok_and(|tracks| tracks > 0) && drive .optical_num_data_tracks() .await .is_ok_and(|tracks| tracks == 0) { // Translators: String used for an audio disc. The %s is the disc type e.g. "CD-ROM Disc" self.media_description = Some(pgettext_f( "optical-media", "Audio {}", [self.media_description.as_deref().unwrap_or_default()], )); } // Apply UDISKS_NAME, UDISKS_ICON_NAME, UDISKS_SYMBOLIC_ICON_NAME hints, if available let block = client.block_for_drive(drive, true).await; if let Some(ref block) = block { if let Ok(hint) = block.hint_name().await { if !hint.is_empty() { self.description = Some(hint.clone()); self.media_description = Some(hint); } } if let Ok(hint_icon) = block.hint_icon_name().await { if !hint_icon.is_empty() { self.icon.name = Some(hint_icon.clone()); self.media_icon.name = Some(hint_icon); } } if let Ok(hint_icon_symbolic) = block.hint_symbolic_icon_name().await { if !hint_icon_symbolic.is_empty() { self.icon.name_symbolic = Some(hint_icon_symbolic.clone()); self.media_icon.name_symbolic = Some(hint_icon_symbolic); } } } let mut block_for_partition = None; if let Some(ref partition) = partition { // safe to unwrap as the table's object path does not need to be converted let object = client.object(partition.inner().path().clone()).unwrap(); block_for_partition = object.block().await.ok(); } block_for_partition = block_for_partition.or_else(|| block.clone()); if let Some(partition) = partition { // Translators: Used to describe a partition of a drive. // The %u is the partition number. // The %s is the description for the drive (e.g. "2 GB Thumb Drive"). //TODO: pgettext_f does not support non-string C placeholders, so we replace it //manually to maintain compatibilty self.description = Some( pgettext_f( "part-drive", "Partition %u of {}", [self.description.as_deref().unwrap_or_default()], ) .replace( "%u", &partition.number().await.unwrap_or_default().to_string(), ), ) } //calculate and set one-liner if let Some(block) = block { if let Ok(drive_revision) = drive.revision().await { // Translators: String used for one-liner description of drive. // The first %s is the description of the object (e.g. "80 GB Disk" or "Partition 2 of 2 GB Thumb Drive"). // The second %s is the name of the object (e.g. "INTEL SSDSA2MH080G1GC"). // The third %s is the fw revision (e.g "45ABX21"). // The fourth %s is the special device file (e.g. "/dev/sda"). self.one_liner = Some(pgettext_f( "one-liner-drive", "{} — {} [{}] ({})", [ self.description.as_deref().unwrap_or_default(), self.name.as_deref().unwrap_or_default(), &drive_revision, &block .preferred_device() .await .ok() .and_then(|dev| CString::from_vec_with_nul(dev).ok()) .and_then(|dev| dev.to_str().map(|p| p.to_string()).ok()) .unwrap_or_default(), ], )); } else { // Translators: String used for one-liner description of drive w/o known fw revision. // The first %s is the description of the object (e.g. "80 GB Disk"). // The second %s is the name of the object (e.g. "INTEL SSDSA2MH080G1GC"). // The third %s is the special device file (e.g. "/dev/sda"). self.one_liner = Some(pgettext_f( "one-liner-drive", "{} — {} ({})", [ self.description.as_deref().unwrap_or_default(), self.name.as_deref().unwrap_or_default(), //safe to unwrap has been set before if it was none &block_for_partition .unwrap() .preferred_device() .await .ok() .and_then(|dev| CString::from_vec_with_nul(dev).ok()) .and_then(|dev| dev.to_str().map(|p| p.to_string()).ok()) .unwrap_or_default(), ], )); } } self.sort_key = Some(format!( "00_drive_{}", drive.sort_key().await.unwrap_or_default(), )); } fn format_level(&self, level: error::Result) -> String { pgettext( "mdraid-desc", match level.as_deref() { Ok("raid0") => "RAID-0 Array", Ok("raid1") => "RAID-1 Array", Ok("raid4") => "RAID-4 Array", Ok("raid5") => "RAID-5 Array", Ok("raid6") => "RAID-6 Array", Ok("raid10") => "RAID-10 Array", _ => "RAID Array", }, ) } } udisks2-0.3.1/src/partition.rs000064400000000000000000000124641046102023000143660ustar 00000000000000//! Block device representing a partition. use enumflags2::{bitflags, BitFlags}; use serde::{Deserialize, Serialize}; use zbus::{proxy, zvariant::Type}; use crate::error; /// Flags describing the partition. #[bitflags] #[repr(u64)] #[derive(Type, Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)] pub enum PartitionFlags { /// The partition is marked as a system partition. /// /// Known flag for `gpt` partitions. SystemPartition = 1 << 0, /// The partition is marked as a Legacy BIOS Bootable partition. /// /// Known flag for `gpt` partitions. LegacyBIOSBootable = 1 << 2, /// The partition is marked as bootable. /// /// Known flag for `dos` partitions. Bootable = 0x80, /// The partition is marked as read-only. /// /// Known flag for `gpt` partitions. ReadOnly = 1 << 60, /// The partition is marked as hidden. /// /// Known flag for `gpt` partitions. Hidden = 1 << 62, /// The partition is marked as Do not automount. /// /// Known flag for `gpt` partitions. NoAutoMount = 1 << 63, } /// Generated code for the [`org.freedesktop.UDisks2.Partition`](https://storaged.org/doc/udisks2-api/latest/gdbus-org.freedesktop.UDisks2.Partition.html) D-Bus interface. #[proxy( interface = "org.freedesktop.UDisks2.Partition", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Partition" )] pub trait Partition { /// Deletes the partition. /// /// If the option `tear-down` is set to `true`, then the block device and all its children will be cleaned up before formatting. /// This cleanup consists of removing entries from `/etc/fstab` and `/etc/crypttab`, and locking of encrypted block devices. /// Entries in `/etc/fstab` and `/etc/crypttab` that have been created with the 'track-parents' options to AddConfigurationItem /// will be removed even if their block device is currently unavailable. fn delete( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Resizes the partition. /// /// The partition will not change its position but might be slightly /// bigger than requested due to sector counts and alignment (e.g. 1MiB). /// If the requested size can't be allocated it results in an error. /// The maximal size can automatically be set by using 0 as size. fn resize( &self, size: u64, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Set the `flags` property. /// /// See [`PartitionFlags`] for more information. fn set_flags( &self, flags: BitFlags, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Sets the partition name (label). fn set_name( &self, name: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Sets the partition type. See the "Type" property for a description of known partition types. fn set_type( &self, type_: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Sets the partition UUID (GPT only). #[zbus(name = "SetUUID")] fn set_uuid( &self, uuid: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Flags describing the partition. /// /// See [`PartitionFlags`] for more information. #[zbus(property)] fn flags(&self) -> error::Result>; /// IsContained property #[zbus(property)] fn is_contained(&self) -> error::Result; /// Whether the partition itself is a container for other partitions. /// /// For example, for dos partition tables, /// this applies to socalled extended partition (partitions of type 0x05, 0x0f or 0x85) /// containing socalled logical partitions. #[zbus(property)] fn is_container(&self) -> error::Result; /// Whether the partition is contained in another partition. /// /// See the [`Self::is_container`] for more information. #[zbus(property)] fn name(&self) -> error::Result; /// Number of the partition in the partition table. #[zbus(property)] fn number(&self) -> error::Result; /// Offset of partition, in bytes. #[zbus(property)] fn offset(&self) -> error::Result; /// Size of partition, in bytes. #[zbus(property)] fn size(&self) -> error::Result; /// Object path of the [org.freedesktop.UDisks2.PartitionTable] /// object that the partition entry belongs to. #[zbus(property)] fn table(&self) -> error::Result; /// Type of the partition. /// /// For `dos` partition tables, this string is a /// hexadecimal number e.g. `0x83` or `0xfd`. /// For `gpt` partition tables this is the UUID e.g. /// `ebd0a0a2-b9e5-4433-87c0-68b6b72699c7`. #[zbus(property)] fn type_(&self) -> error::Result; /// UUID of the partition. /// /// Blank if not supported or unknown. #[zbus(property, name = "UUID")] fn uuid(&self) -> error::Result; } udisks2-0.3.1/src/partition_subtypes.rs000064400000000000000000000022451046102023000163200ustar 00000000000000#[derive(Debug)] pub(crate) struct PartitionTableSubType { pub ty: &'static str, pub subtype: &'static str, pub name: &'static str, } impl PartitionTableSubType { const fn new(ty: &'static str, subtype: &'static str, name: &'static str) -> Self { //TODO: wrap name with gettext call Self { ty, subtype, name } } } /// Known [PartitionTableSubType]s. pub(crate) const PARTITION_TABLE_SUBTYPES: [PartitionTableSubType; 11] = [ //Translators: name of partition table format PartitionTableSubType::new("dos", "generic", "Generic"), PartitionTableSubType::new("dos", "linux", "Linux"), PartitionTableSubType::new("dos", "microsoft", "Windows"), PartitionTableSubType::new("dos", "other", "Other"), // PartitionTableSubType::new("gpt", "generic", "Generic"), PartitionTableSubType::new("gpt", "linux", "Linux"), PartitionTableSubType::new("gpt", "microsoft", "Windows"), PartitionTableSubType::new("gpt", "apple", "Mac OS X"), PartitionTableSubType::new("gpt", "other", "Other"), // PartitionTableSubType::new("apm", "apple", "Mac OS X"), PartitionTableSubType::new("apm", "microsoft", "Windows"), ]; udisks2-0.3.1/src/partition_types.rs000064400000000000000000001322671046102023000156160ustar 00000000000000/// Flags describing a partition type. #[derive(Debug, Clone, Copy)] pub enum PartitionTypeInfoFlags { /// No flags set. None = 0, /// Partition type is used for swap. Swap = (1 << 0), /// Partition type is used for RAID/LVM or similar. Raid = (1 << 1), /// Partition type indicates the partition is hidden /// (e.g. 'dos' type 0x1b PartitionType::new("Hidden W95 FAT32"). /// Note that this is not the same as user-toggleable /// attributes/flags for a partition. Hidden = (1 << 2), /// Partition type can only be used when creating a partition /// and e.g. should not be selectable in a "change partition type" /// user interface (e.g. 'dos' type 0x05, 0x0f and 0x85 /// for extended partitions). CreateOnly = (1 << 3), /// Partition type indicates the partition is part of the system / bootloader (e.g. 'dos' types 0xee, 0xff, 'gpt' types for 'EFI System partition' and 'BIOS Boot partition'). System = (1 << 4), } /// Detailed information about a partition type. /// /// `table_subtype` is used to break the set of partition types for /// `table_type` into a logical subsets. It is typically only used in /// user interfaces where the partition type is selected. #[derive(Debug)] pub struct PartitionTypeInfo { /// A partition table type e.g. `dos` or `gpt` pub table_type: &'static str, /// A partition table sub-type pub table_subtype: &'static str, /// A partition type pub ty: &'static str, /// Name of the partition pub(crate) name: &'static str, /// Flags describing the partition type pub flags: PartitionTypeInfoFlags, } impl PartitionTypeInfo { const fn new( table_type: &'static str, table_subtype: &'static str, ty: &'static str, name: &'static str, flags: PartitionTypeInfoFlags, ) -> Self { //TODO: wrap name with gettext call Self { table_type, table_subtype, ty, name, flags, } } } /// Known [PartitionType]s. /// see http://en.wikipedia.org/wiki/GUID_Partition_Table pub(crate) const PARTITION_TYPES: [PartitionTypeInfo; 228] = [ // Not associated with any OS PartitionTypeInfo::new( "gpt", "generic", "024dee41-33e7-11d3-9d69-0008c781f39f", "MBR Partition Scheme", PartitionTypeInfoFlags::System, ), PartitionTypeInfo::new( "gpt", "generic", "c12a7328-f81f-11d2-ba4b-00a0c93ec93b", "EFI System", PartitionTypeInfoFlags::System, ), PartitionTypeInfo::new( "gpt", "generic", "21686148-6449-6e6f-744e-656564454649", "BIOS Boot", PartitionTypeInfoFlags::System, ), // This is also defined in the Apple and Solaris section PartitionTypeInfo::new( "gpt", "generic", "6a898cc3-1dd2-11b2-99a6-080020736631", "ZFS", PartitionTypeInfoFlags::None, ), // Extended Boot Partition, see http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ PartitionTypeInfo::new( "gpt", "generic", "bc13c2ff-59e6-4262-a352-b275fd6f7172", "Extended Boot Partition", PartitionTypeInfoFlags::None, ), // Discoverable Linux Partitions, see http://systemd.io/DISCOVERABLE_PARTITIONS/ PartitionTypeInfo::new( "gpt", "linux", "6523f8ae-3eb1-4e2a-a05a-18b695ae656f", "Linux Root Partition (Alpha)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d27f46ed-2919-4cb8-bd25-9531f3c16534", "Linux Root Partition (ARC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "69dad710-2ce4-4e3c-b16c-21a1d49abed3", "Linux Root Partition (32-bit ARM)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b921b045-1df0-41c3-af44-4c6f280d3fae", "Linux Root Partition (64-bit ARM/AArch64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "993d8d3d-f80e-4225-855a-9daf8ed7ea97", "Linux Root Partition (Itanium/IA-64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "77055800-792c-4f94-b39a-98c91b762bb6", "Linux Root Partition (LoongArch 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "37c58c8a-d913-4156-a25f-48b1b64e07f0", "Linux Root Partition (32-bit MIPS LittleEndian/mipsel)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "700bda43-7a34-4507-b179-eeb93d7a7ca3", "Linux Root Partition (64-bit MIPS LittleEndian/mips64el)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "1aacdb3b-5444-4138-bd9e-e5c2239b2346", "Linux Root Partition (HPPA/PARISC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "1de3f1ef-fa98-47b5-8dcd-4a860a654d78", "Linux Root Partition (32-bit PowerPC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "912ade1d-a839-4913-8964-a10eee08fbd2", "Linux Root Partition (64-bit PowerPC BigEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c31c45e6-3f39-412e-80fb-4809c4980599", "Linux Root Partition (64-bit PowerPC LittleEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "60d5a7fe-8e7d-435c-b714-3dd8162144e1", "Linux Root Partition (RISC-V 32-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "72ec70a6-cf74-40e6-bd49-4bda08e8f224", "Linux Root Partition (RISC-V 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "08a7acea-624c-4a20-91e8-6e0fa67d23f9", "Linux Root Partition (s390)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "5eead9a9-fe09-4a1e-a1d7-520d00531306", "Linux Root Partition (s390x)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c50cdd70-3862-4cc3-90e1-809a8c93ee2c", "Linux Root Partition (TILE-Gx)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "44479540-f297-41b2-9af7-d131d5f0458a", "Linux Root Partition (x86)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "4f68bce3-e8cd-4db1-96e7-fbcaf984b709", "Linux Root Partition (amd64/x86_64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "e18cf08c-33ec-4c0d-8246-c6c6fb3da024", "Linux /usr/ Partition (Alpha)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "7978a683-6316-4922-bbee-38bff5a2fecc", "Linux /usr/ Partition (ARC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "7d0359a3-02b3-4f0a-865c-654403e70625", "Linux /usr/ Partition (32-bit ARM)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b0e01050-ee5f-4390-949a-9101b17104e9", "Linux /usr/ Partition (64-bit ARM/AArch64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "4301d2a6-4e3b-4b2a-bb94-9e0b2c4225ea", "Linux /usr/ Partition (Itanium/IA-64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "e611c702-575c-4cbe-9a46-434fa0bf7e3f", "Linux /usr/ Partition (LoongArch 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "0f4868e9-9952-4706-979f-3ed3a473e947", "Linux /usr/ Partition (32-bit MIPS LittleEndian/mipsel)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c97c1f32-ba06-40b4-9f22-236061b08aa8", "Linux /usr/ Partition (64-bit MIPS LittleEndian/mips64el)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "dc4a4480-6917-4262-a4ec-db9384949f25", "Linux /usr/ Partition (HPPA/PARISC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "7d14fec5-cc71-415d-9d6c-06bf0b3c3eaf", "Linux /usr/ Partition (32-bit PowerPC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "2c9739e2-f068-46b3-9fd0-01c5a9afbcca", "Linux /usr/ Partition (64-bit PowerPC BigEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "15bb03af-77e7-4d4a-b12b-c0d084f7491c", "Linux /usr/ Partition (64-bit PowerPC LittleEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b933fb22-5c3f-4f91-af90-e2bb0fa50702", "Linux /usr/ Partition (RISC-V 32-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "beaec34b-8442-439b-a40b-984381ed097d", "Linux /usr/ Partition (RISC-V 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "cd0f869b-d0fb-4ca0-b141-9ea87cc78d66", "Linux /usr/ Partition (s390)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "8a4f5770-50aa-4ed3-874a-99b710db6fea", "Linux /usr/ Partition (s390x)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "55497029-c7c1-44cc-aa39-815ed1558630", "Linux /usr/ Partition (TILE-Gx)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "75250d76-8cc6-458e-bd66-bd47cc81a812", "Linux /usr/ Partition (x86)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "8484680c-9521-48c6-9c11-b0720656f69e", "Linux /usr/ Partition (amd64/x86_64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "fc56d9e9-e6e5-4c06-be32-e74407ce09a5", "Linux Root Verity Partition (Alpha)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "24b2d975-0f97-4521-afa1-cd531e421b8d", "Linux Root Verity Partition (ARC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "7386cdf2-203c-47a9-a498-f2ecce45a2d6", "Linux Root Verity Partition (32-bit ARM)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "df3300ce-d69f-4c92-978c-9bfb0f38d820", "Linux Root Verity Partition (64-bit ARM/AArch64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "86ed10d5-b607-45bb-8957-d350f23d0571", "Linux Root Verity Partition (Itanium/IA-64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "f3393b22-e9af-4613-a948-9d3bfbd0c535", "Linux Root Verity Partition (LoongArch 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d7d150d2-2a04-4a33-8f12-16651205ff7b", "Linux Root Verity Partition (32-bit MIPS LittleEndian/mipsel)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "16b417f8-3e06-4f57-8dd2-9b5232f41aa6", "Linux Root Verity Partition (64-bit MIPS LittleEndian/mips64el)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d212a430-fbc5-49f9-a983-a7feef2b8d0e", "Linux Root Verity Partition (HPPA/PARISC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "906bd944-4589-4aae-a4e4-dd983917446a", "Linux Root Verity Partition (64-bit PowerPC LittleEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "9225a9a3-3c19-4d89-b4f6-eeff88f17631", "Linux Root Verity Partition (64-bit PowerPC BigEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "98cfe649-1588-46dc-b2f0-add147424925", "Linux Root Verity Partition (32-bit PowerPC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "ae0253be-1167-4007-ac68-43926c14c5de", "Linux Root Verity Partition (RISC-V 32-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b6ed5582-440b-4209-b8da-5ff7c419ea3d", "Linux Root Verity Partition (RISC-V 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "7ac63b47-b25c-463b-8df8-b4a94e6c90e1", "Linux Root Verity Partition (s390)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b325bfbe-c7be-4ab8-8357-139e652d2f6b", "Linux Root Verity Partition (s390x)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "966061ec-28e4-4b2e-b4a5-1f0a825a1d84", "Linux Root Verity Partition (TILE-Gx)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "2c7357ed-ebd2-46d9-aec1-23d437ec2bf5", "Linux Root Verity Partition (amd64/x86_64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d13c5d3b-b5d1-422a-b29f-9454fdc89d76", "Linux Root Verity Partition (x86)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "8cce0d25-c0d0-4a44-bd87-46331bf1df67", "Linux /usr/ Verity Partition (Alpha)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "fca0598c-d880-4591-8c16-4eda05c7347c", "Linux /usr/ Verity Partition (ARC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c215d751-7bcd-4649-be90-6627490a4c05", "Linux /usr/ Verity Partition (32-bit ARM)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "6e11a4e7-fbca-4ded-b9e9-e1a512bb664e", "Linux /usr/ Verity Partition (64-bit ARM/AArch64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "6a491e03-3be7-4545-8e38-83320e0ea880", "Linux /usr/ Verity Partition (Itanium/IA-64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "f46b2c26-59ae-48f0-9106-c50ed47f673d", "Linux /usr/ Verity Partition (LoongArch 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "46b98d8d-b55c-4e8f-aab3-37fca7f80752", "Linux /usr/ Verity Partition (32-bit MIPS LittleEndian/mipsel)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "3c3d61fe-b5f3-414d-bb71-8739a694a4ef", "Linux /usr/ Verity Partition (64-bit MIPS LittleEndian/mips64el)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "5843d618-ec37-48d7-9f12-cea8e08768b2", "Linux /usr/ Verity Partition (HPPA/PARISC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "ee2b9983-21e8-4153-86d9-b6901a54d1ce", "Linux /usr/ Verity Partition (64-bit PowerPC LittleEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "bdb528a5-a259-475f-a87d-da53fa736a07", "Linux /usr/ Verity Partition (64-bit PowerPC BigEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "df765d00-270e-49e5-bc75-f47bb2118b09", "Linux /usr/ Verity Partition (32-bit PowerPC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "cb1ee4e3-8cd0-4136-a0a4-aa61a32e8730", "Linux /usr/ Verity Partition (RISC-V 32-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "8f1056be-9b05-47c4-81d6-be53128e5b54", "Linux /usr/ Verity Partition (RISC-V 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b663c618-e7bc-4d6d-90aa-11b756bb1797", "Linux /usr/ Verity Partition (s390)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "31741cc4-1a2a-4111-a581-e00b447d2d06", "Linux /usr/ Verity Partition (s390x)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "2fb4bf56-07fa-42da-8132-6b139f2026ae", "Linux /usr/ Verity Partition (TILE-Gx)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "77ff5f63-e7b6-4633-acf4-1565b864c0e6", "Linux /usr/ Verity Partition (amd64/x86_64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "8f461b0d-14ee-4e81-9aa9-049b6fb97abd", "Linux /usr/ Verity Partition (x86)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d46495b7-a053-414f-80f7-700c99921ef8", "Linux Root Verity Signature Partition (Alpha)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "143a70ba-cbd3-4f06-919f-6c05683a78bc", "Linux Root Verity Signature Partition (ARC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "42b0455f-eb11-491d-98d3-56145ba9d037", "Linux Root Verity Signature Partition (32-bit ARM)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "6db69de6-29f4-4758-a7a5-962190f00ce3", "Linux Root Verity Signature Partition (64-bit ARM/AArch64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "e98b36ee-32ba-4882-9b12-0ce14655f46a", "Linux Root Verity Signature Partition (Itanium/IA-64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "5afb67eb-ecc8-4f85-ae8e-ac1e7c50e7d0", "Linux Root Verity Signature Partition (LoongArch 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c919cc1f-4456-4eff-918c-f75e94525ca5", "Linux Root Verity Signature Partition (32-bit MIPS LittleEndian/mipsel)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "904e58ef-5c65-4a31-9c57-6af5fc7c5de7", "Linux Root Verity Signature Partition (64-bit MIPS LittleEndian/mips64el)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "15de6170-65d3-431c-916e-b0dcd8393f25", "Linux Root Verity Signature Partition (HPPA/PARISC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d4a236e7-e873-4c07-bf1d-bf6cf7f1c3c6", "Linux Root Verity Signature Partition (64-bit PowerPC LittleEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "f5e2c20c-45b2-4ffa-bce9-2a60737e1aaf", "Linux Root Verity Signature Partition (64-bit PowerPC BigEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "1b31b5aa-add9-463a-b2ed-bd467fc857e7", "Linux Root Verity Signature Partition (32-bit PowerPC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "3a112a75-8729-4380-b4cf-764d79934448", "Linux Root Verity Signature Partition (RISC-V 32-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "efe0f087-ea8d-4469-821a-4c2a96a8386a", "Linux Root Verity Signature Partition (RISC-V 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "3482388e-4254-435a-a241-766a065f9960", "Linux Root Verity Signature Partition (s390)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c80187a5-73a3-491a-901a-017c3fa953e9", "Linux Root Verity Signature Partition (s390x)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b3671439-97b0-4a53-90f7-2d5a8f3ad47b", "Linux Root Verity Signature Partition (TILE-Gx)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "41092b05-9fc8-4523-994f-2def0408b176", "Linux Root Verity Signature Partition (amd64/x86_64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "5996fc05-109c-48de-808b-23fa0830b676", "Linux Root Verity Signature Partition (x86)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "5c6e1c76-076a-457a-a0fe-f3b4cd21ce6e", "Linux /usr/ Verity Signature Partition (Alpha)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "94f9a9a1-9971-427a-a400-50cb297f0f35", "Linux /usr/ Verity Signature Partition (ARC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d7ff812f-37d1-4902-a810-d76ba57b975a", "Linux /usr/ Verity Signature Partition (32-bit ARM)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c23ce4ff-44bd-4b00-b2d4-b41b3419e02a", "Linux /usr/ Verity Signature Partition (64-bit ARM/AArch64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "8de58bc2-2a43-460d-b14e-a76e4a17b47f", "Linux /usr/ Verity Signature Partition (Itanium/IA-64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "b024f315-d330-444c-8461-44bbde524e99", "Linux /usr/ Verity Signature Partition (LoongArch 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "3e23ca0b-a4bc-4b4e-8087-5ab6a26aa8a9", "Linux /usr/ Verity Signature Partition (32-bit MIPS LittleEndian/mipsel)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "f2c2c7ee-adcc-4351-b5c6-ee9816b66e16", "Linux /usr/ Verity Signature Partition (64-bit MIPS LittleEndian/mips64el)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "450dd7d1-3224-45ec-9cf2-a43a346d71ee", "Linux /usr/ Verity Signature Partition (HPPA/PARISC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c8bfbd1e-268e-4521-8bba-bf314c399557", "Linux /usr/ Verity Signature Partition (64-bit PowerPC LittleEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "0b888863-d7f8-4d9e-9766-239fce4d58af", "Linux /usr/ Verity Signature Partition (64-bit PowerPC BigEndian)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "7007891d-d371-4a80-86a4-5cb875b9302e", "Linux /usr/ Verity Signature Partition (32-bit PowerPC)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "c3836a13-3137-45ba-b583-b16c50fe5eb4", "Linux /usr/ Verity Signature Partition (RISC-V 32-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "d2f9000a-7a18-453f-b5cd-4d32f77a7b32", "Linux /usr/ Verity Signature Partition (RISC-V 64-bit)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "17440e4f-a8d0-467f-a46e-3912ae6ef2c5", "Linux /usr/ Verity Signature Partition (s390)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "3f324816-667b-46ae-86ee-9b0c0c6c11b4", "Linux /usr/ Verity Signature Partition (s390x)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "4ede75e2-6ccc-4cc8-b9c7-70334b087510", "Linux /usr/ Verity Signature Partition (TILE-Gx)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "e7bb33fb-06cf-4e81-8273-e543b413e2e2", "Linux /usr/ Verity Signature Partition (amd64/x86_64)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "974a71c0-de41-43c3-be5d-5c5ccd1ad2c0", "Linux /usr/ Verity Signature Partition (x86)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "4d21b016-b534-45c2-a9fb-5c16e091fd2d", "Linux Variable Data Partition", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "7ec6f557-3bc5-4aca-b293-16ef5df639d1", "Linux Temporary Data Partition", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "773f91ef-66d4-49b5-bd83-d683bf40ad16", "Linux Per-user Home Partition", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "933ac7e1-2eb4-4f13-b844-0e14e2aef915", "Linux Home Partition", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "3b8f8425-20e0-4f3b-907f-1a25a76f98e8", "Linux Server Data Partition", PartitionTypeInfoFlags::None, ), // Linux PartitionTypeInfo::new( "gpt", "linux", "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f", "Linux Swap", PartitionTypeInfoFlags::Swap, ), PartitionTypeInfo::new( "gpt", "linux", "0fc63daf-8483-4772-8e79-3d69d8477de4", "Linux Filesystem", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "linux", "a19d880f-05fc-4d3b-a006-743f0f84911e", "Linux RAID", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "gpt", "linux", "e6d6d379-f507-44c2-a23c-238f2a3df928", "Linux LVM", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "gpt", "linux", "8da63339-0007-60c0-c436-083ac8230908", "Linux Reserved", PartitionTypeInfoFlags::None, ), // Microsoft PartitionTypeInfo::new( "gpt", "microsoft", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7", "Basic Data", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "microsoft", "e3c9e316-0b5c-4db8-817d-f92df00215ae", "Microsoft Reserved", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "microsoft", "5808c8aa-7e8f-42e0-85d2-e1e90434cfb3", "Microsoft LDM metadata", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "microsoft", "af9b60a0-1431-4f62-bc68-3311714a69ad", "Microsoft LDM data", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "microsoft", "de94bba4-06d1-4d40-a16a-bfd50179d6ac", "Microsoft Windows Recovery Environment", PartitionTypeInfoFlags::None, ), // Apple OS X PartitionTypeInfo::new( "gpt", "apple", "48465300-0000-11aa-aa11-00306543ecac", "Apple HFS/HFS+", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "apple", "7c3457ef-0000-11aa-aa11-00306543ecac", "Apple APFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "apple", "55465300-0000-11aa-aa11-00306543ecac", "Apple UFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "apple", "6a898cc3-1dd2-11b2-99a6-080020736631", "Apple ZFS", PartitionTypeInfoFlags::None, ), // same as ZFS PartitionTypeInfo::new( "gpt", "apple", "52414944-0000-11aa-aa11-00306543ecac", "Apple RAID", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "gpt", "apple", "52414944-5f4f-11aa-aa11-00306543ecac", "Apple RAID (offline)", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "gpt", "apple", "426f6f74-0000-11aa-aa11-00306543ecac", "Apple Boot", PartitionTypeInfoFlags::System, ), PartitionTypeInfo::new( "gpt", "apple", "4c616265-6c00-11aa-aa11-00306543ecac", "Apple Label", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "apple", "5265636f-7665-11aa-aa11-00306543ecac", "Apple TV Recovery", PartitionTypeInfoFlags::System, ), PartitionTypeInfo::new( "gpt", "apple", "53746f72-6167-11aa-aa11-00306543ecac", "Apple Core Storage", PartitionTypeInfoFlags::Raid, ), // HP-UX PartitionTypeInfo::new( "gpt", "other", "75894c1e-3aeb-11d3-b7c1-7b03a0000000", "HP-UX Data", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "e2a1e728-32e3-11d6-a682-7b03a0000000", "HP-UX Service", PartitionTypeInfoFlags::None, ), // FreeBSD PartitionTypeInfo::new( "gpt", "other", "83bd6b9d-7f41-11dc-be0b-001560b84f0f", "FreeBSD Boot", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "516e7cb4-6ecf-11d6-8ff8-00022d09712b", "FreeBSD Data", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "516e7cb5-6ecf-11d6-8ff8-00022d09712b", "FreeBSD Swap", PartitionTypeInfoFlags::Swap, ), PartitionTypeInfo::new( "gpt", "other", "516e7cb6-6ecf-11d6-8ff8-00022d09712b", "FreeBSD UFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "516e7cb8-6ecf-11d6-8ff8-00022d09712b", "FreeBSD Vinum", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "gpt", "other", "516e7cba-6ecf-11d6-8ff8-00022d09712b", "FreeBSD ZFS", PartitionTypeInfoFlags::None, ), // Solaris PartitionTypeInfo::new( "gpt", "other", "6a82cb45-1dd2-11b2-99a6-080020736631", "Solaris Boot", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a85cf4d-1dd2-11b2-99a6-080020736631", "Solaris Root", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a87c46f-1dd2-11b2-99a6-080020736631", "Solaris Swap", PartitionTypeInfoFlags::Swap, ), PartitionTypeInfo::new( "gpt", "other", "6a8b642b-1dd2-11b2-99a6-080020736631", "Solaris Backup", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a898cc3-1dd2-11b2-99a6-080020736631", "Solaris /usr", PartitionTypeInfoFlags::None, ), // same as ZFS PartitionTypeInfo::new( "gpt", "other", "6a8ef2e9-1dd2-11b2-99a6-080020736631", "Solaris /var", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a90ba39-1dd2-11b2-99a6-080020736631", "Solaris /home", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a9283a5-1dd2-11b2-99a6-080020736631", "Solaris Alternate Sector", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a945a3b-1dd2-11b2-99a6-080020736631", "Solaris Reserved", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a9630d1-1dd2-11b2-99a6-080020736631", "Solaris Reserved (2)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a980767-1dd2-11b2-99a6-080020736631", "Solaris Reserved (3)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a96237f-1dd2-11b2-99a6-080020736631", "Solaris Reserved (4)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "6a8d2ac7-1dd2-11b2-99a6-080020736631", "Solaris Reserved (5)", PartitionTypeInfoFlags::None, ), // NetBSD PartitionTypeInfo::new( "gpt", "other", "49f48d32-b10e-11dc-b99b-0019d1879648", "NetBSD Swap", PartitionTypeInfoFlags::Swap, ), PartitionTypeInfo::new( "gpt", "other", "49f48d5a-b10e-11dc-b99b-0019d1879648", "NetBSD FFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "49f48d82-b10e-11dc-b99b-0019d1879648", "NetBSD LFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "49f48daa-b10e-11dc-b99b-0019d1879648", "NetBSD RAID", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "gpt", "other", "2db519c4-b10f-11dc-b99b-0019d1879648", "NetBSD Concatenated", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "2db519ec-b10f-11dc-b99b-0019d1879648", "NetBSD Encrypted", PartitionTypeInfoFlags::None, ), // VMWare, see http://blogs.vmware.com/vsphere/2011/08/vsphere-50-storage-features-part-7-gpt.html PartitionTypeInfo::new( "gpt", "other", "aa31e02a-400f-11db-9590-000c2911d1b8", "VMWare VMFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "9d275380-40ad-11db-bf97-000c2911d1b8", "VMWare vmkcore", PartitionTypeInfoFlags::None, ), // ChromeOS, see http://www.chromium.org/chromium-os/chromiumos-design-docs/disk-format PartitionTypeInfo::new( "gpt", "other", "cab6e88e-abf3-4102-a07a-d4bb9be3c1d3", "ChromeOS Firmware", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "fe3a2a5d-4f32-41a7-b725-accc3285a309", "ChromeOS Kernel", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec", "ChromeOS Root Filesystem", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "gpt", "other", "2e0a753d-9e48-43b0-8337-b15192cb1b5e", "ChromeOS Reserved", PartitionTypeInfoFlags::None, ), // Intel Partition Types // FFS = Fast Flash Standby, aka Intel Rapid start // http://downloadmirror.intel.com/22647/eng/Intel%20Rapid%20Start%20Technology%20Deployment%20Guide%20v1.0.pdf PartitionTypeInfo::new( "gpt", "other", "d3bfe2de-3daf-11df-ba40-e3a556d89593", "Intel FFS Reserved", PartitionTypeInfoFlags::None, ), // see http://developer.apple.com/documentation/mac/devices/devices-126.html // http://lists.apple.com/archives/Darwin-drivers/2003/May/msg00021.html PartitionTypeInfo::new( "apm", "apple", "Apple_Unix_SVR2", "Apple UFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "apple", "Apple_HFS", "Apple HFS/HFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "apple", "Apple_partition_map", "Apple Partition Map", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "apple", "Apple_Free", "Unused", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "apple", "Apple_Scratch", "Empty", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "apple", "Apple_Driver", "Driver", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "apple", "Apple_Driver43", "Driver 4.3", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "apple", "Apple_PRODOS", "ProDOS file system", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "microsoft", "DOS_FAT_12", "FAT 12", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "microsoft", "DOS_FAT_16", "FAT 16", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "microsoft", "DOS_FAT_32", "FAT 32", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "microsoft", "Windows_FAT_16", "FAT 16 (Windows)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "apm", "microsoft", "Windows_FAT_32", "FAT 32 (Windows)", PartitionTypeInfoFlags::None, ), // see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html PartitionTypeInfo::new( "dos", "generic", "0x05", "Extended", PartitionTypeInfoFlags::CreateOnly, ), PartitionTypeInfo::new( "dos", "generic", "0xee", "EFI GPT", PartitionTypeInfoFlags::System, ), PartitionTypeInfo::new( "dos", "generic", "0xef", "EFI (FAT-12/16/32)", PartitionTypeInfoFlags::System, ), PartitionTypeInfo::new( "dos", "linux", "0x82", "Linux swap", PartitionTypeInfoFlags::Swap, ), PartitionTypeInfo::new( "dos", "linux", "0x83", "Linux", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "linux", "0x85", "Linux Extended", PartitionTypeInfoFlags::CreateOnly, ), PartitionTypeInfo::new( "dos", "linux", "0x8e", "Linux LVM", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "dos", "linux", "0xfd", "Linux RAID auto", PartitionTypeInfoFlags::Raid, ), PartitionTypeInfo::new( "dos", "microsoft", "0x01", "FAT12", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "microsoft", "0x04", "FAT16 <32M", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "microsoft", "0x06", "FAT16", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "microsoft", "0x07", "NTFS/exFAT/HPFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "microsoft", "0x0b", "W95 FAT32", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "microsoft", "0x0c", "W95 FAT32 (LBA)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "microsoft", "0x0e", "W95 FAT16 (LBA)", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "microsoft", "0x0f", "W95 Ext d (LBA)", PartitionTypeInfoFlags::CreateOnly, ), PartitionTypeInfo::new( "dos", "microsoft", "0x11", "Hidden FAT12", PartitionTypeInfoFlags::Hidden, ), PartitionTypeInfo::new( "dos", "microsoft", "0x14", "Hidden FAT16 <32M", PartitionTypeInfoFlags::Hidden, ), PartitionTypeInfo::new( "dos", "microsoft", "0x16", "Hidden FAT16", PartitionTypeInfoFlags::Hidden, ), PartitionTypeInfo::new( "dos", "microsoft", "0x17", "Hidden HPFS/NTFS", PartitionTypeInfoFlags::Hidden, ), PartitionTypeInfo::new( "dos", "microsoft", "0x1b", "Hidden W95 FAT32", PartitionTypeInfoFlags::Hidden, ), PartitionTypeInfo::new( "dos", "microsoft", "0x1c", "Hidden W95 FAT32 (LBA)", PartitionTypeInfoFlags::Hidden, ), PartitionTypeInfo::new( "dos", "microsoft", "0x1e", "Hidden W95 FAT16 (LBA)", PartitionTypeInfoFlags::Hidden, ), PartitionTypeInfo::new("dos", "other", "0x10", "OPUS", PartitionTypeInfoFlags::None), PartitionTypeInfo::new( "dos", "other", "0x12", "Compaq diagnostics", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0x3c", "PartitionMagic", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0x81", "Minix", PartitionTypeInfoFlags::None, ), // cf. http://en.wikipedia.org/wiki/MINIX_file_system PartitionTypeInfo::new( "dos", "other", "0x84", "Hibernation", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xa0", "Hibernation", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xa5", "FreeBSD", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xa6", "OpenBSD", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xa8", "Mac OS X", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xaf", "Mac OS X", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xbe", "Solaris boot", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xbf", "Solaris", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xeb", "BeOS BFS", PartitionTypeInfoFlags::None, ), PartitionTypeInfo::new( "dos", "other", "0xec", "SkyOS SkyFS", PartitionTypeInfoFlags::None, ), ]; udisks2-0.3.1/src/partitiontable.rs000064400000000000000000000031531046102023000153710ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.PartitionTable` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.PartitionTable", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/PartitionTable" )] pub trait PartitionTable { /// CreatePartition method fn create_partition( &self, offset: u64, size: u64, type_: &str, name: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// CreatePartitionAndFormat method #[allow(clippy::too_many_arguments)] fn create_partition_and_format( &self, offset: u64, size: u64, type_: &str, name: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, format_type: &str, format_options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result; /// Partitions property #[zbus(property)] fn partitions(&self) -> error::Result>; /// Type property #[zbus(property)] fn type_(&self) -> error::Result; } udisks2-0.3.1/src/swapspace.rs000064400000000000000000000026531046102023000143420ustar 00000000000000//! # DBus interface proxy for: `org.freedesktop.UDisks2.Swapspace` //! //! This code was generated by `zbus-xmlgen` `4.0.0` from DBus introspection data. //! Source: `org.freedesktop.UDisks2.xml`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://dbus2.github.io/zbus/client.html) //! section of the zbus documentation. //! use zbus::proxy; use crate::error; #[proxy( interface = "org.freedesktop.UDisks2.Swapspace", default_service = "org.freedesktop.UDisks2", default_path = "/org/freedesktop/UDisks2/Swapspace" )] pub trait Swapspace { /// SetLabel method fn set_label( &self, label: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// SetUUID method #[zbus(name = "SetUUID")] fn set_uuid( &self, uuid: &str, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Start method fn start( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Stop method fn stop( &self, options: std::collections::HashMap<&str, zbus::zvariant::Value<'_>>, ) -> error::Result<()>; /// Active property #[zbus(property)] fn active(&self) -> error::Result; } udisks2-0.3.1/src/types/mod.rs000064400000000000000000000022121046102023000142660ustar 00000000000000use std::ffi::CString; use zbus::zvariant::{OwnedValue, Value}; #[derive(Debug, Default, PartialEq, Eq)] pub struct UDisks2Path(String); //https://github.com/search?q=zbus%3A%3AResult%3CVec%3C+language%3ARust&type=code&p=5 impl std::ops::Deref for UDisks2Path { type Target = String; fn deref(&self) -> &Self::Target { &self.0 } } impl TryFrom for UDisks2Path { type Error = as TryFrom>::Error; fn try_from(v: OwnedValue) -> Result { let data: Vec = v.try_into()?; Ok(Self( CString::from_vec_with_nul(data) .unwrap() .to_str() .unwrap() .to_owned(), )) } } impl TryFrom> for UDisks2Path { type Error = as TryFrom>::Error; fn try_from(v: zbus::zvariant::Value<'_>) -> Result { let data: Vec = v.try_into()?; Ok(Self( CString::from_vec_with_nul(data) .unwrap() .to_str() .unwrap() .to_owned(), )) } }