Linux的open file 与 file descriptor区别
来源:互联网 发布:手机淘宝忘记登录密码 编辑:程序博客网 时间:2024/06/03 19:10
1 open file
An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file.
2 file descriptor
A file descriptor is a data structure used by a program to get a handle on a file. The most commonly known are:
0 for standard in
1 for standard out
2 for standard error前后两者关系
一个文件即使被打开,也可能没有文件描述符。
比如current working directories, memory mapped files and executable > text files。
3 区别
- lsof 可以查出某个进程打开的文件数目(即 open file)。
root@testbox ~]# lsof | grep '4448'oracle 4448 oracle cwd DIR 3,2 4096 1913941 /u01/app/oracle/product/10.2.0/db_1/dbsoracle 4448 oracle rtd DIR 3,2 4096 2 /oracle 4448 oracle txt REG 3,2 93300099 1915187 /u01/app/oracle/product/10.2.0/db_1/bin/oracleoracle 4448 oracle mem REG 3,2 95148 2174926 /lib/libnsl-2.3.4.sooracle 4448 oracle mem REG 3,2 106397 2174894 /lib/ld-2.3.4.sooracle 4448 oracle mem REG 3,2 1454546 2501884 /lib/tls/libc-2.3.4.so[root@testbox ~]# lsof | grep '4448' | wc -l42 //打开的文件数目
- ls用于查询进程使用的文件描述符数目
[root@testbox ~]# ls -l /proc/4448/fd/total 18lr-x------ 1 oracle oinstall 64 Mar 5 15:04 0 -> /dev/nulllr-x------ 1 oracle oinstall 64 Mar 5 15:04 1 -> /dev/nulllrwx------ 1 oracle oinstall 64 Mar 5 15:04 10 -> /u01/app/oracle/product/10.2.0/db_1/rdbms/audit/ora_4446.audlr-x------ 1 oracle oinstall 64 Mar 5 15:04 11 -> /dev/zerolr-x------ 1 oracle oinstall 64 Mar 5 15:04 12 -> /dev/zero:[root@testbox ~]# ls -l /proc/4448/fd/ | wc -l19 //文件描述符数目 + 1 (注意还有一行 “total 18”)
4 查看文件描述符的设置
$cat /proc/sys/fs/file-max65536--该参数可以动态修改
5 计算当前被使用的文件描述符数目
$cat /proc/sys/fs/file-nr //该文件只能读,不能修改1380 180 65536 | | |_ Max no. of file descriptors allowed on the system | | (与file-max一致) | |__ Total free allocated file descriptors | |__ Total allocated file descriptorsTo compute the number of file descriptors currently being used:1380 - 180 = 1200
参考文献:
[1] http://blog.itpub.net/15480802/viewspace-734062/ 博主:myownstars
0 0
- Linux的open file 与 file descriptor区别
- Linux下FILE结构与“File descriptor”的区别
- linux文件描述符open file descriptors与open files的区别
- open 创建文件并读写的错误--bad file descriptor
- Python 文件处理 file 与 open 的区别与注意
- Linux编程基础:文件描述符file descriptor与inode
- linux系统文件描述符file descriptor与inode的相关知识
- linux系统文件描述符file descriptor与inode的相关知识
- linux系统文件描述符file descriptor与inode的相关知识 , 文件描述符泄露
- 获得目录的file descriptor.
- linux open file
- file.delete()与file.deleteOnExit(); 的区别
- Linux 文件描述符简介(file descriptor)
- Linux之file_struct&fd(file descriptor)
- Linux socket连接数(file descriptor)
- linux系统编程之基础必备(三):文件描述符file descriptor与inode的相关知识
- linux系统编程之基础必备(三):文件描述符file descriptor与inode的相关知识
- linux系统编程之基础必备(三):文件描述符file descriptor与inode的相关知识
- cocos2dx 雷达的实现
- ubuntu mysql 完全卸载
- Android Studio和Gradle那些坑爹事
- openCV中IplImage的使用
- 软件测试之日志抓取
- Linux的open file 与 file descriptor区别
- 蒙头刷水题
- 求三角形的面积
- Android小米手机接收不到开机广播(个人笔记)
- 修改eclipse workspace的历史记录
- DOM基础
- spring task定时任务实现
- env: ruby_executable_hooks: No such file or directory
- Eclipse自动生成作者、日期注释等功能设置