open 함수질문

qw3709의 이미지

open(file,114);

여기서 114가 뭘뜻하는거죠 저기에 권한옵션이들어가야하는거 아닌가요

세벌의 이미지

fcntl.h 파일 찾아보셔요.

qw3709의 이미지

답글 골때리네 씨발ㅋㅋㅋ

세벌의 이미지

man open3
https://linux.die.net/man/3/open

bitwise or
https://www.tutorialspoint.com/cprogramming/c_bitwise_operators.htm

여기서 114가 뭘뜻하는거죠 저기에 권한 옵션이 들어가야하는 거 아닌가요
에 답이 되셨길...
jachin의 이미지

각 oflags 에 들어갈 옵션값은 전체 자릿수에서 한 자리만 1인 값을 갖습니다. 114 를 2진수로 표현해보면
0111 0010 이 되는데요, 각각 2 + 16 +32 + 64 에 해당하는 값이지요. 다음 소스코드의 결과값을 비교해보면..

#include <stdio.h>
#include <fcntl.h>
 
int main( )
{
        printf("O_RDONLY\t %8d\n", O_RDONLY);
        printf("O_WRONLY\t %8d\n", O_WRONLY);
        printf("O_RDWR\t %8d\n", O_RDWR);
        printf("O_APPEND\t %8d\n", O_APPEND);
        printf("O_TRUNC\t %8d\n", O_TRUNC);
        printf("O_EXCL\t %8d\n", O_EXCL);
        printf("O_CREAT\t %8d\n", O_CREAT);
        printf("\n");
        printf("S_IRUSR\t %8d\n", S_IRUSR);
        printf("S_IWUSR\t %8d\n", S_IWUSR);
        printf("S_IXUSR\t %8d\n", S_IXUSR);
        printf("S_IRGRP\t %8d\n", S_IRGRP);
        printf("S_IWGRP\t %8d\n", S_IWGRP);
        printf("S_IXGRP\t %8d\n", S_IXGRP);
        printf("S_IROTH\t %8d\n", S_IROTH);
        printf("S_IWOTH\t %8d\n", S_IWOTH);
        printf("S_IXOTH\t %8d\n", S_IXOTH);
        return 0;
}

O_RDONLY	        0
O_WRONLY	        1
O_RDWR	        2
O_APPEND	     1024
O_TRUNC	      512
O_EXCL	      128
O_CREAT	       64
 
S_IRUSR	      256
S_IWUSR	      128
S_IXUSR	       64
S_IRGRP	       32
S_IWGRP	       16
S_IXGRP	        8
S_IROTH	        4
S_IWOTH	        2
S_IXOTH	        1

라고 나오는데, 2 에 해당하는 값이 S_IWOTH 가 아니라면, O_RDWR 과 O_CREAT, S_IRGRP, S_IWGRP 를 OR 한 결과값이라고 추정할 수 있습니다.

그리고 기대한 답변이 아니어도 조금은 참으셨으면 좋겠습니다.

세벌의 이미지

O_RDONLY, O_WRONLY 등등의 값을 찍어볼 생각은 어떻게 하게 되었는지 알려주셔요.

저는 님처럼 친절한 답변 못 할 거 같네요 :)

jachin의 이미지

O_RDONLY, O_WRONLY 선언부를 찾을 수는 없었지만, #define 으로 선언된 값이라면, 상수값을 갖을것이고, 소스코드에 기술하는 것만으로도 충분히 값을 알 수 있지 않을까 생각했습니다. oflags 는 말 그대로 플래그이니, 비트마다 의미가 있을테고, 2^n 단위로 값이 결정되어 있었을거라 예상했습니다.

jick의 이미지

...그 생각을 못했으면 fcntl.h를 찾아보라는 답글은 무슨 의미로 다신 거죠. -.-

세벌의 이미지

제가 한 질문은 원 질문자의 질문을 예상해서 한 거였습니다.

그나저나 처음에 질문했던 분은 원하는 답을 잘 찾으셨나 모르겠네요.
여러분들이 힌트 많이 주셨는데 :)

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.