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 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)procfs.h 8.6 (Berkeley) 02/03/94 12 * 13 * From: 14 * $Id: procfs.h,v 3.2 1993/12/15 09:40:17 jsp Exp $ 15 */ 16 17 /* 18 * The different types of node in a procfs filesystem 19 */ 20 typedef enum { 21 Proot, /* the filesystem root */ 22 Pproc, /* a process-specific sub-directory */ 23 Pfile, /* the executable file */ 24 Pmem, /* the process's memory image */ 25 Pregs, /* the process's register set */ 26 Pfpregs, /* the process's FP register set */ 27 Pctl, /* process control */ 28 Pstatus, /* process status */ 29 Pnote, /* process notifier */ 30 Pnotepg /* process group notifier */ 31 } pfstype; 32 33 /* 34 * control data for the proc file system. 35 */ 36 struct pfsnode { 37 struct pfsnode *pfs_next; /* next on list */ 38 struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ 39 pfstype pfs_type; /* type of procfs node */ 40 pid_t pfs_pid; /* associated process */ 41 u_short pfs_mode; /* mode bits for stat() */ 42 u_long pfs_flags; /* open flags */ 43 u_long pfs_fileno; /* unique file id */ 44 }; 45 46 #define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */ 47 #define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */ 48 49 /* 50 * Kernel stuff follows 51 */ 52 #ifdef KERNEL 53 #define CNEQ(cnp, s, len) \ 54 ((cnp)->cn_namelen == (len) && \ 55 (bcmp((s), (cnp)->cn_nameptr, (len)) == 0)) 56 57 /* 58 * Format of a directory entry in /proc, ... 59 * This must map onto struct dirent (see <dirent.h>) 60 */ 61 #define PROCFS_NAMELEN 8 62 struct pfsdent { 63 u_long d_fileno; 64 u_short d_reclen; 65 u_char d_type; 66 u_char d_namlen; 67 char d_name[PROCFS_NAMELEN]; 68 }; 69 #define UIO_MX sizeof(struct pfsdent) 70 #define PROCFS_FILENO(pid, type) \ 71 (((type) == Proot) ? \ 72 2 : \ 73 ((((pid)+1) << 3) + ((int) (type)))) 74 75 /* 76 * Convert between pfsnode vnode 77 */ 78 #define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) 79 #define PFSTOV(pfs) ((pfs)->pfs_vnode) 80 81 typedef struct vfs_namemap vfs_namemap_t; 82 struct vfs_namemap { 83 const char *nm_name; 84 int nm_val; 85 }; 86 87 extern int vfs_getuserstr __P((struct uio *, char *, int *)); 88 extern vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int)); 89 90 /* <machine/reg.h> */ 91 struct reg; 92 struct fpreg; 93 94 #define PFIND(pid) ((pid) ? pfind(pid) : &proc0) 95 extern int procfs_freevp __P((struct vnode *)); 96 extern int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); 97 extern struct vnode *procfs_findtextvp __P((struct proc *)); 98 extern int procfs_sstep __P((struct proc *)); 99 extern void procfs_fix_sstep __P((struct proc *)); 100 extern int procfs_read_regs __P((struct proc *, struct reg *)); 101 extern int procfs_write_regs __P((struct proc *, struct reg *)); 102 extern int procfs_read_fpregs __P((struct proc *, struct fpreg *)); 103 extern int procfs_write_fpregs __P((struct proc *, struct fpreg *)); 104 extern int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 105 extern int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 106 extern int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 107 extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 108 extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 109 extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 110 111 #define PROCFS_LOCKED 0x01 112 #define PROCFS_WANT 0x02 113 114 extern int (**procfs_vnodeop_p)(); 115 extern struct vfsops procfs_vfsops; 116 117 /* 118 * Prototypes for procfs vnode ops 119 */ 120 int procfs_badop(); /* varargs */ 121 int procfs_rw __P((struct vop_read_args *)); 122 int procfs_lookup __P((struct vop_lookup_args *)); 123 #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop) 124 #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop) 125 int procfs_open __P((struct vop_open_args *)); 126 int procfs_close __P((struct vop_close_args *)); 127 int procfs_access __P((struct vop_access_args *)); 128 int procfs_getattr __P((struct vop_getattr_args *)); 129 int procfs_setattr __P((struct vop_setattr_args *)); 130 #define procfs_read procfs_rw 131 #define procfs_write procfs_rw 132 int procfs_ioctl __P((struct vop_ioctl_args *)); 133 #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop) 134 #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop) 135 #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop) 136 #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop) 137 #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop) 138 #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop) 139 #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop) 140 #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop) 141 #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop) 142 #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop) 143 int procfs_readdir __P((struct vop_readdir_args *)); 144 #define procfs_readlink ((int (*) __P((struct vop_readlink_args *))) procfs_badop) 145 int procfs_abortop __P((struct vop_abortop_args *)); 146 int procfs_inactive __P((struct vop_inactive_args *)); 147 int procfs_reclaim __P((struct vop_reclaim_args *)); 148 #define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop) 149 #define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop) 150 int procfs_bmap __P((struct vop_bmap_args *)); 151 #define procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop) 152 int procfs_print __P((struct vop_print_args *)); 153 #define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop) 154 #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop) 155 #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop) 156 #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop) 157 #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop) 158 #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop) 159 #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop) 160 #endif /* KERNEL */ 161