VFS Module Docs & Examples

Uri Simchoni uri at samba.org
Tue Jul 31 18:00:46 UTC 2018


On 07/31/2018 08:56 PM, Kory Draughn via samba-technical wrote:
> Uri - That is actually what I was doing.  I've added debug statements to
> the beginning of each function so that I could figure out the order of
> calls and implement each function one by one.  What also
> 
Seems like you're on the right track.

> How can I make the virtual path exported by the share be "/"?
> Is it just setting "path = /" under the [share_name] config?
> 
Yes.

> Looking at glusterfs.c, I noticed that not all functions are implemented.
> They're set to NULL instead.  If my module is not stackable, aren't I
> required to implement all functions?  Why would glusterfs.c not implement
> everything?
> 
I don't know, but everything it doesn't implement goes to vfs_default,
which is basically implemented by the kernel. Maybe glusterfs relies
somewhat on the kernel and is not 100% virtual.

> Thanks,
> Kory
> 
> 
> 
> On Tue, Jul 31, 2018 at 1:26 PM Uri Simchoni <uri at samba.org> wrote:
> 
>> On 07/31/2018 07:55 PM, Richard Sharpe via samba-technical wrote:
>>>
>>> Yes, it makes sense. If the files are not in a local file system then
>>> you have to implement every VFS function and provide the correct steps
>>> for your file system. In some cases you may need to return ENOSYS.
>>>
>>> As Jeremy says, look at the module for CEPH or GlusterFS.
>>>
>> I think I can sympathize with the confusion around path names, and I
>> don't think ceph or gluster help with that because the VFS module hands
>> the work to the ceph/gluster lib, and they magically do what smbd expects.
>>
>> You need to have some minimal support for absolute paths. IIRC:
>> 1. configure the path of the share with some made-up absolute path
>> /my/bogus/path
>> 2. Maintain a state variable of your current "cloud" working directory
>> 3. when asked to do a chdir:
>> a. If it's absolute, and the path is a child of /my/bogus/path, adjust
>> your cloud cwd accordingly (e.g. if it's "/my/bogus/path/foo" the you're
>> at "foo") You get /my/bogus/path with handle->conn->connectpath.
>> b. If it's relative, append the path to your your cloud cwd (if you're
>> at "foo" and chdir into "bar/baz" then you're at "foo/bar/baz")
>> c. otherwise you don't know how to handle it - return an error.
>> 4. Any path operation is relative to your cloud cwd (if asked to open
>> "bar" and the cloud cwd is "foo" then open "foo/bar")
>> 5. When asked what's the current directory, append the cloud wd to
>> /my/bogus/path.
>>
>> I think that about covers it, plus all the other advice you were give
>> about implementing everything.
>>
>> Oh, I now see Jeremy has already answered with a somewhat different
>> answer - I suppose my algorithm above can be simplified with setting the
>> share path to / and then if the path is absolute just remove the leading /.
>>
>> Thanks,
>> Uri.
>>




More information about the samba-technical mailing list