Skip to content

fs: Fix parsing tune.exfat output with variable whitespace#1198

Merged
vojtechtrefny merged 1 commit into
storaged-project:masterfrom
vojtechtrefny:master_new-exfat-info-parsing-fix
Jun 3, 2026
Merged

fs: Fix parsing tune.exfat output with variable whitespace#1198
vojtechtrefny merged 1 commit into
storaged-project:masterfrom
vojtechtrefny:master_new-exfat-info-parsing-fix

Conversation

@vojtechtrefny
Copy link
Copy Markdown
Member

@vojtechtrefny vojtechtrefny commented Jun 2, 2026

The format of tune.exfat output changed from "key : value" to
"key : value" with variable padding around the colon. Replace
hard-coded prefix matching with key-name matching and a helper that
finds the value after the first colon on the line.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced exFAT filesystem information parsing to reliably extract sector size, sector count, and cluster count.

The format of tune.exfat output changed from "key : value" to
"key      : value" with variable padding around the colon. Replace
hard-coded prefix matching with key-name matching and a helper that
finds the value after the first colon on the line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

src/plugins/fs/exfat.c refactors exFAT filesystem info parsing by replacing hardcoded prefix-based string matching with a shared helper function that extracts numeric values using key-based field lookup and : separator detection.

Changes

exFAT parsing refactor

Layer / File(s) Summary
Parsing helper and constants
src/plugins/fs/exfat.c
New parsing key constants ("Block sector size", "Block count", "Cluster count") and _exfat_parse_line_val() helper that locates :, skips whitespace, and parses the remainder as guint64.
Updated parsing in bd_fs_exfat_get_info
src/plugins/fs/exfat.c
Remove val_start variable and update the output parsing loop to match field keys and call _exfat_parse_line_val() instead of using fixed prefix lengths and offset arithmetic.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: fixing the parsing of tune.exfat output to handle variable whitespace around the colon separator.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/plugins/fs/exfat.c

src/plugins/fs/exfat.c:20:10: fatal error: 'blockdev/utils.h' file not found
20 | #include <blockdev/utils.h>
| ^~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/be36f457491691eb9c6c698acb6e2cf0a923f6dd-b404a9c872919e7a/tmp/clang_command_.tmp.5beb79.txt
++Contents of '/tmp/coderabbit-infer/be36f457491691eb9c6c698acb6e2cf0a923f6dd-b404a9c872919e7a/tmp/clang_command_.tmp.5beb79.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disabl

... [truncated 701 characters] ...

/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/b404a9c872919e7a/file.o" "-x" "c"
"src/plugins/fs/exfat.c" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/plugins/fs/exfat.c`:
- Around line 428-433: The parser currently uses g_strrstr() to find
BLOCK_SIZE_KEY/SECTORS_KEY/CLUSTERS_KEY anywhere in the line, causing false
positives; update the matching logic in the block that sets ret->sector_size,
ret->sector_count, and ret->cluster_count to first trim leading whitespace from
*line_p (or compute the substring before the first ':'), then check that the key
appears at the start of the trimmed line (e.g., starts-with BLOCK_SIZE_KEY) or
equals the trimmed pre-colon token before calling _exfat_parse_line_val, leaving
the existing assignments intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fda999f5-f179-4903-965d-ccc202c92a31

📥 Commits

Reviewing files that changed from the base of the PR and between 711c764 and be36f45.

📒 Files selected for processing (1)
  • src/plugins/fs/exfat.c

Comment thread src/plugins/fs/exfat.c
Copy link
Copy Markdown
Member

@tbzatek tbzatek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The g_strrstr() usage looks suspicious but I think that's still okay.

@vojtechtrefny vojtechtrefny merged commit fed134b into storaged-project:master Jun 3, 2026
46 of 47 checks passed
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