{"id":46549247,"url":"https://github.com/raspberrypi/block-device-id","last_synced_at":"2026-03-07T03:00:49.679Z","repository":{"id":342572287,"uuid":"1174378912","full_name":"raspberrypi/block-device-id","owner":"raspberrypi","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-06T13:07:26.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-06T16:16:40.937Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raspberrypi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-06T11:25:12.000Z","updated_at":"2026-03-06T13:45:28.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/raspberrypi/block-device-id","commit_stats":null,"previous_names":["raspberrypi/block-device-id"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/raspberrypi/block-device-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fblock-device-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fblock-device-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fblock-device-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fblock-device-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raspberrypi","download_url":"https://codeload.github.com/raspberrypi/block-device-id/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fblock-device-id/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30206336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"online","status_checked_at":"2026-03-07T02:00:06.765Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-07T03:00:30.339Z","updated_at":"2026-03-07T03:00:49.659Z","avatar_url":"https://github.com/raspberrypi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# block-device-id\n\nA Rust library and command-line tool to retrieve hardware-innate unique identifiers from block devices, such as MMC CID or NVME controller serial numbers. These identifiers are suitable for use in cryptographic key derivation or device-specific configuration.\n\n## Features\n\n- C-compatible shared library interface\n- Command-line tool for querying device identifiers\n- Supports multiple block device types (MMC, NVME, etc.)\n- Debian-native package with vendored dependencies\n\n## Building\n\n### Standard Build\n\nTo build the Debian package normally:\n\n```bash\ndebuild -b -uc -us\n```\n\n### Network-Isolated Build with bwrap\n\nThis is a Debian-native Rust package that uses vendored Debian versions of packages rather than fetching from crates.io. For network-isolated builds (e.g., in build environments without internet access), you can use `bwrap` (bubblewrap) to create an isolated build environment.\n\n#### Prerequisites\n\n- `bwrap` must be installed\n- A `resolv.conf` file must be present in the project root (or create one for DNS resolution if needed)\n\n#### Build Command\n\n```bash\nbwrap --bind / / --bind ./resolv.conf /etc/resolv.conf --dev /dev --proc /proc -- debuild -b -uc -us\n```\n\nThis command:\n- `--bind / /` - Binds the root filesystem\n- `--bind ./resolv.conf /etc/resolv.conf` - Uses a local resolv.conf file (prevents DNS lookups)\n- `--dev /dev` - Provides access to device files\n- `--proc /proc` - Provides access to /proc filesystem\n- `-- debuild -b -uc -us` - Runs the Debian build process\n\n#### Creating resolv.conf\n\nIf you don't have a `resolv.conf` file, you can create a minimal one:\n\n```bash\necho \"nameserver 127.0.0.1\" \u003e resolv.conf\n```\n\nOr copy your system's resolv.conf:\n\n```bash\ncp /etc/resolv.conf ./resolv.conf\n```\n\nNote: The `resolv.conf` file is used to prevent DNS resolution attempts during the build. Even with a non-functional nameserver, the build will work because all dependencies are vendored and no network access is required.\n\n#### How It Works\n\nThe build process uses Debian's `dh-cargo` which:\n1. Sets up a vendored cargo registry from `/usr/share/cargo/registry`\n2. Creates a `config.toml` in `debian/cargo_home/` that replaces crates.io with the local registry\n3. Pre-generates cargo metadata for cbindgen to avoid network access\n4. Uses cbindgen with the pre-generated metadata to create C headers\n\nAll Rust dependencies are provided by Debian packages (e.g., `librust-libc-dev`, `librust-nix-dev`, etc.), so no network access to crates.io is needed.\n\n## Package Structure\n\n- `block-device-id` - Command-line tool\n- `libblockdeviceid1` - Shared library (C-compatible)\n- `libblockdeviceid-dev` - Development files (headers, examples)\n- `librust-block-device-id-dev` - Rust source package\n\n## Usage\n\n### Command Line\n\n```bash\nblock-device-id /dev/mmcblk0\n```\n\n### C API\n\nSee `examples/get_device_id.c` for a complete example.\n\n```c\n#include \u003cblock_device_id.h\u003e\n\nchar id[129];\nint ret = bdi_get_id(\"/dev/nvme0n1\", id, sizeof(id));\nif (ret == 0) {\n    printf(\"Device ID: %s\\n\", id);\n}\n```\n\n## License\n\nBSD-3-Clause - See LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspberrypi%2Fblock-device-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraspberrypi%2Fblock-device-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspberrypi%2Fblock-device-id/lists"}