Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With Samba, the directories that FUSE mounts are not visible, why? #424

Closed
zhongguang-cn opened this issue May 11, 2022 · 8 comments
Closed

Comments

@zhongguang-cn
Copy link

A has two subdirectories B and C, which are shared by Samba and visible on Windows.

If mounted to B by fuse, B will disappear on Windows and only C will be visible.

@zhongguang-cn
Copy link
Author

Have you ever encountered this problem? @hanwen

@hanwen
Copy link
Owner

hanwen commented May 12, 2022

@zhongguang-cn
Copy link
Author

example code:https://pkg.go.dev/github.com/hanwen/go-fuse/[email protected]/fs#example-package-HandleLess

func main() {
	mntDir := "/example1/mount/"
	if len(os.Args) > 1 {
		mntDir = os.Args[1]
	}

	root := &fs.Inode{}

	// Mount the file system
	server, err := fs.Mount(mntDir, root, &fs.Options{
		MountOptions: fuse.MountOptions{Debug: false, AllowOther: true},

		// Setup the file.
		OnAdd: func(ctx context.Context) {
			ch := root.NewPersistentInode(
				ctx,
				&bytesNode{},
				fs.StableAttr{
					Mode: syscall.S_IFREG,
					// Make debug output readable.
					Ino: 2,
				})
			root.AddChild("bytes", ch, true)
		},
		UID: 100,
		GID: 101,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf(`Try:

  cd %s
  ls -l bytes
  echo hello > bytes
  ls -l bytes
  cat bytes
  cd -

`, mntDir)
	fmt.Printf("Unmount by calling 'fusermount -u %s'\n", mntDir)

	// Serve the file system, until unmounted by calling fusermount -u
	server.Wait()
}

Results seen in the Samba container:

bash-5.1# mount|grep mount
rawBridge on /example1/mount type fuse.rawBridge (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
bash-5.1# ls -l /example1/
total 4
drwxr-x---    2 smbuser  smb           4096 May 12 06:48 m-test
drwxr-xr-x    0 smbuser  smb              0 Jan  1  1970 mount
bash-5.1# ls -l /example1/mount/
total 0
-rw-r--r--    0 smbuser  smb              0 Jan  1     1 bytes

Results seen on Windows:
image

On Windows, you see a file, not directories.

Why do directories on Linux see files on Windows?

@hanwen
Copy link
Owner

hanwen commented May 12, 2022

I don't know. I've never tried this. Does it work as expected when you use an example file system from the original libfuse package?

@zhongguang-cn
Copy link
Author

zhongguang-cn commented May 13, 2022

I don't know. I've never tried this. Does it work as expected when you use an example file system from the original libfuse package?

The use of Libfuse is as follows:

[root@EulixOS example]# mount|grep libfuse
/root/fuse/libfuse/libfuse-fuse-3.11.0/example/hello on /example1/mount type fuse.hello (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
[root@EulixOS example]# ll /example1/      
total 4.0K
drwxr-xr-x 2 root     root        0 Jan  1  1970 mount
drwxr-xr-x 2 example1 example1 4.0K May 13 08:15 test
-rwxr--r-- 1 example1 example1    0 May 13 08:29 test2.txt
[root@EulixOS example]# ll /example1/mount/
total 0
-r--r--r-- 1 root root 13 Jan  1  1970 hello
[root@EulixOS example]# cat /example1/mount/hello 
Hello World!

image

image

the example file system from the original libfuse package looks fine, no more problems.

@zhongguang-cn
Copy link
Author

Thanks for your advice, this issue will be closed first. @hanwen

@JoKr4
Copy link

JoKr4 commented Apr 8, 2023

I had the same problem with cgofuse

Please have a look at my PR there

I didnt found a way in go-fuse to add the nlink attribute, so just take this as a hint

@hanwen
Copy link
Owner

hanwen commented Apr 8, 2023

the Attr type has an Nlink field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants