LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 09-26-2003, 06:44 AM   #1
Lord CyKill
LQ Newbie
 
Registered: Sep 2003
Posts: 2

Rep: Reputation: 0
File permission display and change in GCC


I want to display the file permission access to the user and then change the permision to read for all the other groups and user except the owner,using stat structure in gcc.
I have been able to display by

fileinfo.st_mode & 0777

but i want to display like this way:
-rwx-r--r--
but not sure how to do that .

And also want to set the permission as described earlier.
NE HELP!
 
Old 09-26-2003, 07:33 AM   #2
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 33
S_IRUSR 00400 owner has read permission
S_IWUSR 00200 owner has write permission
S_IXUSR 00100 owner has execute permission
S_IRGRP 00040 group has read permission
S_IWGRP 00020 group has write permission
S_IXGRP 00010 group has execute permission
........

These can be used to find out the permissions of a given file...

check out "man 2 stat" for more details abt this....

You can use a if condition n print r if user has write permissions else - .....
Reply if you have still not understood.

#include <sys/types.h>
#include <sys/stat.h>
int chmod(const char *path, mode_t mode);
int fchmod(int fildes, mode_t mode);

check out "man 2 chmod" . It can be used to change permissions of a file...

Try reading the man pages n implement them....If you still have probs. I'll help you...

Welcome to LQ
 
  


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
how to change the file permission ?? AK prince Slackware 17 08-05-2005 12:16 PM
using chmod to change file permission kiwidoc Linux - Newbie 3 07-25-2004 06:39 AM
chmod 755 won't change file permission. duffboygrim Linux - General 11 04-29-2004 06:17 PM
Cannot Change File Permission dsuratman Linux - Newbie 12 11-03-2003 01:47 PM
cp command change the file permission? myunicom Linux - General 6 09-24-2003 08:15 AM

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

All times are GMT -5. The time now is 04:26 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