Skip to content

Commit 0250c53

Browse files
committed
16624 Want support for FD_CLOFORK and friends
16638 Add some additional details to socket(3HEAD) Reviewed by: C Fraire <[email protected]> Reviewed by: Hans Rosenfeld <[email protected]> Approved by: Gordon Ross <[email protected]>
1 parent d0b93cc commit 0250c53

File tree

47 files changed

+2620
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2620
-290
lines changed

usr/src/cmd/ptools/pfiles/pfiles.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
/*
2727
* Copyright (c) 2017 Joyent, Inc. All Rights reserved.
2828
* Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
29+
* Copyright 2024 Oxide Computer Company
2930
*/
3031

3132
#include <stdio.h>
@@ -318,6 +319,26 @@ show_files(struct ps_prochandle *Pr)
318319
(void) Pfdinfo_iter(Pr, show_file, Pr);
319320
}
320321

322+
static void
323+
show_fdflags(int fdflags)
324+
{
325+
if (fdflags <= 0)
326+
return;
327+
328+
/*
329+
* show_fileflags() already has printed content here. We translate these
330+
* back to the O_ versions for consistency with the flags that were
331+
* already printed.
332+
*/
333+
if ((fdflags & FD_CLOEXEC) != 0) {
334+
(void) printf("|O_CLOEXEC");
335+
}
336+
337+
if ((fdflags & FD_CLOFORK) != 0) {
338+
(void) printf("|O_CLOFORK");
339+
}
340+
}
341+
321342
/* examine open file with fcntl() */
322343
static void
323344
dofcntl(struct ps_prochandle *Pr, const prfdinfo_t *info, int mandatory,
@@ -333,8 +354,8 @@ dofcntl(struct ps_prochandle *Pr, const prfdinfo_t *info, int mandatory,
333354
(void) printf(" ");
334355
if (fileflags != -1)
335356
show_fileflags(fileflags);
336-
if (fdflags != -1 && (fdflags & FD_CLOEXEC))
337-
(void) printf(" FD_CLOEXEC");
357+
if (fdflags != -1)
358+
show_fdflags(fdflags);
338359
if (isdoor && (Pstate(Pr) != PS_DEAD))
339360
show_door(Pr, info);
340361
(void) fputc('\n', stdout);

usr/src/cmd/sgs/elfdump/common/corenote.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ dump_prfdinfo(note_state_t *state, const char *title)
16901690
{
16911691
const sl_prfdinfo_layout_t *layout = state->ns_arch->prfdinfo;
16921692
char buf[1024];
1693-
uint32_t fileflags, mode;
1693+
uint32_t fileflags, mode, fdflags;
16941694

16951695
indent_enter(state, title, &layout->pr_fd);
16961696

@@ -1718,7 +1718,9 @@ dump_prfdinfo(note_state_t *state, const char *title)
17181718
print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FILEFLAGS),
17191719
conv_cnote_fileflags(fileflags, 0, buf, sizeof (buf)));
17201720

1721-
PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_FDFLAGS), pr_fdflags);
1721+
fdflags = extract_as_word(state, &layout->pr_fdflags);
1722+
print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FDFLAGS),
1723+
conv_cnote_fdflags(fdflags, 0, buf, sizeof (buf)));
17221724

17231725
PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_PATH), pr_path);
17241726

usr/src/cmd/sgs/include/conv.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
2828
* Copyright (c) 2018, Joyent, Inc.
2929
* Copyright 2016 RackTop Systems.
30-
* Copyright 2022 Oxide Computer Company
30+
* Copyright 2024 Oxide Computer Company
3131
*/
3232

3333
#ifndef _CONV_H
@@ -869,6 +869,8 @@ extern const char *conv_cnote_syscall(Word, Conv_fmt_flags_t,
869869
Conv_inv_buf_t *);
870870
extern const char *conv_cnote_sysset(uint32_t *, int,
871871
Conv_fmt_flags_t, Conv_cnote_sysset_buf_t *);
872+
extern const char *conv_cnote_fdflags(uint32_t, Conv_fmt_flags_t,
873+
char *, size_t);
872874
extern const char *conv_cnote_fileflags(uint32_t, Conv_fmt_flags_t,
873875
char *, size_t);
874876
extern const char *conv_cnote_filemode(uint32_t, Conv_fmt_flags_t,

usr/src/cmd/sgs/libconv/common/corenote.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,29 @@ conv_cnote_filemode(uint32_t mode, Conv_fmt_flags_t fmt_flags,
26052605
return (buf);
26062606
}
26072607

2608+
const char *
2609+
conv_cnote_fdflags(uint32_t flags, Conv_fmt_flags_t fmt_flags,
2610+
char *buf, size_t bufsize)
2611+
{
2612+
CONV_EXPN_FIELD_ARG arg = { 0 };
2613+
2614+
static const Val_desc fdflags[] = {
2615+
{ 0x01, MSG_FD_CLOEXEC },
2616+
{ 0x02, MSG_FD_CLOFORK },
2617+
{ 0, 0 }
2618+
};
2619+
2620+
if (flags == 0)
2621+
return (MSG_ORIG(MSG_GBL_ZERO));
2622+
2623+
arg.buf = buf;
2624+
arg.bufsize = bufsize;
2625+
arg.oflags = flags;
2626+
arg.rflags = flags;
2627+
2628+
(void) conv_expn_field(&arg, fdflags, fmt_flags);
2629+
return (buf);
2630+
}
26082631

26092632
#define PROCSECFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
26102633
MSG_ASLR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \

usr/src/cmd/sgs/libconv/common/corenote.msg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,9 @@
11151115
@ MSG_PR_O_NOFOLLOW "O_NOFOLLOW"
11161116
@ MSG_PR_O_NOLINKS "O_NOLINKS"
11171117

1118+
@ MSG_FD_CLOEXEC "FD_CLOEXEC"
1119+
@ MSG_FD_CLOFORK "FD_CLOFORK"
1120+
11181121
@ MSG_S_IFIFO "S_IFIFO"
11191122
@ MSG_S_IFCHR "S_IFCHR"
11201123
@ MSG_S_IFDIR "S_IFDIR"

usr/src/cmd/sgs/rtld/common/external.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
#include <libintl.h>
185185
#include <debug.h>
186186
#include <libc_int.h>
187+
#include <fcntl.h>
187188
#include "_elf.h"
188189
#include "_rtld.h"
189190

@@ -622,13 +623,21 @@ int
622623
fcntl(int fildes, int cmd, ...)
623624
{
624625
extern int __fcntl(int, int, ...);
625-
intptr_t arg;
626+
intptr_t arg, arg1 = 0;
626627
va_list ap;
627628

628629
va_start(ap, cmd);
629-
arg = va_arg(ap, intptr_t);
630+
switch (cmd) {
631+
case F_DUP3FD:
632+
arg = va_arg(ap, int);
633+
arg1 = va_arg(ap, int);
634+
break;
635+
default:
636+
arg = va_arg(ap, intptr_t);
637+
break;
638+
}
630639
va_end(ap);
631-
return (__fcntl(fildes, cmd, arg));
640+
return (__fcntl(fildes, cmd, arg, arg1));
632641
}
633642

634643
int

usr/src/cmd/truss/codes.c

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* Copyright 2020 Joyent, Inc.
2727
* Copyright (c) 2014, OmniTI Computer Consulting, Inc. All rights reserved.
2828
* Copyright 2022 Garrett D'Amore <[email protected]>
29+
* Copyright 2024 Oxide Computer Company
2930
*/
3031

3132
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -111,63 +112,58 @@
111112
#include "proto.h"
112113

113114
#define FCNTLMIN F_DUPFD
114-
#define FCNTLMAX F_FLOCKW
115+
#define FCNTLMAX F_DUP3FD
115116
const char *const FCNTLname[] = {
116-
"F_DUPFD",
117-
"F_GETFD",
118-
"F_SETFD",
119-
"F_GETFL",
120-
"F_SETFL",
121-
"F_O_GETLK",
122-
"F_SETLK",
123-
"F_SETLKW",
124-
"F_CHKFL",
125-
"F_DUP2FD",
126-
"F_ALLOCSP",
127-
"F_FREESP",
128-
NULL, /* 12 */
129-
NULL, /* 13 */
130-
"F_GETLK",
131-
NULL, /* 15 */
132-
NULL, /* 16 */
133-
NULL, /* 17 */
134-
NULL, /* 18 */
135-
NULL, /* 19 */
136-
NULL, /* 20 */
137-
NULL, /* 21 */
138-
NULL, /* 22 */
139-
"F_GETOWN",
140-
"F_SETOWN",
141-
"F_REVOKE",
142-
"F_HASREMOTELOCKS",
143-
"F_FREESP64",
144-
NULL, /* 28 */
145-
NULL, /* 29 */
146-
NULL, /* 30 */
147-
NULL, /* 31 */
148-
NULL, /* 32 */
149-
"F_GETLK64",
150-
"F_SETLK64",
151-
"F_SETLKW64",
152-
"F_DUP2FD_CLOEXEC",
153-
"F_DUPFD_CLOEXEC",
154-
NULL, /* 38 */
155-
NULL, /* 39 */
156-
"F_SHARE",
157-
"F_UNSHARE",
158-
"F_SETLK_NBMAND",
159-
"F_SHARE_NBMAND",
160-
"F_SETLK64_NBMAND",
161-
NULL, /* 45 */
162-
"F_BADFD",
163-
"F_OFD_GETLK",
164-
"F_OFD_SETLK",
165-
"F_OFD_SETLKW",
166-
NULL, /* 50 */
167-
NULL, /* 51 */
168-
NULL, /* 52 */
169-
"F_FLOCK",
170-
"F_FLOCKW"
117+
[0] = "F_DUPFD",
118+
[1] = "F_GETFD",
119+
[2] = "F_SETFD",
120+
[3] = "F_GETFL",
121+
[4] = "F_SETFL",
122+
[5] = "F_O_GETLK",
123+
[6] = "F_SETLK",
124+
[7] = "F_SETLKW",
125+
[8] = "F_CHKFL",
126+
[9] = "F_DUP2FD",
127+
[10] = "F_ALLOCSP",
128+
[11] = "F_FREESP",
129+
[13] = "F_ISSTREAM",
130+
[14] = "F_GETLK",
131+
[15] = "F_PRIV",
132+
[16] = "F_NPRIV",
133+
[17] = "F_QUOTACTL",
134+
[18] = "F_BLOCKS",
135+
[19] = "F_BLKSIZE",
136+
[23] = "F_GETOWN",
137+
[24] = "F_SETOWN",
138+
[25] = "F_REVOKE",
139+
[26] = "F_HASREMOTELOCKS",
140+
[27] = "F_FREESP64",
141+
[28] = "F_ALLOCSP64",
142+
[33] = "F_GETLK64",
143+
[34] = "F_SETLK64",
144+
[35] = "F_SETLKW64",
145+
[36] = "F_DUP2FD_CLOEXEC",
146+
[37] = "F_DUPFD_CLOEXEC",
147+
[40] = "F_SHARE",
148+
[41] = "F_UNSHARE",
149+
[42] = "F_SETLK_NBMAND",
150+
[43] = "F_SHARE_NBMAND",
151+
[44] = "F_SETLK64_NBMAND",
152+
[45] = "F_GETXFL",
153+
[46] = "F_BADFD",
154+
[47] = "F_OFD_GETLK",
155+
[48] = "F_OFD_SETLK",
156+
[49] = "F_OFD_SETLKW",
157+
[50] = "F_OFD_GETLK64",
158+
[51] = "F_OFD_SETLK64",
159+
[52] = "F_OFD_SETLKW64",
160+
[53] = "F_FLOCK",
161+
[54] = "F_FLOCKW",
162+
[55] = "F_FLOCK64",
163+
[56] = "F_FLOCKW64",
164+
[57] = "F_DUP2FD_CLOFORK",
165+
[58] = "F_DUPFD_CLOFORK",
166+
[59] = "F_DUP3FD"
171167
};
172168

173169
#define SYSFSMIN GETFSIND
@@ -2203,7 +2199,7 @@ pathconfname(int code)
22032199
#define ALL_O_FLAGS \
22042200
(O_NDELAY|O_APPEND|O_SYNC|O_DSYNC|O_NONBLOCK|O_CREAT|O_TRUNC\
22052201
|O_EXCL|O_NOCTTY|O_LARGEFILE|O_RSYNC|O_XATTR|O_NOFOLLOW|O_NOLINKS\
2206-
|O_CLOEXEC|O_DIRECTORY|O_DIRECT|FXATTRDIROPEN)
2202+
|O_CLOEXEC|O_DIRECTORY|O_DIRECT|O_CLOFORK|FXATTRDIROPEN)
22072203

22082204
const char *
22092205
openarg(private_t *pri, int arg)
@@ -2267,6 +2263,8 @@ openarg(private_t *pri, int arg)
22672263
(void) strlcat(str, "|O_DIRECTORY", sizeof (pri->code_buf));
22682264
if (arg & O_DIRECT)
22692265
(void) strlcat(str, "|O_DIRECT", sizeof (pri->code_buf));
2266+
if (arg & O_CLOFORK)
2267+
(void) strlcat(str, "|O_CLOFORK", sizeof (pri->code_buf));
22702268
if (arg & FXATTRDIROPEN)
22712269
(void) strlcat(str, "|FXATTRDIROPEN", sizeof (pri->code_buf));
22722270

usr/src/cmd/truss/expound.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,15 @@ show_ffg(private_t *pri)
18131813
(void) puts(pri->sys_string);
18141814
}
18151815

1816+
void
1817+
show_ffd(private_t *pri)
1818+
{
1819+
(void) putchar('\t');
1820+
(void) putchar('\t');
1821+
prt_ffd(pri, 0, pri->Rval1);
1822+
(void) puts(pri->sys_string);
1823+
}
1824+
18161825
/* print values in fcntl() pointed-to structure */
18171826
void
18181827
show_fcntl(private_t *pri)
@@ -1824,6 +1833,11 @@ show_fcntl(private_t *pri)
18241833
return;
18251834
}
18261835

1836+
if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFD) {
1837+
show_ffd(pri);
1838+
return;
1839+
}
1840+
18271841
if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == 0)
18281842
return;
18291843

0 commit comments

Comments
 (0)