Module Name: src Committed By: christos Date: Mon Jul 10 15:49:19 UTC 2023
Modified Files: src/sys/kern: sys_memfd.c src/usr.bin/fstat: misc.c Added Files: src/sys/sys: miscfd.h Log Message: move the memfd struct to a separate file. Requested by riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/kern/sys_memfd.c cvs rdiff -u -r0 -r1.1 src/sys/sys/miscfd.h cvs rdiff -u -r1.25 -r1.26 src/usr.bin/fstat/misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_memfd.c diff -u src/sys/kern/sys_memfd.c:1.1 src/sys/kern/sys_memfd.c:1.2 --- src/sys/kern/sys_memfd.c:1.1 Sun Jul 9 22:31:55 2023 +++ src/sys/kern/sys_memfd.c Mon Jul 10 11:49:18 2023 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: sys_memfd.c, #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> Index: src/usr.bin/fstat/misc.c diff -u src/usr.bin/fstat/misc.c:1.25 src/usr.bin/fstat/misc.c:1.26 --- src/usr.bin/fstat/misc.c:1.25 Sun Jul 9 22:31:55 2023 +++ src/usr.bin/fstat/misc.c Mon Jul 10 11:49:19 2023 @@ -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 @@ __RCSID("$NetBSD: misc.c,v 1.25 2023/07/ #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> Added files: Index: src/sys/sys/miscfd.h diff -u /dev/null src/sys/sys/miscfd.h:1.1 --- /dev/null Mon Jul 10 11:49:19 2023 +++ src/sys/sys/miscfd.h Mon Jul 10 11:49:19 2023 @@ -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_ */