Index | Thread | Search

From:
Jeremie Courreges-Anglas <jca@wxcvbn.org>
Subject:
Re: [PATCH]: Add POSIX O_CLOFORK flag
To:
Theo Buehler <tb@theobuehler.org>
Cc:
Philip Guenther <pguenther@proofpoint.com>, "Todd C. Miller" <Todd.Miller@sudo.ws>, tech@openbsd.org
Date:
Thu, 11 Dec 2025 20:20:58 +0100

Download raw body.

Thread
On Thu, Dec 11, 2025 at 07:59:08PM +0100, Theo Buehler wrote:
> On Thu, Dec 11, 2025 at 10:47:01AM -0800, Philip Guenther wrote:
> > On Thu, 11 Dec 2025, Theo Buehler wrote:
> > > On Thu, Dec 11, 2025 at 11:23:30AM -0700, Todd C. Miller wrote:
> > > > On Thu, 11 Dec 2025 13:29:59 +0100, Theo Buehler wrote:
> > > > 
> > > > > Found this piece of this submission in one of my trees. Do we want this
> > > > > or was that omitted deliberately?
> > > > 
> > > > I think we do want the fstat.c change, but it needs a man page
> > > > addition as well.
> > > 
> > > thanks. like this?
> > 
> > almost ok guenther@
> > 
> > 
> > > --- fstat.c	20 Jun 2022 01:39:44 -0000	1.103
> > > +++ fstat.c	11 Dec 2025 18:36:17 -0000
> > > @@ -482,6 +482,8 @@ vtrans(struct kinfo_file *kf)
> > >  		strlcat(rwep, "w", sizeof rwep);
> > >  	if (kf->fd_ofileflags & UF_EXCLOSE)
> > >  		strlcat(rwep, "e", sizeof rwep);
> > > +	if (kf->fd_ofileflags & UF_FORKCLOSE)
> > > +		strlcat(rwep, "f", sizeof rwep);
> > 
> > The size of the rwep array needs to be bumped by one too.
> > 
> 
> Oh, right. We also need an extra column, otherwise the MODE and R/W
> columns touch in -n mode if all 5 flags are set.

Right, ok jca@

with a test program and without -n:
jca      clofork    41193    3 /           27103  crw-rw-rw-  rwefp     null

with -n:
jca      clofork    77676    3  4,64    27103        20666 rwefp    2,2

> Index: fstat.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/fstat/fstat.1,v
> diff -u -p -r1.59 fstat.1
> --- fstat.1	31 Mar 2019 06:40:26 -0000	1.59
> +++ fstat.1	11 Dec 2025 18:37:06 -0000
> @@ -175,6 +175,8 @@ Open for reading
>  Open for writing
>  .It e
>  close-on-exec flag is set
> +.It f
> +close-on-fork flag is set
>  .It p
>  Opened after
>  .Xr pledge 2
> Index: fstat.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/fstat/fstat.c,v
> diff -u -p -r1.103 fstat.c
> --- fstat.c	20 Jun 2022 01:39:44 -0000	1.103
> +++ fstat.c	11 Dec 2025 18:53:43 -0000
> @@ -337,10 +337,10 @@ fstat_header(void)
>  {
>  	if (nflg)
>  		printf("%s",
> -"USER     CMD          PID   FD  DEV      INUM        MODE   R/W    SZ|DV");
> +"USER     CMD          PID   FD  DEV      INUM        MODE    R/W    SZ|DV");
>  	else
>  		printf("%s",
> -"USER     CMD          PID   FD MOUNT        INUM  MODE         R/W    SZ|DV");
> +"USER     CMD          PID   FD MOUNT        INUM  MODE          R/W    SZ|DV");
>  	if (oflg)
>  		printf("%s", ":OFFSET  ");
>  	if (checkfile && fsflg == 0)
> @@ -427,7 +427,7 @@ void
>  vtrans(struct kinfo_file *kf)
>  {
>  	const char *badtype = NULL;
> -	char rwep[5], mode[12];
> +	char rwep[6], mode[12];
>  	char *filename = NULL;
>  
>  	if (kf->v_type == VNON)
> @@ -482,9 +482,11 @@ vtrans(struct kinfo_file *kf)
>  		strlcat(rwep, "w", sizeof rwep);
>  	if (kf->fd_ofileflags & UF_EXCLOSE)
>  		strlcat(rwep, "e", sizeof rwep);
> +	if (kf->fd_ofileflags & UF_FORKCLOSE)
> +		strlcat(rwep, "f", sizeof rwep);
>  	if (kf->fd_ofileflags & UF_PLEDGED)
>  		strlcat(rwep, "p", sizeof rwep);
> -	printf(" %4s", rwep);
> +	printf(" %5s", rwep);
>  	switch (kf->v_type) {
>  	case VBLK:
>  	case VCHR: {
> 

-- 
jca