Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src move the memfd struct to a separate file. Requested by riast...



details:   https://anonhg.NetBSD.org/src/rev/bba15f64f391
branches:  trunk
changeset: 377396:bba15f64f391
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jul 10 15:49:18 2023 +0000

description:
move the memfd struct to a separate file. Requested by riastradh@

diffstat:

 sys/kern/sys_memfd.c |   5 +++--
 sys/sys/miscfd.h     |  47 +++++++++++++++++++++++++++++++++++++++++++++++
 usr.bin/fstat/misc.c |   8 +++-----
 3 files changed, 53 insertions(+), 7 deletions(-)

diffs (106 lines):

diff -r 6423b78fc4c0 -r bba15f64f391 sys/kern/sys_memfd.c
--- a/sys/kern/sys_memfd.c      Mon Jul 10 14:13:19 2023 +0000
+++ b/sys/kern/sys_memfd.c      Mon Jul 10 15:49:18 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_memfd.c,v 1.1 2023/07/10 02:31:55 christos Exp $   */
+/*     $NetBSD: sys_memfd.c,v 1.2 2023/07/10 15:49:18 christos Exp $   */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_memfd.c,v 1.1 2023/07/10 02:31:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_memfd.c,v 1.2 2023/07/10 15:49:18 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -38,6 +38,7 @@
 #include <sys/file.h>
 #include <sys/filedesc.h>
 #include <sys/mman.h>
+#include <sys/miscfd.h>
 #include <sys/syscallargs.h>
 
 #include <uvm/uvm_extern.h>
diff -r 6423b78fc4c0 -r bba15f64f391 sys/sys/miscfd.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/sys/miscfd.h  Mon Jul 10 15:49:18 2023 +0000
@@ -0,0 +1,47 @@
+/*     $NetBSD: miscfd.h,v 1.1 2023/07/10 15:49:19 christos Exp $      */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _SYS_MISCFD_H_
+#define _SYS_MISCFD_H_
+
+#include <sys/syslimits.h>     /* for NAME_MAX */
+#include <sys/timespec.h>      /* for struct timespec */
+#include <sys/mutex.h>         /* for kmutex_t */
+
+struct memfd {
+       char                    mfd_name[NAME_MAX+1];
+       struct uvm_object       *mfd_uobj;
+       size_t                  mfd_size;
+       int                     mfd_seals;
+       kmutex_t                mfd_lock;       /* for truncate */
+
+       struct timespec         mfd_btime;
+       struct timespec         mfd_atime;
+       struct timespec         mfd_mtime;
+};
+
+#endif /* _SYS_MISCFD_H_ */
diff -r 6423b78fc4c0 -r bba15f64f391 usr.bin/fstat/misc.c
--- a/usr.bin/fstat/misc.c      Mon Jul 10 14:13:19 2023 +0000
+++ b/usr.bin/fstat/misc.c      Mon Jul 10 15:49:18 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.25 2023/07/10 02:31:55 christos Exp $       */
+/*     $NetBSD: misc.c,v 1.26 2023/07/10 15:49:19 christos Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: misc.c,v 1.25 2023/07/10 02:31:55 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.26 2023/07/10 15:49:19 christos Exp $");
 
 #include <stdbool.h>
 #include <sys/param.h>
@@ -56,9 +56,7 @@
 #undef _KERNEL
 #include <sys/cprng.h>
 #include <sys/vnode.h>
-#define _KERNEL
-#include <sys/mman.h>
-#undef _KERNEL
+#include <sys/miscfd.h>
 #include <sys/mount.h>
 
 #include <net/bpfdesc.h>



Home | Main Index | Thread Index | Old Index