static int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj, u64 offset, void *p, unsigned length) { struct osd_request *or = osd_start_request(od, GFP_KERNEL); /* struct osd_sense_info osi = {.key = 0};*/ int ret; if (unlikely(!or)) { EXOFS_DBGMSG("%s: osd_start_request failed.\n", __func__); return -ENOMEM; } ret = osd_req_read_kern(or, obj, offset, p, length); if (unlikely(ret)) { EXOFS_DBGMSG("%s: osd_req_read_kern failed.\n", __func__); goto out; } ret = osd_finalize_request(or, 0, cred, NULL); if (unlikely(ret)) { EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", ret); goto out; } ret = osd_execute_request(or); if (unlikely(ret)) EXOFS_DBGMSG("osd_execute_request() => %d\n", ret); /* osd_req_decode_sense(or, ret); */ out: osd_end_request(or); EXOFS_DBGMSG2("read_kern(0x%llx) offset=0x%llx " "length=0x%llx dev=%p ret=>%d\n", _LLU(obj->id), _LLU(offset), _LLU(length), od, ret); return ret; }
static int _osd_print_system_info(struct osd_dev *od, void *caps) { struct osd_request *or; struct osd_attr get_attrs[] = { ATTR_DEF_RI(OSD_ATTR_RI_VENDOR_IDENTIFICATION, 8), ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_IDENTIFICATION, 16), ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_MODEL, 32), ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_REVISION_LEVEL, 4), ATTR_DEF_RI(OSD_ATTR_RI_PRODUCT_SERIAL_NUMBER, 64 /*variable*/), ATTR_DEF_RI(OSD_ATTR_RI_OSD_NAME, 64 /*variable*/), ATTR_DEF_RI(OSD_ATTR_RI_TOTAL_CAPACITY, 8), ATTR_DEF_RI(OSD_ATTR_RI_USED_CAPACITY, 8), ATTR_DEF_RI(OSD_ATTR_RI_NUMBER_OF_PARTITIONS, 8), ATTR_DEF_RI(OSD_ATTR_RI_CLOCK, 6), /* IBM-OSD-SIM Has a bug with this one put it last */ ATTR_DEF_RI(OSD_ATTR_RI_OSD_SYSTEM_ID, 20), }; void *iter = NULL, *pFirst; int nelem = ARRAY_SIZE(get_attrs), a = 0; int ret; or = osd_start_request(od, GFP_KERNEL); if (!or) return -ENOMEM; /* get attrs */ osd_req_get_attributes(or, &osd_root_object); osd_req_add_get_attr_list(or, get_attrs, ARRAY_SIZE(get_attrs)); ret = osd_finalize_request(or, 0, caps, NULL); if (ret) goto out; ret = osd_execute_request(or); if (ret) { OSD_ERR("Failed to detect %s => %d\n", _osd_ver_desc(or), ret); goto out; } osd_req_decode_get_attr_list(or, get_attrs, &nelem, &iter); OSD_INFO("Detected %s device\n", _osd_ver_desc(or)); pFirst = get_attrs[a++].val_ptr; OSD_INFO("VENDOR_IDENTIFICATION [%s]\n", (char *)pFirst); pFirst = get_attrs[a++].val_ptr; OSD_INFO("PRODUCT_IDENTIFICATION [%s]\n", (char *)pFirst); pFirst = get_attrs[a++].val_ptr; OSD_INFO("PRODUCT_MODEL [%s]\n", (char *)pFirst); pFirst = get_attrs[a++].val_ptr; OSD_INFO("PRODUCT_REVISION_LEVEL [%u]\n", pFirst ? get_unaligned_be32(pFirst) : ~0U); pFirst = get_attrs[a++].val_ptr; OSD_INFO("PRODUCT_SERIAL_NUMBER [%s]\n", (char *)pFirst); pFirst = get_attrs[a].val_ptr; OSD_INFO("OSD_NAME [%s]\n", (char *)pFirst); a++; pFirst = get_attrs[a++].val_ptr; OSD_INFO("TOTAL_CAPACITY [0x%llx]\n", pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL); pFirst = get_attrs[a++].val_ptr; OSD_INFO("USED_CAPACITY [0x%llx]\n", pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL); pFirst = get_attrs[a++].val_ptr; OSD_INFO("NUMBER_OF_PARTITIONS [%llu]\n", pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL); if (a >= nelem) goto out; /* FIXME: Where are the time utilities */ pFirst = get_attrs[a++].val_ptr; OSD_INFO("CLOCK [0x%02x%02x%02x%02x%02x%02x]\n", ((char *)pFirst)[0], ((char *)pFirst)[1], ((char *)pFirst)[2], ((char *)pFirst)[3], ((char *)pFirst)[4], ((char *)pFirst)[5]); if (a < nelem) { /* IBM-OSD-SIM bug, Might not have it */ unsigned len = get_attrs[a].len; char sid_dump[32*4 + 2]; /* 2nibbles+space+ASCII */ hex_dump_to_buffer(get_attrs[a].val_ptr, len, 32, 1, sid_dump, sizeof(sid_dump), true); OSD_INFO("OSD_SYSTEM_ID(%d)\n" " [%s]\n", len, sid_dump); a++; } out: osd_end_request(or); return ret; }