Writing a Samba VFS in Samba 3.6 and earlier
- 1 Introduction
- 2 The Samba VFS
- 3 Two Types of File Systems
- 4 Writing a VFS Module
- 4.1 VFS Module Initialization
- 4.2 VFS Function Pointer Structure
- 4.3 Include Files
- 4.4 VFS Functions
- 4.5 The Life Cycle of a VFS
- 4.6 Memory Management and talloc
- 4.7 Providing Context between Calls
- 4.8 Module Specific Parameters
- 4.9 Extending the Samba files_struct structure
- 4.10 AIO Handling in a VFS Module
- 4.11 Conforming to the VFS Interfaces
- 4.12 Be prepared for "stat" opens
- 4.13 Things to watch out for
- 5 Samba Version VFS Differences
- 6 Some Existing VFS Modules
- 7 Building, Installing and Debugging your VFS Module
- 8 Adding New VFS Routines
This document is intended to help people who want to write Samba VFS modules. It is a Wiki-based version of an earlier document written by Richard Sharpe that can be found at Writing a Samba VFS.
The rest of this document is organized into a number of sections that:
- Provides and outline of the Samba VFS and discuss the interactions between the main Samba code, the VFS Layer, VFS modules and the underlying OS.
- Discusses two different types of file systems that module writers might want to write a VFS module for.
- Provides more detail on actually writing a Samba VFS and some of the functions and macros Samba makes available to help you.
- Lists differences in the VFS for different versions of Samba.
- Introduces some existing VFS modules, especially in the context of the two file system types outlined above.
- Gives details on the steps module writes will have to take to add their code and build their module.
- Provides some information on adding additional VFS routines over and above those already provided.
The Samba VFS
The Samba VFS provides a mechanism to allow people to extend the functionality of Samba in useful ways. Some examples are:
- Convert NTFS ACLs to NFSv4 ACLs for storing in a file system that supports them. The GPFS VFS module does this and the same could be done for Linux when RichACL support is complete.
- Support features that a vendor has implemented in their file system that Linux file systems do not support. The OneFS VFS module from Isilon interfaces with their in-kernel distributed file system which provides more complete NTFS functionality, including four file times, etc.
- Implement features like Alternate Data Streams.
- Implement full NT ACL support by storing them in XATTRs and correctly handling the semantics (see source3/modules/vfs_acl_xattr.c and source3/modules/vfs_acl_common.c.)
- Support user-space file systems, perhaps accessible via a shared memory interface or via a user-space library (eg, Ceph's libceph.)
Two Types of File Systems
Writing a VFS Module
VFS Module Initialization
VFS Function Pointer Structure
The Life Cycle of a VFS
Memory Management and talloc
Providing Context between Calls
Module Specific Parameters
Extending the Samba files_struct structure
AIO Handling in a VFS Module
Conforming to the VFS Interfaces
Be prepared for "stat" opens
Things to watch out for
Samba Version VFS Differences
Some Existing VFS Modules
Building, Installing and Debugging your VFS Module