Skip to content

linux: fix reading zram values#2045

Merged
fasterit merged 1 commit into
htop-dev:mainfrom
eworm-de:linux-zram
Jul 15, 2026
Merged

linux: fix reading zram values#2045
fasterit merged 1 commit into
htop-dev:mainfrom
eworm-de:linux-zram

Conversation

@eworm-de

Copy link
Copy Markdown
Contributor

This is a follow-up on an earlier commit 'linux: avoid repeated zram ENOENT probes'.
Actually /sys/block/zramN are symlinks, so setting O_NOFOLLOW breaks this. Let's drop the option.

Fixes: 9fe974b

This is a follow-up on an earlier commit 'linux: avoid repeated zram
ENOENT probes'.
Actually `/sys/block/zramN` are symlinks, so setting O_NOFOLLOW breaks
this. Let's drop the option.

Fixes: 9fe974b
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1f40aa4f-22e3-4a17-ad10-5d2ed28c093e

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef4226 and bdf4ffc.

📒 Files selected for processing (1)
  • linux/LinuxMachine.c

📝 Walkthrough

Walkthrough

The zram device scanner’s HAVE_OPENAT path now opens each per-device directory with O_DIRECTORY | O_PATH instead of also specifying O_NOFOLLOW. The fallback path remains unchanged.

Suggested reviewers: intelfx

Poem

A zram door swings wide,
With directory and path allied,
One flag steps away,
The fallback holds its sway,
And scanning proceeds inside.


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.

@eworm-de

Copy link
Copy Markdown
Contributor Author

Well, alternatively we could look into /sys/devices/virtual/block/...

Wondering if the paths and/or symlinks changed with recent linux versions?

@Komzpa Komzpa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for catching this and for opening #2045.

/sys/block/zramN has been zram's documented sysfs interface since the
original 2010 sysfs conversion,
and the current kernel ABI still documents
disksize and mm_stat there.

On current kernels, entries under /sys/block are symlinks, so
openat(..., O_DIRECTORY | O_PATH | O_NOFOLLOW) fails with ENOTDIR before
the relative disksize and mm_stat reads can run. Dropping O_NOFOLLOW
fixes that while retaining the dirfd-relative reads.

I would keep /sys/block: switching to /sys/devices/virtual/block would bind
htop to the backing sysfs topology instead of the documented userspace ABI.
The one-line fix looks correct to me. Thank you!

@eworm-de

Copy link
Copy Markdown
Contributor Author

Thanks for revealing the details. Sounds like keeping the documented path is the correct approach.

@fasterit
fasterit merged commit bf8cc6e into htop-dev:main Jul 15, 2026
21 checks passed
@eworm-de
eworm-de deleted the linux-zram branch July 15, 2026 15:05
@BenBE BenBE added bug 🐛 Something isn't working Linux 🐧 Linux related issues labels Jul 15, 2026
@BenBE BenBE added this to the 3.6.0 milestone Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 Something isn't working Linux 🐧 Linux related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants