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

Changeset ed903174 in mainline for uspace/srv/vfs/vfs.h


Ignore:
Timestamp:
2010-02-10T23:51:23Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
e70edd1
Parents:
b32c604
Message:

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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    rb32c604 red903174  
    4242#include <ipc/vfs.h>
    4343
    44 // FIXME: according to CONFIG_DEBUG
    45 // #define dprintf(...)  printf(__VA_ARGS__)
    46 
    47 #define dprintf(...)
     44#ifndef dprintf
     45        #define dprintf(...)
     46#endif
    4847
    4948/**
     
    9392        vfs_triplet_t triplet;
    9493        vfs_node_type_t type;
    95         size_t size;
    96         unsigned lnkcnt;
     94        aoff64_t size;
     95        unsigned int lnkcnt;
    9796} vfs_lookup_res_t;
    9897
     
    117116        vfs_node_type_t type;   /**< Partial info about the node type. */
    118117
    119         size_t size;            /**< Cached size if the node is a file. */
     118        aoff64_t size;          /**< Cached size if the node is a file. */
    120119
    121120        /**
     
    141140        bool append;
    142141
    143         /** Current position in the file. */
    144         off_t pos;
     142        /** Current absolute position in the file. */
     143        aoff64_t pos;
    145144} vfs_file_t;
    146145
     
    214213extern void vfs_truncate(ipc_callid_t, ipc_call_t *);
    215214extern void vfs_fstat(ipc_callid_t, ipc_call_t *);
    216 extern void vfs_fstat(ipc_callid_t, ipc_call_t *);
    217215extern void vfs_stat(ipc_callid_t, ipc_call_t *);
    218216extern void vfs_mkdir(ipc_callid_t, ipc_call_t *);
Note: See TracChangeset for help on using the changeset viewer.