Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How can a file's contents change but the file's attibutes remain the same?

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
Yonut
Posts: 13
Joined: 2022-01-14 18:02
Been thanked: 2 times

How can a file's contents change but the file's attibutes remain the same?

#1 Post by Yonut »

I'm trying to write a system monitor for my desktop (no, I don't want to use something else), but I've come across a problem I can't understand.

I open the file `/sys/class/power_supply/BAT0/uevent` and notice all the fields. Close it and open it again and notice the field `POWER_SUPPLY_TEMP` value has changed from `315` to `318`. But when I do `ls /sys/class/power_supply/BAT0/uevent` it lists the modified date as the day I booted my system up (2 days prior).

How can the information in the file be updated but not have the attributes updated?

Also, why `inotify` isn't informed of a change to the file?

User avatar
canci
Global Moderator
Global Moderator
Posts: 2502
Joined: 2006-09-24 11:28
Has thanked: 136 times
Been thanked: 136 times

Re: How can a file's contents change but the file's attibutes remain the same?

#2 Post by canci »

Maybe the polling is so frequent that disk i/o or journaling would be compromised otherwise?
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

reinob
Posts: 1189
Joined: 2014-06-30 11:42
Has thanked: 97 times
Been thanked: 47 times

Re: How can a file's contents change but the file's attibutes remain the same?

#3 Post by reinob »

The stuff in /sys are not files. They just behave like files. The content is actually retrieved/calculated by the kernel *when you read*, while the "file" itself is created during boot, when /sys is mounted.

Yonut
Posts: 13
Joined: 2022-01-14 18:02
Been thanked: 2 times

Re: How can a file's contents change but the file's attibutes remain the same?

#4 Post by Yonut »

Ty for the responses.

Looks like I'll have to make a `cron` job to copy the file regularly.

Post Reply