summaryrefslogtreecommitdiffstats
path: root/sbin/savecore
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-05-27 07:54:43 +0000
committermarcel <marcel@FreeBSD.org>2002-05-27 07:54:43 +0000
commit36a7d4b91404b3e0174fbde050a5e26230c971d7 (patch)
treeee163d4e73cf9ba53996a3e9aa01f62a04e87cc7 /sbin/savecore
parent857b1f2ee6792a10fb293e7c3d50ad4f06c9f69e (diff)
downloadFreeBSD-src-36a7d4b91404b3e0174fbde050a5e26230c971d7.zip
FreeBSD-src-36a7d4b91404b3e0174fbde050a5e26230c971d7.tar.gz
Work around a memory fault on ia64 caused by having the 1MB buffer on
the stack in DoFile(). This needs some investigation. In the mean time we do a one time malloc() for the buffer to have it on the heap instead.
Diffstat (limited to 'sbin/savecore')
-rw-r--r--sbin/savecore/savecore.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 2571334..56ee242 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -205,8 +205,8 @@ check_space(char *savedir, off_t dumpsize)
static void
DoFile(char *savedir, const char *device)
{
+ static char *buf = NULL;
struct kerneldumpheader kdhf, kdhl;
- char buf[1024 * 1024];
off_t mediasize, dumpsize, firsthd, lasthd, dmpcnt;
FILE *info, *fp;
int fd, fdinfo, error, wl;
@@ -218,6 +218,20 @@ DoFile(char *savedir, const char *device)
dmpcnt = 0;
mediasize = 0;
+ /*
+ * XXX On ia64 something breaks when the buffer is put on the
+ * stack. When the buffer is roughly larger than 128K the read()
+ * below simply fails with errno=14 (EFAULT). We work around
+ * this by doing a on-time allocation...
+ */
+ if (buf == NULL) {
+ buf = malloc(1024 * 1024);
+ if (buf == NULL) {
+ syslog(LOG_ERR, "%m");
+ return;
+ }
+ }
+
if (verbose)
printf("checking for kernel dump on device %s\n", device);
@@ -226,6 +240,7 @@ DoFile(char *savedir, const char *device)
syslog(LOG_ERR, "%s: %m", device);
return;
}
+
error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
if (!error)
error = ioctl(fd, DIOCGSECTORSIZE, &sectorsize);
OpenPOWER on IntegriCloud