mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Luis Henriques <luis@igalia.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Chen Linxuan <me@black-desk.cn>,
	 Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	fuse-devel@lists.linux.dev,  linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	 Matt Harvey <mharvey@jumptrading.com>,
	kernel-dev@igalia.com
Subject: Re: [RFC PATCH v3 5/8] selftests/fuse: use dynamically allocated memory to store ACLs
Date: Sat, 5 Sep 2026 16:00:58 +0200	[thread overview]
Message-ID: <CAOQ4uxjMvHdaZfwjkHK3tV6ChsapobpHE9mq8NJSvduOGruvMg@mail.gmail.com> (raw)
In-Reply-To: <20260904103920.4471-6-luis@igalia.com>

On Fri, Sep 4, 2026 at 12:38 PM Luis Henriques <luis@igalia.com> wrote:
>
> Instead of directly using static arrays for the ACL value, allocate memory
> for storing it.  This will make it easier to implement ACL tests that also
> set the xattr dynamically.
>
> Signed-off-by: Luis Henriques <luis@igalia.com>

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  .../filesystems/fuse/fuse_acl_cache_test.c    | 32 ++++++++++++++++---
>  1 file changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c b/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
> index 12cbf9753d03..c2d6658ff7de 100644
> --- a/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
> +++ b/tools/testing/selftests/filesystems/fuse/fuse_acl_cache_test.c
> @@ -80,7 +80,7 @@ static const uint8_t acl_b[] = {
>
>  struct daemon_state {
>         pthread_mutex_t lock;
> -       const uint8_t  *acl;
> +       uint8_t        *acl;
>         size_t          acl_size;
>         int             getxattr_count;
>  };
> @@ -142,15 +142,26 @@ static void fs_getattr(fuse_req_t req, fuse_ino_t ino,
>  static void fs_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
>                         size_t size)
>  {
> +       uint8_t *acl = NULL;
> +       size_t acl_size;
> +
>         if (ino != FILE_INO ||
>             strcmp(name, "system.posix_acl_access") != 0) {
>                 fuse_reply_err(req, ENODATA);
>                 return;
>         }
>
> +       if (size) {
> +               acl = malloc(size);
> +               if (!acl) {
> +                       fuse_reply_err(req, ENOMEM);
> +                       return;
> +               }
> +       }
>         pthread_mutex_lock(&g_ds.lock);
> -       const uint8_t *acl      = g_ds.acl;
> -       size_t         acl_size = g_ds.acl_size;
> +       acl_size = g_ds.acl_size;
> +       if (acl && (size >= acl_size))
> +               memcpy(acl, g_ds.acl, acl_size);
>         g_ds.getxattr_count++;
>         pthread_mutex_unlock(&g_ds.lock);
>
> @@ -160,6 +171,8 @@ static void fs_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
>                 fuse_reply_err(req, ERANGE);
>         else
>                 fuse_reply_buf(req, (const char *)acl, acl_size);
> +
> +       free(acl);
>  }
>
>  static const struct fuse_lowlevel_ops fs_ops = {
> @@ -181,8 +194,10 @@ FIXTURE_SETUP(acl_cache)
>  {
>         char err[MAX_ERR_MSG];
>
> -       g_ds.acl = acl_a;
>         g_ds.acl_size = sizeof(acl_a);
> +       g_ds.acl = malloc(g_ds.acl_size);
> +       ASSERT_NE(g_ds.acl, NULL);
> +       memcpy(g_ds.acl, acl_a, g_ds.acl_size);
>         g_ds.getxattr_count = 0;
>
>         if (fs_setup(&self->se, self->mountpoint, &fs_ops, &self->thread, err))
> @@ -195,6 +210,7 @@ FIXTURE_SETUP(acl_cache)
>  FIXTURE_TEARDOWN(acl_cache)
>  {
>         fs_teardown(self->se, self->thread, self->mountpoint);
> +       free(g_ds.acl);
>  }
>
>  static int do_force_statx(const char *path)
> @@ -210,6 +226,7 @@ TEST_F(acl_cache, stale_after_force_sync)
>         char    buf[512];
>         ssize_t sz;
>         int     count;
> +       uint8_t *acl;
>
>         /*
>          * Step 1: two getxattr calls before any statx(FORCE_SYNC).
> @@ -270,8 +287,13 @@ TEST_F(acl_cache, stale_after_force_sync)
>          * !fc->posix_acl mounts (it skips forget_all_cached_acls in that case).
>          * On a fixed kernel the ACL was never cached, so this is moot.
>          */
> +       acl = malloc(sizeof(acl_b));
> +       ASSERT_NE(acl, NULL);
> +       memcpy(acl, acl_b, sizeof(acl_b));
> +
>         pthread_mutex_lock(&g_ds.lock);
> -       g_ds.acl      = acl_b;
> +       free(g_ds.acl);
> +       g_ds.acl      = acl;
>         g_ds.acl_size = sizeof(acl_b);
>         pthread_mutex_unlock(&g_ds.lock);
>         TH_LOG("step 4: daemon switched to ACL_B (%zu bytes)", sizeof(acl_b));

  reply	other threads:[~2026-09-05 14:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 10:39 [RFC PATCH v3 0/8] fuse: caches documentation and testing Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 1/8] Documentation: fuse: add document on caches being used by FUSE Luis Henriques
2026-09-05 21:04   ` Amir Goldstein
2026-09-07 10:38     ` Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 2/8] selftests/fuse: convert fusectl test to fuse3 Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 3/8] selftests/fuse: check that fusectlfs is mounted Luis Henriques
2026-09-05 13:59   ` Amir Goldstein
2026-09-04 10:39 ` [RFC PATCH v3 4/8] selftests/fuse: factor-out test fixture setup/teardown Luis Henriques
2026-09-05 12:45   ` Amir Goldstein
2026-09-07 10:44     ` Luis Henriques
2026-09-07 11:38       ` Amir Goldstein
2026-09-04 10:39 ` [RFC PATCH v3 5/8] selftests/fuse: use dynamically allocated memory to store ACLs Luis Henriques
2026-09-05 14:00   ` Amir Goldstein [this message]
2026-09-04 10:39 ` [RFC PATCH v3 6/8] selftests/fuse: add some extra ACL caching tests Luis Henriques
2026-09-05 12:38   ` Amir Goldstein
2026-09-07 10:48     ` Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 7/8] selftests/fuse: add fuse symlink caching test Luis Henriques
2026-09-05 12:32   ` Amir Goldstein
2026-09-07 10:58     ` Luis Henriques
2026-09-04 10:39 ` [RFC PATCH v3 8/8] selftests/fuse: add fuse readdir " Luis Henriques
2026-09-05 14:11   ` Amir Goldstein
2026-09-07 10:55     ` Luis Henriques

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=CAOQ4uxjMvHdaZfwjkHK3tV6ChsapobpHE9mq8NJSvduOGruvMg@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=corbet@lwn.net \
    --cc=fuse-devel@lists.linux.dev \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luis@igalia.com \
    --cc=me@black-desk.cn \
    --cc=mharvey@jumptrading.com \
    --cc=miklos@szeredi.hu \
    --cc=skhan@linuxfoundation.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

all inboxes | Powered by JetHome®