⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testmycopy.c

📁 使用内核编译的方法增加一个文件拷贝的系统调用
💻 C
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -