LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-11-2001, 08:44 AM   #1
iam3
LQ Newbie
 
Registered: Oct 2001
Posts: 5

Rep: Reputation: 0
Unhappy umask...inheritance of file attributes problem


Hei,

The program I have used:
*******************************************
main () {
FILE *fp;
struct stat statbuf;
if ((fp = fopen("newfile","w")) == NULL)
{
perror("fopen");
return error;
}
fprintf(fp,"This is an example file.");
fclose(fp);

// Now check permissions
if (stat("newfile",&statbuf) == -1)
{
perror("stat");
return error;
}
printf("The file perms on the file are %o\n",statbuf.st_mode & 07777);
chmod("newfile",0755);
if (stat("newfile",&statbuf) == -1)
{
perror("stat");
return error;
}
printf("The file perms on the file are now %o\n",statbuf.st_mode &
07777);
}
*******************************************

Output that I got:

bash-2.05$ umask 022
bash-2.05$ appl
The file perms on the file are 666
The file perms on the file are now 755
bash-2.05$ ls -l newfile-rwxr-xr-x 1 hussait2 student 24 Nov 11
14:26 newfile
bash-2.05$
bash-2.05$ rm newfile
bash-2.05$ umask 077
bash-2.05$ appl
The file perms on the file are 666
The file perms on the file are now 755
bash-2.05$ ls -l newfile-rwxr-xr-x 1 hussait2 student 24 Nov 11
14:26 newfile

Why does it always print 666 and not according to the value of umask. In
unix default is 666 but I do change the value of umask from shell. But it
does not affect it, WHY?

Student
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing File Attributes terdbird Slackware 6 04-23-2005 03:39 AM
file inheritance tulip4heaven Linux - Networking 1 02-24-2005 02:30 AM
File permission inheritance HowTo ? Satriani Linux - Security 4 11-26-2004 05:13 AM
uploaded file on vsftpd has wrong file attributes rune.kg Linux - Newbie 2 03-06-2004 09:23 AM
file attributes binky22 Linux - Newbie 2 09-26-2003 04:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:11 AM.

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