Merge pull request #45563 from samikama:Configurable_FS_1

PiperOrigin-RevId: 354095230
Change-Id: Ifa224951194c12b282b3162052ae88b6b569f267
This commit is contained in:
TensorFlower Gardener 2021-01-27 08:21:28 -08:00
commit 8e2b87c9a2

View File

@ -83,6 +83,26 @@ typedef struct TF_TransactionToken {
TF_Filesystem* owner;
} TF_TransactionToken;
typedef struct TF_Filesystem_Option_Value {
int type_tag;
int num_values;
union {
int64_t inv_val;
double real_val;
struct {
char* buf;
int buf_length;
} buffer_val;
} * values; // owned
} TF_Filesystem_Option_Value;
typedef struct TF_Filesystem_Option {
char* name; // null terminated, owned
char* description; // null terminated, owned
int per_file; // bool actually, but bool is not a C type
TF_Filesystem_Option_Value* value; // owned
} TF_Filesystem_Option;
/// SECTION 2. Function tables for functionality provided by plugins
/// ----------------------------------------------------------------------------
///
@ -811,6 +831,85 @@ typedef struct TF_FilesystemOps {
char* (*decode_transaction_token)(const TF_Filesystem* filesystem,
const TF_TransactionToken* token);
/// Returns pointer to an array of available configuration options and their
/// current/default values in `options` and number of options in array in
/// `num_options`. Ownership of the array is transferred to caller and the
/// caller is responsible of freeing the buffers using respective file systems
/// allocation API.
///
/// Plugins:
/// * Must set `status` to `TF_OK` if `options` and `num_options` set.
/// If there is no configurable option, `num_options` should be 0.
/// * Might use any other error value for `status` to signal other errors.
///
/// DEFAULT IMPLEMENTATION: return 0 options and `TF_OK`.
void (*get_filesystem_configuration)(const TF_Filesystem* filesystem,
TF_Filesystem_Option** options,
int* num_options, TF_Status* status);
/// Updates filesystem configuration with options passed in `options`. It can
/// contain full set of options supported by the filesystem or just a subset
/// of them. Ownership of options and buffers therein belongs to the caller
/// and any buffers need to be allocated through filesystem allocation API.
/// Filesystems may choose to ignore configuration errors but should at least
/// display a warning or error message to warn the users.
///
/// Plugins:
/// * Must set `status` to `TF_OK` if options are updated.
/// * Might use any other error value for `status` to signal other errors.
///
/// DEFAULT IMPLEMENTATION: return `TF_NOT_FOUND`.
void (*set_filesystem_configuration)(const TF_Filesystem* filesystem,
const TF_Filesystem_Option** options,
int num_options, TF_Status* status);
/// Returns the value of the filesystem option given in `key` in `option`.
/// Valid values of the `key` are returned by
/// `get_file_system_configuration_keys` call. Ownership of the
/// `option` is transferred to caller. Buffers therein should be allocated and
/// freed by the relevant filesystems allocation API.
///
/// Plugins:
/// * Must set `status` to `TF_OK` if `option` is set
/// * Must set `status` to `TF_NOT_FOUND` if the key is invalid
/// * Might use any other error value for `status` to signal other errors.
///
/// DEFAULT IMPLEMENTATION: return `TF_NOT_FOUND`.
void (*get_filesystem_configuration_option)(const TF_Filesystem* filesystem,
const char* key,
TF_Filesystem_Option** option,
TF_Status* status);
/// Sets the value of the filesystem option given in `key` to value in
/// `option`. Valid values of the `key` are returned by
/// `get_file_system_configuration_keys` call. Ownership of the `option` and
/// the `key` belogs to the caller. Buffers therein should be allocated and
/// freed by the filesystems allocation API.
///
/// Plugins:
/// * Must set `status` to `TF_OK` if `option` is set/updated
/// * Must set `status` to `TF_NOT_FOUND` if the key is invalid
/// * Might use any other error value for `status` to signal other errors.
///
/// DEFAULT IMPLEMENTATION: return `TF_NOT_FOUND`.
void (*set_filesystem_configuration_option)(
const TF_Filesystem* filesystem, const TF_Filesystem_Option* option,
TF_Status* status);
/// Returns a list of valid configuration keys in `keys` array and number of
/// keys in `num_keys`. Ownership of the buffers in `keys` are transferred to
/// caller and needs to be freed using relevant filesystem allocation API.
///
/// Plugins:
/// * Must set `status` to `TF_OK` on success. If there are no configurable
/// keys, `num_keys` should be set to 0
/// * Might use any other error value for `status` to signal other errors.
///
/// DEFAULT IMPLEMENTATION: return `TF_OK` and `num_keys`=0.
void (*get_filesystem_configuration_keys)(const TF_Filesystem* filesystem,
char** keys, int* num_keys,
TF_Status* status);
} TF_FilesystemOps;
// LINT.ThenChange(:filesystem_ops_version)