Bug 12273 - copy file from samba to windows error
Summary: copy file from samba to windows error
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.5.0
Hardware: All Windows 10
: P2 regression (vote)
Target Milestone: 4.5
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
Depends on:
Reported: 2016-09-18 09:29 UTC by crashskyshadow
Modified: 2016-10-25 07:37 UTC (History)
4 users (show)

See Also:

possible fix (859 bytes, patch)
2016-10-07 06:07 UTC, Uri Simchoni
no flags Details
git-am fix for 4.5.next (1.62 KB, patch)
2016-10-08 04:14 UTC, Uri Simchoni
jra: review+

Note You need to log in before you can comment on or make changes to this bug.
Description crashskyshadow 2016-09-18 09:29:00 UTC
1、open multi channel support,map samba share to y:\
2、copy a file in samba to win10 C:\
3、get error y: not usable.
message in samba:

    sys_path_to_bdev() failed for path [.]!

I have mntent  in my system.
Comment 1 crashskyshadow 2016-09-18 09:32:02 UTC
int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp)
	int ret = -1;
	int i;
	bool ready = False;
	char *mntpath = NULL;
	char *bdev = NULL;
	char *fs = NULL;

	if (!path||!dp)
		smb_panic("sys_get_quota: called with NULL pointer");

	if (command_get_quota(path, qtype, id, dp)==0) {	
		return 0;
	} else if (errno != ENOSYS) {
		return -1;

	if ((ret=sys_path_to_bdev(path,&mntpath,&bdev,&fs))!=0) {
		DEBUG(0,("sys_path_to_bdev() failed for path [%s]!\n",path));
		return ret;
Comment 2 crashskyshadow 2016-09-19 02:11:38 UTC
this issue also happened when I close multi channel support. So this issue is no relation to multi channel. 
It can copy to c:\newdir when i create a new directory on C:\.
Comment 3 mamachine 2016-10-05 09:23:46 UTC
I have the same issue since Samba 4.5.0 by just doing an "ls" in a smbclient session.

It looks like the generation of the path for checking quota is wrong in the function "sys_path_to_bdev" of "sysquotas.c".

For instance if I connect on a home share located in "/home/me" it'll search for a mntpath with the value "//ome/me".
Obviously there is a slash badly placed.

I managed to make it work with this patch, but I didn't test every input possibility :

--- samba-4.5.0.ORI/source3/lib/sysquotas.c     2016-07-27 15:09:58.000000000 +0200
+++ samba-4.5.0/source3/lib/sysquotas.c 2016-09-08 15:52:45.848353018 +0200
@@ -99,8 +99,7 @@
                                    stat_mntpath, strerror(errno));
                        goto out;
-               if (S.st_ex_dev != devno) {
-                       *p = '/';
+               if (S.st_ex_dev == devno) {
Comment 5 Uri Simchoni 2016-10-07 06:07:52 UTC
Created attachment 12552 [details]
possible fix
Comment 6 Uri Simchoni 2016-10-07 06:12:15 UTC
(In reply to mamachine from comment #3)
For instance if I connect on a home share located in "/home/me" it'll search for a mntpath with the value "//ome/me".

Would you agree that before the fix, if the share is in /home/me, and the mount point is /home, then it'll search a mntpath with the value "//ome", not "//ome/me"?

Does the attached patch fix the issue?
Comment 7 mamachine 2016-10-07 07:52:40 UTC
I agree with you, the mntpath value was "//ome", not "//ome/me" in my case.

I also confirm that your patch fix the issue for me.

Comment 8 Uri Simchoni 2016-10-07 17:37:49 UTC
The bug is a regression introduced by the improvement of avoiding stat of all mount points in the system just in order to find our mount point. This is only in the 4.5 and master branches.
Comment 9 Uri Simchoni 2016-10-08 04:14:15 UTC
Created attachment 12554 [details]
git-am fix for 4.5.next
Comment 10 Jeremy Allison 2016-10-10 19:45:13 UTC
Re-assigning to Karolin for inclusion in 4.5.next.
Comment 11 Karolin Seeger 2016-10-19 07:00:13 UTC
(In reply to Jeremy Allison from comment #10)
Pushed to autobuild-v4-5-test.
Comment 12 Karolin Seeger 2016-10-25 07:37:54 UTC
(In reply to Karolin Seeger from comment #11)
Pushed to v4-5-test.
Closing out bug report.