Changeset 095a989 in mainline
- Timestamp:
- 2024-09-05T22:34:53Z (8 months ago)
- Children:
- ee83e9c
- Parents:
- e192339
- git-author:
- Miroslav Cimerman <mc@…> (2024-09-05 22:31:28)
- git-committer:
- Miroslav Cimerman <mc@…> (2024-09-05 22:34:53)
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hrctl/hrctl.c
re192339 r095a989 231 231 return 0; 232 232 case 's': 233 printf("hrctl: status not implemented yet\n"); 234 return 1; 233 rc = hr_print_status(); 234 if (rc != EOK) 235 return 1; 236 return 0; 235 237 case 'a': 236 238 if (str_size(optarg) > 31) { -
uspace/lib/device/include/hr.h
re192339 r095a989 63 63 } hr_config_t; 64 64 65 typedef struct hr_vol_info { 66 service_id_t extents[HR_MAXDEVS]; 67 size_t extent_no; 68 service_id_t svc_id; 69 hr_level_t level; 70 uint64_t nblocks; 71 size_t bsize; 72 } hr_vol_info_t; 73 65 74 extern errno_t hr_sess_init(hr_t **); 66 75 extern void hr_sess_destroy(hr_t *); 67 76 68 77 extern errno_t hr_create(hr_t *, hr_config_t *); 78 extern errno_t hr_print_status(void); 69 79 70 80 #endif -
uspace/lib/device/include/ipc/hr.h
re192339 r095a989 39 39 40 40 typedef enum { 41 HR_CREATE = IPC_FIRST_USER_METHOD 41 HR_CREATE = IPC_FIRST_USER_METHOD, 42 HR_STATUS 42 43 } hr_request_t; 43 44 -
uspace/lib/device/src/hr.c
re192339 r095a989 114 114 } 115 115 116 static errno_t print_vol_info(size_t index, hr_vol_info_t *vol_info) 117 { 118 errno_t rc; 119 size_t i; 120 char *devname; 121 122 printf("--- vol %zu ---\n", index); 123 124 printf("svc_id: %lu\n", vol_info->svc_id); 125 126 rc = loc_service_get_name(vol_info->svc_id, &devname); 127 if (rc != EOK) 128 return rc; 129 printf("devname: %s\n", devname); 130 131 printf("level: %d\n", vol_info->level); 132 printf("nblocks: %lu\n", vol_info->nblocks); 133 printf("bsize: %zu\n", vol_info->bsize); 134 135 printf("extents: [index] [devname]\n"); 136 for (i = 0; i < vol_info->extent_no; i++) { 137 rc = loc_service_get_name(vol_info->extents[i], &devname); 138 if (rc != EOK) 139 return rc; 140 printf(" %zu %s\n", i, devname); 141 } 142 return EOK; 143 } 144 145 errno_t hr_print_status(void) 146 { 147 hr_t *hr; 148 errno_t rc, retval; 149 async_exch_t *exch; 150 aid_t req; 151 size_t size, i; 152 hr_vol_info_t *vols; 153 154 rc = hr_sess_init(&hr); 155 if (rc != EOK) 156 return rc; 157 158 exch = async_exchange_begin(hr->sess); 159 if (exch == NULL) 160 return EINVAL; 161 162 req = async_send_0(exch, HR_STATUS, NULL); 163 164 rc = async_data_read_start(exch, &size, sizeof(size_t)); 165 if (rc != EOK) { 166 async_exchange_end(exch); 167 async_forget(req); 168 return rc; 169 } 170 171 vols = calloc(size, sizeof(hr_vol_info_t)); 172 if (vols == NULL) { 173 async_exchange_end(exch); 174 async_forget(req); 175 return ENOMEM; 176 } 177 178 for (i = 0; i < size; i++) { 179 rc = async_data_read_start(exch, &vols[i], 180 sizeof(hr_vol_info_t)); 181 if (rc != EOK) { 182 async_exchange_end(exch); 183 async_forget(req); 184 goto error; 185 } 186 } 187 188 async_exchange_end(exch); 189 async_wait_for(req, &retval); 190 if (retval != EOK) { 191 rc = retval; 192 goto error; 193 } 194 195 for (i = 0; i < size; i++) { 196 rc = print_vol_info(i, &vols[i]); 197 if (rc != EOK) 198 goto error; 199 } 200 201 error: 202 if (vols != NULL) 203 free(vols); 204 return rc; 205 } 206 116 207 /** @} 117 208 */ -
uspace/srv/bd/hr/hr.c
re192339 r095a989 136 136 } 137 137 138 static void hr_print_status_srv(ipc_call_t *icall) 139 { 140 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_status_srv()"); 141 142 errno_t rc; 143 size_t vol_cnt = 0; 144 hr_vol_info_t info; 145 ipc_call_t call; 146 size_t size; 147 148 fibril_mutex_lock(&hr_volumes_lock); 149 150 vol_cnt = list_count(&hr_volumes); 151 152 if (!async_data_read_receive(&call, &size)) { 153 rc = EREFUSED; 154 goto error; 155 } 156 157 if (size != sizeof(size_t)) { 158 rc = EINVAL; 159 goto error; 160 } 161 162 rc = async_data_read_finalize(&call, &vol_cnt, size); 163 if (rc != EOK) 164 goto error; 165 166 list_foreach(hr_volumes, lvolumes, hr_volume_t, volume) { 167 memcpy(info.extents, volume->devs, 168 sizeof(service_id_t) * HR_MAXDEVS); 169 info.svc_id = volume->svc_id; 170 info.extent_no = volume->dev_no; 171 info.level = volume->level; 172 info.nblocks = volume->nblocks; 173 info.bsize = volume->bsize; 174 175 if (!async_data_read_receive(&call, &size)) { 176 rc = EREFUSED; 177 goto error; 178 } 179 180 if (size != sizeof(hr_vol_info_t)) { 181 rc = EINVAL; 182 goto error; 183 } 184 185 rc = async_data_read_finalize(&call, &info, size); 186 if (rc != EOK) 187 goto error; 188 } 189 190 fibril_mutex_unlock(&hr_volumes_lock); 191 async_answer_0(icall, EOK); 192 return; 193 error: 194 fibril_mutex_unlock(&hr_volumes_lock); 195 async_answer_0(&call, rc); 196 async_answer_0(icall, rc); 197 } 198 138 199 static void hr_ctl_conn(ipc_call_t *icall, void *arg) 139 200 { … … 155 216 case HR_CREATE: 156 217 hr_create_srv(&call); 218 break; 219 case HR_STATUS: 220 hr_print_status_srv(&call); 157 221 break; 158 222 default:
Note:
See TracChangeset
for help on using the changeset viewer.