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

This commit is contained in:
christos 2023-07-10 15:49:18 +00:00
parent 099e7d7953
commit d46449bb48
3 changed files with 53 additions and 7 deletions

View File

@ -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,v 1.1 2023/07/10 02:31:55 christos Exp $
#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>

47
sys/sys/miscfd.h Normal file
View File

@ -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_ */

View File

@ -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/10 02:31:55 christos Exp $");
#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>