memory map program --------uses mmap function to copy file fd to stdout
来源:互联网 发布:dedecms 帝国 cms 编辑:程序博客网 时间:2024/05/16 08:28
#include<unistd.h>
#include<sys/stat.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/mman.h>//PROT_READ header file
#include<string.h>
#include<fcntl.h>//O_RDONLY header file
void mmapcopy(int fd, int size)
{
char *bufp;
bufp = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
write(1, bufp, size);
return ;
}
int main(int argc, char **argv)
{
struct stat stat1;
int fd;
if(argc != 2)
{
printf("usage: %s <filename>\n", argv[0]);
exit(0);
}
fd = open(argv[1], O_RDONLY, 0);
fstat(fd, &stat1);
mmapcopy(fd, stat1.st_size);
exit(0);
}
#include<sys/stat.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/mman.h>//PROT_READ header file
#include<string.h>
#include<fcntl.h>//O_RDONLY header file
void mmapcopy(int fd, int size)
{
char *bufp;
bufp = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
write(1, bufp, size);
return ;
}
int main(int argc, char **argv)
{
struct stat stat1;
int fd;
if(argc != 2)
{
printf("usage: %s <filename>\n", argv[0]);
exit(0);
}
fd = open(argv[1], O_RDONLY, 0);
fstat(fd, &stat1);
mmapcopy(fd, stat1.st_size);
exit(0);
}
- memory map program --------uses mmap function to copy file fd to stdout
- Using mmap to Copy an Arbitrary-sized Disk File to stdout
- Native memory allocation (mmap) failed to map 142606336 bytes for committing reserved memory.
- Uses serialization to make a deep copy
- .Net Program Unable to copy a file from obj\Debug to bin\Debug
- Output message to a file or stdout
- Kakfka启动报错: Native memory allocation (mmap) failed to map 1073741824 bytes ..解决方案
- More ways to map memory
- DM6467 memory map HOW-TO
- DM6467 memory map HOW-TO
- Express Morgan not writing logs to file or STDOUT
- How To Redirect stderr To stdout ( redirect stderr to a File )
- fd to filename
- ABAP--program to download BITMAP file to PC
- ABAP--program to download BITMAP file to PC
- maven Failed to copy file for artifact
- android copy raw file to sdcard
- maven Failed to copy file for artifact
- Kinect 1.7中的错误
- 判断从TextView里取出的字符串是否为空
- Ubuntu常用命令大全
- ActionBar上面添加popup menu
- SHELL十三问要点总结
- memory map program --------uses mmap function to copy file fd to stdout
- IOS知识点
- SQL Server排序规则冲突
- [Django1.5]two-scoops-django-best-practices 笔记三
- 技术政治之肿瘤还是异形
- android:全屏设置 + 去标题 + 只去程序标题栏 (应用和activity设置)
- 设计模式:模板模式
- 杭电2042
- CGridCtrl控件