Fix a bug when '-f -H' is used and the target already exists. cpdup was
[dragonfly.git] / sys / vm / vm_vmspace.c
1 /*
2  * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
3  * 
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  * 
34  * $DragonFly: src/sys/vm/vm_vmspace.c,v 1.1 2006/09/03 17:11:51 dillon Exp $
35  */
36
37 #include <sys/param.h>
38 #include <sys/kernel.h>
39 #include <sys/systm.h>
40 #include <sys/sysproto.h>
41
42 /*
43  * vmspace_ctl {void *id, void *ctx, int what }
44  *
45  * Create, destroy, or execute a VM space.  This functions returns when
46  * the VM space has run for a specified period of time, a signal occurs,
47  * or the VM space traps or makes a system call.
48  *
49  * Execution of a VM space is accomplished by swapping out the caller's
50  * current VM space.  Any signal or condition applicable to the caller
51  * will swap the caller's VM space back in for processing, then return
52  * EINTR.  A trap, system call, or page fault in the VM space will swap
53  * the caller's VM space back in, adjust the context, and return the
54  * appropriate code.
55  *
56  * A virtual kernel manages multiple 'process' VM spaces this way, the
57  * real kernel only sees only the processes representing the virtual kernel
58  * itself, typically one per virtual cpu.
59  */
60 int
61 sys_vmspace_ctl(struct vmspace_ctl_args *uap)
62 {
63         return (EINVAL);
64 }
65
66 /*
67  * vmspace_map { void *id, off_t offset, void *ptr, int bytes, int prot }
68  *
69  * Map pages backing the specified memory in the caller's context into
70  * the specified VM space and reduce their protection using 'prot'.  A
71  * protection value of 0 removes the page mapping.  Page mappings can be
72  * removed by the kernel at any time and cause execution of the VM space
73  * to return with VMSPACE_PAGEFAULT.
74  */
75 int
76 sys_vmspace_map(struct vmspace_map_args *uap)
77 {
78         return (EINVAL);
79 }
80
81 /*
82  * vmspace_protect { void *id, off_t offset, int bytes, int prot }
83  *
84  * Adjust the protection of mapped pages in the specified VM context.  Pages
85  * that are not mapped or whos mapping was removed by the kernel are not
86  * effected.
87  */
88 int
89 sys_vmspace_protect(struct vmspace_protect_args *uap)
90 {
91         return (EINVAL);
92 }
93
94 /*
95  * vmspace_read { void *id, void *ptr, int bytes }
96  *
97  * Read data from the VM space.  Only data in mapped pages can be read.  If
98  * an unmapped page is encountered this function will return fewer then the
99  * requested number of bytes and the caller must map the additional pages
100  * before restarting the call.
101  */
102 int
103 sys_vmspace_read(struct vmspace_read_args *uap)
104 {
105         return (EINVAL);
106 }
107
108 /*
109  * vmspace_write { void *id, const void *ptr, int bytes }
110  *
111  * Write data to the VM space.  Only mapped, writable pages can be written.
112  * If an unmapped or read-only page is encountered this function will return
113  * fewer then the requested number of bytes and the caller must map the
114  * additional pages before restarting the call.
115  */
116 int
117 sys_vmspace_write(struct vmspace_write_args *uap)
118 {
119         return (EINVAL);
120 }
121