github.com/creachadair/ffs@v0.17.3/file/wiretype/wiretype.proto (about)

     1  // Copyright 2021 Michael J. Fromberger. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // This schema defines the encoding types for the ffs package.
    16  syntax = "proto3";
    17  
    18  package ffs.file;
    19  option go_package = "github.com/creachadair/ffs/file/wiretype";
    20  
    21  import "index/indexpb/index.proto";
    22  
    23  // An Object is the top-level wrapper for encoded objects.
    24  message Object {
    25    oneof value {
    26      Node node = 1;              // a structured file object
    27      Root root = 2;              // a root pointer
    28      ffs.index.Index index = 3;  // a blob index
    29    }
    30  
    31    // next id: 4
    32  
    33    // A version marker for the stored object.
    34    // Currently 0 is the only known value.
    35    uint64 version = 15;
    36  }
    37  
    38  // A Root records the location of a root node of a file tree.
    39  message Root {
    40    // The storage key of the root of the tree.
    41    // The blob contains an Object holding a Node message.
    42    // This field must be non-empty for a root to be valid.
    43    bytes file_key = 1;
    44  
    45    // A human-readable descriptive label for the root.
    46    string description = 2;
    47  
    48    // The storage key of a blob index for the root.
    49    // The blob contains a Object holding an ffs.index.Index message.
    50    bytes index_key = 4;
    51  
    52    // The storage key of a previous version of this root.  The file_key and
    53    // index_key of the chained root, if any, are considered reachable from this
    54    // root.
    55    bytes chain_key = 6;
    56  
    57    // next id: 7
    58  
    59    reserved 3;  // was: owner_key
    60    reserved 5;  // was: predecessor
    61  }
    62  
    63  // A Node is the top-level encoding of a file.
    64  message Node {
    65    Index index = 1;              // file contents
    66    Stat stat = 2;                // stat metadata (optional)
    67    repeated XAttr x_attrs = 3;   // extended attributes
    68    repeated Child children = 4;  // child file pointers
    69  
    70    // next id: 5
    71  }
    72  
    73  // Stat records POSIX style file metadata. Other than the modification time,
    74  // these metadata are not interpreted by the file plumbing, but are preserved
    75  // for the benefit of external tools.
    76  message Stat {
    77    // The low-order 12 bits of this field hold the standard Unix permissions,
    78    // along with the sticky, setuid, and setgid bits. The rest are reserved and
    79    // must be set to zero. In binary:
    80    //
    81    //             owner group other
    82    //  ... +-+-+-+-----+-----+-----+   S: setuid
    83    //      |S|G|T|r w x|r w x|r w x|   G: setgid
    84    //  ... +-+-+-+-----+-----+-----+   T: sticky
    85    //       B A 9     6     3     0  « bit
    86    //
    87    uint32 permissions = 1;
    88  
    89    FileType file_type = 2;
    90    Timestamp mod_time = 3;
    91    Ident owner = 4;
    92    Ident group = 5;
    93  
    94    // An Ident represents the identity of a user or group.
    95    message Ident {
    96      uint64 id = 1;    // numeric ID
    97      string name = 2;  // human-readable name
    98    }
    99  
   100    // A FileType abstracts the type of a file.
   101    enum FileType {
   102      REGULAR = 0;      // a regular file
   103      DIRECTORY = 1;    // a directory
   104      SYMLINK = 2;      // a symbolic link
   105      SOCKET = 3;       // a Unix-domain socket
   106      NAMED_PIPE = 4;   // a named pipe
   107      DEVICE = 5;       // a (block) device file
   108      CHAR_DEVICE = 6;  // a (character) device file
   109      UNKNOWN = 404;    // nothing is known about the type of this file
   110    }
   111    // next id: 6
   112  }
   113  
   114  // Time is the encoding of a timestamp, in seconds and nanoseconds elapsed
   115  // since the Unix epoch in UTC.
   116  message Timestamp {
   117    uint64 seconds = 1;
   118    uint32 nanos = 2;
   119  }
   120  
   121  // An Index records the size and storage locations of file data.
   122  message Index {
   123    uint64 total_bytes = 1;
   124  
   125    // File contents are split into blocks, which are in turn grouped into
   126    // contiguous extents. However, for the common case of small files that have
   127    // only one block, the index may instead store the key of that one block
   128    // without the overhead of extent metadata.
   129    //
   130    // At most one of these fields may be non-empty. We do not use a oneof here
   131    // because oneof does not allow repeated fields, and we don't want to spend
   132    // storage on a wrapper message.
   133  
   134    repeated Extent extents = 2;  // multiple blocks
   135    bytes single = 3;             // a single block
   136  
   137    // next id: 4
   138  }
   139  
   140  // An Extent describes a single contiguous span of stored data.
   141  message Extent {
   142    uint64 base = 1;   // the starting offset
   143    uint64 bytes = 2;  // the number of bytes in this extent
   144    repeated Block blocks = 3;
   145  
   146    // next id: 4
   147  }
   148  
   149  // A Block describes the size and storage key of a data blob.
   150  message Block {
   151    uint64 bytes = 1;  // the number of bytes in this block
   152    bytes key = 2;     // the storage key of the block data
   153  
   154    // next id: 3
   155  }
   156  
   157  // An XAttr records the name and value of an extended attribute.
   158  // The contents of the value are not interpreted.
   159  message XAttr {
   160    string name = 1;
   161    bytes value = 2;
   162  
   163    // next id: 3
   164  }
   165  
   166  // A Child records the name and storage key of a child Node.
   167  message Child {
   168    string name = 1;
   169    bytes key = 2;
   170  
   171    // next id: 3
   172  }