Page MenuHomeFreeBSD

D33277.id99493.diff
No OneTemporary

D33277.id99493.diff

diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2
--- a/lib/libc/sys/fcntl.2
+++ b/lib/libc/sys/fcntl.2
@@ -28,7 +28,7 @@
.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
.\" $FreeBSD$
.\"
-.Dd January 6, 2021
+.Dd December 7, 2021
.Dt FCNTL 2
.Os
.Sh NAME
@@ -53,7 +53,7 @@
.Fa cmd ,
.Fn fcntl
can take an additional third argument
-.Fa "int arg" .
+.Fa "long arg" .
.Bl -tag -width F_DUP2FD_CLOEXEC
.It Dv F_DUPFD
Return a new descriptor as follows:
@@ -190,6 +190,14 @@
.Xr mount 2
or unionfs).
This is a hack not intended to be used outside of libc.
+.It Dv F_KINFO
+Fills
+.Vt struct kinfo_file
+for the file referenced by the specified file descriptor.
+The
+.Fa arg
+argument should point to the storage for
+.Vt struct kinfo_file .
.El
.Pp
The flags for the
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -477,6 +477,7 @@
struct proc *p;
struct vnode *vp;
struct mount *mp;
+ struct kinfo_file *kif;
int error, flg, seals, tmp;
uint64_t bsize;
off_t foffset;
@@ -852,6 +853,26 @@
fdrop(fp, td);
break;
+ case F_KINFO:
+#ifdef CAPABILITY_MODE
+ if (IN_CAPABILITY_MODE(td)) {
+ error = ECAPMODE;
+ break;
+ }
+#endif
+ kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK);
+ error = fget_unlocked(fdp, fd, &cap_fcntl_rights, &fp);
+ if (error == 0) {
+ error = fo_fill_kinfo(fp, kif, fdp);
+ if (error == 0) {
+ error = copyout(kif, (void *)arg,
+ sizeof(*kif));
+ }
+ fdrop(fp, td);
+ }
+ free(kif, M_TEMP);
+ break;
+
default:
error = EINVAL;
break;
diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h
--- a/sys/sys/fcntl.h
+++ b/sys/sys/fcntl.h
@@ -270,6 +270,7 @@
#define F_ADD_SEALS 19
#define F_GET_SEALS 20
#define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */
+#define F_KINFO 22 /* Return kinfo_file for this fd */
/* Seals (F_ADD_SEALS, F_GET_SEALS). */
#define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 9, 6:45 AM (1 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28549969
Default Alt Text
D33277.id99493.diff (1 KB)

Event Timeline