Lines Matching refs:res
302 TEE_Result res = TEE_SUCCESS; in tee_rpmb_key_gen() local
305 res = TEE_ERROR_BAD_PARAMETERS; in tee_rpmb_key_gen()
313 return res; in tee_rpmb_key_gen()
370 static void get_op_result_bits(uint8_t *bytes, uint8_t *res) in get_op_result_bits() argument
372 *res = *(bytes + 1) & RPMB_RESULT_MASK; in get_op_result_bits()
380 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_mac_calc() local
387 res = crypto_mac_alloc_ctx(&ctx, TEE_ALG_HMAC_SHA256); in tee_rpmb_mac_calc()
388 if (res) in tee_rpmb_mac_calc()
389 return res; in tee_rpmb_mac_calc()
391 res = crypto_mac_init(ctx, key, keysize); in tee_rpmb_mac_calc()
392 if (res != TEE_SUCCESS) in tee_rpmb_mac_calc()
396 res = crypto_mac_update(ctx, datafrms[i].data, in tee_rpmb_mac_calc()
398 if (res != TEE_SUCCESS) in tee_rpmb_mac_calc()
402 res = crypto_mac_final(ctx, mac, macsize); in tee_rpmb_mac_calc()
403 if (res != TEE_SUCCESS) in tee_rpmb_mac_calc()
406 res = TEE_SUCCESS; in tee_rpmb_mac_calc()
410 return res; in tee_rpmb_mac_calc()
488 TEE_Result res = TEE_SUCCESS; in rpmb_probe_reset() local
490 res = thread_rpc_cmd(OPTEE_RPC_CMD_RPMB_PROBE_RESET, 1, params); in rpmb_probe_reset()
491 if (res) in rpmb_probe_reset()
492 return res; in rpmb_probe_reset()
512 TEE_Result res = TEE_SUCCESS; in rpmb_probe_next() local
526 res = thread_rpc_cmd(OPTEE_RPC_CMD_RPMB_PROBE_NEXT, 2, params); in rpmb_probe_next()
532 } while (res == TEE_ERROR_SHORT_BUFFER); in rpmb_probe_next()
533 if (res) in rpmb_probe_next()
534 return res; in rpmb_probe_next()
582 TEE_Result res = TEE_SUCCESS; in decrypt() local
604 res = decrypt_block(tmp, frm->data, blk_idx, fek, uuid); in decrypt()
605 if (res == TEE_SUCCESS) in decrypt()
609 res = decrypt_block(out, frm->data, blk_idx, fek, uuid); in decrypt()
613 return res; in decrypt()
622 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_req_pack() local
661 res = TEE_ERROR_GENERIC; in tee_rpmb_req_pack()
677 res = encrypt_block(datafrm[i].data, in tee_rpmb_req_pack()
682 if (res != TEE_SUCCESS) in tee_rpmb_req_pack()
694 res = in tee_rpmb_req_pack()
699 if (res != TEE_SUCCESS) in tee_rpmb_req_pack()
716 res = TEE_SUCCESS; in tee_rpmb_req_pack()
719 return res; in tee_rpmb_req_pack()
726 TEE_Result res; in data_cpy_mac_calc_1b() local
733 res = tee_rpmb_mac_calc(rawdata->key_mac, RPMB_KEY_MAC_SIZE, in data_cpy_mac_calc_1b()
735 if (res != TEE_SUCCESS) in data_cpy_mac_calc_1b()
736 return res; in data_cpy_mac_calc_1b()
741 res = decrypt(data, frm, rawdata->len, rawdata->byte_offset, idx, fek, in data_cpy_mac_calc_1b()
743 return res; in data_cpy_mac_calc_1b()
753 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_data_cpy_mac_calc() local
772 res = crypto_mac_alloc_ctx(&ctx, TEE_ALG_HMAC_SHA256); in tee_rpmb_data_cpy_mac_calc()
773 if (res) in tee_rpmb_data_cpy_mac_calc()
776 res = crypto_mac_init(ctx, rpmb_ctx->key, RPMB_KEY_MAC_SIZE); in tee_rpmb_data_cpy_mac_calc()
777 if (res != TEE_SUCCESS) in tee_rpmb_data_cpy_mac_calc()
796 res = crypto_mac_update(ctx, localfrm.data, in tee_rpmb_data_cpy_mac_calc()
798 if (res != TEE_SUCCESS) in tee_rpmb_data_cpy_mac_calc()
811 res = decrypt(data, &localfrm, size, offset, start_idx + i, in tee_rpmb_data_cpy_mac_calc()
813 if (res != TEE_SUCCESS) in tee_rpmb_data_cpy_mac_calc()
823 res = decrypt(data, lastfrm, size, 0, start_idx + nbr_frms - 1, fek, in tee_rpmb_data_cpy_mac_calc()
825 if (res != TEE_SUCCESS) in tee_rpmb_data_cpy_mac_calc()
829 res = crypto_mac_update(ctx, lastfrm->data, RPMB_MAC_PROTECT_DATA_SIZE); in tee_rpmb_data_cpy_mac_calc()
830 if (res != TEE_SUCCESS) in tee_rpmb_data_cpy_mac_calc()
833 res = crypto_mac_final(ctx, rawdata->key_mac, RPMB_KEY_MAC_SIZE); in tee_rpmb_data_cpy_mac_calc()
834 if (res != TEE_SUCCESS) in tee_rpmb_data_cpy_mac_calc()
837 res = TEE_SUCCESS; in tee_rpmb_data_cpy_mac_calc()
841 return res; in tee_rpmb_data_cpy_mac_calc()
850 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_resp_unpack_verify() local
923 res = tee_rpmb_data_cpy_mac_calc(datafrm, rawdata, in tee_rpmb_resp_unpack_verify()
927 if (res != TEE_SUCCESS) in tee_rpmb_resp_unpack_verify()
928 return res; in tee_rpmb_resp_unpack_verify()
937 res = tee_rpmb_mac_calc(rawdata->key_mac, in tee_rpmb_resp_unpack_verify()
943 if (res != TEE_SUCCESS) in tee_rpmb_resp_unpack_verify()
944 return res; in tee_rpmb_resp_unpack_verify()
963 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_get_dev_info() local
970 res = tee_rpmb_alloc(0, sizeof(struct rpmb_dev_info), &mem); in tee_rpmb_get_dev_info()
971 if (res != TEE_SUCCESS) in tee_rpmb_get_dev_info()
972 return res; in tee_rpmb_get_dev_info()
980 res = tee_rpmb_invoke(&mem); in tee_rpmb_get_dev_info()
981 if (res != TEE_SUCCESS) in tee_rpmb_get_dev_info()
982 return res; in tee_rpmb_get_dev_info()
998 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_init_read_wr_cnt() local
1009 res = tee_rpmb_alloc(RPMB_DATA_FRAME_SIZE, RPMB_DATA_FRAME_SIZE, &mem); in tee_rpmb_init_read_wr_cnt()
1010 if (res != TEE_SUCCESS) in tee_rpmb_init_read_wr_cnt()
1011 return res; in tee_rpmb_init_read_wr_cnt()
1013 res = crypto_rng_read(nonce, RPMB_NONCE_SIZE); in tee_rpmb_init_read_wr_cnt()
1014 if (res != TEE_SUCCESS) in tee_rpmb_init_read_wr_cnt()
1015 return res; in tee_rpmb_init_read_wr_cnt()
1023 res = tee_rpmb_req_pack(mem.req_hdr, mem.req_data, &rawdata, 1, NULL, in tee_rpmb_init_read_wr_cnt()
1025 if (res != TEE_SUCCESS) in tee_rpmb_init_read_wr_cnt()
1026 return res; in tee_rpmb_init_read_wr_cnt()
1028 res = tee_rpmb_invoke(&mem); in tee_rpmb_init_read_wr_cnt()
1029 if (res != TEE_SUCCESS) in tee_rpmb_init_read_wr_cnt()
1030 return res; in tee_rpmb_init_read_wr_cnt()
1048 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_write_key() local
1053 res = tee_rpmb_alloc(RPMB_DATA_FRAME_SIZE, RPMB_DATA_FRAME_SIZE, &mem); in tee_rpmb_write_key()
1054 if (res != TEE_SUCCESS) in tee_rpmb_write_key()
1055 return res; in tee_rpmb_write_key()
1063 res = tee_rpmb_req_pack(mem.req_hdr, mem.req_data, &rawdata, 1, NULL, in tee_rpmb_write_key()
1065 if (res != TEE_SUCCESS) in tee_rpmb_write_key()
1066 return res; in tee_rpmb_write_key()
1068 res = tee_rpmb_invoke(&mem); in tee_rpmb_write_key()
1069 if (res != TEE_SUCCESS) in tee_rpmb_write_key()
1070 return res; in tee_rpmb_write_key()
1083 TEE_Result res; in tee_rpmb_write_and_verify_key() local
1093 res = tee_rpmb_write_key(); in tee_rpmb_write_and_verify_key()
1094 if (res == TEE_SUCCESS) { in tee_rpmb_write_and_verify_key()
1096 res = tee_rpmb_init_read_wr_cnt(&rpmb_ctx->wr_cnt); in tee_rpmb_write_and_verify_key()
1098 return res; in tee_rpmb_write_and_verify_key()
1140 TEE_Result res = TEE_SUCCESS; in legacy_rpmb_init() local
1151 res = tee_rpmb_get_dev_info(&dev_info); in legacy_rpmb_init()
1152 if (res != TEE_SUCCESS) in legacy_rpmb_init()
1153 return res; in legacy_rpmb_init()
1155 res = rpmb_set_dev_info(&dev_info); in legacy_rpmb_init()
1156 if (res) in legacy_rpmb_init()
1157 return res; in legacy_rpmb_init()
1165 res = tee_rpmb_key_gen(rpmb_ctx->key, RPMB_KEY_MAC_SIZE); in legacy_rpmb_init()
1166 if (res != TEE_SUCCESS) { in legacy_rpmb_init()
1168 res); in legacy_rpmb_init()
1169 return res; in legacy_rpmb_init()
1179 res = tee_rpmb_init_read_wr_cnt(&rpmb_ctx->wr_cnt); in legacy_rpmb_init()
1180 if (res == TEE_SUCCESS) { in legacy_rpmb_init()
1184 } else if (res == TEE_ERROR_ITEM_NOT_FOUND && in legacy_rpmb_init()
1190 res = tee_rpmb_write_and_verify_key(); in legacy_rpmb_init()
1192 EMSG("Verify key failed! %#"PRIx32, res); in legacy_rpmb_init()
1197 return res; in legacy_rpmb_init()
1203 TEE_Result res = TEE_SUCCESS; in tee_rpmb_init() local
1223 res = rpmb_probe_reset(); in tee_rpmb_init()
1224 if (res) { in tee_rpmb_init()
1225 if (res != TEE_ERROR_NOT_SUPPORTED && in tee_rpmb_init()
1226 res != TEE_ERROR_NOT_IMPLEMENTED) in tee_rpmb_init()
1227 return res; in tee_rpmb_init()
1231 res = rpmb_probe_next(&dev_info); in tee_rpmb_init()
1232 if (res) { in tee_rpmb_init()
1233 DMSG("rpmb_probe_next error %#"PRIx32, res); in tee_rpmb_init()
1234 return res; in tee_rpmb_init()
1251 res = rpmb_probe_reset(); in tee_rpmb_init()
1252 if (res) { in tee_rpmb_init()
1253 if (res != TEE_ERROR_NOT_SUPPORTED && in tee_rpmb_init()
1254 res != TEE_ERROR_NOT_IMPLEMENTED) in tee_rpmb_init()
1255 return res; in tee_rpmb_init()
1260 res = rpmb_probe_next(&dev_info); in tee_rpmb_init()
1261 if (res) { in tee_rpmb_init()
1262 DMSG("rpmb_probe_next error %#"PRIx32, res); in tee_rpmb_init()
1263 return res; in tee_rpmb_init()
1265 res = rpmb_set_dev_info(&dev_info); in tee_rpmb_init()
1266 if (res) { in tee_rpmb_init()
1271 res = tee_rpmb_key_gen(rpmb_ctx->key, RPMB_KEY_MAC_SIZE); in tee_rpmb_init()
1272 if (res) in tee_rpmb_init()
1273 return res; in tee_rpmb_init()
1275 res = tee_rpmb_init_read_wr_cnt(&rpmb_ctx->wr_cnt); in tee_rpmb_init()
1276 if (res) in tee_rpmb_init()
1307 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_read() local
1328 res = tee_rpmb_init(); in tee_rpmb_read()
1329 if (res != TEE_SUCCESS) in tee_rpmb_read()
1330 return res; in tee_rpmb_read()
1332 res = tee_rpmb_alloc(RPMB_DATA_FRAME_SIZE, in tee_rpmb_read()
1334 if (res != TEE_SUCCESS) in tee_rpmb_read()
1335 return res; in tee_rpmb_read()
1338 res = crypto_rng_read(nonce, RPMB_NONCE_SIZE); in tee_rpmb_read()
1339 if (res != TEE_SUCCESS) in tee_rpmb_read()
1340 return res; in tee_rpmb_read()
1346 res = tee_rpmb_req_pack(mem.req_hdr, mem.req_data, &rawdata, 1, NULL, in tee_rpmb_read()
1348 if (res != TEE_SUCCESS) in tee_rpmb_read()
1349 return res; in tee_rpmb_read()
1357 res = tee_rpmb_invoke(&mem); in tee_rpmb_read()
1358 if (res != TEE_SUCCESS) in tee_rpmb_read()
1359 return res; in tee_rpmb_read()
1383 TEE_Result res = TEE_SUCCESS; in write_req() local
1404 res = tee_rpmb_req_pack(mem->req_hdr, mem->req_data, &rawdata, in write_req()
1406 if (res) { in write_req()
1414 return res; in write_req()
1424 res = tee_rpmb_invoke(mem); in write_req()
1425 if (res != TEE_SUCCESS) { in write_req()
1445 res = tee_rpmb_resp_unpack_verify(mem->resp_data, &rawdata, 1, in write_req()
1447 if (res != TEE_SUCCESS) { in write_req()
1478 TEE_Result res; in tee_rpmb_write_blk() local
1492 res = tee_rpmb_init(); in tee_rpmb_write_blk()
1493 if (res != TEE_SUCCESS) in tee_rpmb_write_blk()
1494 return res; in tee_rpmb_write_blk()
1501 res = tee_rpmb_alloc(req_size, RPMB_DATA_FRAME_SIZE, &mem); in tee_rpmb_write_blk()
1502 if (res != TEE_SUCCESS) in tee_rpmb_write_blk()
1503 return res; in tee_rpmb_write_blk()
1522 res = write_req(tmp_blk_idx, data_blks + offs, in tee_rpmb_write_blk()
1524 if (res) in tee_rpmb_write_blk()
1525 return res; in tee_rpmb_write_blk()
1554 TEE_Result res = TEE_ERROR_GENERIC; in tee_rpmb_write() local
1566 res = tee_rpmb_write_blk(blk_idx, data, blkcnt, fek, uuid); in tee_rpmb_write()
1567 if (res != TEE_SUCCESS) in tee_rpmb_write()
1572 res = TEE_ERROR_OUT_OF_MEMORY; in tee_rpmb_write()
1577 res = tee_rpmb_read(blk_idx * RPMB_DATA_SIZE, data_tmp, in tee_rpmb_write()
1579 if (res != TEE_SUCCESS) in tee_rpmb_write()
1585 res = tee_rpmb_write_blk(blk_idx, data_tmp, blkcnt, fek, uuid); in tee_rpmb_write()
1586 if (res != TEE_SUCCESS) in tee_rpmb_write()
1590 res = TEE_SUCCESS; in tee_rpmb_write()
1594 return res; in tee_rpmb_write()
1604 TEE_Result res = TEE_SUCCESS; in tee_rpmb_get_max_block() local
1613 res = tee_rpmb_init(); in tee_rpmb_get_max_block()
1614 if (res != TEE_SUCCESS) in tee_rpmb_get_max_block()
1621 return res; in tee_rpmb_get_max_block()
1651 TEE_Result res = TEE_ERROR_GENERIC; in fat_entry_dir_init() local
1659 res = rpmb_fs_setup(); in fat_entry_dir_init()
1660 if (res) in fat_entry_dir_init()
1661 return res; in fat_entry_dir_init()
1663 res = get_fat_start_address(&fat_address); in fat_entry_dir_init()
1664 if (res) in fat_entry_dir_init()
1665 return res; in fat_entry_dir_init()
1687 res = TEE_ERROR_OUT_OF_MEMORY; in fat_entry_dir_init()
1691 res = tee_rpmb_read(fat_address, (uint8_t *)fe, in fat_entry_dir_init()
1693 if (res) in fat_entry_dir_init()
1708 return res; in fat_entry_dir_init()
1802 TEE_Result res = TEE_ERROR_GENERIC; in fat_entry_dir_get_next() local
1836 res = tee_rpmb_read(fat_address_local, (uint8_t *)fe, in fat_entry_dir_get_next()
1839 if (res) in fat_entry_dir_get_next()
1840 return res; in fat_entry_dir_get_next()
1871 res = tee_rpmb_read(fat_address_local, in fat_entry_dir_get_next()
1876 if (res) in fat_entry_dir_get_next()
1877 return res; in fat_entry_dir_get_next()
1895 res = tee_rpmb_read(fat_address_local, in fat_entry_dir_get_next()
1900 if (res) in fat_entry_dir_get_next()
1901 return res; in fat_entry_dir_get_next()
1927 TEE_Result res = TEE_ERROR_SECURITY; in dump_fat() local
1937 res = fat_entry_dir_get_next(&fe, NULL); in dump_fat()
1938 if (res || !fe) in dump_fat()
2034 TEE_Result res = TEE_ERROR_GENERIC; in write_fat_entry() local
2038 res = TEE_ERROR_ACCESS_CONFLICT; in write_fat_entry()
2043 res = TEE_ERROR_BAD_PARAMETERS; in write_fat_entry()
2047 res = tee_rpmb_write(fh->rpmb_fat_address, (uint8_t *)&fh->fat_entry, in write_fat_entry()
2053 if (CFG_RPMB_FS_CACHE_ENTRIES && !res) in write_fat_entry()
2054 res = fat_entry_dir_update(&fh->fat_entry, in write_fat_entry()
2058 return res; in write_fat_entry()
2068 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_fs_setup() local
2074 res = TEE_SUCCESS; in rpmb_fs_setup()
2078 res = tee_rpmb_get_max_block(&max_rpmb_block); in rpmb_fs_setup()
2079 if (res != TEE_SUCCESS) in rpmb_fs_setup()
2090 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_setup()
2094 res = tee_rpmb_read(RPMB_STORAGE_START_ADDRESS, in rpmb_fs_setup()
2097 if (res != TEE_SUCCESS) in rpmb_fs_setup()
2104 res = tee_rpmb_write(RPMB_STORAGE_START_ADDRESS, in rpmb_fs_setup()
2107 if (res != TEE_SUCCESS) in rpmb_fs_setup()
2115 res = tee_rpmb_read(RPMB_STORAGE_START_ADDRESS, in rpmb_fs_setup()
2118 if (res != TEE_SUCCESS) in rpmb_fs_setup()
2124 res = TEE_SUCCESS; in rpmb_fs_setup()
2128 res = TEE_ERROR_ACCESS_DENIED; in rpmb_fs_setup()
2144 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_setup()
2151 res = write_fat_entry(fh); in rpmb_fs_setup()
2152 if (res != TEE_SUCCESS) in rpmb_fs_setup()
2155 res = tee_rpmb_write(RPMB_STORAGE_START_ADDRESS, in rpmb_fs_setup()
2166 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_setup()
2178 return res; in rpmb_fs_setup()
2203 TEE_Result res = TEE_ERROR_GENERIC; in read_fat() local
2213 res = fat_entry_dir_init(); in read_fat()
2214 if (res) in read_fat()
2224 res = fat_entry_dir_get_next(&fe, &fat_address); in read_fat()
2225 if (res || !fe) in read_fat()
2248 res = TEE_ERROR_OUT_OF_MEMORY; in read_fat()
2278 if (res) in read_fat()
2296 res = TEE_ERROR_OUT_OF_MEMORY; in read_fat()
2309 res = write_fat_entry(&last_fh); in read_fat()
2310 if (res != TEE_SUCCESS) in read_fat()
2316 res = TEE_ERROR_ITEM_NOT_FOUND; in read_fat()
2320 return res; in read_fat()
2325 TEE_Result res; in generate_fek() local
2328 res = tee_fs_generate_fek(uuid, fe->fek, sizeof(fe->fek)); in generate_fek()
2329 if (res != TEE_SUCCESS) in generate_fek()
2330 return res; in generate_fek()
2335 return res; in generate_fek()
2344 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_fs_open_internal() local
2347 res = rpmb_fs_setup(); in rpmb_fs_open_internal()
2348 if (res != TEE_SUCCESS) in rpmb_fs_open_internal()
2362 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_open_internal()
2366 res = read_fat(fh, &p); in rpmb_fs_open_internal()
2368 if (res != TEE_SUCCESS) in rpmb_fs_open_internal()
2371 res = read_fat(fh, NULL); in rpmb_fs_open_internal()
2372 if (res != TEE_SUCCESS) in rpmb_fs_open_internal()
2389 res = generate_fek(&fh->fat_entry, uuid); in rpmb_fs_open_internal()
2390 if (res != TEE_SUCCESS) in rpmb_fs_open_internal()
2396 res = write_fat_entry(fh); in rpmb_fs_open_internal()
2397 if (res != TEE_SUCCESS) in rpmb_fs_open_internal()
2402 res = TEE_SUCCESS; in rpmb_fs_open_internal()
2405 return res; in rpmb_fs_open_internal()
2419 TEE_Result res; in rpmb_fs_read() local
2433 res = read_fat(fh, NULL); in rpmb_fs_read()
2434 if (res != TEE_SUCCESS) in rpmb_fs_read()
2445 res = tee_rpmb_read(fh->fat_entry.start_address + pos, in rpmb_fs_read()
2448 if (res != TEE_SUCCESS) in rpmb_fs_read()
2453 res = check_user_access(f, buf_user, size); in rpmb_fs_read()
2454 if (res) in rpmb_fs_read()
2457 res = tee_rpmb_read(fh->fat_entry.start_address + pos, in rpmb_fs_read()
2461 if (res) in rpmb_fs_read()
2469 return res; in rpmb_fs_read()
2484 TEE_Result res = TEE_SUCCESS; in update_write_helper() local
2502 res = tee_rpmb_read(old_fat + blk_offset, blk_buf, in update_write_helper()
2505 if (res != TEE_SUCCESS) in update_write_helper()
2531 res = tee_rpmb_write(new_fat + blk_offset, blk_buf, blk_size, in update_write_helper()
2533 if (res != TEE_SUCCESS) in update_write_helper()
2541 return res; in update_write_helper()
2548 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_fs_write_primitive() local
2559 res = TEE_ERROR_GENERIC; in rpmb_fs_write_primitive()
2573 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_write_primitive()
2577 res = read_fat(fh, &p); in rpmb_fs_write_primitive()
2578 if (res != TEE_SUCCESS) in rpmb_fs_write_primitive()
2585 res = TEE_ERROR_BAD_PARAMETERS; in rpmb_fs_write_primitive()
2589 res = TEE_ERROR_BAD_PARAMETERS; in rpmb_fs_write_primitive()
2597 res = tee_rpmb_write(start_addr, buf, in rpmb_fs_write_primitive()
2611 res = TEE_ERROR_STORAGE_NO_SPACE; in rpmb_fs_write_primitive()
2617 res = update_write_helper(fh, pos, buf, size, in rpmb_fs_write_primitive()
2619 if (res == TEE_SUCCESS) { in rpmb_fs_write_primitive()
2623 res = write_fat_entry(fh); in rpmb_fs_write_primitive()
2631 return res; in rpmb_fs_write_primitive()
2638 TEE_Result res = TEE_SUCCESS; in rpmb_fs_write() local
2648 res = rpmb_fs_write_primitive((struct rpmb_file_handle *)tfh, in rpmb_fs_write()
2653 res = check_user_access(f, buf_user, size); in rpmb_fs_write()
2654 if (res) in rpmb_fs_write()
2657 res = rpmb_fs_write_primitive((struct rpmb_file_handle *)tfh, in rpmb_fs_write()
2664 return res; in rpmb_fs_write()
2669 TEE_Result res; in rpmb_fs_remove_internal() local
2671 res = read_fat(fh, NULL); in rpmb_fs_remove_internal()
2672 if (res) in rpmb_fs_remove_internal()
2673 return res; in rpmb_fs_remove_internal()
2682 TEE_Result res; in rpmb_fs_remove() local
2690 res = rpmb_fs_remove_internal(fh); in rpmb_fs_remove()
2695 return res; in rpmb_fs_remove()
2702 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_fs_rename_internal() local
2707 res = TEE_ERROR_BAD_PARAMETERS; in rpmb_fs_rename_internal()
2716 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_rename_internal()
2725 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_rename_internal()
2729 res = read_fat(fh_old, NULL); in rpmb_fs_rename_internal()
2730 if (res != TEE_SUCCESS) in rpmb_fs_rename_internal()
2733 res = read_fat(fh_new, NULL); in rpmb_fs_rename_internal()
2734 if (res == TEE_SUCCESS) { in rpmb_fs_rename_internal()
2736 res = TEE_ERROR_ACCESS_CONFLICT; in rpmb_fs_rename_internal()
2742 res = write_fat_entry(fh_new); in rpmb_fs_rename_internal()
2743 if (res != TEE_SUCCESS) in rpmb_fs_rename_internal()
2751 res = write_fat_entry(fh_old); in rpmb_fs_rename_internal()
2757 return res; in rpmb_fs_rename_internal()
2763 TEE_Result res; in rpmb_fs_rename() local
2766 res = rpmb_fs_rename_internal(old, new, overwrite); in rpmb_fs_rename()
2769 return res; in rpmb_fs_rename()
2781 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_fs_truncate() local
2787 res = TEE_ERROR_BAD_PARAMETERS; in rpmb_fs_truncate()
2792 res = read_fat(fh, NULL); in rpmb_fs_truncate()
2793 if (res != TEE_SUCCESS) in rpmb_fs_truncate()
2806 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_truncate()
2809 res = read_fat(fh, &p); in rpmb_fs_truncate()
2810 if (res != TEE_SUCCESS) in rpmb_fs_truncate()
2816 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_truncate()
2821 res = tee_rpmb_read(fh->fat_entry.start_address, in rpmb_fs_truncate()
2824 if (res != TEE_SUCCESS) in rpmb_fs_truncate()
2829 res = tee_rpmb_write(newaddr, newbuf, in rpmb_fs_truncate()
2831 if (res != TEE_SUCCESS) in rpmb_fs_truncate()
2842 res = write_fat_entry(fh); in rpmb_fs_truncate()
2851 return res; in rpmb_fs_truncate()
2880 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_fs_dir_populate() local
2885 res = fat_entry_dir_init(); in rpmb_fs_dir_populate()
2886 if (res) in rpmb_fs_dir_populate()
2892 res = fat_entry_dir_get_next(&fe, &fat_address); in rpmb_fs_dir_populate()
2893 if (res || !fe) in rpmb_fs_dir_populate()
2912 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_dir_populate()
2933 if (res) in rpmb_fs_dir_populate()
2937 res = TEE_SUCCESS; in rpmb_fs_dir_populate()
2939 res = TEE_ERROR_ITEM_NOT_FOUND; /* No directories were found. */ in rpmb_fs_dir_populate()
2944 if (res) in rpmb_fs_dir_populate()
2947 return res; in rpmb_fs_dir_populate()
2954 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_fs_opendir() local
2958 res = TEE_ERROR_BAD_PARAMETERS; in rpmb_fs_opendir()
2964 res = TEE_ERROR_BAD_PARAMETERS; in rpmb_fs_opendir()
2975 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_fs_opendir()
2980 res = rpmb_fs_dir_populate(path_local, rpmb_dir); in rpmb_fs_opendir()
2981 if (res != TEE_SUCCESS) { in rpmb_fs_opendir()
2990 return res; in rpmb_fs_opendir()
3022 TEE_Result res; in rpmb_fs_open() local
3030 res = rpmb_fs_open_internal(fh, &po->uuid, false); in rpmb_fs_open()
3031 if (!res && size) in rpmb_fs_open()
3036 if (res) in rpmb_fs_open()
3041 return res; in rpmb_fs_open()
3051 TEE_Result res; in rpmb_fs_create() local
3062 res = rpmb_fs_open_internal(fh, &po->uuid, true); in rpmb_fs_create()
3063 if (res) in rpmb_fs_create()
3067 res = rpmb_fs_write_primitive(fh, pos, head, head_size); in rpmb_fs_create()
3068 if (res) in rpmb_fs_create()
3074 res = rpmb_fs_write_primitive(fh, pos, attr, attr_size); in rpmb_fs_create()
3075 if (res) in rpmb_fs_create()
3082 res = rpmb_fs_write_primitive(fh, pos, data_core, in rpmb_fs_create()
3084 if (res) in rpmb_fs_create()
3090 res = check_user_access(f, data_user, data_size); in rpmb_fs_create()
3091 if (res) in rpmb_fs_create()
3094 res = rpmb_fs_write_primitive(fh, pos, data_user, in rpmb_fs_create()
3097 if (res) in rpmb_fs_create()
3109 res = rpmb_fs_rename_internal(po, NULL, overwrite); in rpmb_fs_create()
3110 if (res) { in rpmb_fs_create()
3119 if (res) { in rpmb_fs_create()
3127 return res; in rpmb_fs_create()
3147 TEE_Result res; in tee_rpmb_fs_raw_open() local
3158 res = rpmb_fs_open_internal(fh, &uuid, create); in tee_rpmb_fs_raw_open()
3162 if (res) { in tee_rpmb_fs_raw_open()
3170 return res; in tee_rpmb_fs_raw_open()
3181 TEE_Result res = TEE_ERROR_GENERIC; in rpmb_mem_stats() local
3190 res = rpmb_fs_setup(); in rpmb_mem_stats()
3191 if (res) in rpmb_mem_stats()
3199 res = TEE_ERROR_OUT_OF_MEMORY; in rpmb_mem_stats()
3203 res = fat_entry_dir_init(); in rpmb_mem_stats()
3204 if (res) in rpmb_mem_stats()
3214 res = fat_entry_dir_get_next(&fe, NULL); in rpmb_mem_stats()
3215 if (res || !fe) in rpmb_mem_stats()
3223 res = TEE_ERROR_GENERIC; in rpmb_mem_stats()
3233 if (!res) in rpmb_mem_stats()
3238 return res; in rpmb_mem_stats()