testmycopy.c

来自「使用内核编译的方法增加一个文件拷贝的系统调用」· C语言 代码 · 共 33 行

C
33
字号
#include <linux/unistd.h>#include <fcntl.h>#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#define  __NR_mycopy		285#define  MAXSIZE	100_syscall3(int,mycopy,int,sflie,int,dfile,char *,buffer)int main(int argc, char **argv){int sfile, dfile;char buffer[MAXSIZE];if (argc != 3) 	{	    	printf( "参数错误\n");	    	exit(-1);     	 }if ((sfile= open(argv[1], O_RDONLY)) == -1) 	{		printf( "文件打开失败\n");		exit(-1);     	}if ((dfile =open(argv[2], O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) == -1)    	{		printf("文件打开失败\n");		exit(-1);   	}mycopy(sfile,dfile,buffer);  return  0;} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?