File Size Reservation Method?

Today, if you wanted to upload a file over the uavcan.file.* protocols, you can do the follow order or operations:

1.) Using uavcan.file.Modify to configure as a “Touch” to create the file & parent directories. If the server is running out of resources it can be determined early here.
2.) uavcan.file.Write repeat file_size/block_size times until the file is uploaded, then send the “EOF” call)

A failure could occur very far into the upload where the File System (or an emulation of one) could run out of space.

The “EOF” call of the uavcan.file.Write message is documented as being sent at the end of the file to notate that all the data has been sent and to truncate any other existing data (if a resize is needed).

Is the intent to also use the EOF style to “reserve” the file space as well?

Sequence:

  1. uavcan.file.Modify (as “Touch”)
  2. uavcan.file.Write (as “EOF” w/ intended size)
    a. does it fill the file with undefined bytes? or
    b. Does it simply ask if there is enough room to support a file of that size? (it can respond with FILE_TOO_LARGE)
  3. uavcan.file.Write (file data transactions + another “EOF” to note the end transactions).
1 Like

Proposed specification change for the wording of uavcan.file.Write:

Write into a remote file.
The server shall place the contents of the field ‘data’ into the file pointed by ‘path’ at the offset specified by the field ‘offset’.

[new] Before writing the file, the sender may test to see if the receiving end can contain the intended size of the file by sending a request with the offset field set to the size of the file and the data field empty. The server can then inform the client if the file size would be possible at the time of the request. This would not necessarily be guaranteed in subsequent transactions but the server may pre-allocate that memory if the implementation could support that.

When writing a file, the client should repeatedly call this service with data while advancing the offset until the file is written completely. When the write sequence is completed, the client shall call the service one last time, with the offset set to the size of the file and with the data field empty, which will signal the server that the transfer is finished.

When the write operation is complete, the server shall truncate the resulting file past the specified offset.

1 Like