🦄 refactor(C13, C14, C115): 更新了linux系统开发部分的结构

This commit is contained in:
lzy
2024-05-16 20:36:01 +08:00
parent cb969dfd41
commit 60d670d130
53 changed files with 1407 additions and 1246 deletions

34
C14-文件系统/big.c Normal file
View File

@@ -0,0 +1,34 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char **argv)
{
if (argc < 2)
{
fprintf(stderr, "Usage:...\n");
exit(1);
}
int fd;
fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd < 0)
{
perror("open()");
exit(1);
}
// 生成一个5G的文件
// !!! 整数溢出
lseek(fd, 5LL * 1024LL * 1024LL * 1024LL - 1LL, SEEK_SET);
// 写入尾0
write(fd, "", 1);
close(fd);
exit(0);
}