sahlberg / libsmb2

SMB2/3 userspace client
Other
322 stars 137 forks source link

smb2_read with offset for random access #347

Closed memecode closed 3 months ago

memecode commented 3 months ago

Currently my fuse wrapper has to do a smb2_lseek and THEN smb2_read because the fuse read api has an offset parameter. Would it be possible for smb2_read have an offset parameter so that only 1 round trip to the server per read needs to happen? Or maybe smb2_read2 / smb2_read_ex? Could be a separate name for backwards compatibility.

FYI the function I have to implement on the fuse side has this form: int (*read)(const char *path, char *buf, size_t size, fuse_off_t off, struct fuse_file_info *fi);

sahlberg commented 3 months ago

libsmb2 tries to mimic the posix api (as far as possible)

If you need a read function that takes an offset you want pread() Have a look at smb2_pread[_async] Is this what you want?

(I think fuse folks misnamed this function in their api, they should have called it pread)

memecode commented 3 months ago

Yeah I think smb2_pread_async should be ok... thanks... I'll close this.

sahlberg commented 3 months ago

Oh, you have a fuse wrapper. Very nice. I was thinking about creating one line fuse-nfs but this means I don't have to :-)

Had a quick look and the only thing I noted was that you pass the password as part of the URL. I personally wouldn't do that because it will show up in "ps" output and will inevitable end up in a plain-text log somewhere because that always happens :-(

Libsmb2 allows you to store the username->password mapping in a file NTLM_USER_FILE and it will read that file to get the password that is to be used for the username specified. Have a look at that. Just a suggestion.

memecode commented 3 months ago

Yeah the whole thing is quite new and those sorts of issues still need to be worked out. It's also only read only at this point. So it's not for everyone. I'm trying to get the performance up to a point where it's actually useful. I also have a GUI for share discovery creating mount points. Also very "alpha".

memecode commented 3 months ago

Ok so with smb2_pread_async I was able to saturate my 2.5G Ethernet connection, 280mb/s. So I think that's good enough for me.

sahlberg commented 3 months ago

Very Nice!

Also, you might want to reach out to these guys if you want some more users to use and test it: https://github.com/LightningMods/Itemzflow

They use libnfs and fuse-nfs right now. They would probably very much like to have a fuse-smb2 thing to put on their jailbroken ps4 boxens.