Newlib: Mode bits?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Newlib: Mode bits?

Post by pcmattman »

Now that I'm at the stage where I'm implementing drivers (and hence, their read/write implementations), I need to start thinking about the mode bits so user programs have the predicted results (for instance, not being able to write to a readonly device).

The problem is, I usually get 0x1B6 as the mode bits, and as far as I can see, this is no combination of the mode constants. Any ideas?
Aali
Member
Member
Posts: 58
Joined: Sat Apr 14, 2007 12:13 pm

Post by Aali »

0x1B6 = 0666 or in human speak, read/write access for everyone
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

check linux/sys/stat.h in newlib. It has all the constants defined, as per the open-group base specification (POSIX).
http://www.opengroup.org/onlinepubs/009695399/ wrote: File mode bits:

S_IRWXU
Read, write, execute/search by owner.

S_IRUSR
Read permission, owner.
S_IWUSR
Write permission, owner.
S_IXUSR
Execute/search permission, owner.

S_IRWXG
Read, write, execute/search by group.

S_IRGRP
Read permission, group.
S_IWGRP
Write permission, group.
S_IXGRP
Execute/search permission, group.

S_IRWXO
Read, write, execute/search by others.

S_IROTH
Read permission, others.
S_IWOTH
Write permission, others.
S_IXOTH
Execute/search permission, others.
addendum: There are no posix-defined constants for these. You are free to make them up (that's why they're defined in sys/stat.h not stat.h). Linux in fact seems to change quite a few of the file constants between implementations (c.f. Linux x86 / Linux MIPSel)

JamesM
Post Reply