Sysfs

為什麼樹不能完全列出 /sys/class/hwmon?我怎麼能這樣做?

  • December 2, 2018

如果我理解正確的話,在 Linux 中,一切都是一條路徑,一直延伸到每一塊硬體。我正在嘗試獲取有關感測器結構的資訊,所以我想我會使用樹來映射我的 hwmon 目錄中的所有內容。但是,tree 在此目錄中的行為與我習慣的不同。

當我在普通目錄上執行樹時,我得到子目錄結構而不使用 -R 或 -L 標誌:

$ tree /home
/home
└── boss
   ├── clones
   ├── Desktop
   ├── Documents
   │   ├── modules.txt
   │   ├── old_docs
   │   │   └── assorted
   │   └── prepscript.txt
   ├── Downloads
   ├── Music
   ├── Pictures
   ├── Public
   ├── Templates
   └── Videos

12 directories, 2 files

但是我嘗試對 HWmon 做同樣的事情,即使我確實使用了 -R 標誌並且即使有更深的東西,它也只會深入一層:

$ tree /sys/class/hwmon/
/sys/class/hwmon/
├── hwmon0 -> ../../devices/pci0000:40/0000:40:01.3/0000:43:00.0/hwmon/hwmon0
├── hwmon1 -> ../../devices/pci0000:00/0000:00:01.3/0000:09:00.0/hwmon/hwmon1
├── hwmon2 -> ../../devices/pci0000:40/0000:40:03.1/0000:44:00.0/hwmon/hwmon2
├── hwmon3 -> ../../devices/pci0000:00/0000:00:18.3/hwmon/hwmon3
├── hwmon4 -> ../../devices/pci0000:00/0000:00:19.3/hwmon/hwmon4
├── hwmon5 -> ../../devices/virtual/thermal/thermal_zone0/hwmon5
└── hwmon6 -> ../../devices/platform/nct6775.656/hwmon/hwmon6

7 directories, 0 files
$ tree /sys/class/hwmon/hwmon0
/sys/class/hwmon/hwmon0
├── device -> ../../../0000:43:00.0
├── fan1_input
├── name
├── power
│   ├── async
│   ├── autosuspend_delay_ms
│   ├── control
│   ├── runtime_active_kids
│   ├── runtime_active_time
│   ├── runtime_enabled
│   ├── runtime_status
│   ├── runtime_suspended_time
│   └── runtime_usage
├── pwm1
├── pwm1_enable
├── pwm1_max
├── pwm1_min
├── subsystem -> ../../../../../../class/hwmon
├── temp1_auto_point1_pwm
├── temp1_auto_point1_temp
├── temp1_auto_point1_temp_hyst
├── temp1_crit
├── temp1_crit_hyst
├── temp1_emergency
├── temp1_emergency_hyst
├── temp1_input
├── temp1_max
├── temp1_max_hyst
├── uevent
└── update_interval

3 directories, 27 files

是什麼導致了這種行為差異,我可以得到所有設備的簡單樹嗎?

tree這樣做是因為預設情況下它不會取消引用符號連結。該-l選項將改變:

tree -l /sys/class/hwmon/

但是你會很有趣地理解所有的輸出。

引用自:https://unix.stackexchange.com/questions/485548