{"id":19378904,"url":"https://github.com/linbit/losetup-container","last_synced_at":"2026-02-03T15:08:47.245Z","repository":{"id":66192251,"uuid":"583289149","full_name":"LINBIT/losetup-container","owner":"LINBIT","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-29T11:30:56.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-08T18:03:51.263Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LINBIT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-29T10:30:55.000Z","updated_at":"2022-12-29T10:50:19.000Z","dependencies_parsed_at":"2023-02-24T08:45:32.797Z","dependency_job_id":null,"html_url":"https://github.com/LINBIT/losetup-container","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/LINBIT/losetup-container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Flosetup-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Flosetup-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Flosetup-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Flosetup-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LINBIT","download_url":"https://codeload.github.com/LINBIT/losetup-container/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Flosetup-container/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29047819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T14:55:20.264Z","status":"ssl_error","status_checked_at":"2026-02-03T14:55:19.725Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-11-10T09:07:52.627Z","updated_at":"2026-02-03T15:08:46.857Z","avatar_url":"https://github.com/LINBIT.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# losetup-container\n\nNormal `losetup`, with one modification. If, and only if it is called with `losetup -l -O NAME,BACK-FILE`, the\noutput is slightly different, in all other cases the normal `losetup` output is used.\n\n## Problem with `losetup`\n\nWhat's wrong with the normal `losetup`? This is difficult to put into words, so here is an example:\n\n```\n# fallocate -l 100m example\n# docker run --privileged --rm -v $PWD:/foo -w /foo -v /dev:/dev almalinux losetup --show -f /foo/example\n/dev/loop0\n# losetup -l\nNAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC\n/dev/loop0         0      0         0  0 /example    0     512\n```\n\nNote that the reported backing file is now `/example`. This is because the loop device only reports the path starting\nfrom the original mount point of our file. Since we bound our working directory to `/foo`, we only see `/example`.\n\nThis is an issue for [LINSTOR®](https://github.com/linbit/linstor-server), and it's file backed storage pools.\nIf run inside a container, and that container restarts, the satellite will think the files are no longer mounted, which\nthen triggers all kinds of unnecessary updates to the volume configuration.\n\n## The solution\n\nIf `losetup -l -O NAME,BACK-FILE` is executed, which is the exact command executed by LINSTOR, `losetup-container` will\ntry to find the right backing file. It does that as follows:\n\n* List all loop devices by searching `/sys/block` for directories starting with `loop`\n* For each `loopX` directory:\n  * Run `ioctl(/dev/loopX, LOOP_GET_STATUS64, ...)`, getting the original backing file name and inode. Since the\n    original file name is limited to 64 characters, it might have been truncated. Add it to the list of candidates.\n  * Read `/sys/block/loopX/loop/backing_file`, which contains the backing file, potentially truncated to the path to\n    the last mount point, as seen in the example above. Add it to the list of candidates.\n  * Read the `LOSETUP_CONTAINER_BIND_MOUNTS` variable. It contains a colon (':') delimited list of paths that will be\n    checked. For each entry, join the path from `loop/backing_file`, adding it to the list of candidates.\n  * Check each candidate, if it exists, and the inode of the file matches the reported inode from the `ioctl()`, we\n    found the current path of the backing file.\n  * If no candidate matched, we report the file from the sys fs `loop/backing_file`, like `losetup`\n\nIf the arguments do not match exactly, `losetup-container` will delegate to the program specified in\n`LOSETUP_CONTAINER_ORIGINAL_LOSETUP` or `/usr/sbin/losetup`. This should be the original `losetup` binary.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinbit%2Flosetup-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinbit%2Flosetup-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinbit%2Flosetup-container/lists"}