Changeset 1c6c3e1d in mainline for uspace/srv/bd/file_bd/file_bd.c
- Timestamp:
- 2023-10-22T17:55:33Z (21 months ago)
- Branches:
- ticket/834-toolchain-update
- Children:
- 350ec74
- Parents:
- 315d487 (diff), 133461c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/file_bd/file_bd.c
r315d487 r1c6c3e1d 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 61 61 static aoff64_t num_blocks; 62 62 static FILE *img; 63 static loc_srv_t *srv; 63 64 64 65 static service_id_t service_id; … … 137 138 return -1; 138 139 139 rc = loc_service_register( device_name, &service_id);140 rc = loc_service_register(srv, device_name, &service_id); 140 141 if (rc != EOK) { 141 142 printf("%s: Unable to register device '%s': %s.\n", … … 150 151 } 151 152 152 rc = loc_service_add_to_cat(s ervice_id, disk_cat);153 rc = loc_service_add_to_cat(srv, service_id, disk_cat); 153 154 if (rc != EOK) { 154 155 printf("%s: Failed adding %s to category: %s", … … 176 177 177 178 async_set_fallback_port_handler(file_bd_connection, NULL); 178 errno_t rc = loc_server_register(NAME );179 errno_t rc = loc_server_register(NAME, &srv); 179 180 if (rc != EOK) { 180 181 printf("%s: Unable to register driver.\n", NAME); … … 183 184 184 185 img = fopen(fname, "rb+"); 185 if (img == NULL) 186 return EINVAL; 186 if (img == NULL) { 187 rc = EINVAL; 188 goto error; 189 } 187 190 188 191 if (fseek(img, 0, SEEK_END) != 0) { 189 fclose(img);190 return EIO;192 rc = EIO; 193 goto error; 191 194 } 192 195 193 196 off64_t img_size = ftell(img); 194 197 if (img_size < 0) { 198 rc = EIO; 199 goto error; 200 } 201 202 num_blocks = img_size / block_size; 203 204 fibril_mutex_initialize(&dev_lock); 205 206 return EOK; 207 error: 208 if (img != NULL) { 195 209 fclose(img); 196 return EIO; 197 } 198 199 num_blocks = img_size / block_size; 200 201 fibril_mutex_initialize(&dev_lock); 202 203 return EOK; 210 img = NULL; 211 } 212 213 if (srv != NULL) { 214 loc_server_unregister(srv); 215 srv = NULL; 216 } 217 218 return rc; 204 219 } 205 220
Note:
See TracChangeset
for help on using the changeset viewer.