摘要: 本文利用以下系统调用实现ls -l命令的功能:1,lstat:获得文件状态,2,getpwuid:#include struct passwd *getpwuid(uid_t uid);描述:The getpwuid() function returns a pointer to a structure containing the broken-out fields of the record in the password database that matches the user ID uid.返回值: The passwd structure is defined in as fo. 阅读全文
posted @ 2013-07-10 22:21 mickole 阅读(2976) 评论(0) 推荐(0) 编辑
摘要: 一、stat()获取文件元数据stat系统调用原型: #include int stat(const char *path, struct stat *buf); int fstat(int fd, struct stat *buf); int lstat(const char *path, struct stat *buf);帮助信息可通过:man 2 stat 查看DESCRIPTION These functions return information about a file. No permissions are required on the file i... 阅读全文
posted @ 2013-07-10 17:04 mickole 阅读(2376) 评论(0) 推荐(0) 编辑
摘要: 1. 目录操作相关的系统调用 1.1 mkdir和rmdir系统调用 1.1.1 实例 1.2 chdir, getcwd系统调用 1.2.1 实例 1.3 opendir, closedir, readdir, 1.3.1 实例:递归便利目录 1. 目录操作相关的系统调用 1.1 mkdir和rmdir系统调用 [code] filename: mk_rm_dir.c #include int mkdir(const char *path, mode_t mode); return: S 0 ... 阅读全文
posted @ 2013-07-10 15:07 mickole 阅读(1486) 评论(0) 推荐(0) 编辑
摘要: 一、lseek()系统调用功能说明:通过指定相对于开始位置、当前位置或末尾位置的字节数来重定位 curp,这取决于 lseek() 函数中指定的位置函数原型:#include #include off_t lseek(int fd, off_t offset, int whence);参数说明:fd:文件描述符offset:偏移量,该值可正可负,负值为向前移whence:搜索的起始位置,有三个选项:(1).SEEK_SET: 当前位置为文件的开头,新位置为偏移量大小 (2).SEEK_CUR: 当前位置为文件指针位置,新位置为当前位置加上偏移量大小 (3).SEEK_END: 当... 阅读全文
posted @ 2013-07-10 13:45 mickole 阅读(2935) 评论(1) 推荐(0) 编辑
摘要: 5.4. Enabling and Disabling SELinux Use the /usr/sbin/getenforce or /usr/sbin/sestatus commands to check the status of SELinux. Thegetenforce command returns Enforcing, Permissive, or Disabled. Th... 阅读全文
posted @ 2013-07-10 11:03 mickole 阅读(2956) 评论(0) 推荐(0) 编辑
摘要: 一、vsftp服务能开启却连接不上的解决办法: 用虚拟机装了centos,vsftp是用centos自带的。启动vsftd服务后却一直连不上,原因是被防火墙给挡了。 查看防火墙状态:/etc/init.d/iptables status 停掉防火墙:/etc/init.d/iptables stop 也可以永久关闭防火墙:chkconfig --level 35 ipt... 阅读全文
posted @ 2013-07-10 10:54 mickole 阅读(979) 评论(0) 推荐(0) 编辑
摘要: read系统调用一旦有了与一个打开文件描述相连的文件描述符,只要该文件是用O_RDONLY或O_RDWR标志打开的,就可以用read()系统调用从该文件中读取字节函数原型:#include ssize_t read(int fd, void *buf, size_t count);参数fd :想要读的文件的文件描述符buf : 指向内存块的指针,从文件中读取来的字节放到这个内存块中count : 从该文件复制到buf中的字节个数返回值如果出现错误,返回-1读文件结束,返回0否则返回从该文件复制到规定的缓冲区中的字节数否则返回从该文件复制到规定的缓冲区中的字节数write系统调用用write() 阅读全文
posted @ 2013-07-10 00:04 mickole 阅读(2848) 评论(0) 推荐(0) 编辑