cff12cd2e4a15543ed4842f8931899522453a060
[dragonfly.git] / sys / emulation / linux / i386 / linprocfs / linprocfs.h
blobcff12cd2e4a15543ed4842f8931899522453a060
1 /*
2 * Copyright (c) 2000 Dag-Erling Coïdan Smørgrav
3 * Copyright (c) 1999 Pierre Beyssac
4 * Copyright (c) 1993 Jan-Simon Pendry
5 * Copyright (c) 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
39 * @(#)procfs.h 8.9 (Berkeley) 5/14/95
41 * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs.h,v 1.2.2.4 2001/06/25 19:46:47 pirzyk Exp $
42 * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs.h,v 1.10 2007/02/03 09:50:49 y0netan1 Exp $
46 * The different types of node in a procfs filesystem
48 typedef enum {
49 Proot, /* the filesystem root */
50 Pself, /* symbolic link for curproc */
51 Pproc, /* a process-specific sub-directory */
52 Pexe, /* the executable file */
53 Pmem, /* the process's memory image */
54 Pprocstat, /* the process's status */
55 Pprocstatus, /* the process's status (again) */
56 Pmeminfo, /* memory system statistics */
57 Pcpuinfo, /* CPU model, speed and features */
58 Pstat, /* kernel/system statistics */
59 Puptime, /* system uptime */
60 Pversion, /* system version */
61 Ploadavg /* system load average */
62 } pfstype;
65 * control data for the proc file system.
67 struct pfsnode {
68 struct pfsnode *pfs_next; /* next on list */
69 struct vnode *pfs_vnode; /* vnode associated with this pfsnode */
70 pfstype pfs_type; /* type of procfs node */
71 pid_t pfs_pid; /* associated process */
72 u_short pfs_mode; /* mode bits for stat() */
73 u_long pfs_flags; /* open flags */
74 u_long pfs_fileno; /* unique file id */
75 struct thread *pfs_lockowner; /* pfs lock owner */
78 #define PROCFS_NAMELEN 8 /* max length of a filename component */
81 * Kernel stuff follows
83 #ifdef _KERNEL
84 #define CNEQ(cnp, s, len) \
85 ((cnp)->cn_namelen == (len) && \
86 (bcmp((s), (cnp)->cn_nameptr, (len)) == 0))
88 #define KMEM_GROUP 2
90 #define PROCFS_FILENO(pid, type) \
91 (((type) < Pproc) ? \
92 ((type) + 2) : \
93 ((((pid)+1) << 4) + ((int) (type))))
96 * Convert between pfsnode vnode
98 #define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data)
99 #define PFSTOV(pfs) ((pfs)->pfs_vnode)
101 typedef struct vfs_namemap vfs_namemap_t;
102 struct vfs_namemap {
103 const char *nm_name;
104 int nm_val;
107 int vfs_getuserstr (struct uio *, char *, int *);
108 vfs_namemap_t *vfs_findname (vfs_namemap_t *, char *, int);
110 /* <sys/reg.h> */
111 struct reg;
112 struct fpreg;
113 struct dbreg;
115 #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
117 void linprocfs_init (void);
118 void linprocfs_exit (struct thread *);
119 int linprocfs_freevp (struct vnode *);
120 int linprocfs_allocvp (struct mount *, struct vnode **, long, pfstype);
121 int linprocfs_sstep (struct proc *);
122 void linprocfs_fix_sstep (struct proc *);
123 #if 0
124 int linprocfs_read_regs (struct proc *, struct reg *);
125 int linprocfs_write_regs (struct proc *, struct reg *);
126 int linprocfs_read_fpregs (struct proc *, struct fpreg *);
127 int linprocfs_write_fpregs (struct proc *, struct fpreg *);
128 int linprocfs_read_dbregs (struct proc *, struct dbreg *);
129 int linprocfs_write_dbregs (struct proc *, struct dbreg *);
130 #endif
131 int linprocfs_domeminfo (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
132 int linprocfs_docpuinfo (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
133 int linprocfs_dostat (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
134 int linprocfs_douptime (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
135 int linprocfs_doversion (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
136 int linprocfs_doprocstat (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
137 int linprocfs_doprocstatus (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
138 int linprocfs_doloadavg (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio);
140 /* functions to check whether or not files should be displayed */
141 int linprocfs_validfile (struct proc *);
143 #define PROCFS_LOCKED 0x01
144 #define PROCFS_WANT 0x02
146 int linprocfs_root (struct mount *, struct vnode **);
147 int linprocfs_rw (struct vop_read_args *);
148 #endif /* _KERNEL */