2.7 KiB
2.7 KiB
How to add support for a new API version
- Update
_REFUSE_MAJOR_VERSION_
and/or_REFUSE_MINOR_VERSION_
infuse.h
. - If the new API introduces some new typedefs, enums, constants, functions, or struct fields, define them unconditionally. Trying to conditionalize them will only increase complexity of the implementation without necessity.
- If the new API removes some existing declarations, move them to
./refuse/legacy.[ch]
. There is no need to conditionally hide them. - If the new API doesn't change any of existing declarations, you are lucky. You are tremendously lucky. But if it does, things get interesting... (Spoiler: this happens all the time. All, the, time. As if there still weren't enough API-breaking changes in the history of FUSE API.)
If it breaks API compatibility by changing function prototypes or whatever
- Create a new header
./refuse/v${VERSION}.h
. Don't forget to add it in./refuse/Makefile.inc
and../../distrib/sets/lists/comp/mi
. - Include it from
./fuse.h
and add a new conditionalized section at the bottom of it. The whole point of the section is to choose correct symbols (or types, or whatever) and expose them without a version postfix.
If it changes struct fuse_operations
- Add
#define _FUSE_OP_VERSION__
for the new API version in the conditionalized section. - Define
struct fuse_operations_v${VERSION}
inv${VERSION}.h
. - Update
./refuse/fs.c
. This is the abstraction layer which absorbs all the subtle differences instruct fuse_operations
between versions. Every function has to be updated for the new version.
If it changes anything else that are already versioned
- Declare them in
./refuse/v${VERSION}.h
with a version postfix. - Update the conditionalized section for the version in
./fuse.h
so that it exposes the correct definition to user code. - Create
./refuse/v${VERSION}.c
and implement version-specific functions in it. Don't forget to add it to./refuse/Makefile.inc
.
If it changes something that have never been changed before
- Move them from the unconditionalized part of the implementation to
./refuse/v${VERSION}.[ch]
. - Add a version postfix to them.
- Update every single conditionalized section in
./fuse.h
so that they will be conditionally exposed without a version postfix depending the value ofFUSE_USE_VERSION
. If you cannot just#define
them but need to introduce some functions, inline functions are preferred over function macros because the latter lack types and are therefore error-prone. Preprocessor conditionals are already error-prone so don't make them worse.