procfs_map.c (83366) | procfs_map.c (87321) |
---|---|
1/* 2 * Copyright (c) 1993 Jan-Simon Pendry 3 * Copyright (c) 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Jan-Simon Pendry. 8 * --- 22 unchanged lines hidden (view full) --- 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)procfs_status.c 8.3 (Berkeley) 2/17/94 38 * | 1/* 2 * Copyright (c) 1993 Jan-Simon Pendry 3 * Copyright (c) 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Jan-Simon Pendry. 8 * --- 22 unchanged lines hidden (view full) --- 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)procfs_status.c 8.3 (Berkeley) 2/17/94 38 * |
39 * $FreeBSD: head/sys/fs/procfs/procfs_map.c 83366 2001-09-12 08:38:13Z julian $ | 39 * $FreeBSD: head/sys/fs/procfs/procfs_map.c 87321 2001-12-04 01:35:06Z des $ |
40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/lock.h> 45#include <sys/mutex.h> 46#include <sys/proc.h> | 40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/lock.h> 45#include <sys/mutex.h> 46#include <sys/proc.h> |
47#include <sys/vnode.h> | 47#include <sys/uio.h> |
48 | 48 |
49#include <fs/pseudofs/pseudofs.h> |
|
49#include <fs/procfs/procfs.h> 50 51#include <vm/vm.h> 52#include <vm/pmap.h> 53#include <vm/vm_map.h> 54#include <vm/vm_page.h> 55#include <vm/vm_object.h> 56 --- 6 unchanged lines hidden (view full) --- 63 * a program that can sense the required size of the buffer, and then 64 * subsequently do a read with the appropriate size. This operation cannot 65 * be atomic. The best that we can do is to allow the program to do a read 66 * with an arbitrarily large buffer, and return as much as we can. We can 67 * return an error code if the buffer is too small (EFBIG), then the program 68 * can try a bigger buffer. 69 */ 70int | 50#include <fs/procfs/procfs.h> 51 52#include <vm/vm.h> 53#include <vm/pmap.h> 54#include <vm/vm_map.h> 55#include <vm/vm_page.h> 56#include <vm/vm_object.h> 57 --- 6 unchanged lines hidden (view full) --- 64 * a program that can sense the required size of the buffer, and then 65 * subsequently do a read with the appropriate size. This operation cannot 66 * be atomic. The best that we can do is to allow the program to do a read 67 * with an arbitrarily large buffer, and return as much as we can. We can 68 * return an error code if the buffer is too small (EFBIG), then the program 69 * can try a bigger buffer. 70 */ 71int |
71procfs_domap(curp, p, pfs, uio) 72 struct proc *curp; 73 struct proc *p; 74 struct pfsnode *pfs; 75 struct uio *uio; | 72procfs_doprocmap(PFS_FILL_ARGS) |
76{ 77 int len; 78 int error; 79 vm_map_t map = &p->p_vmspace->vm_map; 80 pmap_t pmap = vmspace_pmap(p->p_vmspace); 81 vm_map_entry_t entry; 82 char mebuffer[MEBUFFERSIZE]; 83 84 GIANT_REQUIRED; 85 86 if (uio->uio_rw != UIO_READ) 87 return (EOPNOTSUPP); 88 89 if (uio->uio_offset != 0) 90 return (0); 91 92 error = 0; | 73{ 74 int len; 75 int error; 76 vm_map_t map = &p->p_vmspace->vm_map; 77 pmap_t pmap = vmspace_pmap(p->p_vmspace); 78 vm_map_entry_t entry; 79 char mebuffer[MEBUFFERSIZE]; 80 81 GIANT_REQUIRED; 82 83 if (uio->uio_rw != UIO_READ) 84 return (EOPNOTSUPP); 85 86 if (uio->uio_offset != 0) 87 return (0); 88 89 error = 0; |
93 if (map != &curproc->p_vmspace->vm_map) | 90 if (map != &curthread->td_proc->p_vmspace->vm_map) |
94 vm_map_lock_read(map); 95 for (entry = map->header.next; 96 ((uio->uio_resid > 0) && (entry != &map->header)); 97 entry = entry->next) { 98 vm_object_t obj, tobj, lobj; 99 int ref_count, shadow_count, flags; 100 vm_offset_t addr; 101 int resident, privateresident; --- 11 unchanged lines hidden (view full) --- 113 resident = 0; 114 addr = entry->start; 115 while (addr < entry->end) { 116 if (pmap_extract( pmap, addr)) 117 resident++; 118 addr += PAGE_SIZE; 119 } 120 | 91 vm_map_lock_read(map); 92 for (entry = map->header.next; 93 ((uio->uio_resid > 0) && (entry != &map->header)); 94 entry = entry->next) { 95 vm_object_t obj, tobj, lobj; 96 int ref_count, shadow_count, flags; 97 vm_offset_t addr; 98 int resident, privateresident; --- 11 unchanged lines hidden (view full) --- 110 resident = 0; 111 addr = entry->start; 112 while (addr < entry->end) { 113 if (pmap_extract( pmap, addr)) 114 resident++; 115 addr += PAGE_SIZE; 116 } 117 |
121 for( lobj = tobj = obj; tobj; tobj = tobj->backing_object) | 118 for (lobj = tobj = obj; tobj; tobj = tobj->backing_object) |
122 lobj = tobj; 123 124 if (lobj) { 125 switch(lobj->type) { | 119 lobj = tobj; 120 121 if (lobj) { 122 switch(lobj->type) { |
126 127default: 128case OBJT_DEFAULT: | 123 default: 124 case OBJT_DEFAULT: |
129 type = "default"; 130 break; | 125 type = "default"; 126 break; |
131case OBJT_VNODE: | 127 case OBJT_VNODE: |
132 type = "vnode"; 133 break; | 128 type = "vnode"; 129 break; |
134case OBJT_SWAP: | 130 case OBJT_SWAP: |
135 type = "swap"; 136 break; | 131 type = "swap"; 132 break; |
137case OBJT_DEVICE: | 133 case OBJT_DEVICE: |
138 type = "device"; 139 break; 140 } 141 142 flags = obj->flags; 143 ref_count = obj->ref_count; 144 shadow_count = obj->shadow_count; 145 } else { 146 type = "none"; 147 flags = 0; 148 ref_count = 0; 149 shadow_count = 0; 150 } | 134 type = "device"; 135 break; 136 } 137 138 flags = obj->flags; 139 ref_count = obj->ref_count; 140 shadow_count = obj->shadow_count; 141 } else { 142 type = "none"; 143 flags = 0; 144 ref_count = 0; 145 shadow_count = 0; 146 } |
151 | |
152 153 /* 154 * format: 155 * start, end, resident, private resident, cow, access, type. 156 */ | 147 148 /* 149 * format: 150 * start, end, resident, private resident, cow, access, type. 151 */ |
157 snprintf(mebuffer, sizeof(mebuffer), | 152 snprintf(mebuffer, sizeof mebuffer, |
158 "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s\n", 159 (u_long)entry->start, (u_long)entry->end, 160 resident, privateresident, obj, 161 (entry->protection & VM_PROT_READ)?"r":"-", 162 (entry->protection & VM_PROT_WRITE)?"w":"-", 163 (entry->protection & VM_PROT_EXECUTE)?"x":"-", 164 ref_count, shadow_count, flags, 165 (entry->eflags & MAP_ENTRY_COW)?"COW":"NCOW", --- 4 unchanged lines hidden (view full) --- 170 if (len > uio->uio_resid) { 171 error = EFBIG; 172 break; 173 } 174 error = uiomove(mebuffer, len, uio); 175 if (error) 176 break; 177 } | 153 "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s\n", 154 (u_long)entry->start, (u_long)entry->end, 155 resident, privateresident, obj, 156 (entry->protection & VM_PROT_READ)?"r":"-", 157 (entry->protection & VM_PROT_WRITE)?"w":"-", 158 (entry->protection & VM_PROT_EXECUTE)?"x":"-", 159 ref_count, shadow_count, flags, 160 (entry->eflags & MAP_ENTRY_COW)?"COW":"NCOW", --- 4 unchanged lines hidden (view full) --- 165 if (len > uio->uio_resid) { 166 error = EFBIG; 167 break; 168 } 169 error = uiomove(mebuffer, len, uio); 170 if (error) 171 break; 172 } |
178 if (map != &curproc->p_vmspace->vm_map) | 173 if (map != &curthread->td_proc->p_vmspace->vm_map) |
179 vm_map_unlock_read(map); 180 | 174 vm_map_unlock_read(map); 175 |
181 return error; | 176 return (error); |
182} | 177} |
183 184int 185procfs_validmap(struct thread *td) 186{ 187 return ((td->td_proc->p_flag & P_SYSTEM) == 0); 188} | |