|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
四、Linux中与文件系统相关的系统调用
1.通过使用man命令,查阅以下的系统调用的使用手册。
文件操作
open, close, read, write, seek
creat, truncate, mknod, dup, dup2
link, unlink, rename, symlink
chmod, chown, umask
fcntl, flock, fstat, lstat, stat, utime
fsync, fdatasync
目录操作
mkdir, chdir, rmdir
readdir, getdents
库函数
fopen, fclose, fread, fwrite, fscanf, fprintf, fseek ,ftell, feof等
2. 文件系统的系统调用的编程练习
利用上面的系统调用,试写出自己的命令程序,完成以下功能(要求至少完成2例):
How to create a file?
How to delete a file? (rm 命令)
How to copy one file to another file? (cp 命令)
How to rename a file? (mv file 命令)
How to truncate a file (or make it be of length zero)?
How to append something to a file?
How to lock a file? (read lock, write lock)
How to generate a unique (temporary) file?
How to create a directory? (mkdir 命令)
How to remove a directory? (rmdir 命令)
How to traverse a directory (or visit every file under it)? (ls –lR 命令)
写两个程序实现两个功能,咋写,求教大佬! |
|