Changes between Version 17 and Version 18 of Developer/FileSystems


Ignore:
Timestamp:
10/15/08 04:40:58 (14 years ago)
Author:
ChrisJohns
Comment:

Add code to sync the cache.

Legend:

Unmodified
Added
Removed
Modified
  • Developer/FileSystems

    v17 v18  
    140140The cache has a swap out task that collects blocks who's hold timer has expired for a specific device and writes them to disk device. Each modified block as an individual timer and the cache can be configured by the driver to only write consecutive blocks helping drivers that support the multi-sector write operations.
    141141
    142 The cache can be synchronized at the request of a user giving an application full control over the  data written to the disk media.
     142The cache can be synchronized at the request of a user giving an application full control over the data written to the disk media. If you do not synchronize the data with the disk media before your applications terminates data could be lost or the file system could become corrupted. To synchronize the cache for a specific disk use the following code:
     143
     144  int fd = open (driver, O_WRONLY, 0);
     145  if (fd < 0) {
     146    fprintf( stderr, "%s: driver open failed: %s\n", argv[0], strerror (errno));
     147    return 1;
     148  }
     149 
     150  if (ioctl (fd, RTEMS_BLKIO_SYNCDEV) < 0) {
     151    fprintf( stderr, "%s: driver sync failed: %s\n", argv[0], strerror (errno));
     152    return 1;
     153  }
     154 
     155  close (fd);
     156  return 0;
    143157= Device Only File System =
    144158