Debian Codegraph @

doc/documents-and-fuse.rst

raw
1 Documents & FUSE
2 ================
3
4 The Document portal exposes files (filesystem entries) to applications through
5 FUSE.
6
7 Files are scoped in a domain operations are restricted with a domain. The FUSE
8 filesystem will proxy the file access by referencing the inodes and presenting
9 the files in a virtual filesystem.
10
11 Much like with xdg-desktop-portal, to run the development version of
12 the Document portal, do:
13
14 .. code-block:: shell
15
16 _build/document-portal/xdg-document-portal --replace
17
18 FUSE
19 ----
20
21 The Document portal is a separate executable, ``xdg-document-portal``, and it
22 implements the virtual filesystem using FUSE. The filesystem is mounted in the
23 user runtime ``doc`` directory. It usually is ``/run/user/[UID]/doc``, where
24 ``[UID]`` is the user id on the system.
25
26 Inside the Flatpak sandbox, files for which the app has permission to access are
27 available at ``/run/flatpak/doc``.
28
29 Like any FUSE filesystem, it exposes inodes through the FUSE API.
30
31 Domains
32 """""""
33
34 Domains specify the scope of an inode and organize the documents into
35 a hierarchy. It helps compartimentalize which documents the
36 applications have access to.
37
38 - ``XDP_DOMAIN_ROOT``: root domain.
39 - ``XDP_DOMAIN_BY_APP``: used to find app domains by app id.
40 - ``XDP_DOMAIN_APP``: contains the documents allowed for the app.
41 - ``XDP_DOMAIN_DOCUMENT``: a physical file or directory is a document
42 in the ``XDP_DOMAIN_DOCUMENT``.
43
44 The first three are considered to be virtual, which mean they are not
45 backed by a physical inode.
46
47 The Document portal defines a few globals to hold the inodes:
48
49 - ``root_inode`` is an inode that holds the root domain.
50 - ``by_app_inode`` is the inode for the by app domain.
51 - ``physical_inodes`` is a hash table for the physical inodes, the key
52 is ``devino``.
53 - ``all_inodes`` is a hash table for all the inodes, the key is the
54 inode number.
55
56 The domains are used to create the filesystem hierarchy presented by
57 the document portal through the FUSE filesystem. It looks like this:
58
59 .. code-block::
60
61 /
62 ├─ by-app
63 │ ├─ org.foo.Bar
64 │ │ ├─ doc1
65 │ │ └─ doc3
66 │ └─ org.bar.Foo
67 │ ├─ doc2
68 │ └─ doc3
69 ├─ doc1
70 ├─ doc2
71 └─ doc3
72
73 ``/`` is the root domain. ``by-app`` is the ``XDP_DOMAIN_BY_APP`` domain.
74 ``org.foo.Bar`` and ``org.bar.Foo`` are application ids.
75
76 ``doc1``, ``doc2``, ``doc3`` are unique identifiers for the documents. As
77 mentioned, they can be shared across apps.
78
79 Document identifiers are unique. They are created using the inode number of the
80 physical file or directory.
81
82 Custom xattrs
83 -------------
84
85 Files and folders mounted through the Document portal have a custom attribute
86 with the host system path: ``user.document-portal.host-path``. This attribute
87 is read-only and any attempt to modify it will result in an error.