Reading eeprom on linux without root right

937 Views Asked by At

I am working on Linux 3.14.28, build with buildroot for an embeded system.

How can I read the file /sys/devices/i2c.4/i2c-1/1-0052/eeprom without root privilege?

Is there a solution to permanently change permission instead of changing it on each reboot of Linux with a script.

I'm not using udev but static table. I easily manage to change permission:

  • using device_table_dev.txt for /dev files
  • using device_table.txt for /home/files

But it has no effect on /sys/devices/i2c.4/i2c-1/1-0052/eeprom

2

There are 2 best solutions below

0
On

First and foremost, don't use static table. It really doesn't make any sense to not use devtmpfs these days, unless you're using a kernel older than 2.6.32.

Then, the device table is about changing permission of files in /dev. The permission of files in /sys is directly controlled by the kernel itself.

0
On

You need to adapt the permissions of the i2c bus device file /dev/i2c-*, not the eeprom file in /sys.
Using udev following rule should do the job:

KERNEL=="i2c-[0-9]*", GROUP="dialout"

Generally something similar should be also possible with static table as you can handle /dev/i2c-* like every other /dev/* file.