Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect_virt segment shows false positive "chroot" for btrfs #2100

Open
piggynl opened this issue Nov 23, 2022 · 0 comments
Open

detect_virt segment shows false positive "chroot" for btrfs #2100

piggynl opened this issue Nov 23, 2022 · 0 comments

Comments

@piggynl
Copy link

piggynl commented Nov 23, 2022

prompt_detect_virt() {
local virt="$(systemd-detect-virt 2>/dev/null)"
if [[ "$virt" == "none" ]]; then
local -a inode
if zstat -A inode +inode / 2>/dev/null && [[ $inode[1] != 2 ]]; then
virt="chroot"
fi
fi
if [[ -n "${virt}" ]]; then
_p9k_prompt_segment "$0" "$_p9k_color1" "yellow" '' 0 '' "${virt//\%/%%}"
fi
}

Btrfs subvolumes always have inode number 256 instead of 2, so detect_virt segment will show false positive "chroot" for btrfs.

Maybe we can check the return value of unshare -U true to determine whether we are in chroot? But it will be much slower :(

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

No branches or pull requests

1 participant