165520Spendry /* 265520Spendry * Copyright (c) 1993 The Regents of the University of California. 365520Spendry * Copyright (c) 1993 Jan-Simon Pendry 465520Spendry * All rights reserved. 565520Spendry * 665520Spendry * This code is derived from software contributed to Berkeley by 765520Spendry * Jan-Simon Pendry. 865520Spendry * 965520Spendry * %sccs.include.redist.c% 1065520Spendry * 11*65531Spendry * @(#)procfs.h 8.2 (Berkeley) 01/05/94 1265520Spendry * 1365520Spendry * From: 1465520Spendry * $Id: procfs.h,v 3.2 1993/12/15 09:40:17 jsp Exp $ 1565520Spendry */ 1665520Spendry 1765520Spendry /* 1865520Spendry * The different types of node in a procfs filesystem 1965520Spendry */ 2065520Spendry typedef enum { 2165520Spendry Proot, /* the filesystem root */ 2265520Spendry Pproc, /* a process-specific sub-directory */ 2365520Spendry Pfile, /* the executable file */ 2465520Spendry Pmem, /* the process's memory image */ 2565520Spendry Pregs, /* the process's register set */ 2665520Spendry Pctl, /* process control */ 2765520Spendry Pstatus, /* process status */ 2865520Spendry Pnote, /* process notifier */ 2965520Spendry Pnotepg /* process group notifier */ 3065520Spendry } pfstype; 3165520Spendry 3265520Spendry /* 3365520Spendry * control data for the proc file system. 3465520Spendry */ 3565520Spendry struct pfsnode { 3665520Spendry struct pfsnode *pfs_next; /* next on list */ 3765520Spendry struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ 3865520Spendry pfstype pfs_type; /* type of procfs node */ 3965520Spendry pid_t pfs_pid; /* associated process */ 4065520Spendry u_short pfs_mode; /* mode bits for stat() */ 4165520Spendry u_long pfs_flags; /* open flags */ 4265520Spendry u_long pfs_fileno; /* unique file id */ 4365520Spendry }; 4465520Spendry 4565520Spendry #define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */ 4665520Spendry #define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */ 4765520Spendry 4865520Spendry /* 4965520Spendry * Kernel stuff follows 5065520Spendry */ 5165520Spendry #ifdef KERNEL 5265520Spendry #define CNEQ(cnp, s, len) \ 5365520Spendry ((cnp)->cn_namelen == (len) && \ 5465520Spendry (bcmp((s), (cnp)->cn_nameptr, (len)) == 0)) 5565520Spendry 5665520Spendry /* 5765520Spendry * Format of a directory entry in /proc, ... 5865520Spendry * This must map onto struct dirent (see <dirent.h>) 5965520Spendry */ 6065520Spendry #define PROCFS_NAMELEN 8 6165520Spendry struct pfsdent { 6265520Spendry u_long d_fileno; 6365520Spendry u_short d_reclen; 6465520Spendry u_char d_type; 6565520Spendry u_char d_namlen; 6665520Spendry char d_name[PROCFS_NAMELEN]; 6765520Spendry }; 6865520Spendry #define UIO_MX sizeof(struct pfsdent) 6965520Spendry #define PROCFS_FILENO(pid, type) \ 7065520Spendry (((type) == Proot) ? \ 7165520Spendry 2 : \ 7265520Spendry ((((pid)+1) << 3) + ((int) (type)))) 7365520Spendry 7465520Spendry /* 7565520Spendry * Convert between pfsnode vnode 7665520Spendry */ 7765520Spendry #define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) 7865520Spendry #define PFSTOV(pfs) ((pfs)->pfs_vnode) 7965520Spendry 8065520Spendry typedef struct vfs_namemap vfs_namemap_t; 8165520Spendry struct vfs_namemap { 8265520Spendry const char *nm_name; 8365520Spendry int nm_val; 8465520Spendry }; 8565520Spendry 8665520Spendry extern int vfs_getuserstr __P((struct uio *, char *, int *)); 8765520Spendry extern vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int)); 8865520Spendry 8965520Spendry /* <machine/reg.h> */ 9065520Spendry struct reg; 9165520Spendry 9265520Spendry #define PFIND(pid) ((pid) ? pfind(pid) : &proc0) 9365520Spendry extern int procfs_freevp __P((struct vnode *)); 9465520Spendry extern int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); 9565520Spendry extern struct vnode *procfs_findtextvp __P((struct proc *)); 9665520Spendry extern int procfs_sstep __P((struct proc *)); 97*65531Spendry extern void procfs_fix_sstep __P((struct proc *)); 9865520Spendry extern int procfs_read_regs __P((struct proc *, struct reg *)); 9965520Spendry extern int procfs_write_regs __P((struct proc *, struct reg *)); 10065520Spendry extern int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 10165520Spendry extern int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 10265520Spendry extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 10365520Spendry extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 10465520Spendry extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); 10565520Spendry 10665520Spendry #define PROCFS_LOCKED 0x01 10765520Spendry #define PROCFS_WANT 0x02 10865520Spendry 10965520Spendry extern int (**procfs_vnodeop_p)(); 11065520Spendry extern struct vfsops procfs_vfsops; 11165520Spendry 11265520Spendry /* 11365520Spendry * Prototypes for procfs vnode ops 11465520Spendry */ 11565520Spendry int procfs_badop(); /* varargs */ 11665520Spendry int procfs_rw __P((struct vop_read_args *)); 11765520Spendry int procfs_lookup __P((struct vop_lookup_args *)); 11865520Spendry #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop) 11965520Spendry #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop) 12065520Spendry int procfs_open __P((struct vop_open_args *)); 12165520Spendry int procfs_close __P((struct vop_close_args *)); 12265520Spendry int procfs_access __P((struct vop_access_args *)); 12365520Spendry int procfs_getattr __P((struct vop_getattr_args *)); 12465520Spendry int procfs_setattr __P((struct vop_setattr_args *)); 12565520Spendry #define procfs_read procfs_rw 12665520Spendry #define procfs_write procfs_rw 12765520Spendry int procfs_ioctl __P((struct vop_ioctl_args *)); 12865520Spendry #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop) 12965520Spendry #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop) 13065520Spendry #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop) 13165520Spendry #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop) 13265520Spendry #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop) 13365520Spendry #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop) 13465520Spendry #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop) 13565520Spendry #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop) 13665520Spendry #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop) 13765520Spendry #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop) 13865520Spendry int procfs_readdir __P((struct vop_readdir_args *)); 13965520Spendry #define procfs_readlink ((int (*) __P((struct vop_readlink_args *))) procfs_badop) 14065520Spendry int procfs_abortop __P((struct vop_abortop_args *)); 14165520Spendry int procfs_inactive __P((struct vop_inactive_args *)); 14265520Spendry int procfs_reclaim __P((struct vop_reclaim_args *)); 14365520Spendry #define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop) 14465520Spendry #define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop) 14565520Spendry int procfs_bmap __P((struct vop_bmap_args *)); 14665520Spendry #define procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop) 14765520Spendry int procfs_print __P((struct vop_print_args *)); 14865520Spendry #define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop) 14965520Spendry #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop) 15065520Spendry #define procfs_pathconf ((int (*) __P((struct vop_pathconf_args *))) procfs_badop) 15165520Spendry #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop) 15265520Spendry #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop) 15365520Spendry #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop) 15465520Spendry #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop) 15565520Spendry #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop) 15665520Spendry #endif /* KERNEL */ 157