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

directory tree portal #200

Closed
mikelpr opened this issue Jul 25, 2018 · 16 comments
Closed

directory tree portal #200

mikelpr opened this issue Jul 25, 2018 · 16 comments
Labels
enhancement portal: documents Issues with the documents portal

Comments

@mikelpr
Copy link

mikelpr commented Jul 25, 2018

file chooser portal for selecting a directory and its contents + subdirectories for RW

@matthiasclasen
Copy link
Contributor

This is not something that the document portal lets us do (export a tree).

@mjog
Copy link
Contributor

mjog commented Sep 3, 2018

Maybe a dupe of #158?

@mildred
Copy link

mildred commented Feb 1, 2019

A‌ use case for this is having VLC being able to open a DVD directory. Without, I have to copy the DVD directory to my homedir

@callaa
Copy link

callaa commented May 1, 2019

I also have a use case that would benefit from a directory portal. My application can export animations, either as video files or as individual frames. When exporting frames, it's not practical to prompt the user for each individual frame, so being able to open a directory is essential. In this particular use case, subdirectory access is not necessary.

Applications like Darktable would also benefit from being able to open directories, both for browsing images and for batch exporting processed photos.

@alice-mkh
Copy link
Contributor

If we're gathering use cases, GNOME Games needs this to be able to support DOS games without full file system access. Those games expect to be able to work with surrounding files, e.g. for reading/writing config and saves.

@TingPing
Copy link
Member

TingPing commented May 2, 2019

It is known hundreds of applications can use this. Lets keep this issue for details on how to implement it.

@swick
Copy link
Contributor

swick commented Feb 13, 2020

What's the situation here. Is there a clear path forward?

Showing a GUI to add a filesystem override would be easy but requires an app restart to become visible which is not nice at all.
Bind-mounting something into a running container doesn't really seem possible with the tools the kernel gives us right now.
Yet another fuse system might work.

More ideas?

@mjog
Copy link
Contributor

mjog commented Feb 14, 2020

Portal API support for this landed in xdg-desktop-portal 1.5.3 and xdg-desktop-portal-gtk 1.5.1. Not sure about the KDE portal.

Applications can use the new API directly or use libportal to access it (assuming people have the portal versions above installed), but no transparent support has landed in GTK or Qt as of yet.

@swick
Copy link
Contributor

swick commented Feb 14, 2020

Do you mean the SaveFiles method on the document portal? It's the only thing I could find which remotely has anything to do with this issue but it certainly isn't a complete solution to it.

@mjog
Copy link
Contributor

mjog commented Feb 16, 2020

Do you mean the SaveFiles method on the document portal?

Oh, yeah I see how that's probably not helpful here. Apologies for the noise.

@swick
Copy link
Contributor

swick commented Feb 25, 2020

Alright, I remembered reading something about a new kernel interface for mounting.

https://lwn.net/Articles/759499/
https://lwn.net/Articles/809125/

This might be suitable for adding new bind mounts in a running container. First I thought it's possible to create a bind mount using fsopen and fsconfig like so

sfd = fsopen(fstype, 0);
fsconfig(sfd, FSCONFIG_SET_FLAG, "ms_bind", NULL, 0);
fsconfig(sfd, FSCONFIG_SET_STRING, "source", "/host/path", 0);
fsconfig(sfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0);
mfd = fsmount(sfd, 0, 0);

but apparently that doesn't work ("Block device required"; maybe it's possible and I'm just doing something wrong).
Another I had was to use the old mount syscall to create a bind mount on the host and then use open_tree.
Either way should yield a file descriptor that represents the mount and can eventually be inserted into the fs tree by calling move_mount. I believe this should work across mount namespaces but I'm really not sure because I'm failing at doing all of this in the host namespace already.

I'd really appreciate if someone who knows more about this would chime in.

@swick
Copy link
Contributor

swick commented Feb 28, 2020

Had some more time to test and…

host:

mfd = open_tree(AT_FDCWD, host_directory, OPEN_TREE_CLONE);
send_to_sandbox(mfd);

sandbox:

mfd = recv_from_host();
move_mount(mfd, "", AT_FDCWD, sandbox_directory, MOVE_MOUNT_F_EMPTY_PATH);

This actually works and creates a bind mount from the host's host_directory to the running container's sandbox_directory. It however requires mount caps on both the host and the container.

swick added a commit to swick/bubblewrap that referenced this issue Mar 3, 2020
In flatpak we would like to be able to make a host subtree visible to
some bwrap'ed processes some time after they have already been started
(flatpak/xdg-desktop-portal#200).

This patch introduces the '--live-mount-fd FD' option. The process
calling bwrap can pass a FD this way and write pairs of directories to
it which will be interpreted as source and destionation of a bind mount
operation.

To make this work in bwrap we make /newroot a shared mount and clone off
into a new mount namespace for what eventually becomes the container,
make /newroot a slave mount in this new mount namespace and continue on
normally with unmounting /oldroot and pivioting to /newroot. The original
process now still has /oldroot and /newroot and changes in /newroot
propagate to the container's mount namespace.
@swick
Copy link
Contributor

swick commented Mar 3, 2020

The mount caps are making the previous approach basically useless but I've found a new way using slave mounts which is looking promising (containers/bubblewrap#356).

@Erick555
Copy link

Erick555 commented Mar 3, 2020

@swick are you aware of recent work? https://github.com/alexlarsson/xdg-desktop-portal/commits/new-fuse-backend

@swick
Copy link
Contributor

swick commented Mar 3, 2020

No, I wasn't. That's unfortunate timing.

@hadess
Copy link
Contributor

hadess commented Mar 26, 2020

This GTK change (and related changes in xdg-desktop-portal and xdg-desktop-portal-gtk) should allow selecting directories for things like music libraries, or output directory if an application is expected to output everything to a single directory.

The bug was fixed in c616b49 (and further fixed still in some opened MRs).

We're still however missing a UI that would make it clear that opening a file, eg. a project file, would also give access to the rest of the files in that same directory. I've moved the conversation to #463

@hadess hadess closed this as completed Mar 26, 2020
agx pushed a commit to agx/xdg-desktop-portal that referenced this issue Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement portal: documents Issues with the documents portal
Projects
None yet
Development

No branches or pull requests

10 participants