🌈 style:
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# 目录
|
||||
|
||||
- [目录](#目录)
|
||||
- [文件系统](#文件系统)
|
||||
- [目录和文件](#目录和文件)
|
||||
@@ -13,15 +14,12 @@
|
||||
- [函数之间正常的跳转](#函数之间正常的跳转)
|
||||
- [资源的获取及控制](#资源的获取及控制)
|
||||
|
||||
|
||||
# 文件系统
|
||||
|
||||
类`ls`的实现,如`myls -l -a -i -n`
|
||||
|
||||
`cmd --长格式 -短格式 非选项的传参`
|
||||
|
||||
|
||||
|
||||
## 目录和文件
|
||||
|
||||
1. 获取文件属性
|
||||
@@ -90,17 +88,16 @@ int fchmod(int fd, mode_t mode);
|
||||
文件或数据的存储格式。
|
||||
1. `FAT`:静态存储的单链表
|
||||
|
||||
```c
|
||||
struct node_st{
|
||||
int next[N];
|
||||
char data[N][SIZE];
|
||||
};
|
||||
```
|
||||
|
||||
2. `UFS`:
|
||||
缺点:不善于处理大量的小文件,因为每个文件都有一个`inode`,占用空间。
|
||||
|
||||
|
||||
```c
|
||||
struct node_st{
|
||||
int next[N];
|
||||
char data[N][SIZE];
|
||||
};
|
||||
```
|
||||
|
||||
2. `UFS`:
|
||||
缺点:不善于处理大量的小文件,因为每个文件都有一个`inode`,占用空间。
|
||||
|
||||
> 面试题:
|
||||
> 不用比较,比较两个uint32_t的大小
|
||||
> 使用位图
|
||||
@@ -114,13 +111,11 @@ int fchmod(int fd, mode_t mode);
|
||||
|
||||
限制:不能给分区建立,不能给目录建立
|
||||
|
||||
|
||||
- 符号链接
|
||||
`ln -s bigfile_link bigfile_s`
|
||||
|
||||
优点:可以跨分区,可以给目录建立
|
||||
|
||||
|
||||
```c
|
||||
int link(const char *oldpath, const char *newpath);
|
||||
|
||||
@@ -275,8 +270,6 @@ long telldir(DIR *dirp);
|
||||
|
||||
作业:用另一套函数实现`mydu`
|
||||
|
||||
|
||||
|
||||
## 系统数据文件和信息
|
||||
|
||||
> 不同环境可能有区别,以具体查询为准,这里以Linux为例
|
||||
@@ -434,8 +427,6 @@ size_t strftime(char *s, size_t max, const char *format,
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 进程环境
|
||||
|
||||
### `main`函数
|
||||
@@ -444,8 +435,6 @@ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
|
||||
int main(int argc, char *argv[]);
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 进程的终止
|
||||
|
||||
1. 正常终止:
|
||||
@@ -470,7 +459,6 @@ int main(int argc, char *argv[]);
|
||||
- 接到一个信号并终止
|
||||
- 最后一个线程对其取消请求作出响应
|
||||
|
||||
|
||||
```c
|
||||
/**
|
||||
* 注册一个函数,当进程终止时调用
|
||||
@@ -481,8 +469,6 @@ int main(int argc, char *argv[]);
|
||||
int atexit(void (*function)(void));// 钩子函数
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 命令行参数的分析
|
||||
|
||||
```c
|
||||
@@ -498,8 +484,6 @@ int getopt_long(int argc, char *const argv[], const char *optstring,
|
||||
const struct option *longopts, int *longindex);
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 环境变量
|
||||
|
||||
**KEY = VALVE**
|
||||
@@ -525,14 +509,10 @@ int unsetenv(const char *name);
|
||||
int putenv(char *string);
|
||||
```
|
||||
|
||||
|
||||
|
||||
### C程序的存储空间布局
|
||||
|
||||
`pmap`命令,查看进程空间布局
|
||||
|
||||
|
||||
|
||||
### 库
|
||||
|
||||
- 动态库
|
||||
@@ -549,8 +529,6 @@ int putenv(char *string);
|
||||
// Link with -ldl
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 函数之间正常的跳转
|
||||
|
||||
`goto`无法跨函数跳转。
|
||||
@@ -573,8 +551,6 @@ int setjmp(jmp_buf env);
|
||||
void longjmp(jmp_buf env, int val);
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 资源的获取及控制
|
||||
|
||||
`ulimit -a`
|
||||
@@ -591,4 +567,3 @@ struct rlimit {
|
||||
rlim_t rlim_max; /* hard limit */
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user