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

📄 psdev.c

📁 嵌入式系统设计与实例开发实验教材二源码 多线程应用程序设计 串行端口程序设计 AD接口实验 CAN总线通信实验 GPS通信实验 Linux内核移植与编译实验 IC卡读写实验 SD驱动使
💻 C
📖 第 1 页 / 共 4 页
字号:
                PRESTO_ALLOC(buffer, char *, input.buffer_len+1);                error=copy_from_user(buffer, input.buffer, input.buffer_len);                if ( error ) {                     EXIT;                    PRESTO_FREE(name,input.name_len+1);                    PRESTO_FREE(buffer,input.buffer_len+1);                    return error;                }                /* Make null terminated for easy printing */                buffer[input.buffer_len]='\0';                 CDEBUG(D_PSDEV," setextattr params: name %s, valuelen %d,"                       " value %s, attr flags %x, mode %o, slot offset %d,"                       " recno %d, kml offset %lu, flags %x, time %d\n",                        name, input.buffer_len, buffer, input.flags, input.mode,                       input.info.slot_offset, input.info.recno,                       (unsigned long) input.info.kml_offset, input.info.flags,                       input.info.updated_time);                error=lento_set_ext_attr                      (input.path,name,buffer,input.buffer_len,                       input.flags, input.mode, &input.info);                PRESTO_FREE(name,input.name_len+1);                PRESTO_FREE(buffer,input.buffer_len+1);                EXIT;                return error;        }        /* IOCTL to delete an extended attribute */        case PRESTO_VFS_DELEXTATTR: {                int error;                struct lento_input_ext_attr input;                char *name;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                     EXIT;                    return error;                }                /* Now setup the input parameters */                PRESTO_ALLOC(name, char *, input.name_len+1);                /* We need null terminated strings for attr names */                name[input.name_len] = '\0';                error=copy_from_user(name, input.name, input.name_len);                if ( error ) {                     EXIT;                    PRESTO_FREE(name,input.name_len+1);                    return error;                }                CDEBUG(D_PSDEV," delextattr params: name %s,"                       " attr flags %x, mode %o, slot offset %d, recno %d,"                       " kml offset %lu, flags %x, time %d\n",                        name, input.flags, input.mode,                       input.info.slot_offset, input.info.recno,                       (unsigned long) input.info.kml_offset, input.info.flags,                       input.info.updated_time);                error=lento_set_ext_attr                      (input.path,name,NULL,0,input.flags,                       input.mode,&input.info);                PRESTO_FREE(name,input.name_len+1);                EXIT;                return error;        }#endif        case PRESTO_VFS_IOPEN: {                struct lento_input_iopen input;                int error;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                        EXIT;                        return error;                }                input.fd = lento_iopen(input.name, (ino_t)input.ino,                                       input.generation, input.flags);                CDEBUG(D_PIOCTL, "lento_iopen file descriptor: %d\n", input.fd);                if (input.fd < 0) {                        EXIT;                        return input.fd;                }                EXIT;                return copy_to_user((char *)arg, &input, sizeof(input));        }        case PRESTO_VFS_CLOSE: {                int error;                struct lento_input_close input;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                        EXIT;                        return error;                }                CDEBUG(D_PIOCTL, "lento_close file descriptor: %d\n", input.fd);                error = lento_close(input.fd, &input.info);                EXIT;                return error;        }        case PRESTO_BACKFETCH_LML: {                char *user_path;                int error;                struct lml_arg {                        char *path;                        __u32 path_len;                        __u64 remote_ino;                        __u32 remote_generation;                        __u32 remote_version;                        struct presto_version remote_file_version;                } input;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                        EXIT;                        return error;                }                user_path = input.path;                PRESTO_ALLOC(input.path, char *, input.path_len + 1);                if ( !input.path ) {                        EXIT;                        return -ENOMEM;                }                error = copy_from_user(input.path, user_path, input.path_len);                if ( error ) {                        EXIT;                        PRESTO_FREE(input.path, input.path_len + 1);                        return error;                }                input.path[input.path_len] = '\0';                CDEBUG(D_DOWNCALL, "lml name: %s\n", input.path);                                return lento_write_lml(input.path,                                        input.remote_ino,                                        input.remote_generation,                                       input.remote_version,                                       &input.remote_file_version);         }                        case PRESTO_CANCEL_LML: {                char *user_path;                int error;                struct lml_arg {                        char *path;                        __u64 lml_offset;                         __u32 path_len;                        __u64 remote_ino;                        __u32 remote_generation;                        __u32 remote_version;                        struct lento_vfs_context info;                } input;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                        EXIT;                        return error;                }                user_path = input.path;                PRESTO_ALLOC(input.path, char *, input.path_len + 1);                if ( !input.path ) {                        EXIT;                        return -ENOMEM;                }                error = copy_from_user(input.path, user_path, input.path_len);                if ( error ) {                        EXIT;                        PRESTO_FREE(input.path, input.path_len + 1);                        return error;                }                input.path[input.path_len] = '\0';                CDEBUG(D_DOWNCALL, "lml name: %s\n", input.path);                                return lento_cancel_lml(input.path,                                         input.lml_offset,                                         input.remote_ino,                                         input.remote_generation,                                        input.remote_version,                                        &input.info);         }        case PRESTO_COMPLETE_CLOSES: {                char *user_path;                int error;                struct lml_arg {                        char *path;                        __u32 path_len;                } input;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                        EXIT;                        return error;                }                user_path = input.path;                PRESTO_ALLOC(input.path, char *, input.path_len + 1);                if ( !input.path ) {                        EXIT;                        return -ENOMEM;                }                error = copy_from_user(input.path, user_path, input.path_len);                if ( error ) {                        EXIT;                        PRESTO_FREE(input.path, input.path_len + 1);                        return error;                }                input.path[input.path_len] = '\0';                CDEBUG(D_DOWNCALL, "lml name: %s\n", input.path);                                error = lento_complete_closes(input.path);                PRESTO_FREE(input.path, input.path_len + 1);                return error;        }        case PRESTO_RESET_FSET: {                char *user_path;                int error;                struct lml_arg {                        char *path;                        __u32 path_len;                        __u64 offset;                        __u32 recno;                } input;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                        EXIT;                        return error;                }                user_path = input.path;                PRESTO_ALLOC(input.path, char *, input.path_len + 1);                if ( !input.path ) {                        EXIT;                        return -ENOMEM;                }                error = copy_from_user(input.path, user_path, input.path_len);                if ( error ) {                        EXIT;                        PRESTO_FREE(input.path, input.path_len + 1);                        return error;                }                input.path[input.path_len] = '\0';                CDEBUG(D_DOWNCALL, "lml name: %s\n", input.path);                                return lento_reset_fset(input.path, input.offset, input.recno);         }                        case PRESTO_MARK: {                char *user_path;                int res = 0;  /* resulting flags - returned to user */                int error;                struct {                        int  mark_what;                        int  and_flag;                        int  or_flag;                        int path_len;                        char *path;                } input;                error = copy_from_user(&input, (char *)arg, sizeof(input));                if ( error ) {                        EXIT;                        return error;                }                user_path = input.path;                PRESTO_ALLOC(input.path, char *, input.path_len + 1);                if ( !input.path ) {                        EXIT;                        return -ENOMEM;                }                error = copy_from_user(input.path, user_path, input.path_len);                if ( error ) {                        EXIT;                        PRESTO_FREE(input.path, input.path_len + 1);                        return error;                }                input.path[input.path_len] = '\0';                CDEBUG(D_DOWNCALL, "mark name: %s, and: %x, or: %x, what %d\n",                       input.path, input.and_flag, input.or_flag,                        input.mark_what);                switch (input.mark_what) {                case MARK_DENTRY:                                       error = presto_mark_dentry(input.path,                                                   input.and_flag,                                                   input.or_flag, &res);                        break;                case MARK_FSET:                        error = presto_mark_fset(input.path,                                                   input.and_flag,                                                   input.or_flag, &res);                        break;                case MARK_CACHE:                        error = presto_mark_cache(input.path,                                                   input.and_flag,                                                   input.or_flag, &res);                        break;                case MARK_GETFL: {                        int fflags, cflags;                        input.and_flag = 0xffffffff;                        input.or_flag = 0;                         error = presto_mark_dentry(input.path,                                                   input.and_flag,                                                   input.or_flag, &res);                        if (error)                                 break;                        error = presto_mark_fset(input.path,                                                   input.and_flag,                                                   input.or_flag, &fflags);                        if (error)                                 break;                        error = presto_mark_cache(input.path,                                                   input.and_flag,                                                   input.or_flag, &cflags);                        if (error)                                 break;                        input.and_flag = fflags;                        input.or_flag = cflags;                	break;                }                default:                        error = -EINVAL;                }                PRESTO_FREE(input.path, input.path_len + 1);                if (error == -EBUSY) {                        input.and_flag = error;                        error = 0;                }                if (error) {                         EXIT;                        return error;                }                /* return the correct cookie to wait for */                input.mark_what = res;                return copy_to_user((char *)arg, &input, sizeof(input));        }#ifdef  CONFIG_KREINT        case PRESTO_REINT_BEGIN:                return begin_kml_reint (file, arg);        case PRESTO_DO_REINT:                return do_kml_reint (file, arg);        case PRESTO_REINT_END:                return end_kml_reint (file, arg);#endif        case PRESTO_RELEASE_PERMIT: {                int error;                char *user_path;                struct {                        int  cookie;                        int path_len;                        char *path;                } permit;                                error = copy_from_user(&permit, (char *)arg, sizeof(permit));                if ( error ) {                        EXIT;                        return error;                        }                user_path = permit.path;                                PRESTO_ALLOC(permit.path, char *, permit.path_len + 1);                if ( !permit.path ) {                        EXIT;                        return -ENOMEM;                }                error = copy_from_user(permit.path, user_path, permit.path_len);                if ( error ) {                        EXIT;                        PRESTO_FREE(permit.path, permit.path_len + 1);                        return error;                }                permit.path[permit.path_len] = '\0';                                CDEBUG(D_DOWNCALL, "release permit: %s, in cookie=%d\n",                       permit.path, permit.cookie);                error = presto_permit_downcall(permit.path, &permit.cookie);                                PRESTO_FREE(permit.path, permit.path_len + 1);                if (error) {                        EXIT;                        return error;                }                /* return the correct cookie to wait for */                return copy_to_user((char *)arg, &permit, sizeof(permit));        }                default:                CDEBUG(D_PSDEV, "bad ioctl 0x%x, \n", cmd);                CDEBUG(D_PSDEV, "valid are 0x%Zx - 0x%Zx, 0x%Zx - 0x%Zx \n",                        PRESTO_GETMOUNT, PRESTO_GET_KMLSIZE,                        PRESTO_VFS_SETATTR, PRESTO_VFS_IOPEN);                EXIT;        }

⌨️ 快捷键说明

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