UNIX I/O摘要

int open(char *filename, int flag, mode_t mode);

The open function converts a file name to a file descriptor and returns the
descriptor number. The descriptor returned is always the smallest descriptor that
is not currently open in the process. The flags argument indicates how the process
intends to access the file:

O_RDONLY: Reading only
O_WRONLY: Writing only
O_RDWR: Reading and writing

The flags argument can also be or’d with one or more bit masks that provide
additional instructions for writing:
O_CREAT: If the file does not exist, then create a truncated (empty) version
of it.
O_TRUNC: If the file already exists, then truncate it.
O_APPEND: Before each write operation, set the file position to the end of
the file.

The mode argument specifies the access permission bits of new files. The
symbolic names for these bits are shown in Figure 10.1. As part of its context,
each process has a umask that is set by calling the umask function. When a process
creates a new file by calling the open function with some mode argument, then the
access permission bits of the file are set to mode & ~umask.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值