Changes in uspace/srv/bd/file_bd/file_bd.c [08232ee:1e4cada] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/file_bd/file_bd.c
r08232ee r1e4cada 56 56 57 57 static const size_t block_size = 512; 58 static bn_t num_blocks;59 58 static FILE *img; 60 59 … … 100 99 { 101 100 int rc; 102 long img_size;103 101 104 102 rc = devmap_driver_register(NAME, file_bd_connection); … … 111 109 if (img == NULL) 112 110 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;126 111 127 112 fibril_mutex_initialize(&dev_lock); … … 189 174 ipc_answer_1(callid, EOK, block_size); 190 175 continue; 191 case BD_GET_NUM_BLOCKS:192 ipc_answer_2(callid, EOK, LOWER32(num_blocks),193 UPPER32(num_blocks));194 continue;195 176 default: 196 177 retval = EINVAL; … … 232 213 233 214 fseek(img, ba * block_size, SEEK_SET); 234 n_wr = f write(buf, block_size, cnt, img);215 n_wr = fread(buf, block_size, cnt, img); 235 216 236 217 if (ferror(img) || n_wr < cnt) {
Note:
See TracChangeset
for help on using the changeset viewer.