1 / 5

Ex3-3

Ex3-3. 2003242017 김 민 호. umask( 파일 생성 마스크 ). 각 프로세스는 파일 생성 마스크라는 정수값을 갖는다 . 파일이 생성될 때나 open( 열기 ) 호출로 파일 모드가 바뀔 때마다 자동적으로 허가 비트를 모두 0 으로 만들어 주기 위해 사용된다 . 파일생성이나 디렉토리 생성시 기본적으로 주어지는 권한을 지정.

xenos
Télécharger la présentation

Ex3-3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ex3-3 2003242017 김 민 호

  2. umask(파일 생성 마스크) • 각 프로세스는 파일 생성 마스크라는 정수값을 갖는다. • 파일이 생성될 때나 open(열기) 호출로 파일 모드가 바뀔 때마다 자동적으로 허가 비트를 모두 0으로 만들어 주기 위해 사용된다. • 파일생성이나 디렉토리 생성시 기본적으로 주어지는 권한을 지정.

  3. Ex3-3 다음 프로그램은 umask 시스템 호출을 이용하여 프로그램의 첫번째 인수를 새로운 mask를 생성하고, newmask와 oldmask를 출력시키는 프로그램이다. #include <stdio.h> #include <fcntl.h> main(argc,argv) int argc; char *argv[]; { int newmask, oldmask, atoi(), umask(); long strtol(); int fork(); newmask = strtol(argv[1], (char **) NULL, 8); oldmask = umask(newmask); printf("Old filemode creation mask: %04o\n", oldmask); printf("New filemode creation mask: %04o\n", newmask); if(fork() == 0) { execvp(argv[2], &argv[2]); perror(argv[2]); exit(127); } } 프로그램 인수(argv[1])로부터 새로운 마스크 값을 얻는다 새로운 마스크 값을 설정한다 oldmask와 newmask를 출력한다 자식 프로세스를 생성하여 새로운 마스크 값으로 수행하며, 이는 umask가 프로그램 수행중에만 영향을 준다는 것을 보여준다

  4. umask • 새로운 파일이나 허가권 지정 명령어로 일반 파일인 경우 666, 디렉토리인 경우 777에서 umask값을 뺀 값을 8진수의 기본 허가권으로 조정 • 리눅스의 파일 사용권한은 drwxrwxrwx(r –읽기, w –쓰기, x –실행)형태로 되어 있는데 여기서 맨 앞에 d는 파일의 성격을 나타내고 그 뒤에서 끝까지 각 세자리씩 owner, group, other를 의미한다. • 예를들어 umask가 0027인 경우 파일 0666 – 0027 = 0640로 이 파일은 0640퍼미션으로 지정됨. 0 6 4 0 -rwxrwxrwx 421421421 -rw-r----- -42-4-----

  5. 감사합니다 ^_^

More Related