Print this page
2605 want to resume interrupted zfs send
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed by: Xin Li <delphij@freebsd.org>
Reviewed by: Arne Jansen <sensille@gmx.net>
Approved by: Dan McDonald <danmcd@omniti.com>
re #13850 Refactor ZFS config discovery IOCs to libzfs_core patterns


   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 /*
  23  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  25  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  26  * Copyright 2015 Joyent, Inc.
  27  */
  28 
  29 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  30 /*        All Rights Reserved   */
  31 
  32 #define _SYSCALL32
  33 
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <unistd.h>
  37 #include <ctype.h>
  38 #include <sys/types.h>
  39 #include <sys/mman.h>
  40 #include <libproc.h>
  41 #include <string.h>
  42 #include <limits.h>
  43 #include <sys/statfs.h>


  85 #include <ucred.h>
  86 #include <sys/ucred.h>
  87 #include <sys/port_impl.h>
  88 #include <sys/zone.h>
  89 #include <sys/priv_impl.h>
  90 #include <sys/priv.h>
  91 #include <tsol/label.h>
  92 #include <sys/nvpair.h>
  93 #include <libnvpair.h>
  94 #include <sys/rctl_impl.h>
  95 #include <sys/socketvar.h>
  96 #include <sys/fs/zfs.h>
  97 #include <sys/zfs_ioctl.h>
  98 
  99 #include "ramdata.h"
 100 #include "systable.h"
 101 #include "proto.h"
 102 
 103 void    show_sigset(private_t *, long, const char *);
 104 void    show_ioctl(private_t *, int, long);
 105 void    show_zfs_ioc(private_t *, long);
 106 
 107 static void
 108 mk_ctime(char *str, size_t maxsize, time_t value)
 109 {
 110         (void) strftime(str, maxsize, "%b %e %H:%M:%S %Z %Y",
 111             localtime(&value));
 112 }
 113 
 114 void
 115 prtime(private_t *pri, const char *name, time_t value)
 116 {
 117         char str[80];
 118 
 119         mk_ctime(str, sizeof (str), value);
 120         (void) printf("%s\t%s%s  [ %lu ]\n",
 121             pri->pname,
 122             name,
 123             str,
 124             value);
 125 }


1471                 break;
1472         case JWINSIZE:
1473                 if (err)
1474                         break;
1475                 show_jwinsize(pri, offset);
1476                 break;
1477         case TIOCGWINSZ:
1478                 if (err)
1479                         break;
1480                 /*FALLTHROUGH*/
1481         case TIOCSWINSZ:
1482                 show_winsize(pri, offset);
1483                 break;
1484         case AUDIO_GETINFO:
1485         case (int)AUDIO_SETINFO:
1486                 show_audio_info(pri, offset);
1487                 break;
1488 
1489         default:
1490                 if ((code & ~0xff) == ZFS_IOC) {
1491                         show_zfs_ioc(pri, offset);
1492                         break;
1493                 }
1494 
1495                 if (code & IOC_INOUT) {
1496                         const char *str = ioctldatastruct(code);
1497 
1498                         (void) printf("\t\t%s",
1499                             (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1500                             code & IOC_IN ? "write" : "read");
1501                         if (str != NULL) {
1502                                 (void) printf(" (struct %s)\n", str);
1503                         } else {
1504                                 (void) printf(" %d bytes\n",
1505                                     (code >> 16) & IOCPARM_MASK);
1506                         }
1507                 }
1508         }
1509 }
1510 
1511 void


4857 {
4858         switch (pri->sys_args[0]) {
4859         case SOCKCONFIG_ADD_FILTER:
4860 #ifdef _LP64
4861                 if (data_model == PR_MODEL_LP64)
4862                         show_sockconfig_filter_prop(pri,
4863                             (long)pri->sys_args[2]);
4864                 else
4865                         show_sockconfig_filter_prop32(pri,
4866                             (long)pri->sys_args[2]);
4867 #else
4868                 show_sockconfig_filter_prop(pri, (long)pri->sys_args[2]);
4869 #endif
4870                 break;
4871         default:
4872                 break;
4873         }
4874 }
4875 
4876 void
4877 show_zfs_ioc(private_t *pri, long addr)
4878 {
4879         static const zfs_share_t zero_share = {0};
4880         static const dmu_objset_stats_t zero_objstats = {0};
4881         static const struct drr_begin zero_drrbegin = {0};
4882         static const zinject_record_t zero_injectrec = {0};
4883         static const zfs_stat_t zero_zstat = {0};
4884         zfs_cmd_t zc;
4885 
4886         if (Pread(Proc, &zc, sizeof (zc), addr) != sizeof (zc)) {
4887                 (void) printf(" zfs_ioctl read failed\n");
4888                 return;
4889         }
4890 
4891         if (zc.zc_name[0])
4892                 (void) printf("    zc_name=%s\n", zc.zc_name);
4893         if (zc.zc_value[0])
4894                 (void) printf("    zc_value=%s\n", zc.zc_value);
4895         if (zc.zc_string[0])
4896                 (void) printf("    zc_string=%s\n", zc.zc_string);
4897         if (zc.zc_guid != 0) {
4898                 (void) printf("    zc_guid=%llu\n",
4899                     (u_longlong_t)zc.zc_guid);
4900         }
4901         if (zc.zc_nvlist_conf_size) {
4902                 (void) printf("    nvlist_conf:\n");
4903                 show_packed_nvlist(pri, zc.zc_nvlist_conf,
4904                     zc.zc_nvlist_conf_size);
4905         }
4906         if (zc.zc_nvlist_src_size) {
4907                 (void) printf("    nvlist_src:\n");
4908                 show_packed_nvlist(pri, zc.zc_nvlist_src,
4909                     zc.zc_nvlist_src_size);
4910         }
4911         if (zc.zc_nvlist_dst_size) {

4912                 (void) printf("    nvlist_dst:\n");
4913                 show_packed_nvlist(pri, zc.zc_nvlist_dst,
4914                     zc.zc_nvlist_dst_size);



4915         }

4916         if (zc.zc_cookie != 0) {
4917                 (void) printf("    zc_cookie=%llu\n",
4918                     (u_longlong_t)zc.zc_cookie);
4919         }
4920         if (zc.zc_objset_type != 0) {
4921                 (void) printf("    zc_objset_type=%llu\n",
4922                     (u_longlong_t)zc.zc_objset_type);
4923         }
4924         if (zc.zc_perm_action != 0) {
4925                 (void) printf("    zc_perm_action=%llu\n",
4926                     (u_longlong_t)zc.zc_perm_action);
4927         }
4928         if (zc.zc_history != 0) {
4929                 (void) printf("    zc_history=%llu\n",
4930                     (u_longlong_t)zc.zc_history);
4931         }
4932         if (zc.zc_obj != 0) {
4933                 (void) printf("    zc_obj=%llu\n",
4934                     (u_longlong_t)zc.zc_obj);
4935         }




   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 /*
  23  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  25  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  26  * Copyright 2015 Joyent, Inc.
  27  */
  28 
  29 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  30 /*        All Rights Reserved   */
  31 
  32 #define _SYSCALL32
  33 
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <unistd.h>
  37 #include <ctype.h>
  38 #include <sys/types.h>
  39 #include <sys/mman.h>
  40 #include <libproc.h>
  41 #include <string.h>
  42 #include <limits.h>
  43 #include <sys/statfs.h>


  85 #include <ucred.h>
  86 #include <sys/ucred.h>
  87 #include <sys/port_impl.h>
  88 #include <sys/zone.h>
  89 #include <sys/priv_impl.h>
  90 #include <sys/priv.h>
  91 #include <tsol/label.h>
  92 #include <sys/nvpair.h>
  93 #include <libnvpair.h>
  94 #include <sys/rctl_impl.h>
  95 #include <sys/socketvar.h>
  96 #include <sys/fs/zfs.h>
  97 #include <sys/zfs_ioctl.h>
  98 
  99 #include "ramdata.h"
 100 #include "systable.h"
 101 #include "proto.h"
 102 
 103 void    show_sigset(private_t *, long, const char *);
 104 void    show_ioctl(private_t *, int, long);
 105 void    show_zfs_ioc(private_t *, long, int);
 106 
 107 static void
 108 mk_ctime(char *str, size_t maxsize, time_t value)
 109 {
 110         (void) strftime(str, maxsize, "%b %e %H:%M:%S %Z %Y",
 111             localtime(&value));
 112 }
 113 
 114 void
 115 prtime(private_t *pri, const char *name, time_t value)
 116 {
 117         char str[80];
 118 
 119         mk_ctime(str, sizeof (str), value);
 120         (void) printf("%s\t%s%s  [ %lu ]\n",
 121             pri->pname,
 122             name,
 123             str,
 124             value);
 125 }


1471                 break;
1472         case JWINSIZE:
1473                 if (err)
1474                         break;
1475                 show_jwinsize(pri, offset);
1476                 break;
1477         case TIOCGWINSZ:
1478                 if (err)
1479                         break;
1480                 /*FALLTHROUGH*/
1481         case TIOCSWINSZ:
1482                 show_winsize(pri, offset);
1483                 break;
1484         case AUDIO_GETINFO:
1485         case (int)AUDIO_SETINFO:
1486                 show_audio_info(pri, offset);
1487                 break;
1488 
1489         default:
1490                 if ((code & ~0xff) == ZFS_IOC) {
1491                         show_zfs_ioc(pri, offset, err);
1492                         break;
1493                 }
1494 
1495                 if (code & IOC_INOUT) {
1496                         const char *str = ioctldatastruct(code);
1497 
1498                         (void) printf("\t\t%s",
1499                             (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
1500                             code & IOC_IN ? "write" : "read");
1501                         if (str != NULL) {
1502                                 (void) printf(" (struct %s)\n", str);
1503                         } else {
1504                                 (void) printf(" %d bytes\n",
1505                                     (code >> 16) & IOCPARM_MASK);
1506                         }
1507                 }
1508         }
1509 }
1510 
1511 void


4857 {
4858         switch (pri->sys_args[0]) {
4859         case SOCKCONFIG_ADD_FILTER:
4860 #ifdef _LP64
4861                 if (data_model == PR_MODEL_LP64)
4862                         show_sockconfig_filter_prop(pri,
4863                             (long)pri->sys_args[2]);
4864                 else
4865                         show_sockconfig_filter_prop32(pri,
4866                             (long)pri->sys_args[2]);
4867 #else
4868                 show_sockconfig_filter_prop(pri, (long)pri->sys_args[2]);
4869 #endif
4870                 break;
4871         default:
4872                 break;
4873         }
4874 }
4875 
4876 void
4877 show_zfs_ioc(private_t *pri, long addr, int err)
4878 {
4879         static const zfs_share_t zero_share = {0};
4880         static const dmu_objset_stats_t zero_objstats = {0};
4881         static const struct drr_begin zero_drrbegin = {0};
4882         static const zinject_record_t zero_injectrec = {0};
4883         static const zfs_stat_t zero_zstat = {0};
4884         zfs_cmd_t zc;
4885 
4886         if (Pread(Proc, &zc, sizeof (zc), addr) != sizeof (zc)) {
4887                 (void) printf(" zfs_ioctl read failed\n");
4888                 return;
4889         }
4890 
4891         if (zc.zc_name[0])
4892                 (void) printf("    zc_name=%s\n", zc.zc_name);
4893         if (zc.zc_value[0])
4894                 (void) printf("    zc_value=%s\n", zc.zc_value);
4895         if (zc.zc_string[0])
4896                 (void) printf("    zc_string=%s\n", zc.zc_string);
4897         if (zc.zc_guid != 0) {
4898                 (void) printf("    zc_guid=%llu\n",
4899                     (u_longlong_t)zc.zc_guid);
4900         }
4901         if (zc.zc_nvlist_conf_size) {
4902                 (void) printf("    nvlist_conf:\n");
4903                 show_packed_nvlist(pri, zc.zc_nvlist_conf,
4904                     zc.zc_nvlist_conf_size);
4905         }
4906         if (zc.zc_nvlist_src_size) {
4907                 (void) printf("    nvlist_src:\n");
4908                 show_packed_nvlist(pri, zc.zc_nvlist_src,
4909                     zc.zc_nvlist_src_size);
4910         }
4911         if (zc.zc_nvlist_dst_size) {
4912                 if (zc.zc_nvlist_dst_filled) {
4913                         (void) printf("    nvlist_dst:\n");
4914                         show_packed_nvlist(pri, zc.zc_nvlist_dst,
4915                             zc.zc_nvlist_dst_size);
4916                 } else if (err == ENOMEM) {
4917                         (void) printf("    nvlist_dst_size: %llu\n",
4918                             (u_longlong_t)zc.zc_nvlist_dst_size);
4919                 }
4920         }
4921         if (zc.zc_cookie != 0) {
4922                 (void) printf("    zc_cookie=%llu\n",
4923                     (u_longlong_t)zc.zc_cookie);
4924         }
4925         if (zc.zc_objset_type != 0) {
4926                 (void) printf("    zc_objset_type=%llu\n",
4927                     (u_longlong_t)zc.zc_objset_type);
4928         }
4929         if (zc.zc_perm_action != 0) {
4930                 (void) printf("    zc_perm_action=%llu\n",
4931                     (u_longlong_t)zc.zc_perm_action);
4932         }
4933         if (zc.zc_history != 0) {
4934                 (void) printf("    zc_history=%llu\n",
4935                     (u_longlong_t)zc.zc_history);
4936         }
4937         if (zc.zc_obj != 0) {
4938                 (void) printf("    zc_obj=%llu\n",
4939                     (u_longlong_t)zc.zc_obj);
4940         }