Print this page
8331 zfs_unshare returns wrong error code for smb unshare failure
Reviewed by: Marcel Telka <marcel@telka.sk>
Reviewed by: Toomas Soome <tsoome@me.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_mount.c
          +++ new/usr/src/lib/libzfs/common/libzfs_mount.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24   24   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  25   25   * Copyright (c) 2014, 2016 by Delphix. All rights reserved.
  26   26   * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
       27 + * Copyright 2017 RackTop Systems.
  27   28   */
  28   29  
  29   30  /*
  30   31   * Routines to manage ZFS mounts.  We separate all the nasty routines that have
  31   32   * to deal with the OS.  The following functions are the main entry points --
  32   33   * they are used by mount and unmount and when changing a filesystem's
  33   34   * mountpoint.
  34   35   *
  35   36   *      zfs_is_mounted()
  36   37   *      zfs_mount()
↓ open down ↓ 47 lines elided ↑ open up ↑
  84   85  
  85   86  #include <libshare.h>
  86   87  #include <sys/systeminfo.h>
  87   88  #define MAXISALEN       257     /* based on sysinfo(2) man page */
  88   89  
  89   90  static int zfs_share_proto(zfs_handle_t *, zfs_share_proto_t *);
  90   91  zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **,
  91   92      zfs_share_proto_t);
  92   93  
  93   94  /*
  94      - * The share protocols table must be in the same order as the zfs_share_prot_t
       95 + * The share protocols table must be in the same order as the zfs_share_proto_t
  95   96   * enum in libzfs_impl.h
  96   97   */
  97   98  typedef struct {
  98   99          zfs_prop_t p_prop;
  99  100          char *p_name;
 100  101          int p_share_err;
 101  102          int p_unshare_err;
 102  103  } proto_table_t;
 103  104  
 104  105  proto_table_t proto_table[PROTO_END] = {
↓ open down ↓ 803 lines elided ↑ open up ↑
 908  909  
 909  910          /*
 910  911           * make sure libshare initialized, initialize everything because we
 911  912           * don't know what other unsharing may happen later. Functions up the
 912  913           * stack are allowed to initialize instead a subset of shares at the
 913  914           * time the set is known.
 914  915           */
 915  916          if ((err = zfs_init_libshare_arg(hdl, SA_INIT_ONE_SHARE_FROM_NAME,
 916  917              (void *)name)) != SA_OK) {
 917  918                  free(mntpt);    /* don't need the copy anymore */
 918      -                return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
      919 +                return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err,
 919  920                      dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),
 920  921                      name, _sa_errorstr(err)));
 921  922          }
 922  923  
 923  924          share = zfs_sa_find_share(hdl->libzfs_sharehdl, mntpt);
 924  925          free(mntpt);    /* don't need the copy anymore */
 925  926  
 926  927          if (share != NULL) {
 927  928                  err = zfs_sa_disable_share(share, proto_table[proto].p_name);
 928  929                  if (err != SA_OK) {
 929      -                        return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
      930 +                        return (zfs_error_fmt(hdl,
      931 +                            proto_table[proto].p_unshare_err,
 930  932                              dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),
 931  933                              name, _sa_errorstr(err)));
 932  934                  }
 933  935          } else {
 934      -                return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
      936 +                return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err,
 935  937                      dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"),
 936  938                      name));
 937  939          }
 938  940          return (0);
 939  941  }
 940  942  
 941  943  /*
 942  944   * Unshare the given filesystem.
 943  945   */
 944  946  int
↓ open down ↓ 426 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX