SlideShare a Scribd company logo
open                          I/O
int open(char* path, int access, ...);

open                                                     unsigned
mode mode                         access     path

access mode                    FCNTL.h              access


#define O_RDONLY              1
#define O_WRONLY              2
#define O_RDWR            4

access             flag

#define O_CREAT    0x0100    /* create and open file */
#define O_TRUNC     0x0200    /* open with truncation */
#define O_EXCL    0x0400    /* exclusive open */
#define O_APPEND        0x0800    /* to end of file */
#define O_CHANGED         0x1000    /* user may read these
bits, but  */
#define O_DEVICE       0x2000     /* only RTLio functions
may touch.    */
#define O_TEXT    0x4000    /* CR-LF translation     */
#define O_BINARY       0x8000     /* no translation     */

       O_CREAT                    mode       mode            sysstat.h


#define S_IREAD      0x0100         /* owner may read */
#define S_IWRITE     0x0080         /* owner may write */

open(s[i], 0x0100,0x0080);                 O_CREAT
s[i]
int open(const char *path, int access,int mode)


                              -1
             path
access                         O_RDONLY 1     ;     O_WRONLY 2
   ;      O_RDWR 4


                       3
O_CREAT      0x0100
O_TRUNC      0x0200                                       0,


O_EXCL      0x0400
O_APPEND      0x0800
O_TEXT      0x4000                    CR-LF
O_BINARY     0x8000                         CR-LF


mode            access=O_CREAT
S_IFMT      0xF000
S_IFDIR     0x4000
S_IFIFO     0x1000     FIFO
S_IFCHR     0x2000
S_IFBLK     0x3000
S_IFREG     0x8000         0x0000
S_IREAD      0x0100
S_IWRITE      0x0080
S_IEXEC      0x0040

int open(const char *path, int access,int mode)
------------------------------------------------
                                   mode          access O_CREAT
              open
                access              mode
        tc2.0 tc3.1 vc6.0 C++Builder       gcc    open

gcc:
_CRTIMP int __cdecl _open (const char*, int, ...);

VC6.0
_CRTIMP int __cdecl _open(const char *, int, ...);

Borland C++Builder
int _RTLENTRY _EXPFUNC open(const char _FAR *__path, int
__access,... /*unsigned mode*/);

tc3.1
int _Cdecl _FARFUNC open(const char _FAR *__path, int
__access,... /*unsigned mode*/);

tc2.0
int _Cdecl open        (const char *path, int access,... /*unsigned
mode*/);

More Related Content

DOCX
Catch and throw blocks
PDF
JVM code reading -- C2
PDF
HotSpot template interpreter memos
PDF
Notes for xx_use_serialgc
DOCX
Michael kontopoulo1s
PDF
Flashback, el primer malware masivo de sistemas Mac
PDF
Burrowing through go! the book
PDF
MATHS SYMBOLS - #2 - EXPONENTIALS and LOGARITHMS
Catch and throw blocks
JVM code reading -- C2
HotSpot template interpreter memos
Notes for xx_use_serialgc
Michael kontopoulo1s
Flashback, el primer malware masivo de sistemas Mac
Burrowing through go! the book
MATHS SYMBOLS - #2 - EXPONENTIALS and LOGARITHMS

Viewers also liked (6)

PPTX
Taco sauce penny cleaner
PDF
The impact of the Grand Paris project on the the Northeast area of Paris – Fo...
 
PDF
Aerolyte pressure cabinets
DOC
Campeonato gaúcho 2014 divisão de acesso - artilharia
PPT
Copy of Sakura
PDF
Cmposicion nutrimental en nopal
Taco sauce penny cleaner
The impact of the Grand Paris project on the the Northeast area of Paris – Fo...
 
Aerolyte pressure cabinets
Campeonato gaúcho 2014 divisão de acesso - artilharia
Copy of Sakura
Cmposicion nutrimental en nopal
Ad

Similar to Unix open (20)

PPT
file handling1
DOCX
File handling in c++
PPT
Filehandlinging cp2
PPT
file_handling_in_c.ppt
PPT
File handling in C++
PDF
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
PDF
Marat-Slides
PPT
Unit 3
PDF
Filepointers1 1215104829397318-9
PDF
Some examples of the 64-bit code errors
DOCX
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
PPT
Ds0201 file
DOCX
Question 1.Discuss at least three ways in which Henry David Thor.docx
PDF
C++ Quick Reference Sheet from Hoomanb.com
file handling1
File handling in c++
Filehandlinging cp2
file_handling_in_c.ppt
File handling in C++
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
Marat-Slides
Unit 3
Filepointers1 1215104829397318-9
Some examples of the 64-bit code errors
lab03build.bat@echo offclsset DRIVE_LETTER=1set.docx
Ds0201 file
Question 1.Discuss at least three ways in which Henry David Thor.docx
C++ Quick Reference Sheet from Hoomanb.com
Ad

Unix open

  • 1. open I/O int open(char* path, int access, ...); open unsigned mode mode access path access mode FCNTL.h access #define O_RDONLY 1 #define O_WRONLY 2 #define O_RDWR 4 access flag #define O_CREAT 0x0100 /* create and open file */ #define O_TRUNC 0x0200 /* open with truncation */ #define O_EXCL 0x0400 /* exclusive open */ #define O_APPEND 0x0800 /* to end of file */ #define O_CHANGED 0x1000 /* user may read these bits, but */ #define O_DEVICE 0x2000 /* only RTLio functions may touch. */ #define O_TEXT 0x4000 /* CR-LF translation */ #define O_BINARY 0x8000 /* no translation */ O_CREAT mode mode sysstat.h #define S_IREAD 0x0100 /* owner may read */ #define S_IWRITE 0x0080 /* owner may write */ open(s[i], 0x0100,0x0080); O_CREAT s[i]
  • 2. int open(const char *path, int access,int mode) -1 path access O_RDONLY 1 ; O_WRONLY 2 ; O_RDWR 4 3 O_CREAT 0x0100 O_TRUNC 0x0200 0, O_EXCL 0x0400 O_APPEND 0x0800 O_TEXT 0x4000 CR-LF O_BINARY 0x8000 CR-LF mode access=O_CREAT S_IFMT 0xF000 S_IFDIR 0x4000 S_IFIFO 0x1000 FIFO S_IFCHR 0x2000 S_IFBLK 0x3000 S_IFREG 0x8000 0x0000 S_IREAD 0x0100
  • 3. S_IWRITE 0x0080 S_IEXEC 0x0040 int open(const char *path, int access,int mode) ------------------------------------------------ mode access O_CREAT open access mode tc2.0 tc3.1 vc6.0 C++Builder gcc open gcc: _CRTIMP int __cdecl _open (const char*, int, ...); VC6.0 _CRTIMP int __cdecl _open(const char *, int, ...); Borland C++Builder int _RTLENTRY _EXPFUNC open(const char _FAR *__path, int __access,... /*unsigned mode*/); tc3.1 int _Cdecl _FARFUNC open(const char _FAR *__path, int __access,... /*unsigned mode*/); tc2.0 int _Cdecl open (const char *path, int access,... /*unsigned mode*/);