Print this page
NEX-9338 improve the layout of the crash directory (use sys/uuid.h)
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-9338 improve the layout of the crash directory (follow-up)
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-9338 improve the layout of the crash directory
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Steve Peng <steve.peng@nexenta.com>
@@ -19,10 +19,11 @@
* CDDL HEADER END
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Panic software-diagnosis subsidiary
*
@@ -82,12 +83,12 @@
* we are prepared to wait.
*/
#include <strings.h>
#include <sys/panic.h>
-#include <alloca.h>
#include <zone.h>
+#include <uuid/uuid.h>
#include "../../common/sw.h"
#include "panic.h"
#define MAX_STRING_LEN 160
@@ -194,11 +195,12 @@
static void
swde_panic_solve(fmd_hdl_t *hdl, fmd_case_t *cp,
nvlist_t *attr, fmd_event_t *ep, boolean_t savecore_success)
{
- char *dumpdir, *path, *uuid;
+ char path[MAXPATHLEN];
+ char *dumpdir, *uuid;
nvlist_t *defect, *rsrc;
nvpair_t *nvp;
int i;
/*
@@ -227,26 +229,15 @@
* as duplicates and discard later cases. We can't actually diagnose
* the panic to anything specific (e.g., a path to a module and
* function/line etc therein). We could pick on a generic
* representative such as /kernel/genunix but that could lead
* to misunderstanding. So we choose a path based on <dumpdir>
- * and the OS instance UUID - "<dumpdir>/.<os-instance-uuid>".
- * There's no file at that path (*) but no matter. We can't use
- * <dumpdir>/vmdump.N or similar because if savecore is disabled
- * or failed we don't have any file or instance number.
- *
- * (*) Some day it would seem tidier to keep all files to do
- * with a single crash (unix/vmcore/vmdump, analysis output etc)
- * in a distinct directory, and <dumpdir>/.<uuid> seems like a good
- * choice. For compatability we'd symlink into it. So that is
- * another reason for this choice - some day it may exist!
+ * and the OS instance UUID - "<dumpdir>/data/<uuid>".
*/
(void) nvlist_lookup_string(attr, "dumpdir", &dumpdir);
(void) nvlist_lookup_string(attr, "os-instance-uuid", &uuid);
- path = alloca(strlen(dumpdir) + 1 + 1 + 36 + 1);
- /* LINTED: E_SEC_SPRINTF_UNBOUNDED_COPY */
- (void) sprintf(path, "%s/.%s", dumpdir, uuid);
+ (void) snprintf(path, sizeof (path), "%s/data/%s", dumpdir, uuid);
rsrc = panic_sw_fmri(hdl, path);
defect = fmd_nvl_create_defect(hdl, SW_SUNOS_PANIC_DEFECT,
100, rsrc, NULL, rsrc);
nvlist_free(rsrc);