🦄 refactor(C14, C15):
This commit is contained in:
34
C14-文件系统/fs/big.c
Normal file
34
C14-文件系统/fs/big.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user