LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-12-2005, 10:38 PM   #1
skie_knite007
Member
 
Registered: Dec 2004
Location: India
Distribution: Fedora Core 4
Posts: 145

Rep: Reputation: 15
problems in getting file permissions using stat


Protection st_mode is of type mode_t in the stat structure. When I'm using %d to print this , I'm not getting the correct permissions...

But when I use %o to print this,,,I'm getting the right perms but a '10' in extra..

say,,,the mode is 0777 ...when I print this using %o,,,I'm getting 100777..

Why is it so?
 
Old 12-12-2005, 11:22 PM   #2
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
st_mode contains not just permissions... see stat(2). To get only the permissions you have to mask it with 0777 first (ie: st_mode & 0777)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot stat /etc/X11/X (no such file or directory) theabyyss Linux - Software 2 02-12-2008 07:15 PM
smbclient copy problem (cant stat file...) taiwf Linux - Networking 6 08-01-2005 05:27 PM
Problems with system-wide file permissions hexadevil Linux - Newbie 2 05-30-2004 07:54 AM
lsattr: no such file or directory while trying to stat... acampbell Linux - General 6 12-01-2003 02:41 PM
Problems with file permissions Manyguns Linux - General 1 02-26-2002 09:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration