Welcome 微信登录

首页 / 操作系统 / Linux / Linux开发 - 02 - 文件和目录

本文列出一些与文件相关的设备和函数,以备查用。至于具体意义和用法自己查man0. 查man page方法
系统调用$man 2 read<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--> 1 NAME
2read - read from a file descriptor
3
4
5
6 SYNOPSIS
7#include <unistd.h>
8
9ssize_t read(int fd, void *buf, size_t count);
10
11 DESCRIPTION
12read() attempts to read up to count bytes from file descriptor fd into
13the buffer starting at buf.
14
15If count is zero, read() returns zero and has nootherresults. If
16count is greater than SSIZE_MAX, the result is unspecified. 标准C函数$man 3 printf... 1. 设备/dev/console/dev/tty/dev/null 2. 文件系统调用函数open, read, write, close, ioctl,ioctl 的功能与具体硬件相关, 所以针对不同的硬件功能可能完全不同。 lseekfstat, stat, lstatdup, dup2 检测程序运行时间$TIMEFORMAT=”” time my_system1.07user 3.50system 0:04.77elapsed 95%CPU 3. 标准IO函数fopen, fclose
fread, fwrite
fflush
fseek
fgetc, getc, getchar
fputc, putc, putchar
fgets, gets
printf, fprintf, and sprintf
scanf, fscanf, and sscanf fgetpos
fsetpos
ftell
rewind
freopen
setvbuf
remove 4. 出错处理#include <errno.h>
extern int errno; #include <stdio.h>
ferror(FILE *stream);
feof(FILE *stream);
clearerr(FILE *stream);strerror(int errno);perror("prefix string"); 5. 文件描述符和FILE流互转函数int fileno(FILE *stream);
FILE *fdopen(int fildes, const char *mode); 6. 文件和目录维护chmodchownunlink, link, symlink mkdir, rmdirchdir, getcwdopendir, closedir
readdir
telldir
seekdir 7. /proc 文件系统procfs 文件系统, provide a higher-level access to driver and kernel information. 8. 更高级的函数fcntlmmap 9. 结束语应该很全了,  如有遗漏, 欢迎补充参考Beginning Linux?Programming Third Edition  Wiley Publishing Inc, Neil Matthew, Richard Stones