procfs.c (113617) | procfs.c (123247) |
---|---|
1/* 2 * Copyright (c) 2001 Dag-Erling Sm�rgrav 3 * Copyright (c) 1993 Jan-Simon Pendry 4 * Copyright (c) 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Jan-Simon Pendry. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95 39 * | 1/* 2 * Copyright (c) 2001 Dag-Erling Sm�rgrav 3 * Copyright (c) 1993 Jan-Simon Pendry 4 * Copyright (c) 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Jan-Simon Pendry. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95 39 * |
40 * $FreeBSD: head/sys/fs/procfs/procfs.c 113617 2003-04-17 22:12:12Z jhb $ | 40 * $FreeBSD: head/sys/fs/procfs/procfs.c 123247 2003-12-07 17:40:00Z des $ |
41 */ 42 43#include <sys/param.h> 44#include <sys/queue.h> 45#include <sys/exec.h> 46#include <sys/lock.h> 47#include <sys/kernel.h> 48#include <sys/malloc.h> --- 39 unchanged lines hidden (view full) --- 88} 89 90/* 91 * Adjust mode for some nodes that need it 92 */ 93int 94procfs_attr(PFS_ATTR_ARGS) 95{ | 41 */ 42 43#include <sys/param.h> 44#include <sys/queue.h> 45#include <sys/exec.h> 46#include <sys/lock.h> 47#include <sys/kernel.h> 48#include <sys/malloc.h> --- 39 unchanged lines hidden (view full) --- 88} 89 90/* 91 * Adjust mode for some nodes that need it 92 */ 93int 94procfs_attr(PFS_ATTR_ARGS) 95{ |
96 | |
97 PROC_LOCK_ASSERT(p, MA_OWNED); 98 99 /* XXX inefficient, split into separate functions */ 100 if (p->p_flag & P_SUGID) 101 vap->va_mode = 0; 102 else if (strcmp(pn->pn_name, "ctl") == 0 || 103 strcmp(pn->pn_name, "note") == 0 || 104 strcmp(pn->pn_name, "notepg") == 0) 105 vap->va_mode = 0200; 106 else if (strcmp(pn->pn_name, "mem") == 0 || 107 strcmp(pn->pn_name, "regs") == 0 || 108 strcmp(pn->pn_name, "dbregs") == 0 || 109 strcmp(pn->pn_name, "fpregs") == 0) 110 vap->va_mode = 0600; 111 112 vap->va_uid = p->p_ucred->cr_uid; 113 vap->va_gid = p->p_ucred->cr_gid; | 96 PROC_LOCK_ASSERT(p, MA_OWNED); 97 98 /* XXX inefficient, split into separate functions */ 99 if (p->p_flag & P_SUGID) 100 vap->va_mode = 0; 101 else if (strcmp(pn->pn_name, "ctl") == 0 || 102 strcmp(pn->pn_name, "note") == 0 || 103 strcmp(pn->pn_name, "notepg") == 0) 104 vap->va_mode = 0200; 105 else if (strcmp(pn->pn_name, "mem") == 0 || 106 strcmp(pn->pn_name, "regs") == 0 || 107 strcmp(pn->pn_name, "dbregs") == 0 || 108 strcmp(pn->pn_name, "fpregs") == 0) 109 vap->va_mode = 0600; 110 111 vap->va_uid = p->p_ucred->cr_uid; 112 vap->va_gid = p->p_ucred->cr_gid; |
114 | 113 |
115 return (0); 116} 117 118/* 119 * Visibility: some files only exist for non-system processes 120 * Non-static because linprocfs uses it. 121 */ 122int --- 6 unchanged lines hidden (view full) --- 129/* 130 * Visibility: some files are only visible to process that can debug 131 * the target process. 132 */ 133int 134procfs_candebug(PFS_VIS_ARGS) 135{ 136 PROC_LOCK_ASSERT(p, MA_OWNED); | 114 return (0); 115} 116 117/* 118 * Visibility: some files only exist for non-system processes 119 * Non-static because linprocfs uses it. 120 */ 121int --- 6 unchanged lines hidden (view full) --- 128/* 129 * Visibility: some files are only visible to process that can debug 130 * the target process. 131 */ 132int 133procfs_candebug(PFS_VIS_ARGS) 134{ 135 PROC_LOCK_ASSERT(p, MA_OWNED); |
137 return ((p->p_flag & P_SYSTEM) == 0 && 138 p_candebug(td, p) == 0); | 136 return ((p->p_flag & P_SYSTEM) == 0 && p_candebug(td, p) == 0); |
139} 140 141/* 142 * Constructor 143 */ 144static int 145procfs_init(PFS_INIT_ARGS) 146{ 147 struct pfs_node *root; 148 struct pfs_node *dir; 149 struct pfs_node *node; 150 151 root = pi->pi_root; 152 153 pfs_create_link(root, "curproc", procfs_docurproc, 154 NULL, NULL, 0); | 137} 138 139/* 140 * Constructor 141 */ 142static int 143procfs_init(PFS_INIT_ARGS) 144{ 145 struct pfs_node *root; 146 struct pfs_node *dir; 147 struct pfs_node *node; 148 149 root = pi->pi_root; 150 151 pfs_create_link(root, "curproc", procfs_docurproc, 152 NULL, NULL, 0); |
155 | 153 |
156 dir = pfs_create_dir(root, "pid", 157 procfs_attr, NULL, PFS_PROCDEP); 158 pfs_create_file(dir, "cmdline", procfs_doproccmdline, 159 NULL, NULL, PFS_RD); 160 pfs_create_file(dir, "ctl", procfs_doprocctl, 161 procfs_attr, NULL, PFS_WR); 162 pfs_create_file(dir, "dbregs", procfs_doprocdbregs, 163 procfs_attr, procfs_candebug, PFS_RDWR|PFS_RAW); --- 12 unchanged lines hidden (view full) --- 176 pfs_create_file(dir, "notepg", procfs_doprocnote, 177 procfs_attr, procfs_candebug, PFS_WR); 178 pfs_create_file(dir, "regs", procfs_doprocregs, 179 procfs_attr, procfs_candebug, PFS_RDWR|PFS_RAW); 180 pfs_create_file(dir, "rlimit", procfs_doprocrlimit, 181 NULL, NULL, PFS_RD); 182 pfs_create_file(dir, "status", procfs_doprocstatus, 183 NULL, NULL, PFS_RD); | 154 dir = pfs_create_dir(root, "pid", 155 procfs_attr, NULL, PFS_PROCDEP); 156 pfs_create_file(dir, "cmdline", procfs_doproccmdline, 157 NULL, NULL, PFS_RD); 158 pfs_create_file(dir, "ctl", procfs_doprocctl, 159 procfs_attr, NULL, PFS_WR); 160 pfs_create_file(dir, "dbregs", procfs_doprocdbregs, 161 procfs_attr, procfs_candebug, PFS_RDWR|PFS_RAW); --- 12 unchanged lines hidden (view full) --- 174 pfs_create_file(dir, "notepg", procfs_doprocnote, 175 procfs_attr, procfs_candebug, PFS_WR); 176 pfs_create_file(dir, "regs", procfs_doprocregs, 177 procfs_attr, procfs_candebug, PFS_RDWR|PFS_RAW); 178 pfs_create_file(dir, "rlimit", procfs_doprocrlimit, 179 NULL, NULL, PFS_RD); 180 pfs_create_file(dir, "status", procfs_doprocstatus, 181 NULL, NULL, PFS_RD); |
184 | 182 |
185 pfs_create_link(dir, "file", procfs_doprocfile, 186 NULL, procfs_notsystem, 0); | 183 pfs_create_link(dir, "file", procfs_doprocfile, 184 NULL, procfs_notsystem, 0); |
187 | 185 |
188 return (0); 189} 190 191/* 192 * Destructor 193 */ 194static int 195procfs_uninit(PFS_INIT_ARGS) 196{ | 186 return (0); 187} 188 189/* 190 * Destructor 191 */ 192static int 193procfs_uninit(PFS_INIT_ARGS) 194{ |
197 | |
198 /* nothing to do, pseudofs will GC */ 199 return (0); 200} 201 202PSEUDOFS(procfs, 1); | 195 /* nothing to do, pseudofs will GC */ 196 return (0); 197} 198 199PSEUDOFS(procfs, 1); |