Bug 402988 - SMBSlave::listDir() should use smbc_readdirplus() if available
Summary: SMBSlave::listDir() should use smbc_readdirplus() if available
Status: RESOLVED FIXED
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: Samba (show other bugs)
Version: 18.12.0
Platform: Other Linux
: NOR task
Target Milestone: ---
Assignee: Harald Sitter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-08 05:55 UTC by Andreas Schneider
Modified: 2020-03-16 12:26 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.04.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schneider 2019-01-08 05:55:02 UTC
SUMMARY

The slave is doing opendir/readdir/close to get the file name list.

At this point we're actually already fetching all required info to satisfy a stat via SMB2_FIND_ID_BOTH_DIRECTORY_INFO.

With the release of Samba 4.9 there is a new smbc_readdirplus() available. This will return all the stat information we already collected for the directory. This significantly will reduce roundtrips which slows down traversing the directories.
Comment 1 Andreas Schneider 2019-01-09 12:14:53 UTC
We need to implement smbc_readdirplus2() as we fscked up the API :-(
Comment 2 Harald Sitter 2020-02-11 14:09:26 UTC
That only applies to directory listing, right?
To list shares and printers and whatnot we'd still need the smbc_dirents from smbc_readdir.

Also this documentation seems a bit lackluster

```
	/**
	 * DOS attributes of file
	 */
	uint16_t attrs;
```

are they mode bits like SMBC_DOS_MODE_HIDDEN?
Comment 3 Andreas Schneider 2020-02-11 16:08:11 UTC
Yes, this is only for listing directory contents.

In the meantime we have smbc_readdirplus2() which addresses some bugs created with smbc_readdirplus().
Comment 4 Harald Sitter 2020-03-16 12:26:33 UTC
Git commit ec40cd6ef3f497637f4e7e31e3dc60c221e25f5c by Harald Sitter.
Committed on 16/03/2020 at 12:25.
Pushed by sitter into branch 'master'.

add readdirplus2 support for samba>=4.12

Summary:
unlike the dirent itering we do not need a separate stat call with this
new api by instead itering on what are effectively stat-like objects.

this simply runs before the regular itering which we still use to list
shares and workgroups. browse_stat_path has been split into stat and
udsentry-construction-from-stat so it can be used across both code
paths.

fun fact on the side: if there actually was a stat() api that returned
libsmb_file_info, we could use that as well and forget about the stats
structs in general :S
FIXED-IN: 20.04.0

Test Plan:
- build samba 4.12 rc
- list server
- list share
- list dir in share

- on 4.7
- all of the above

Reviewers: ngraham, asn

Reviewed By: ngraham

Subscribers: kde-frameworks-devel, kfm-devel

Tags: #dolphin, #frameworks

Differential Revision: https://phabricator.kde.org/D27520

# Conflicts:
#	smb/CMakeLists.txt
#	smb/kio_smb.h
#	smb/kio_smb_browse.cpp

M  +7    -0    smb/CMakeLists.txt
M  +1    -0    smb/config-smb.h.cmake
M  +1    -1    smb/kio_smb.h
M  +82   -53   smb/kio_smb_browse.cpp

https://commits.kde.org/kio-extras/ec40cd6ef3f497637f4e7e31e3dc60c221e25f5c