Linux filesystem development
 help / color / mirror / Atom feed
* Re: man 2 unshare: UNSHARE_EMPTY_MNTNS
       [not found]   ` <20261127-rundlich-geldkassette-farbaufnahme-62856c08c80b@brauner>
@ 2026-11-27 13:08     ` Alejandro Colomar
  2026-12-01 11:02       ` Christian Brauner
  0 siblings, 1 reply; 3+ messages in thread
From: Alejandro Colomar @ 2026-11-27 13:08 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Niklas Hambüchen, linux-man, linux-api, linux-fsdevel,
	Jan Kara, Alexander Viro

[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]

[CC += linux-api@]

Hi Christian,

> Date: 2026-11-27 13:51:03+0100
> From: Christian Brauner <brauner@kernel.org>
>
> On Fri, Nov 20, 2026 at 12:22:52AM +0100, Alejandro Colomar wrote:
> > That same commit also adds CLONE_EMPTY_MNTNS (according to the commit
> > message, for clone3(2)).  Could you explain why there are two separate
> > flags?
> 
> unshare() only takes 32 bits. All of them are taken by legacy CLONE_*
> flags. New clone3() flags live above bit 31 so CLONE_EMPTY_MNTNS (1ULL
> << 37) can't be passed to unshare(). UNSHARE_EMPTY_MNTNS reuses the
> CLONE_PARENT_SETTID bit which has no meaning for unshare(). Both imply
> CLONE_NEWNS.

Hmmm, thanks!

$ git grep -hP -f <(grepc_c -tm CLONE_EMPTY_MNTNS) include/
#define CLONE_EMPTY_MNTNS       (1ULL << 37) /* Create an empty mount namespace. */
$ git grep -hP -f <(grepc_c -tm UNSHARE_EMPTY_MNTNS) include/
#define UNSHARE_EMPTY_MNTNS 0x00100000 /* Unshare an empty mount namespace. */
$ git grep -hP -f <(grepc_c -tm CLONE_PARENT_SETTID) include/
#define CLONE_PARENT_SETTID     0x00100000      /* set the TID in the parent */

Would it make sense to create new UNSHARE_* flags for all the existing
CLONE_* flags that make sense in unshare(2)?  That would avoid some
possible confusion.

That is:

$ man 2 unshare | grep -o '^.....CLONE_\w*' | sed s/CLONE/UNSHARE/;
     UNSHARE_FILES
     UNSHARE_FS
     UNSHARE_NEWCGROUP
     UNSHARE_NEWIPC
     UNSHARE_NEWNET
     UNSHARE_NEWNS
     UNSHARE_NEWPID
     UNSHARE_NEWTIME
     UNSHARE_NEWUSER
     UNSHARE_NEWUTS
     UNSHARE_SYSVSEM


Have a lovely day!
Alex


-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: man 2 unshare: UNSHARE_EMPTY_MNTNS
  2026-11-27 13:08     ` man 2 unshare: UNSHARE_EMPTY_MNTNS Alejandro Colomar
@ 2026-12-01 11:02       ` Christian Brauner
  2026-12-01 12:30         ` Alejandro Colomar
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Brauner @ 2026-12-01 11:02 UTC (permalink / raw)
  To: Alejandro Colomar
  Cc: Niklas Hambüchen, linux-man, linux-api, linux-fsdevel,
	Jan Kara, Alexander Viro

On Fri, Nov 27, 2026 at 02:08:04PM +0100, Alejandro Colomar wrote:
> Would it make sense to create new UNSHARE_* flags for all the existing
> CLONE_* flags that make sense in unshare(2)?  That would avoid some
> possible confusion.

Sounds ok albeit a bit silly since they're just aliases for the same
bits but it makes unshare(2) read consistently.

-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: man 2 unshare: UNSHARE_EMPTY_MNTNS
  2026-12-01 11:02       ` Christian Brauner
@ 2026-12-01 12:30         ` Alejandro Colomar
  0 siblings, 0 replies; 3+ messages in thread
From: Alejandro Colomar @ 2026-12-01 12:30 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Niklas Hambüchen, linux-man, linux-api, linux-fsdevel,
	Jan Kara, Alexander Viro

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

Hi Christian,

> Date: 2026-12-01 12:02:18+0100
> From: Christian Brauner <brauner@kernel.org>
>
> On Fri, Nov 27, 2026 at 02:08:04PM +0100, Alejandro Colomar wrote:
> > Would it make sense to create new UNSHARE_* flags for all the existing
> > CLONE_* flags that make sense in unshare(2)?  That would avoid some
> > possible confusion.
> 
> Sounds ok

Thanks!

> albeit a bit silly since they're just aliases for the same

I'd say s/silly/redundant/.

> bits but it makes unshare(2) read consistently.

Indeed, consistency feels more important than redundancy.
It'll simplify documentation, and reduce chances of making mistakes.
I'll send a patch adding them.


Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <64fb02fd-0ffa-4311-bf21-a3211e9d599e@nh2.me>
     [not found] ` <av-DinDzrAeN_1mU@devuan>
     [not found]   ` <20261127-rundlich-geldkassette-farbaufnahme-62856c08c80b@brauner>
2026-11-27 13:08     ` man 2 unshare: UNSHARE_EMPTY_MNTNS Alejandro Colomar
2026-12-01 11:02       ` Christian Brauner
2026-12-01 12:30         ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox