Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ccce242 in mainline


Ignore:
Timestamp:
2010-01-10T14:01:25Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
0ff9e67
Parents:
1ac3a52 (diff), 6c01702 (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.
Message:

Merge file_bd fixes.

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/io/io.c

    r1ac3a52 rccce242  
    595595}
    596596
     597void clearerr(FILE *stream)
     598{
     599        stream->eof = false;
     600        stream->error = false;
     601}
     602
    597603int fphone(FILE *stream)
    598604{
  • uspace/srv/bd/file_bd/file_bd.c

    r1ac3a52 rccce242  
    205205{
    206206        size_t n_rd;
     207        int rc;
    207208
    208209        fibril_mutex_lock(&dev_lock);
    209210
    210         fseek(img, ba * block_size, SEEK_SET);
     211        clearerr(img);
     212        rc = fseek(img, ba * block_size, SEEK_SET);
     213        if (rc < 0) {
     214                fibril_mutex_unlock(&dev_lock);
     215                return EIO;
     216        }
     217
    211218        n_rd = fread(buf, block_size, cnt, img);
    212219
     
    228235{
    229236        size_t n_wr;
     237        int rc;
    230238
    231239        fibril_mutex_lock(&dev_lock);
    232240
    233         fseek(img, ba * block_size, SEEK_SET);
     241        clearerr(img);
     242        rc = fseek(img, ba * block_size, SEEK_SET);
     243        if (rc < 0) {
     244                fibril_mutex_unlock(&dev_lock);
     245                return EIO;
     246        }
     247
    234248        n_wr = fwrite(buf, block_size, cnt, img);
    235249
     
    237251                fibril_mutex_unlock(&dev_lock);
    238252                return EIO;     /* Write error */
     253        }
     254
     255        if (fflush(img) != 0) {
     256                fibril_mutex_unlock(&dev_lock);
     257                return EIO;
    239258        }
    240259
Note: See TracChangeset for help on using the changeset viewer.