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

Changeset 6c01702 in mainline


Ignore:
Timestamp:
2010-01-10T13:58:07Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
383ddd6, ccce242
Parents:
c77a64f
Message:

Flush stream when writing blocks in file_bd. Also check fseek() return values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/file_bd/file_bd.c

    rc77a64f r6c01702  
    205205{
    206206        size_t n_rd;
     207        int rc;
    207208
    208209        fibril_mutex_lock(&dev_lock);
    209210
    210211        clearerr(img);
    211         fseek(img, ba * block_size, SEEK_SET);
     212        rc = fseek(img, ba * block_size, SEEK_SET);
     213        if (rc < 0) {
     214                fibril_mutex_unlock(&dev_lock);
     215                return EIO;
     216        }
     217
    212218        n_rd = fread(buf, block_size, cnt, img);
    213219
     
    229235{
    230236        size_t n_wr;
     237        int rc;
    231238
    232239        fibril_mutex_lock(&dev_lock);
    233240
    234241        clearerr(img);
    235         fseek(img, ba * block_size, SEEK_SET);
     242        rc = fseek(img, ba * block_size, SEEK_SET);
     243        if (rc < 0) {
     244                fibril_mutex_unlock(&dev_lock);
     245                return EIO;
     246        }
     247
    236248        n_wr = fwrite(buf, block_size, cnt, img);
    237249
     
    239251                fibril_mutex_unlock(&dev_lock);
    240252                return EIO;     /* Write error */
     253        }
     254
     255        if (fflush(img) != 0) {
     256                fibril_mutex_unlock(&dev_lock);
     257                return EIO;
    241258        }
    242259
Note: See TracChangeset for help on using the changeset viewer.