public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd@bsbernd.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
	Joanne Koong <joannelkoong@gmail.com>,
	Bernd Schubert <bschubert@ddn.com>
Subject: Re: [PATCH 09/19] Move mount flags to mount_i.h
Date: Tue, 24 Mar 2026 19:40:37 +0100	[thread overview]
Message-ID: <44f05318-7f58-454f-a09d-2ba0a4523daf@bsbernd.com> (raw)
In-Reply-To: <20260323224529.GK6202@frogsfrogsfrogs>



On 3/23/26 23:45, Darrick J. Wong wrote:
> On Mon, Mar 23, 2026 at 06:45:04PM +0100, Bernd Schubert wrote:
>> From: Bernd Schubert <bschubert@ddn.com>
>>
>> This is preparation work for the new mount API, which goes into
>> its own file.
>>
>> Signed-off-by: Bernd Schubert <bschubert@ddn.com>
>> ---
>>  lib/mount.c         | 59 ++++++++---------------------------------------------
>>  lib/mount_i_linux.h | 35 ++++++++++++++++++++++++++++++-
>>  2 files changed, 42 insertions(+), 52 deletions(-)
>>
>> diff --git a/lib/mount.c b/lib/mount.c
>> index fe353e2cc4579adb47473cac5db7d1bae2defb2c..b3ee9ba4c0a74c1d0d55f916e7046e064f8468b0 100644
>> --- a/lib/mount.c
>> +++ b/lib/mount.c
>> @@ -34,16 +34,6 @@
>>  #include "fuse_mount_compat.h"
>>  
>>  #ifdef __NetBSD__
> 
> Hopefully the rest of the bsd stuff can go in its own files too?

Just created another patch for that.

> 
>> -#include <perfuse.h>
>> -
>> -#define MS_RDONLY	MNT_RDONLY
>> -#define MS_NOSUID	MNT_NOSUID
>> -#define MS_NODEV	MNT_NODEV
>> -#define MS_NOEXEC	MNT_NOEXEC
>> -#define MS_SYNCHRONOUS	MNT_SYNCHRONOUS
>> -#define MS_NOATIME	MNT_NOATIME
>> -#define MS_NOSYMFOLLOW	MNT_NOSYMFOLLOW
>> -
>>  #define umount2(mnt, flags) unmount(mnt, (flags == 2) ? MNT_FORCE : 0)
>>  #endif
>>  
>> @@ -51,10 +41,6 @@
>>  #define FUSE_COMMFD_ENV		"_FUSE_COMMFD"
>>  #define FUSE_COMMFD2_ENV	"_FUSE_COMMFD2"
>>  
>> -#ifndef MS_DIRSYNC
>> -#define MS_DIRSYNC 128
>> -#endif
>> -
>>  enum {
>>  	KEY_KERN_FLAG,
>>  	KEY_KERN_OPT,
>> @@ -154,35 +140,6 @@ void fuse_mount_version(void)
>>  			 FUSERMOUNT_PROG);
>>  }
>>  
>> -struct mount_flags {
>> -	const char *opt;
>> -	unsigned long flag;
>> -	int on;
>> -};
>> -
>> -static const struct mount_flags mount_flags[] = {
>> -	{"rw",	    MS_RDONLY,	    0},
>> -	{"ro",	    MS_RDONLY,	    1},
>> -	{"suid",    MS_NOSUID,	    0},
>> -	{"nosuid",  MS_NOSUID,	    1},
>> -	{"dev",	    MS_NODEV,	    0},
>> -	{"nodev",   MS_NODEV,	    1},
>> -	{"exec",    MS_NOEXEC,	    0},
>> -	{"noexec",  MS_NOEXEC,	    1},
>> -	{"async",   MS_SYNCHRONOUS, 0},
>> -	{"sync",    MS_SYNCHRONOUS, 1},
>> -	{"noatime", MS_NOATIME,	    1},
>> -	{"nodiratime",	    MS_NODIRATIME,	1},
>> -	{"norelatime",	    MS_RELATIME,	0},
>> -	{"nostrictatime",   MS_STRICTATIME,	0},
>> -	{"symfollow",	    MS_NOSYMFOLLOW,	0},
>> -	{"nosymfollow",	    MS_NOSYMFOLLOW,	1},
>> -#ifndef __NetBSD__
>> -	{"dirsync", MS_DIRSYNC,	    1},
>> -#endif
>> -	{NULL,	    0,		    0}
>> -};
>> -
>>  unsigned int get_max_read(struct mount_opts *o)
>>  {
>>  	return o->max_read;
>> @@ -192,13 +149,13 @@ static void set_mount_flag(const char *s, int *flags)
>>  {
>>  	int i;
>>  
>> -	for (i = 0; mount_flags[i].opt != NULL; i++) {
>> -		const char *opt = mount_flags[i].opt;
>> +	for (i = 0; fuse_mount_flags[i].opt != NULL; i++) {
>> +		const char *opt = fuse_mount_flags[i].opt;
>>  		if (strcmp(opt, s) == 0) {
>> -			if (mount_flags[i].on)
>> -				*flags |= mount_flags[i].flag;
>> +			if (fuse_mount_flags[i].on)
>> +				*flags |= fuse_mount_flags[i].flag;
>>  			else
>> -				*flags &= ~mount_flags[i].flag;
>> +				*flags &= ~fuse_mount_flags[i].flag;
>>  			return;
>>  		}
>>  	}
>> @@ -645,9 +602,9 @@ static int get_mnt_flag_opts(char **mnt_optsp, int flags)
>>  	if (!(flags & MS_RDONLY) && fuse_opt_add_opt(mnt_optsp, "rw") == -1)
>>  		return -1;
>>  
>> -	for (i = 0; mount_flags[i].opt != NULL; i++) {
>> -		if (mount_flags[i].on && (flags & mount_flags[i].flag) &&
>> -		    fuse_opt_add_opt(mnt_optsp, mount_flags[i].opt) == -1)
>> +	for (i = 0; fuse_mount_flags[i].opt != NULL; i++) {
>> +		if (fuse_mount_flags[i].on && (flags & fuse_mount_flags[i].flag) &&
>> +		    fuse_opt_add_opt(mnt_optsp, fuse_mount_flags[i].opt) == -1)
>>  			return -1;
>>  	}
>>  	return 0;
>> diff --git a/lib/mount_i_linux.h b/lib/mount_i_linux.h
>> index abcd1b08012feedef6b4c8961b55ac847a27496a..c0de6228fce5a4d9070cc246ec76222b66de56fb 100644
>> --- a/lib/mount_i_linux.h
>> +++ b/lib/mount_i_linux.h
>> @@ -10,7 +10,8 @@
>>  #ifndef FUSE_MOUNT_I_H_
>>  #define FUSE_MOUNT_I_H_
>>  
>> -/* Forward declaration for fuse_args */
>> +#include <sys/mount.h>
>> +
>>  struct fuse_args;
>>  
>>  /* Mount options structure */
>> @@ -28,5 +29,37 @@ struct mount_opts {
>>  	unsigned int max_read;
>>  };
>>  
>> +/* Mount flags mapping structure */
>> +struct mount_flags {
>> +	const char *opt;
>> +	unsigned long flag;
>> +	int on;
>> +};
>> +
>> +/* Mount flags table */
>> +static const struct mount_flags fuse_mount_flags[] = {
> 
> Hmmm, doesn't this create a fuse_mount_flags[] in every single .o file
> that #includes this header?  I'd have thought you'd want an extern
> declaration here and a definition elsewhere?

Uh oh, thanks for spotting that. Fixed.

> 
>> +	{"rw",			MS_RDONLY,      0},
>> +	{"ro",			MS_RDONLY,      1},
>> +	{"suid",		MS_NOSUID,      0},
>> +	{"nosuid",		MS_NOSUID,      1},
>> +	{"dev",			MS_NODEV,       0},
>> +	{"nodev",		MS_NODEV,       1},
>> +	{"exec",		MS_NOEXEC,      0},
>> +	{"noexec",		MS_NOEXEC,      1},
>> +	{"async",		MS_SYNCHRONOUS, 0},
>> +	{"sync",		MS_SYNCHRONOUS, 1},
>> +	{"noatime",		MS_NOATIME,     1},
>> +	{"nodiratime",		MS_NODIRATIME,  1},
>> +	{"norelatime",		MS_RELATIME,    0},
>> +	{"nostrictatime",	MS_STRICTATIME, 0},
>> +	{"symfollow",		MS_NOSYMFOLLOW, 0},
>> +	{"nosymfollow",		MS_NOSYMFOLLOW, 1},
>> +#ifndef __NetBSD__
> 
> When would we have __NetBSD__ defined on a Linux build?
> 
> Though I see no meson.build changes here, so I can't tell if
> mount_i_linux.c only gets built on Linux or everywhere or ...?

mount_i_linux.h should be included in files used by linux only. Same
as mount.c. Next patch removes this BSD condition.


Thanks,
Bernd

> 
> --D
> 
>> +	{"dirsync", MS_DIRSYNC,     1},
>> +#endif
>> +	{NULL,      0,          0}
>> +};
>> +
>> +
>>  
>>  #endif /* FUSE_MOUNT_I_H_ */
>>
>> -- 
>> 2.43.0
>>
>>


  reply	other threads:[~2026-03-24 18:40 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 17:44 [PATCH 00/19] libfuse: Add support for synchronous init Bernd Schubert
2026-03-23 17:44 ` [PATCH 01/19] ci-build: Add environment logging Bernd Schubert
2026-03-23 17:44 ` [PATCH 02/19] Add 'STRCPY' to the checkpatch ignore option Bernd Schubert
2026-03-23 21:03   ` Darrick J. Wong
2026-03-23 17:44 ` [PATCH 03/19] checkpatch.pl: Add _Atomic to $Attribute patttern Bernd Schubert
2026-03-23 21:09   ` Darrick J. Wong
2026-03-23 17:44 ` [PATCH 04/19] Add a new daemonize API Bernd Schubert
2026-03-23 22:28   ` Darrick J. Wong
2026-03-24 17:36     ` Bernd Schubert
2026-03-24 22:20       ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 05/19] Sync fuse_kernel.h with linux-6.18 Bernd Schubert
2026-03-23 21:16   ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 06/19] mount.c: Split fuse_mount_sys to prepare privileged sync FUSE_INIT Bernd Schubert
2026-03-23 22:34   ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 07/19] Add FUSE_MOUNT_FALLBACK_NEEDED define for -2 mount errors Bernd Schubert
2026-03-23 22:36   ` Darrick J. Wong
2026-03-24 18:03     ` Bernd Schubert
2026-03-23 17:45 ` [PATCH 08/19] Refactor mount code / move common functions to mount_util.c Bernd Schubert
2026-03-23 22:40   ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 09/19] Move mount flags to mount_i.h Bernd Schubert
2026-03-23 22:45   ` Darrick J. Wong
2026-03-24 18:40     ` Bernd Schubert [this message]
2026-03-23 17:45 ` [PATCH 10/19] conftest.py: Add more valgrind filter patterns Bernd Schubert
2026-03-23 17:45 ` [PATCH 11/19] Add support for the new linux mount API Bernd Schubert
2026-03-23 23:42   ` Darrick J. Wong
2026-03-24 20:16     ` Bernd Schubert
2026-03-24 22:46       ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 12/19] fuse mount: Support synchronous FUSE_INIT (privileged daemon) Bernd Schubert
2026-03-24  0:03   ` Darrick J. Wong
2026-03-24 20:42     ` Bernd Schubert
2026-03-24 22:50       ` Darrick J. Wong
2026-03-25  7:52         ` Bernd Schubert
2026-03-25 16:42           ` Darrick J. Wong
2026-03-26 19:32         ` Bernd Schubert
2026-03-26 22:33           ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 13/19] Add fuse_session_set_debug() to enable debug output without foreground Bernd Schubert
2026-03-24  0:04   ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 14/19] Move more generic mount code to mount_util.{c,h} Bernd Schubert
2026-03-24  0:06   ` Darrick J. Wong
2026-03-24 20:57     ` Bernd Schubert
2026-03-23 17:45 ` [PATCH 15/19] Split the fusermount do_mount function Bernd Schubert
2026-03-24  0:14   ` Darrick J. Wong
2026-03-24 21:05     ` Bernd Schubert
2026-03-24 22:53       ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 16/19] fusermount: Refactor extract_x_options Bernd Schubert
2026-03-24  0:18   ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 17/19] Make fusermount work bidirectional for sync init Bernd Schubert
2026-03-24 19:35   ` Darrick J. Wong
2026-03-24 21:24     ` Bernd Schubert
2026-03-24 22:59       ` Darrick J. Wong
2026-03-25 19:48         ` Bernd Schubert
2026-03-25 22:03           ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 18/19] New mount API: Filter out "user=" Bernd Schubert
2026-03-24 19:51   ` Darrick J. Wong
2026-03-24 20:01     ` Bernd Schubert
2026-03-24 23:02       ` Darrick J. Wong
2026-03-23 17:45 ` [PATCH 19/19] Add support for sync-init of unprivileged daemons Bernd Schubert
2026-03-24 20:21   ` Darrick J. Wong
2026-03-24 21:53     ` Bernd Schubert
2026-03-24 23:13       ` Darrick J. Wong
2026-03-24  0:19 ` [PATCH 00/19] libfuse: Add support for synchronous init Darrick J. Wong

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=44f05318-7f58-454f-a09d-2ba0a4523daf@bsbernd.com \
    --to=bernd@bsbernd.com \
    --cc=bschubert@ddn.com \
    --cc=djwong@kernel.org \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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