Print this page
5819 want dumpadm(1m) option to print estimated dump size


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 #include <sys/types.h>
  26 #include <sys/stat.h>
  27 #include <sys/swap.h>
  28 #include <sys/dumpadm.h>
  29 #include <sys/utsname.h>
  30 
  31 #include <unistd.h>
  32 #include <string.h>
  33 #include <stdlib.h>
  34 #include <stdio.h>
  35 #include <fcntl.h>
  36 #include <errno.h>
  37 #include <libdiskmgt.h>
  38 #include <libzfs.h>
  39 #include <uuid/uuid.h>
  40 
  41 #include "dconf.h"
  42 #include "minfree.h"


 502 }
 503 
 504 int
 505 dconf_write_uuid(dumpconf_t *dcp)
 506 {
 507         char uuidstr[36 + 1];
 508         uuid_t uu;
 509         int err;
 510 
 511         uuid_generate(uu);
 512         uuid_unparse(uu, uuidstr);
 513 
 514         err = ioctl(dcp->dc_dump_fd, DIOCSETUUID, uuidstr);
 515 
 516         if (err)
 517                 warn(gettext("kernel image uuid write failed"));
 518 
 519         return (err == 0);
 520 }
 521 

















 522 void
 523 dconf_print(dumpconf_t *dcp, FILE *fp)
 524 {
 525         u_longlong_t min;
 526         char *content;
 527 
 528         if (dcp->dc_cflags & DUMP_ALL)
 529                 content = gettext("all");
 530         else if (dcp->dc_cflags & DUMP_CURPROC)
 531                 content = gettext("kernel and current process");
 532         else
 533                 content = gettext("kernel");
 534 
 535         (void) fprintf(fp, gettext("      Dump content: %s pages\n"), content);
 536 
 537         if (dcp->dc_device[0] != '\0') {
 538                 (void) fprintf(fp, gettext("       Dump device: %s (%s)\n"),
 539                     dcp->dc_device, (dcp->dc_cflags & DUMP_EXCL) ?
 540                     gettext("dedicated") : gettext("swap"));
 541         } else {




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  24  */
  25 
  26 #include <sys/types.h>
  27 #include <sys/stat.h>
  28 #include <sys/swap.h>
  29 #include <sys/dumpadm.h>
  30 #include <sys/utsname.h>
  31 
  32 #include <unistd.h>
  33 #include <string.h>
  34 #include <stdlib.h>
  35 #include <stdio.h>
  36 #include <fcntl.h>
  37 #include <errno.h>
  38 #include <libdiskmgt.h>
  39 #include <libzfs.h>
  40 #include <uuid/uuid.h>
  41 
  42 #include "dconf.h"
  43 #include "minfree.h"


 503 }
 504 
 505 int
 506 dconf_write_uuid(dumpconf_t *dcp)
 507 {
 508         char uuidstr[36 + 1];
 509         uuid_t uu;
 510         int err;
 511 
 512         uuid_generate(uu);
 513         uuid_unparse(uu, uuidstr);
 514 
 515         err = ioctl(dcp->dc_dump_fd, DIOCSETUUID, uuidstr);
 516 
 517         if (err)
 518                 warn(gettext("kernel image uuid write failed"));
 519 
 520         return (err == 0);
 521 }
 522 
 523 int
 524 dconf_get_dumpsize(dumpconf_t *dcp)
 525 {
 526         char buf[32];
 527         uint64_t d;
 528 
 529         if (ioctl(dcp->dc_dump_fd, DIOCGETDUMPSIZE, &d) == -1) {
 530                 warn(gettext("failed to get kernel dump size"));
 531                 return (-1);
 532         }
 533 
 534         zfs_nicenum(d, buf, sizeof (buf));
 535 
 536         (void) printf(gettext("Estimated dump size: %s\n"), buf);
 537         return (0);
 538 }
 539 
 540 void
 541 dconf_print(dumpconf_t *dcp, FILE *fp)
 542 {
 543         u_longlong_t min;
 544         char *content;
 545 
 546         if (dcp->dc_cflags & DUMP_ALL)
 547                 content = gettext("all");
 548         else if (dcp->dc_cflags & DUMP_CURPROC)
 549                 content = gettext("kernel and current process");
 550         else
 551                 content = gettext("kernel");
 552 
 553         (void) fprintf(fp, gettext("      Dump content: %s pages\n"), content);
 554 
 555         if (dcp->dc_device[0] != '\0') {
 556                 (void) fprintf(fp, gettext("       Dump device: %s (%s)\n"),
 557                     dcp->dc_device, (dcp->dc_cflags & DUMP_EXCL) ?
 558                     gettext("dedicated") : gettext("swap"));
 559         } else {