Lines Matching full:id
24 we're talking about an id in the upper or lower idmapset.
58 and id ``k11000`` which has been generated by the first idmapping by mapping
62 what id ``k11000`` corresponds to in the second or third idmapping. The
79 an id mapped. We can simply say that ``u1000`` is unmapped in the second and
83 The algorithm to calculate what a given id maps to is pretty simple. First, we
84 need to verify that the range can contain our target id. We will skip this step
85 for simplicity. After that if we want to know what ``id`` maps to we can do
91 id - u + k = n
96 id - k + u = n
108 want to know what id this was mapped from in the upper idmapset of the first
111 id - k + u = n
114 Now assume we are given the id ``u1100`` in the upper idmapset of the second
115 idmapping and we want to know what this id maps down to in the lower idmapset
119 id - u + k = n
128 userspace-id:kernel-id:range
130 A userspace id is always an element in the upper idmapset of an idmapping of
131 type ``uid_t`` or ``gid_t`` and a kernel id is always an element in the lower
133 "userspace id" will be used to refer to the well known ``uid_t`` and ``gid_t``
134 types and "kernel id" will be used to refer to ``kuid_t`` and ``kgid_t``.
138 A userspace id on the other hand is an id that is reported to userspace by the
139 kernel, or is passed by userspace to the kernel, or a raw device id that is
149 For example, the id ``u1000`` is an id in the upper idmapset or "userspace
151 kernel id in the lower idmapset or "kernel idmapset" starting with ``k10000``.
153 A kernel id is always created by an idmapping. Such idmappings are associated
172 ownership of a file is read from disk by a filesystem, the userspace id is
173 immediately translated into a kernel id according to the idmapping associated
181 simply the identity idmapping. This would mean id ``u1000`` read from disk
182 would be mapped to id ``k1000``. So an inode's ``i_uid`` and ``i_gid`` field
202 If we've been given ``k11000`` from one idmapping we can map that id up in
204 the same kernel id in their kernel idmapsets. For example, consider the
211 then translate ``k11000`` into a userspace id in the second idmapping using the
214 /* Map the kernel id up into a userspace id in the second idmapping. */
217 Note, how we can get back to the kernel id in the first idmapping by inverting
220 /* Map the userspace id down into a kernel id in the second idmapping. */
223 /* Map the kernel id up into a userspace id in the first idmapping. */
226 This algorithm allows us to answer the question what userspace id a given
227 kernel id corresponds to in a given idmapping. In order to be able to answer
228 this question both idmappings need to contain the same kernel id in their
231 For example, when the kernel reads a raw userspace id from disk it maps it down
232 into a kernel id according to the idmapping associated with the filesystem.
239 ownership information about the file the kernel can't simply map the id back up
243 So the kernel will map the id back up in the idmapping of the caller. Let's
251 It is possible to translate a kernel id from one idmapping to another one via
253 a kernel id.
261 kernel id in the first idmapping into a kernel id in the second idmapping we
264 1. Map the kernel id up into a userspace id in the first idmapping::
266 /* Map the kernel id up into a userspace id in the first idmapping. */
269 2. Map the userspace id down into a kernel id in the second idmapping::
271 /* Map the userspace id down into a kernel id in the second idmapping. */
275 the kernel id in one idmapping to a kernel id in another idmapping.
277 This allows us to answer the question what kernel id we would need to use to
278 get the same userspace id in another idmapping. In order to be able to answer
279 this question both idmappings need to contain the same userspace id in their
282 Note, how we can easily get back to the kernel id in the first idmapping by
285 1. Map the kernel id up into a userspace id in the second idmapping::
287 /* Map the kernel id up into a userspace id in the second idmapping. */
290 2. Map the userspace id down into a kernel id in the first idmapping::
292 /* Map the userspace id down into a kernel id in the first idmapping. */
297 userspace id mapped. This will come in handy when working with idmapped mounts.
302 It is never valid to use an id in the kernel idmapset of one idmapping as the
303 id in the userspace idmapset of another or the same idmapping. While the kernel
304 idmapset always indicates an idmapset in the kernel id space the userspace
305 idmapset indicates a userspace id. So the following translations are forbidden::
307 /* Map the userspace id down into a kernel id in the first idmapping. */
310 /* INVALID: Map the kernel id down into a kernel id in the second idmapping. */
316 /* Map the kernel id up into a userspace id in the first idmapping. */
319 /* INVALID: Map the userspace id up into a userspace id in the second idmapping. */
326 The concepts of mapping an id down or mapping an id up are expressed in the two
330 /* Map the userspace id down into a kernel id. */
333 /* Map the kernel id up into a userspace id. */
361 the kernel id back up into a userspace id when writing to disk.
362 So with the second step the kernel guarantees that a valid userspace id can be
368 kernel maps the caller's userspace id down into a kernel id according to the
369 caller's idmapping and then maps that kernel id up according to the
382 caller id: u1000
402 on. Ultimately the userspace id that lands on disk will be ``u1000``.
409 caller id: u1000
423 It's immediately clear that while the caller's userspace id could be
437 caller id: u1000
451 We can see that the translation always succeeds. The userspace id that the
453 the kernel id that was created in the caller's idmapping. This has mainly two
457 userspace id. We could only do this if we were to mount the whole fileystem
479 file id: u1000
486 1. Map the userspace id on disk down into a kernel id in the filesystem's
491 2. Map the kernel id up into a userspace id in the caller's idmapping::
495 The crossmapping algorithm fails in this case because the kernel id in the
496 filesystem idmapping cannot be mapped up to a userspace id in the caller's
505 file id: u1000
512 1. Map the userspace id on disk down into a kernel id in the filesystem's
517 2. Map the kernel id up into a userspace id in the caller's idmapping::
521 Again, the crossmapping algorithm fails in this case because the kernel id in
522 the filesystem idmapping cannot be mapped to a userspace id in the caller's
531 1. Map the userspace id on disk down into a kernel id in the filesystem's
536 2. Map the kernel id up into a userspace id in the caller's idmapping::
557 dir id: u0
558 dir/file1 id: u1000
559 dir/file2 id: u2000
569 dir id: u10000
570 dir/file1 id: u11000
571 dir/file2 id: u12000
580 different login userspace ids. Most users will have ``u1000`` as the login id
582 owned by ``u1000``. At uni or at work they may have another login id such as
638 /* Map the filesystem's kernel id up into a userspace id in the filesystem's idmapping. */
641 /* Map the filesystem's userspace id down ito a kernel id in the mount's idmapping. */
646 The ``mapped_fs*id()`` functions translate the caller's kernel ids into
650 /* Map the caller's kernel id up into a userspace id in the mount's idmapping. */
653 /* Map the mount's userspace id down into a kernel id in the filesystem's idmapping. */
663 Assume a file owned by ``u1000`` is read from disk. The filesystem maps this id
669 kernel id up to a userspace id in the caller's idmapping.
672 first call ``i_uid_into_mnt()`` thereby translating the filesystem's kernel id
673 into a kernel id in the mount's idmapping::
676 /* Map the filesystem's kernel id up into a userspace id. */
679 /* Map the filesystem's userspace id down ito a kernel id in the mount's idmapping. */
683 kernel id in the mount's idmapping into a userspace id in the caller's
693 mapped to a userspace id in the filesystem's idmapping. Since ``k11000`` can't
698 first call ``mapped_fs*id()`` thereby translating the caller's kernel id into
699 a kernel id according to the mount's idmapping::
702 /* Map the caller's kernel id up into a userspace id in the mount's idmapping. */
705 /* Map the mount's userspace id down into a kernel id in the filesystem's idmapping. */
709 userspace id in the filesystem's idmapping::
725 caller id: u1000
737 2. Translate the caller's kernel id into a kernel id in the filesystem's
741 /* Map the kernel id up into a userspace id in the mount's idmapping. */
744 /* Map the userspace id down into a kernel id in the filesystem's idmapping. */
759 caller id: u1000
770 2. Translate the caller's kernel id into a kernel id in the filesystem's
774 /* Map the kernel id up into a userspace id in the mount's idmapping. */
777 /* Map the userspace id down into a kernel id in the filesystem's idmapping. */
792 file id: u1000
800 1. Map the userspace id on disk down into a kernel id in the filesystem's
805 2. Translate the kernel id into a kernel id in the mount's idmapping::
808 /* Map the kernel id up into a userspace id in the filesystem's idmapping. */
811 /* Map the userspace id down into a kernel id in the mounts's idmapping. */
814 3. Map the kernel id up into a userspace id in the caller's idmapping::
818 Earlier, the caller's kernel id couldn't be crossmapped in the filesystems's
828 file id: u1000
836 1. Map the userspace id on disk down into a kernel id in the filesystem's
841 2. Translate the kernel id into a kernel id in the mount's idmapping::
844 /* Map the kernel id up into a userspace id in the filesystem's idmapping. */
847 /* Map the userspace id down into a kernel id in the mounts's idmapping. */
850 3. Map the kernel id up into a userspace id in the caller's idmapping::
854 Earlier, the file's kernel id couldn't be crossmapped in the filesystems's
880 storage. At home they have id ``u1000`` and all files in their home directory
881 are owned by ``u1000`` whereas at uni or work they have login id ``u1125``.
899 caller id: u1125
908 2. Translate the caller's kernel id into a kernel id in the filesystem's
912 /* Map the kernel id up into a userspace id in the mount's idmapping. */
915 /* Map the userspace id down into a kernel id in the filesystem's idmapping. */
925 Now let's briefly look at what ownership the caller with id ``u1125`` will see
930 file id: u1000
935 1. Map the userspace id on disk down into a kernel id in the filesystem's
940 2. Translate the kernel id into a kernel id in the mount's idmapping::
943 /* Map the kernel id up into a userspace id in the filesystem's idmapping. */
946 /* Map the userspace id down into a kernel id in the mounts's idmapping. */
949 3. Map the kernel id up into a userspace id in the caller's idmapping::
954 which is the caller's userspace id on their workstation in our example.
956 The raw userspace id that is put on disk is ``u1000`` so when the user takes