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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 #include <smbsrv/smb_kproto.h>
  27 #include <smbsrv/smb_fsops.h>
  28 #include <smbsrv/smbinfo.h>
  29 
  30 static int smb_trans2_set_fs_ctrl_info(smb_request_t *, smb_xa_t *);
  31 
  32 /*
  33  * smb_com_query_information_disk
  34  *
  35  * The SMB_COM_QUERY_INFORMATION_DISK command is used to determine the
  36  * capacity and remaining free space on the drive hosting the directory
  37  * structure indicated by Tid in the SMB header.
  38  *
  39  * The blocking/allocation units used in this response may be independent
  40  * of the actual physical or logical blocking/allocation algorithm(s) used
  41  * internally by the server.  However, they must accurately reflect the
  42  * amount of space on the server.
  43  *
  44  * This SMB only returns 16 bits of information for each field, which may
  45  * not be large enough for some disk systems.  In particular TotalUnits is
  46  * commonly > 64K.  Fortunately, it turns out the all the client cares
  47  * about is the total disk size, in bytes, and the free space, in bytes.
  48  * So,  it is reasonable for a server to adjust the relative values of
  49  * BlocksPerUnit and BlockSize to accommodate.  If after all adjustment,
  50  * the numbers are still too high, the largest possible values for
  51  * TotalUnit or FreeUnits (i.e. 0xFFFF) should be returned.
  52  */
  53 
  54 smb_sdrc_t
  55 smb_pre_query_information_disk(smb_request_t *sr)
  56 {
  57         DTRACE_SMB_1(op__QueryInformationDisk__start, smb_request_t *, sr);
  58         return (SDRC_SUCCESS);
  59 }
  60 
  61 void
  62 smb_post_query_information_disk(smb_request_t *sr)
  63 {
  64         DTRACE_SMB_1(op__QueryInformationDisk__done, smb_request_t *, sr);
  65 }
  66 
  67 smb_sdrc_t
  68 smb_com_query_information_disk(smb_request_t *sr)
  69 {
  70         int                     rc;
  71         fsblkcnt64_t            total_blocks, free_blocks;
  72         unsigned long           block_size, unit_size;
  73         unsigned short          blocks_per_unit, bytes_per_block;
  74         unsigned short          total_units, free_units;
  75         smb_fssize_t            fssize;
  76 
  77         if (STYPE_ISIPC(sr->tid_tree->t_res_type)) {
  78                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRDOS, ERRnoaccess);
  79                 return (SDRC_ERROR);
  80         }
  81 
  82         if (smb_fssize(sr, &fssize) != 0)
  83                 return (SDRC_ERROR);
  84 
 
 | 
 
 
   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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 #include <smbsrv/smb_kproto.h>
  27 #include <smbsrv/smb_fsops.h>
  28 #include <smbsrv/smbinfo.h>
  29 
  30 static int smb_trans2_set_fs_ctrl_info(smb_request_t *, smb_xa_t *);
  31 
  32 /*
  33  * smb_com_query_information_disk
  34  *
  35  * The SMB_COM_QUERY_INFORMATION_DISK command is used to determine the
  36  * capacity and remaining free space on the drive hosting the directory
  37  * structure indicated by Tid in the SMB header.
  38  *
  39  * The blocking/allocation units used in this response may be independent
  40  * of the actual physical or logical blocking/allocation algorithm(s) used
  41  * internally by the server.  However, they must accurately reflect the
  42  * amount of space on the server.
  43  *
  44  * This SMB only returns 16 bits of information for each field, which may
  45  * not be large enough for some disk systems.  In particular TotalUnits is
  46  * commonly > 64K.  Fortunately, it turns out the all the client cares
  47  * about is the total disk size, in bytes, and the free space, in bytes.
  48  * So,  it is reasonable for a server to adjust the relative values of
  49  * BlocksPerUnit and BlockSize to accommodate.  If after all adjustment,
  50  * the numbers are still too high, the largest possible values for
  51  * TotalUnit or FreeUnits (i.e. 0xFFFF) should be returned.
  52  */
  53 
  54 smb_sdrc_t
  55 smb_pre_query_information_disk(smb_request_t *sr)
  56 {
  57         DTRACE_SMB_START(op__QueryInformationDisk, smb_request_t *, sr);
  58         return (SDRC_SUCCESS);
  59 }
  60 
  61 void
  62 smb_post_query_information_disk(smb_request_t *sr)
  63 {
  64         DTRACE_SMB_DONE(op__QueryInformationDisk, smb_request_t *, sr);
  65 }
  66 
  67 smb_sdrc_t
  68 smb_com_query_information_disk(smb_request_t *sr)
  69 {
  70         int                     rc;
  71         fsblkcnt64_t            total_blocks, free_blocks;
  72         unsigned long           block_size, unit_size;
  73         unsigned short          blocks_per_unit, bytes_per_block;
  74         unsigned short          total_units, free_units;
  75         smb_fssize_t            fssize;
  76 
  77         if (STYPE_ISIPC(sr->tid_tree->t_res_type)) {
  78                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRDOS, ERRnoaccess);
  79                 return (SDRC_ERROR);
  80         }
  81 
  82         if (smb_fssize(sr, &fssize) != 0)
  83                 return (SDRC_ERROR);
  84 
 
 |