linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Askar Safin <safinaskar@gmail.com>
To: luca.boccassi@gmail.com
Cc: alx@kernel.org, brauner@kernel.org, cyphar@cyphar.com,
	linux-fsdevel@vger.kernel.org, linux-man@vger.kernel.org,
	safinaskar@gmail.com
Subject: Re: [PATCH] man/man2/move_mount.2: document EINVAL on multiple instances
Date: Sun, 12 Oct 2025 14:27:21 +0300	[thread overview]
Message-ID: <20251012112721.44974-1-safinaskar@gmail.com> (raw)
In-Reply-To: <CAMw=ZnSBMpQsuTu9Gv7T3JhrBQMgJQxhR7OP9H_cuF=St=SeMg@mail.gmail.com>

Luca Boccassi <luca.boccassi@gmail.com>:
> IIRC Christian said this was working as intended? Just fsmount() to
> create a detached mount, and then try to apply it multiple times with
> multiple move_mount(), and the second and subsequent ones will fail
> with EINVAL

I just tested current mainline kernel (67029a49db6c).
And move_mount doesn't return EINVAL in this case (move_mount succeds).
This means that either EINVAL is not intended, either current mainline kernel
is buggy.

I tested this in Qemu in very minimal environment (rdinit=/bin/busybox sh).

See C source below.

-- 
Askar Safin

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/mount.h>

#define ASSERT(cond) if (!(cond)) { \
    fprintf (stderr, "%s: assertion failed\n", #cond); \
    exit (1); \
}

#define ASSERT_ERRNO(cond) if (!(cond)) { \
    fprintf (stderr, "%d: ", __LINE__); \
    perror (#cond); \
    exit (1); \
}

int
main (void)
{
    ASSERT_ERRNO (mkdir ("/a", 0777) == 0);
    ASSERT_ERRNO (mkdir ("/b", 0777) == 0);
    ASSERT_ERRNO (mkdir ("/c", 0777) == 0);
    {
        {
            int fsfd = fsopen ("tmpfs", 0);
            ASSERT_ERRNO (fsfd != -1);
            ASSERT_ERRNO (fsconfig (fsfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) == 0);
            {
                int mntfd = fsmount (fsfd, 0, 0);
                ASSERT_ERRNO (mntfd != -1);
                ASSERT_ERRNO (move_mount (mntfd, "", AT_FDCWD, "/a", MOVE_MOUNT_F_EMPTY_PATH) == 0);
                ASSERT_ERRNO (move_mount (mntfd, "", AT_FDCWD, "/b", MOVE_MOUNT_F_EMPTY_PATH) == 0);
                ASSERT_ERRNO (move_mount (mntfd, "", AT_FDCWD, "/c", MOVE_MOUNT_F_EMPTY_PATH) == 0);
                ASSERT_ERRNO (close (mntfd) == 0);
            }
            ASSERT_ERRNO (close (fsfd) == 0);
        }
        ASSERT_ERRNO (umount ("/c") == 0);
    }
}

  reply	other threads:[~2025-10-12 11:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251006103852.506614-1-luca.boccassi@gmail.com>
     [not found] ` <2hg43wshc3iklydtwx25ulqadzyuldkyi6wylgztzwendi5zhw@kw223cxay7qn>
     [not found]   ` <CAMw=ZnR6QMNevxtxWysqi5UkDmbD68Ge=R5cVAxskqtmhb5m5A@mail.gmail.com>
     [not found]     ` <bywtfrezkfevzz7y2ecq4w75nfjhz2qqu2cugwl3ml57jlom5k@b5bebz4f24sd>
     [not found]       ` <CAMw=ZnSZmW=BFbLLSKsn7sze-FXZroQw6o4eJU9675VmGjzDRw@mail.gmail.com>
     [not found]         ` <rleqiwn4mquteybmica3jwilel3mbmaww5p3wr7ju7tfj2d6wt@g6rliisekp2e>
     [not found]           ` <CAMw=ZnTDw59GqW-kQkf1aTEHgmBRzcD0z9Rk+wpE_REEmaEJBw@mail.gmail.com>
2025-10-06 13:40             ` [PATCH] man/man2/move_mount.2: document EINVAL on multiple instances Aleksa Sarai
2025-10-06 13:44               ` Luca Boccassi
2025-10-07 18:37                 ` Aleksa Sarai
2025-10-07 18:38                   ` Luca Boccassi
2025-10-12  6:14                 ` Askar Safin
2025-10-12  9:40                   ` Luca Boccassi
2025-10-12 11:27                     ` Askar Safin [this message]
2025-10-12 12:58                     ` Askar Safin
2025-10-12 13:16                       ` Alejandro Colomar
2025-10-13  5:51                         ` Askar Safin
2025-10-12 14:25                       ` Luca Boccassi
2025-10-12 14:57                         ` Alejandro Colomar
2025-10-12 18:57                           ` G. Branden Robinson
2025-10-13  4:14                         ` Askar Safin

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=20251012112721.44974-1-safinaskar@gmail.com \
    --to=safinaskar@gmail.com \
    --cc=alx@kernel.org \
    --cc=brauner@kernel.org \
    --cc=cyphar@cyphar.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=luca.boccassi@gmail.com \
    /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).