![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
apue学习笔记
Gk_zheng
这个作者很懒,什么都没留下…
展开
-
真实用户id、有效用户id、保存的设置用户id的区别以及联系(setuid、seteuid)
文章转载自:https://blog.csdn.net/taiyang1987912/article/details/40651623在使用 setuid() 函数时会遇到 3 个关于 ID 的概念:real user ID -- 真实用户 IDeffective user ID -- 有效用户 IDsaved set-user-ID -- 保存了的设置用户 ID。真实用户 ID (real user ID) 就是通常所说的 UID,在 /etc/passwd 中能看到它的身影,如:b.转载 2020-06-13 20:18:08 · 1893 阅读 · 1 评论 -
unix中c语言典型的存储空间布局
此文转载于:https://www.cnblogs.com/LUO77/p/5853534.html-------------------------------------------------------------------------------------------------------------------------------------------------------------------------一个程序本质上都是由 BSS 段、data段、text段三个组成的转载 2020-06-13 12:45:41 · 245 阅读 · 0 评论 -
unix中的环境表、环境变量(environ、getenv、setenv、putenv)
环境表每个程序都有一张环境表。与参数表一样,环境表也是一个字符指针数组,其中每个指针包含一个以null结束的c字符串地址。全局变量environ则包含了该指针数组的地址:extern char ** environ;如下程序可以打印环境表。#include <stdio.h>#include <stdlib.h>extern char ** environ;int main(){ int i; for(i=0;environ[i]!=NULL;i++)..原创 2020-06-13 10:55:47 · 1056 阅读 · 0 评论 -
APUE学习笔记--系统数据文件和信息--时间相关的函数(time、localtime、gmtime、mktime、strftime)
time函数定义 #include <time.h> time_t time(time_t *t);功能描述time() returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.If t is non-NULL, the return value is also stored in the memory pointed to by t.返回值On..原创 2020-06-11 14:57:56 · 361 阅读 · 0 评论 -
APUE学习笔记--系统数据文件和信息-(shadow文件、crypt、getspnam、getpass、实现密码检查)
shadow文件存放在/etc/shadowstruct spwd {char sp_namp; / user login name */char sp_pwdp; / encrypted password /long int sp_lstchg; / last password change /long int sp_min; / days until change allowed. /long int sp_max; ..原创 2020-06-10 17:11:33 · 296 阅读 · 0 评论 -
APUE学习笔记--文件系统(stat、fstat、lstat、空洞文件、读取目录内容、实现自己的du)
stat、fstat、lstat函数定义#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>int stat(const char *path, struct stat *buf);int fstat(int fd, struct stat *buf);int lstat(const char *path, struct stat *buf);功能描述这三个函数都通过b..原创 2020-06-09 11:54:48 · 362 阅读 · 0 评论 -
APUE学习笔记--文本IO(系统调用IO)(open、read、write、lseek、close、fileno、fdopen、truncate、ftruncate)
前言当前笔记是基于我现在使用的centos6.3系统,各种细节最终以当前使用系统的man手册为准。文本IO的函数位于man手册第二部分,man 2 命令名 打开文本IO帮助文档。open功能描述:打开一个文件或者设备。函数定义:#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>int open(const char *pathname, int flags);..原创 2020-06-04 09:00:13 · 270 阅读 · 1 评论 -
APUE学习笔记--标准I/O (三)(getline、tmpnam、tmpfile)
getline功能描述:前面介绍的scanf、sscanf都设置的静态内存。数据很大时,没法灵活存储。getline使用动态内存技术。getline读取一行,遇到’\0’、‘\n’、EOF结束。遇到‘\n’,会把’\n’读取保存,并结束一行读取。函数定义#define _GNU_SOURCE#include <stdio.h>ssize_t getline(char **lineptr, size_t *n, FILE *stream);在我的centos 6.3版本中,..原创 2020-06-04 04:32:38 · 308 阅读 · 0 评论 -
APUE学习笔记--标准I/O流(二)(fprintf、sprintf、snprintf、fscanf、sscanf、fseek、ftell、rewind、fseeko 、ftello、fflush)
fprintfint fprintf(FILE *stream, const char *format, …);与printf很相似,只是printf默认输出流为stdout,fprintf可以指定输出流。sprintfint sprintf(char *str, const char *format, …);这不是输出到某个流,而是直接输出到某个内存中的字符数组中。atoi把一个字符数组转换为int,sprintf可以把int转化为字符数组。snprintfint s..原创 2020-06-03 11:44:55 · 295 阅读 · 0 评论 -
APUE学习笔记--标准I/O流(一)(fopen、perror、strerror、fgetc、fputc、gets、fgets、fputs、fread、fwrite)
fopen返回结果若执行成功:返回FILE 指针,一个非负整数。若执行失败:返回NULL,并设置errno为对应的非负整数。errno为全局变量,所以想获得正确的出错原因,得立马打印,否则可能会被其他进程修改。errno在现在的系统中,很多时候是定义为一个宏。参数解析path:文件所在路径。mode:一个字符串用于表达该文件的打开方式。r:在文件起始位置打开文件,只读。若文件不存在,则执行失败。r+:在文件起始位置打开文件,可读可写。若文件不存在,则执行失..原创 2020-06-03 02:31:59 · 455 阅读 · 0 评论