当前位置:网站首页>Gossip about the 88 of redis source code
Gossip about the 88 of redis source code
2022-06-12 18:00:00 【Tao song remains the same】
This is actually a test program , Related to file operation , It's very simple :
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
int main(int argc, char **argv) {
struct stat stat;
int fd, cycles;
if (argc != 3) {
fprintf(stderr,"Usage: <filename> <cycles>\n");
exit(1);
}
srand(time(NULL));
char *filename = argv[1];
cycles = atoi(argv[2]);
fd = open(filename,O_RDWR);
if (fd == -1) {
perror("open");
exit(1);
}
fstat(fd,&stat);
while(cycles--) {
unsigned char buf[32];
unsigned long offset = rand()%stat.st_size;
int writelen = 1+rand()%31;
int j;
for (j = 0; j < writelen; j++) buf[j] = (char)rand();
lseek(fd,offset,SEEK_SET);
printf("Writing %d bytes at offset %lu\n", writelen, offset);
write(fd,buf,writelen);
}
return 0;
}
边栏推荐
猜你喜欢

C operation database added business data value content case school table

Byte flybook Human Resources Kit three sides

vant3+ts h5页面嵌套进app 与原生app通信

Overall flow chart of kernel interrupt

Use applet to quickly generate app in seven steps

JDBC several pits

Nixos 22.05 installation process record

ESP32-C3 ESP-IDF 配置smartconfig 和 sntp 获取网络时间

有源差分晶振原理圖以及LV-PECL、LVDS、HCSL區別

JDBC快速入门教程
随机推荐
Extreme Programming -- Practice of root cause analysis
Vant3+ts H5 pages are nested into apps to communicate with native apps
Leetcode491 increasing subsequence
1.5 what is an architect (serialization)
General differences between SQL server versions released by Microsoft in different periods so far, for reference
TypeScript类型声明文件(三)
Stream flow precautions
Vant3 +ts packaged simple step advancer component
Tensorflow prompts typeerror: unsupported operand type (s) for *: 'float' and 'nonetype‘
118. 杨辉三角(动态规划)
C operation database added business data value content case school table
LCD parameter interpretation and calculation
Channel Original
有关cookie的用法介绍
js判断回文数
EasyCode模板
String s = null ; String s = new String(); String s = "; what is the difference between string s?
ftrace
JDBC快速入門教程
小程序+App,低成本获客及活跃的一种技术组合思路