⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p4.8.c

📁 linux编程源代码,其中是由大量的实例
💻 C
字号:
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>int main(void){        int fd1,fd2;                fd1=open("test",O_CREAT | O_RDWR,0777);	 		if(fd1<0){		perror("Cannot create the test file");		return 1;	}	 	close(fd1);        struct stat file_stat;		if(stat("test",&file_stat)==-1){		perror("Cannot get the information of the file!\n");		return 1;	}	printf("Premission is : %o\n",file_stat.st_mode & 0x1ff);	umask(S_IWGRP | S_IRGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH);	 	fd2=open("test1",O_CREAT | O_RDWR,0777);	if(fd2<0){		 perror("Cannot create the test file");	 	 return 1;	}		close(fd1);	 if(stat("test1",&file_stat)==-1){		 perror("Cannot get the information of the file!\n");		 return 1;	 }        	printf("After Modify umask value, Premission is : %o\n",file_stat.st_mode & 0x1ff);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -