Print this page
NEX-16159 Time spent sharing SMB filesystems could be reduced by optimizing smb_getdataset for default mount points
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-3981 bad pointer free causes crash in fksmbd
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Alek Pinchuk <alek@nexenta.com>
NEX-1456 Cannot receive incremental stream for dataset shared via SMB: destination dataset has been modified. part 1
SMB-153 Quota tab for the Share does not work

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libmlsvc/common/smb_quota.c
          +++ new/usr/src/lib/smbsrv/libmlsvc/common/smb_quota.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       24 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  25   25   */
  26   26  
  27   27  #include <stdio.h>
  28   28  #include <stdlib.h>
  29   29  #include <fcntl.h>
  30   30  #include <attr.h>
  31   31  #include <unistd.h>
  32   32  #include <libuutil.h>
  33   33  #include <libzfs.h>
  34   34  #include <assert.h>
↓ open down ↓ 1041 lines elided ↑ open up ↑
1076 1076  /*
1077 1077   * smb_quota_zfs_init
1078 1078   *
1079 1079   * Initialize zfs library and dataset handles
1080 1080   */
1081 1081  static uint32_t
1082 1082  smb_quota_zfs_init(const char *path, smb_quota_zfs_handle_t *zfs_hdl)
1083 1083  {
1084 1084          char dataset[MAXPATHLEN];
1085 1085  
1086      -        if (smb_getdataset(path, dataset, MAXPATHLEN) != 0)
1087      -                return (NT_STATUS_INVALID_PARAMETER);
1088      -
1089 1086          if ((zfs_hdl->z_lib = libzfs_init()) == NULL)
1090 1087                  return (NT_STATUS_INTERNAL_ERROR);
1091 1088  
     1089 +        if (smb_getdataset(zfs_hdl->z_lib, path, dataset, MAXPATHLEN) != 0) {
     1090 +                libzfs_fini(zfs_hdl->z_lib);
     1091 +                return (NT_STATUS_INVALID_PARAMETER);
     1092 +        }
     1093 +
1092 1094          zfs_hdl->z_fs = zfs_open(zfs_hdl->z_lib, dataset, ZFS_TYPE_DATASET);
1093 1095          if (zfs_hdl->z_fs == NULL) {
1094 1096                  libzfs_fini(zfs_hdl->z_lib);
1095 1097                  return (NT_STATUS_ACCESS_DENIED);
1096 1098          }
1097 1099  
1098 1100          return (NT_STATUS_SUCCESS);
1099 1101  }
1100 1102  
1101 1103  /*
↓ open down ↓ 106 lines elided ↑ open up ↑
1208 1210          (void) close(afd);
1209 1211  
1210 1212          if (acl_get(file, 0, &existing_aclp) == -1) {
1211 1213                  (void) unlink(file);
1212 1214                  if (qdir_created)
1213 1215                          (void) remove(dir);
1214 1216                  return;
1215 1217          }
1216 1218  
1217 1219          acl_text = acl_totext(existing_aclp, ACL_COMPACT_FMT);
1218      -        acl_free(existing_aclp);
1219 1220          if (acl_text == NULL) {
     1221 +                acl_free(existing_aclp);
1220 1222                  (void) unlink(file);
1221 1223                  if (qdir_created)
1222 1224                          (void) remove(dir);
1223 1225                  return;
1224 1226          }
     1227 +        acl_free(existing_aclp);
1225 1228  
1226 1229          aclp = NULL;
1227 1230          if (strcmp(acl_text, SMB_QUOTA_CNTRL_PERM) != 0) {
1228 1231                  if (acl_fromtext(SMB_QUOTA_CNTRL_PERM, &aclp) != 0) {
1229 1232                          free(acl_text);
1230 1233                          (void) unlink(file);
1231 1234                          if (qdir_created)
1232 1235                                  (void) remove(dir);
1233 1236                          return;
1234 1237                  }
↓ open down ↓ 29 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX