On 4 November 2015 at 03:40, Pierre-Louis Constant <[email protected]>
wrote:

> you guys provided me enough info leads for a whole year of insomnia.
>

haha, sorry :-)


> Correct, pretty much anything can be used from userspace like that,
>> although some people will frown at you for bypassing the kernel if you do.
>
>
> Righteo, so far I was using the somewhat slow (but easy) way thyrough FS,
> however I am stuck with running my program as root, as I can't access the
> PWM (or hardware) as normal user. Using the mmap() method would be
> permission free, would it ?
>

other way around: you can simply change owner/group/permissions in sysfs if
you want to (although obviously it won't persist across reboots, hence
would need to be done e.g. in an udev rule).

/dev/mem however always requires root permissions to open. You can of
course open it and then drop permissions (and close the descriptor after
mmapping the regions you need). The same is true for other files and
devices of course, including sysfs files.

uio is the cleanest here: the pastebin I linked to actually included an
example udev rule for setting group and permissions.

sysfs files aren't devices hence you can't set their permissions in the
same way but need to do something ugly like RUN="/bin/chmod ...". It's
still wise to do it in an udev rule rather than a fixed startup script
since it may run too early and the files may not exist yet.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to