Skip to content

tools: the image extractors work from a path with a space - #625

Merged
derekross merged 1 commit into
derekross:mainfrom
only21mil:build/fix-debugfs-path-quoting
Nov 11, 2026
Merged

derekross merged 1 commit into
derekross:mainfrom
only21mil:build/fix-debugfs-path-quoting

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

What and why

The factory-image extractors break when a laptop path has a space. debugfs splits its -R command at blanks, and the tools put host paths (work dir, staging dir, TMPDIR) into it bare:

  • extract-vendor-firmware: with the output under such a path, every file reads as missing from a good image. With only -w there, build.prop isn't read and the device check is skipped, so a Pixel 7 vendor image is staged as cheetah's without -f.
  • extract-vendor-chroot and extract-fingerprint-vendor: "vendor.img has no build.prop" for a good image.
  • extract-camera-data --apex: a Python traceback when TMPDIR has a space.

Each host path now goes in double quotes, with any " doubled (debugfs's own quoting). Paths without a space behave as before.

Device and build

  • Phone: none: laptop tools only
  • Kernel release (uname -r): not applicable
  • Packages changed, with versions: none

Checks (no phone needed)

  • tools/pr-check origin/main passes
  • tests/all passes
  • tests/packages passes (or the packages I touched: ...): no package touched
  • Each changed package has its version bumped, and the new version is in the commit subject: no package changed
  • Commits have area prefixes and bodies that say why; any AI help is a Co-Authored-By: or Assisted-by: trailer, never a Signed-off-by:

tests/extract-vendor-firmware gets a check on its real ext4 image with -w and -o under a directory named a "spaced" dir. It fails on main ("fw_bcmdhd.bin is missing") and passes here. Its stand-in debugfs now reads the quotes too.

Real runs of each tool with a space in the path, on ext4 images made by mkfs.ext4 -d from made-up files. Before, on main:

Before, on main: four extractors fail or skip the device check with a space in the path

After, on this branch (chroot and fingerprint now stop where main stops with a plain path: the made-up system image has no runtime APEX):

After, on this branch: firmware staged, the panther image refused, build.prop read, the HAL read

On the phone

  • I ran this on my own phone, booted into this build: no phone; these tools run on the laptop
  • Runbook steps passed (plan, step, result): not applicable
  • What I did not test: a Google factory image (none on this machine), and a full chroot or fingerprint tree with a space in the path.
  • Nothing in this change writes outside slot B and userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)

tools/install-phone (writes the phone's image) and tools/release also run debugfs; they are left alone here.

Generated with Claude Opus 5.5 in T3 Code Nightly

debugfs reads its -R command with its own parser, which splits at
blanks. The factory-image extractors put host paths (the work
directory, the output staging directory, the temporary directory) into
those commands bare, so a path with a space broke them:

- extract-vendor-firmware: with the output under such a path, every
  file read as missing from a good image; with only the work directory
  there, build.prop was not read and the device check was skipped, so
  another phone's vendor image was staged without -f.
- extract-vendor-chroot, extract-fingerprint-vendor: "vendor.img has
  no build.prop" for a good image.
- extract-camera-data --apex: a traceback when TMPDIR has a space.

Each host path now goes in double quotes, with any double quote in it
doubled, which is debugfs's own quoting. Paths without a space give
the same files as before.

Tested with tests/extract-vendor-firmware's real ext4 image under a
directory named with a space and a double quote (fails before, passes
after), and by running each tool on mkfs.ext4 images of made-up files
from a directory with a space. Not tested on a Google factory image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Thanks, @only21mil. I ran this on today's main with the host's real debugfs: the new case under a "spaced" dir passes, and fails with main's extract-vendor-firmware. I also went through the other debugfs -R calls in the tree; the ones you left alone take only paths inside the image, or run on the phone with fixed paths, so the set is complete.

Two follow-ups, neither for this PR:

  • Your description points at something worse than the space: in extract-vendor-firmware, when build.prop can't be read the device check is skipped, and another phone's vendor image is staged without -f. That's if get_file build.prop …; then … fi around the check. The other two extractors stop with "vendor.img has no build.prop", and this one should as well, unless -f is given.
  • tools/install-phone writes its files into the image copy with a debugfs command file that names $work paths bare, so --work under a path with a space fails with "writing firstboot.conf into the image copy failed". It fails safely, but the same quoting would fix it.

Merging.

@derekross
derekross merged commit 2db896b into derekross:main Nov 11, 2026
2 checks passed
@only21mil

Copy link
Copy Markdown
Contributor Author

Note

🤖 Opus 5.5 replying on behalf of Victor.

Both follow-ups are open:

  • extract-vendor-firmware: stop when build.prop can't be read, unless -f #647: when build.prop is missing or empty, extract-vendor-firmware now stops with "vendor.img has no build.prop; use -f to override", as the other two extractors do, and -f still stages. It was run before and after on made-up raw ext4, sparse ext4 and EROFS images and an image zip; no Google factory image was tested.
  • install-phone: --work can be a path with a space #646: install-phone quotes its three debugfs write lines with the same dq() as the extractors, so a --work path with a space installs (fastboot faked). What reaches the phone is unchanged: boot-update.conf and authorized_keys match main's byte for byte, and firstboot.conf matches once its salted PASSWORD_HASH is normalized.

derekross pushed a commit that referenced this pull request Nov 11, 2026
install-phone named the three host files of its debugfs command file bare, and debugfs splits commands at blanks, so a `--work` directory with a space stopped the install with "writing firstboot.conf into the image copy failed" before anything was flashed. Each host path now goes in debugfs's double quotes with any double quote doubled, as #625 did for the image extractors. `tests/install-phone` installs from a `--work` path with a space and a quote and reads the three files back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
)

debugfs splits its -R command at blanks, and the factory-image extractors put host paths into it bare, so a work, output or temporary directory with a space made good images read as broken and let extract-vendor-firmware skip its device check. Each host path now goes in debugfs's own double quotes; tests/extract-vendor-firmware runs its real ext4 image from a directory with a space and a quote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
install-phone named the three host files of its debugfs command file bare, and debugfs splits commands at blanks, so a `--work` directory with a space stopped the install with "writing firstboot.conf into the image copy failed" before anything was flashed. Each host path now goes in debugfs's double quotes with any double quote doubled, as derekross#625 did for the image extractors. `tests/install-phone` installs from a `--work` path with a space and a quote and reads the three files back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants