linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Hongbo Li <lihongbo22@huawei.com>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: How to create new file in idmapped mountpoint
Date: Mon, 17 Jun 2024 09:53:22 +0200	[thread overview]
Message-ID: <20240617-backfisch-chilipulver-77c21e2b338c@brauner> (raw)
In-Reply-To: <e4f9392e-b5b6-4063-aecb-4d034c5d2bb6@huawei.com>

On Fri, Jun 14, 2024 at 03:09:22PM GMT, Hongbo Li wrote:
> Hi everyone !
> 
> How can I create new file in idmapped mountpoint in ext4?
> 
> I try to do the following test:
> ```
> losetup /dev/loop1 ext4.img
> mkfs.ext4 /dev/loop1
> mount /dev/loop1 /mnt/ext4
> ./mount-idmapped --map-mount b:0:1001:1 /mnt/ext4 /mnt/idmapped1
> cp testfile /mnt/idmapped1
> ```
> then it rebacks me:
> ```
> cp: cannot create regular file '/mnt/idmapped1/testfile': Value too large
> for defined data type
> ```
> Did I use it incorrectly?

You're setting up a mount in which uid 1001 maps to uid 0. So if you
create files as uid 1001 they will map to uid 0 on-disk.

But you haven't mapped uid 0 to anything so the mount doesn't allow the
root user to create files. In order to that you could e.g., do:

sudo mount --bind -o X-mount.idmap='0:1001:1 1001:0:1' /mnt/ex4/ /mnt/idmapped1/

If you now (as root) do cp testfile /mnt/idmapped1/ it will work and
files created by root will show up as being owned by uid 1001 on disk.

      reply	other threads:[~2024-06-17  7:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14  7:09 How to create new file in idmapped mountpoint Hongbo Li
2024-06-17  7:53 ` Christian Brauner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240617-backfisch-chilipulver-77c21e2b338c@brauner \
    --to=brauner@kernel.org \
    --cc=lihongbo22@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).