version 1.69, 1999/09/02 23:33:45 |
version 1.69.2.1, 2000/11/20 18:09:49 |
|
|
* procfs vnode interface |
* procfs vnode interface |
*/ |
*/ |
|
|
|
#if defined(_KERNEL) && !defined(_LKM) |
|
#include "opt_compat_linux.h" |
|
#endif |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
#include <sys/time.h> |
#include <sys/time.h> |
|
|
#include <sys/ptrace.h> |
#include <sys/ptrace.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
|
|
#include <vm/vm.h> /* for PAGE_SIZE */ |
#include <uvm/uvm_extern.h> /* for PAGE_SIZE */ |
|
|
#include <machine/reg.h> |
#include <machine/reg.h> |
|
|
|
|
* |
* |
*/ |
*/ |
|
|
|
#ifdef COMPAT_LINUX |
|
static int procfs_validfile_linux __P((struct proc *)); |
|
#endif |
|
|
/* |
/* |
* This is a list of the valid names in the |
* This is a list of the valid names in the |
* process-specific sub-directories. It is |
* process-specific sub-directories. It is |
Line 95 struct proc_target { |
|
Line 103 struct proc_target { |
|
{ DT_REG, N("notepg"), Pnotepg, NULL }, |
{ DT_REG, N("notepg"), Pnotepg, NULL }, |
{ DT_REG, N("map"), Pmap, procfs_validmap }, |
{ DT_REG, N("map"), Pmap, procfs_validmap }, |
{ DT_REG, N("cmdline"), Pcmdline, NULL }, |
{ DT_REG, N("cmdline"), Pcmdline, NULL }, |
|
#ifdef COMPAT_LINUX |
|
{ DT_REG, N("exe"), Pfile, procfs_validfile_linux }, |
|
#endif |
#undef N |
#undef N |
}; |
}; |
static int nproc_targets = sizeof(proc_targets) / sizeof(proc_targets[0]); |
static int nproc_targets = sizeof(proc_targets) / sizeof(proc_targets[0]); |
|
|
static pid_t atopid __P((const char *, u_int)); |
|
|
|
int procfs_lookup __P((void *)); |
int procfs_lookup __P((void *)); |
#define procfs_create genfs_eopnotsupp_rele |
#define procfs_create genfs_eopnotsupp_rele |
#define procfs_mknod genfs_eopnotsupp_rele |
#define procfs_mknod genfs_eopnotsupp_rele |
|
|
procfs_validfile(p) |
procfs_validfile(p) |
struct proc *p; |
struct proc *p; |
{ |
{ |
|
|
return (procfs_findtextvp(p) != NULLVP); |
return (procfs_findtextvp(p) != NULLVP); |
} |
} |
|
|
|
#ifdef COMPAT_LINUX |
|
static int |
|
procfs_validfile_linux(p) |
|
struct proc *p; |
|
{ |
|
return (!strcmp("linux", p->p_emul->e_name) && procfs_validfile(p)); |
|
} |
|
#endif |
|
|
/* |
/* |
* readdir returns directory entries from pfsnode (vp). |
* readdir returns directory entries from pfsnode (vp). |
* |
* |
Line 896 procfs_readdir(v) |
|
Line 913 procfs_readdir(v) |
|
|
|
if (ap->a_ncookies) { |
if (ap->a_ncookies) { |
ncookies = min(ncookies, (nproc_targets - i)); |
ncookies = min(ncookies, (nproc_targets - i)); |
MALLOC(cookies, off_t *, ncookies * sizeof (off_t), |
cookies = malloc(ncookies * sizeof (off_t), |
M_TEMP, M_WAITOK); |
M_TEMP, M_WAITOK); |
*ap->a_cookies = cookies; |
*ap->a_cookies = cookies; |
} |
} |
Line 942 procfs_readdir(v) |
|
Line 959 procfs_readdir(v) |
|
* XXX Potentially allocating too much space here, |
* XXX Potentially allocating too much space here, |
* but I'm lazy. This loop needs some work. |
* but I'm lazy. This loop needs some work. |
*/ |
*/ |
MALLOC(cookies, off_t *, ncookies * sizeof (off_t), |
cookies = malloc(ncookies * sizeof (off_t), |
M_TEMP, M_WAITOK); |
M_TEMP, M_WAITOK); |
*ap->a_cookies = cookies; |
*ap->a_cookies = cookies; |
} |
} |
Line 1024 procfs_readdir(v) |
|
Line 1041 procfs_readdir(v) |
|
if (ap->a_ncookies) { |
if (ap->a_ncookies) { |
if (error) { |
if (error) { |
if (cookies) |
if (cookies) |
FREE(*ap->a_cookies, M_TEMP); |
free(*ap->a_cookies, M_TEMP); |
*ap->a_ncookies = 0; |
*ap->a_ncookies = 0; |
*ap->a_cookies = NULL; |
*ap->a_cookies = NULL; |
} else |
} else |