version 1.12, 2008/04/24 18:39:23 |
version 1.12.10.1, 2009/01/19 13:19:38 |
|
|
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
__KERNEL_RCSID(0, "$NetBSD$"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
#include "opt_coredump.h" |
|
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/vnode.h> |
#include <sys/vnode.h> |
#include <sys/namei.h> |
#include <sys/namei.h> |
Line 51 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 49 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/exec.h> |
#include <sys/exec.h> |
#include <sys/filedesc.h> |
#include <sys/filedesc.h> |
#include <sys/kauth.h> |
#include <sys/kauth.h> |
|
#include <sys/module.h> |
|
|
#if !defined(COREDUMP) |
MODULE(MODULE_CLASS_MISC, coredump, NULL); |
|
|
int |
|
coredump(struct lwp *l, const char *pattern) |
|
{ |
|
|
|
return (ENOSYS); |
|
} |
|
|
|
#else /* COREDUMP */ |
|
|
|
struct coredump_iostate { |
struct coredump_iostate { |
struct lwp *io_lwp; |
struct lwp *io_lwp; |
Line 70 struct coredump_iostate { |
|
Line 60 struct coredump_iostate { |
|
off_t io_offset; |
off_t io_offset; |
}; |
}; |
|
|
|
static int coredump(struct lwp *, const char *); |
static int coredump_buildname(struct proc *, char *, const char *, size_t); |
static int coredump_buildname(struct proc *, char *, const char *, size_t); |
|
|
|
static int |
|
coredump_modcmd(modcmd_t cmd, void *arg) |
|
{ |
|
|
|
switch (cmd) { |
|
case MODULE_CMD_INIT: |
|
coredump_vec = coredump; |
|
return 0; |
|
case MODULE_CMD_FINI: |
|
/* |
|
* In theory we don't need to patch this, as the various |
|
* exec formats depend on this module. If this module has |
|
* no references, and so can be unloaded, no user programs |
|
* can be running and so nothing can call *coredump_vec. |
|
*/ |
|
coredump_vec = (int (*)(struct lwp *, const char *))enosys; |
|
return 0; |
|
default: |
|
return ENOTTY; |
|
} |
|
} |
|
|
/* |
/* |
* Dump core, into a file named "progname.core" or "core" (depending on the |
* Dump core, into a file named "progname.core" or "core" (depending on the |
* value of shortcorename), unless the process was setuid/setgid. |
* value of shortcorename), unless the process was setuid/setgid. |
*/ |
*/ |
int |
static int |
coredump(struct lwp *l, const char *pattern) |
coredump(struct lwp *l, const char *pattern) |
{ |
{ |
struct vnode *vp; |
struct vnode *vp; |
Line 227 coredump_buildname(struct proc *p, char |
|
Line 240 coredump_buildname(struct proc *p, char |
|
p->p_pgrp->pg_session->s_login); |
p->p_pgrp->pg_session->s_login); |
break; |
break; |
case 't': |
case 't': |
i = snprintf(d, end - d, "%ld", |
i = snprintf(d, end - d, "%lld", |
p->p_stats->p_start.tv_sec); |
(long long)p->p_stats->p_start.tv_sec); |
break; |
break; |
default: |
default: |
goto copy; |
goto copy; |
Line 267 coredump_write(void *cookie, enum uio_se |
|
Line 280 coredump_write(void *cookie, enum uio_se |
|
io->io_offset += len; |
io->io_offset += len; |
return (0); |
return (0); |
} |
} |
|
|
#endif /* COREDUMP */ |
|