您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sys_open函数代码示例

51自学网 2021-06-03 08:37:22
  C++
这篇教程C++ sys_open函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sys_open函数的典型用法代码示例。如果您正苦于以下问题:C++ sys_open函数的具体用法?C++ sys_open怎么用?C++ sys_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sys_open函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: load_565rle_image

/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */int load_565rle_image(char *filename, bool bf_supported){	struct fb_info *info;	int fd, count, err = 0;	unsigned max;	unsigned short *data, *ptr ;	uint32_t *bits;	unsigned int out;	info = registered_fb[0];	if (!info) {		printk(KERN_WARNING "%s: Can not access framebuffer/n",			__func__);		return -ENODEV;	}	fd = sys_open(filename, O_RDONLY, 0);	if (fd < 0) {		printk(KERN_WARNING "%s: Can not open %s/n",			__func__, filename);		return -ENOENT;	}	count = sys_lseek(fd, (off_t)0, 2);	if (count <= 0) {		err = -EIO;		goto err_logo_close_file;	}	sys_lseek(fd, (off_t)0, 0);	data = kmalloc(count, GFP_KERNEL);	if (!data) {		printk(KERN_WARNING "%s: Can not alloc data/n", __func__);		err = -ENOMEM;		goto err_logo_close_file;	}	if (sys_read(fd, (char *)data, count) != count) {		err = -EIO;		goto err_logo_free_data;	}	max = fb_width(info) * fb_height(info);	ptr = data;	if (bf_supported && (info->node == 1 || info->node == 2)) {		err = -EPERM;		pr_err("%s:%d no info->creen_base on fb%d!/n",		       __func__, __LINE__, info->node);		goto err_logo_free_data;	}	bits = (uint32_t*)(info->screen_base);	while (count > 3) {		unsigned n = ptr[0];		if (n > max)			break;		out = rgb32(ptr[1]);  		memset32(bits, out, n << 2);		bits += n;		max -= n;		ptr += 2;		count -= 4;	}err_logo_free_data:	kfree(data);err_logo_close_file:	sys_close(fd);	return err;}
开发者ID:android-armv7a-belalang-tempur,项目名称:android_kernel_sony_msm7x27a-Mesona,代码行数:68,


示例2: handle_initrd

static void __init handle_initrd(void){    int error;    int pid;    real_root_dev = new_encode_dev(ROOT_DEV);    create_dev("/dev/root.old", Root_RAM0);    /* mount initrd on rootfs' /root */    mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);    sys_mkdir("/old", 0700);    root_fd = sys_open("/", 0, 0);    old_fd = sys_open("/old", 0, 0);    /* move initrd over / and chdir/chroot in initrd root */    sys_chdir("/root");    sys_mount(".", "/", NULL, MS_MOVE, NULL);    sys_chroot(".");    /*     * In case that a resume from disk is carried out by linuxrc or one of     * its children, we need to tell the freezer not to wait for us.     */    current->flags |= PF_FREEZER_SKIP;    pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);    if (pid > 0)        while (pid != sys_wait4(-1, NULL, 0, NULL))            yield();    current->flags &= ~PF_FREEZER_SKIP;    /* move initrd to rootfs' /old */    sys_fchdir(old_fd);    sys_mount("/", ".", NULL, MS_MOVE, NULL);    /* switch root and cwd back to / of rootfs */    sys_fchdir(root_fd);    sys_chroot(".");    sys_close(old_fd);    sys_close(root_fd);    if (new_decode_dev(real_root_dev) == Root_RAM0) {        sys_chdir("/old");        return;    }    ROOT_DEV = new_decode_dev(real_root_dev);    mount_root();    printk(KERN_NOTICE "Trying to move old root to /initrd ... ");    error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);    if (!error)        printk("okay/n");    else {        int fd = sys_open("/dev/root.old", O_RDWR, 0);        if (error == -ENOENT)            printk("/initrd does not exist. Ignored./n");        else            printk("failed/n");        printk(KERN_NOTICE "Unmounting old root/n");        sys_umount("/old", MNT_DETACH);        printk(KERN_NOTICE "Trying to free ramdisk memory ... ");        if (fd < 0) {            error = fd;        } else {            error = sys_ioctl(fd, BLKFLSBUF, 0);            sys_close(fd);        }        printk(!error ? "okay/n" : "failed/n");    }}
开发者ID:YaFilthy,项目名称:android_kernel_lge_voltdos,代码行数:69,


示例3: mips_syscall

voidmips_syscall(struct trapframe *tf){	int callno;	int32_t retval;	int err;	assert(curspl==0);	callno = tf->tf_v0;	/*	 * Initialize retval to 0. Many of the system calls don't	 * really return a value, just 0 for success and -1 on	 * error. Since retval is the value returned on success,	 * initialize it to 0 by default; thus it's not necessary to	 * deal with it except for calls that return other values, 	 * like write.	 */	retval = 0;	switch (callno) {	    case SYS_reboot:			err = sys_reboot(tf->tf_a0);			break;#if OPT_A2	    case SYS_open:			err = sys_open((char *)tf->tf_a0, tf->tf_a1, tf->tf_a2);			if (err > 0)			{				retval = err;				err = 0;			}			break;	    case SYS_close:	    	err = sys_close(tf->tf_a0);			break;	    case SYS_read:	    	err = sys_read(tf->tf_a0, (void *)tf->tf_a1, tf->tf_a2);			if (err > 0)			{				retval = err;				err = 0;			}			break;	    case SYS_write:			err = sys_write(tf->tf_a0, (void *)tf->tf_a1, tf->tf_a2);			if (err > 0)			{				retval = err;				err = 0;			}			break;	    case SYS_fork:			err = sys_fork(tf);            if (err >= 0)            {                retval = err;                err = 0;            }			break;	    case SYS_getpid:            err = sys_getpid();                        if (err > 0)            {                retval = err;                err = 0;            }            break;	    case SYS_waitpid:            err = sys_waitpid(tf->tf_a0, (int *)tf->tf_a1, (int)tf->tf_a2);			break;	    case SYS__exit:	    	sys__exit(0);			break;	    case SYS_execv:			err = sys_execv((char *)tf->tf_a0, (char **)tf->tf_a1);			break;#endif	    	    default:			kprintf("Unknown syscall %d/n", callno);			err = ENOSYS;			break;	}    	if (err < 0) {//.........这里部分代码省略.........
开发者ID:dkim1000,项目名称:areallylongdirectorynamethatwehopethatpeoplewillnotfind,代码行数:101,


示例4: syscall

/* * System call dispatcher. * * A pointer to the trapframe created during exception entry (in * exception-*.S) is passed in. * * The calling conventions for syscalls are as follows: Like ordinary * function calls, the first 4 32-bit arguments are passed in the 4 * argument registers a0-a3. 64-bit arguments are passed in *aligned* * pairs of registers, that is, either a0/a1 or a2/a3. This means that * if the first argument is 32-bit and the second is 64-bit, a1 is * unused. * * This much is the same as the calling conventions for ordinary * function calls. In addition, the system call number is passed in * the v0 register. * * On successful return, the return value is passed back in the v0 * register, or v0 and v1 if 64-bit. This is also like an ordinary * function call, and additionally the a3 register is also set to 0 to * indicate success. * * On an error return, the error code is passed back in the v0 * register, and the a3 register is set to 1 to indicate failure. * (Userlevel code takes care of storing the error code in errno and * returning the value -1 from the actual userlevel syscall function. * See src/user/lib/libc/arch/mips/syscalls-mips.S and related files.) * * Upon syscall return the program counter stored in the trapframe * must be incremented by one instruction; otherwise the exception * return code will restart the "syscall" instruction and the system * call will repeat forever. * * If you run out of registers (which happens quickly with 64-bit * values) further arguments must be fetched from the user-level * stack, starting at sp+16 to skip over the slots for the * registerized values, with copyin(). */voidsyscall(struct trapframe *tf){	int callno;	int32_t retval;	int err;	KASSERT(curthread != NULL);	KASSERT(curthread->t_curspl == 0);	KASSERT(curthread->t_iplhigh_count == 0);	callno = tf->tf_v0;	/*	 * Initialize retval to 0. Many of the system calls don't	 * really return a value, just 0 for success and -1 on	 * error. Since retval is the value returned on success,	 * initialize it to 0 by default; thus it's not necessary to	 * deal with it except for calls that return other values,	 * like write.	 */	retval = 0;	int whence = 0;    off_t position = 0;	int32_t retval2 = 0; 	switch (callno) {	    case SYS_reboot:		err = sys_reboot(tf->tf_a0);		break;	    case SYS___time:		err = sys___time((userptr_t)tf->tf_a0,				 (userptr_t)tf->tf_a1);		break;	    /* Add stuff here */	    case SYS_write:		err = sys_write((int)tf->tf_a0,(const void *)tf->tf_a1,(size_t)tf->tf_a2, &retval);		break; 		case SYS_read:		err = sys_read(tf->tf_a0, (void *) tf->tf_a1, (size_t) tf->tf_a2, &retval);		break;				case SYS_open:		err = sys_open((char *)tf->tf_a0, tf->tf_a1, (mode_t)tf->tf_a2, &retval);		break;		case SYS_close:		err = sys_close(tf->tf_a0);		break;		case SYS_dup2:		err = sys_dup2(tf->tf_a0, tf->tf_a1, &retval);		break;   	    case SYS_lseek:    	position |= (off_t)tf->tf_a2;    	position <<= 32;//.........这里部分代码省略.........
开发者ID:roopaliv,项目名称:os161,代码行数:101,


示例5: SYSCALL_DEFINE2

/* * For backward compatibility?  Maybe this should be moved * into arch/i386 instead? */SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode){	return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);}
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:8,


示例6: bbe16_stress_test_start

s32 bbe16_stress_test_start(void){    u32 readlen = 0;    unsigned int handle;    mm_segment_t oldfs;    u32 buffer[0x10];    long ret;#ifdef BSP_DSP_BBE16    set_hi_crg_ctrl15_tensi_dps0_srst_req(0);    set_hi_crg_ctrl15_tensi_bbe16_srst_req(0);#else	set_hi_crg_srstdis2_tensi_dps0_pd_srst_dis(1);	set_hi_crg_srstdis2_tensi_dsp0_core_srst_dis(1);#endif    bbe16_tcm_addr = (u32)ioremap_nocache(BBE_TCM_ADDR, BBE_TCM_SIZE);    if (NULL == (void*)bbe16_tcm_addr)    {        printk(KERN_ERR"fail to io remap/n");        return -ENOMEM;    }#if 0    /* BBE16 DMEM1 
C++ sys_page_alloc函数代码示例
C++ sys_mutex_unlock函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。