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

Changeset ed903174 in mainline for uspace/srv/fs/fat/fat_fat.c

2010-02-10T23:51:23Z (12 years ago)
Martin Decky <martin@…>
lfn, master

implement support for 64bit file offsets

  • the libc API is a small deviation from standard, but we have no reason to keep a strict backward compatibility with ancient code so far
    • the basic signed 64bit offset type is called off64_t
      • lseek() and fseek() take off64_t arguments (since the argument represents a relative offset)
      • ftell() returns off64_t values (since it is a wrapper of lseek())
      • vfs_seek() implementation supports negative offsets when SEEK_CUR and SEEK_END is used
    • aoff64_t is used for internal unsigned representation of sizes (in bytes, blocks, etc.) and absolute offsets
      • mmap() and ftruncate() take aoff64_t arguments (since the full range of the absolute file offset should be used here)
      • struct stat stores the file size as aoff64_t
    • in both cases the explicit range of the types shown in the names is helpful for proper filesystem and IPC interaction
    • note: size_t should be used only for representing in-memory sizes and offsets, not device and file-related information, and vice versa
      • the code base still needs a thorough revision with respect to this rule
    • PRIdOFF64 and PRIuOFF64 can be used for printing the offsets
  • VFS_OUT_LOOKUP returns the 64bit file size in two IPC arguments
    • since all 5 IPC arguments have already been taken, the fs_handle is returned as the return value (fs_handle has only 16 bits, thus the return value can be used for both indicating errors as negative values and returning positive handles)
  • VFS_OUT_READ and VFS_OUT_WRITE use aoff64_t absolute offsets split into two IPC arguments

replace bn_t with aoff64_t as a generic 64bit bytes/block counter type

note: filesystem drivers need to be revised with respect to make sure that all out-of-range checks are correct (especially w.r.t. file and block offsets)

1 edited


  • uspace/srv/fs/fat/fat_fat.c

    rb32c604 red903174  
    9494        while (clst < FAT_CLST_LAST1 && clusters < max_clusters) {
    95                 bn_t fsec;      /* sector offset relative to FAT1 */
     95                aoff64_t fsec;  /* sector offset relative to FAT1 */
    9696                unsigned fidx;  /* FAT1 entry index */
    136136_fat_block_get(block_t **block, fat_bs_t *bs, dev_handle_t dev_handle,
    137     fat_cluster_t firstc, bn_t bn, int flags)
     137    fat_cluster_t firstc, aoff64_t bn, int flags)
    139139        unsigned bps;
    196196 * @return              EOK on success or a negative error code.
    197197 */
    198 int fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, off_t pos)
     198int fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, aoff64_t pos)
    200200        uint16_t bps;
    201201        unsigned spc;
    202202        block_t *b;
    203         off_t o, boundary;
     203        aoff64_t o, boundary;
    204204        int rc;
Note: See TracChangeset for help on using the changeset viewer.