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