Changes in uspace/srv/bd/file_bd/file_bd.c [1ee00b7:08232ee] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/file_bd/file_bd.c
r1ee00b7 r08232ee 45 45 #include <async.h> 46 46 #include <as.h> 47 #include <fibril_sync .h>47 #include <fibril_synch.h> 48 48 #include <devmap.h> 49 49 #include <sys/types.h> … … 56 56 57 57 static const size_t block_size = 512; 58 static bn_t num_blocks; 58 59 static FILE *img; 59 60 … … 99 100 { 100 101 int rc; 102 long img_size; 101 103 102 104 rc = devmap_driver_register(NAME, file_bd_connection); … … 109 111 if (img == NULL) 110 112 return EINVAL; 113 114 if (fseek(img, 0, SEEK_END) != 0) { 115 fclose(img); 116 return EIO; 117 } 118 119 img_size = ftell(img); 120 if (img_size < 0) { 121 fclose(img); 122 return EIO; 123 } 124 125 num_blocks = img_size / block_size; 111 126 112 127 fibril_mutex_initialize(&dev_lock); … … 130 145 ipc_answer_0(iid, EOK); 131 146 132 if (! ipc_share_out_receive(&callid, &comm_size, &flags)) {147 if (!async_share_out_receive(&callid, &comm_size, &flags)) { 133 148 ipc_answer_0(callid, EHANGUP); 134 149 return; … … 141 156 } 142 157 143 (void) ipc_share_out_finalize(callid, fs_va);158 (void) async_share_out_finalize(callid, fs_va); 144 159 145 160 while (1) { … … 174 189 ipc_answer_1(callid, EOK, block_size); 175 190 continue; 191 case BD_GET_NUM_BLOCKS: 192 ipc_answer_2(callid, EOK, LOWER32(num_blocks), 193 UPPER32(num_blocks)); 194 continue; 176 195 default: 177 196 retval = EINVAL; … … 213 232 214 233 fseek(img, ba * block_size, SEEK_SET); 215 n_wr = f read(buf, block_size, cnt, img);234 n_wr = fwrite(buf, block_size, cnt, img); 216 235 217 236 if (ferror(img) || n_wr < cnt) {
Note:
See TracChangeset
for help on using the changeset viewer.