19fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 29fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * CDDL HEADER START 39fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 49fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * The contents of this file are subject to the terms of the 59fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Common Development and Distribution License (the "License"). 69fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * You may not use this file except in compliance with the License. 79fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 89fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * or http://www.opensolaris.org/os/licensing. 109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * See the License for the specific language governing permissions 119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * and limitations under the License. 129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * When distributing Covered Code, include this CDDL HEADER in each 149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * If applicable, add the following below this CDDL HEADER, with the 169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * fields enclosed by brackets "[]" replaced with your own identifying 179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * information: Portions Copyright [yyyy] [name of copyright owner] 189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * CDDL HEADER END 209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 22fd9ee8b5Sjoyce mcintosh * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 23*a90cf9f2SGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/smb_kproto.h> 279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/smb_fsops.h> 289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/smbinfo.h> 299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int smb_trans2_set_fs_ctrl_info(smb_request_t *, smb_xa_t *); 319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * smb_com_query_information_disk 349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * The SMB_COM_QUERY_INFORMATION_DISK command is used to determine the 369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * capacity and remaining free space on the drive hosting the directory 379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * structure indicated by Tid in the SMB header. 389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * The blocking/allocation units used in this response may be independent 409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * of the actual physical or logical blocking/allocation algorithm(s) used 419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * internally by the server. However, they must accurately reflect the 429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * amount of space on the server. 439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * This SMB only returns 16 bits of information for each field, which may 459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * not be large enough for some disk systems. In particular TotalUnits is 469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * commonly > 64K. Fortunately, it turns out the all the client cares 479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * about is the total disk size, in bytes, and the free space, in bytes. 489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * So, it is reasonable for a server to adjust the relative values of 499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * BlocksPerUnit and BlockSize to accommodate. If after all adjustment, 509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * the numbers are still too high, the largest possible values for 519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * TotalUnit or FreeUnits (i.e. 0xFFFF) should be returned. 529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_sdrc_t 559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_pre_query_information_disk(smb_request_t *sr) 569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States DTRACE_SMB_1(op__QueryInformationDisk__start, smb_request_t *, sr); 589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_SUCCESS); 599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void 629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_post_query_information_disk(smb_request_t *sr) 639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States DTRACE_SMB_1(op__QueryInformationDisk__done, smb_request_t *, sr); 659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_sdrc_t 689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_com_query_information_disk(smb_request_t *sr) 699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States int rc; 719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fsblkcnt64_t total_blocks, free_blocks; 729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States unsigned long block_size, unit_size; 739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States unsigned short blocks_per_unit, bytes_per_block; 749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States unsigned short total_units, free_units; 759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_fssize_t fssize; 769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (STYPE_ISIPC(sr->tid_tree->t_res_type)) { 789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRDOS, ERRnoaccess); 799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_fssize(sr, &fssize) != 0) 839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States unit_size = fssize.fs_sectors_per_unit; 869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States block_size = fssize.fs_bytes_per_sector; 879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States total_blocks = fssize.fs_caller_units; 889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States free_blocks = fssize.fs_caller_avail; 899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * It seems that DOS clients cannot handle block sizes 929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * bigger than 512 KB. So we have to set the block size at 939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * most to 512 949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States while (block_size > 512) { 969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States block_size >>= 1; 979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States unit_size <<= 1; 989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* adjust blocks and sizes until they fit into a word */ 1019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States while (total_blocks >= 0xFFFF) { 1029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States total_blocks >>= 1; 1039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States free_blocks >>= 1; 1049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((unit_size <<= 1) > 0xFFFF) { 1059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States unit_size >>= 1; 1069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States total_blocks = 0xFFFF; 1079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States free_blocks <<= 1; 1089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 1099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States total_units = (total_blocks >= 0xFFFF) ? 1139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0xFFFF : (unsigned short)total_blocks; 1149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States free_units = (free_blocks >= 0xFFFF) ? 1159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0xFFFF : (unsigned short)free_blocks; 1169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bytes_per_block = (unsigned short)block_size; 1179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States blocks_per_unit = (unsigned short)unit_size; 1189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rc = smbsr_encode_result(sr, 5, 0, "bwwww2.w", 1209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5, 1219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States total_units, /* total_units */ 1229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States blocks_per_unit, /* blocks_per_unit */ 1239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bytes_per_block, /* blocksize */ 1249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States free_units, /* free_units */ 1259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0); /* bcc */ 1269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 1289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 1319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * smb_com_trans2_query_fs_information 1329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * This transaction requests information about the filesystem. 1349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * The following information levels are supported: 1359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * InformationLevel Value 1379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * ================================== ====== 1389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_INFO_ALLOCATION 1 1399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_INFO_VOLUME 2 1409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_QUERY_FS_VOLUME_INFO 0x102 1419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_QUERY_FS_SIZE_INFO 0x103 1429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_QUERY_FS_DEVICE_INFO 0x104 1439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_QUERY_FS_ATTRIBUTE_INFO 0x105 1449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_FILE_FS_VOLUME_INFORMATION 1001 1459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_FILE_FS_SIZE_INFORMATION 1003 1469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_FILE_FS_DEVICE_INFORMATION 1004 1479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_FILE_FS_ATTRIBUTE_INFORMATION 1005 1489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_FILE_FS_CONTROL_INFORMATION 1006 1499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_FILE_FS_FULLSIZE_INFORMATION 1007 1509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * The fsid provides a system-wide unique file system ID. 1529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * fsid.val[0] is the 32-bit dev for the file system of the share root 1539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * smb_node. 1549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * fsid.val[1] is the file system type. 1559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 1569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_sdrc_t 1579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_com_trans2_query_fs_information(smb_request_t *sr, smb_xa_t *xa) 1589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 1599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t flags; 1609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char *encode_str, *tmpbuf; 1619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint64_t max_int; 1629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint16_t infolev; 1639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States int rc, length, buflen; 1649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_tree_t *tree; 1659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_node_t *snode; 1669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char *fsname = "NTFS"; 1679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fsid_t fsid; 1689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_fssize_t fssize; 1699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_msgbuf_t mb; 1709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States tree = sr->tid_tree; 1729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!STYPE_ISDSK(tree->t_res_type)) { 1749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 1759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_ACCESS_DENIED); 1769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 1779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_mbc_decodef(&xa->req_param_mb, "w", &infolev) != 0) 1809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 1819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States snode = tree->t_snode; 1839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fsid = SMB_NODE_FSID(snode); 1849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (infolev) { 1869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_INFO_ALLOCATION: 1879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_fssize(sr, &fssize) != 0) 1889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 1899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States max_int = (uint64_t)UINT_MAX; 1919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (fssize.fs_caller_units > max_int) 1929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_units = max_int; 1939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (fssize.fs_caller_avail > max_int) 1949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_avail = max_int; 1959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_mbc_encodef(&xa->rep_data_mb, "llllw", 1979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, 1989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_sectors_per_unit, 1999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_units, 2009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_avail, 2019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_bytes_per_sector); 2029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 2039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_INFO_VOLUME: 2059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 2069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * In this response, the unicode volume label is NOT 2079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * expected to be aligned. Encode ('U') into a temporary 2089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * buffer, then encode buffer as a byte stream ('#c'). 2099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 2109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((sr->smb_flg2 & SMB_FLAGS2_UNICODE) || 2119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (sr->session->native_os == NATIVE_OS_WIN95)) { 2129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length = smb_wcequiv_strlen(tree->t_volume); 2139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States buflen = length + sizeof (smb_wchar_t); 2149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States tmpbuf = smb_srm_zalloc(sr, buflen); 2159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_msgbuf_init(&mb, (uint8_t *)tmpbuf, buflen, 2169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States SMB_MSGBUF_UNICODE); 2179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_msgbuf_encode(&mb, "U", tree->t_volume); 2189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (rc >= 0) { 2199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_mbc_encodef(&xa->rep_data_mb, 2209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States "%lb#c", sr, fsid.val[0], 2219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length, length, tmpbuf); 2229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_msgbuf_term(&mb); 2249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } else { 2259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length = strlen(tree->t_volume); 2269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_mbc_encodef(&xa->rep_data_mb, "%lbs", sr, 2279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fsid.val[0], length, tree->t_volume); 2289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (rc < 0) 2319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 2329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 2339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_QUERY_FS_VOLUME_INFO: 2359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_VOLUME_INFORMATION: 2369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((sr->smb_flg2 & SMB_FLAGS2_UNICODE) || 2379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (sr->session->native_os == NATIVE_OS_WIN95)) { 2389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length = smb_wcequiv_strlen(tree->t_volume); 2399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States encode_str = "%qllb.U"; 2409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } else { 2419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length = strlen(tree->t_volume); 2429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States encode_str = "%qllb.s"; 2439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 2469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * NT has the "supports objects" flag set to 1. 2479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 2489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_mbc_encodef(&xa->rep_data_mb, encode_str, sr, 2499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0ll, /* Volume creation time */ 2509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fsid.val[0], /* Volume serial number */ 2519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length, /* label length */ 2529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* Supports objects */ 2539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States tree->t_volume); 2549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 2559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_QUERY_FS_SIZE_INFO: 2579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_SIZE_INFORMATION: 2589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_fssize(sr, &fssize) != 0) 2599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 2609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_mbc_encodef(&xa->rep_data_mb, "qqll", 2629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_units, 2639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_avail, 2649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_sectors_per_unit, 2659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_bytes_per_sector); 2669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 2679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_QUERY_FS_DEVICE_INFO: 2699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_DEVICE_INFORMATION: 2709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_mbc_encodef(&xa->rep_data_mb, "ll", 2719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FILE_DEVICE_FILE_SYSTEM, 2729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FILE_DEVICE_IS_MOUNTED); 2739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 2749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_QUERY_FS_ATTRIBUTE_INFO: 2769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_ATTRIBUTE_INFORMATION: 2779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((sr->smb_flg2 & SMB_FLAGS2_UNICODE) || 2789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (sr->session->native_os == NATIVE_OS_WINNT) || 2799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (sr->session->native_os == NATIVE_OS_WIN2000) || 2809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (sr->session->native_os == NATIVE_OS_WIN95) || 2819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (sr->session->native_os == NATIVE_OS_MACOS)) { 2829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length = smb_wcequiv_strlen(fsname); 2839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States encode_str = "%lllU"; 2849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States sr->smb_flg2 |= SMB_FLAGS2_UNICODE; 2859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } else { 2869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length = strlen(fsname); 2879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States encode_str = "%llls"; 2889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States flags = FILE_CASE_PRESERVED_NAMES; 2919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (tree->t_flags & SMB_TREE_UNICODE_ON_DISK) 2939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States flags |= FILE_UNICODE_ON_DISK; 2949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (tree->t_flags & SMB_TREE_SUPPORTS_ACLS) 2969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States flags |= FILE_PERSISTENT_ACLS; 2979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((tree->t_flags & SMB_TREE_CASEINSENSITIVE) == 0) 2999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States flags |= FILE_CASE_SENSITIVE_SEARCH; 3009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (tree->t_flags & SMB_TREE_STREAMS) 3029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States flags |= FILE_NAMED_STREAMS; 3039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (tree->t_flags & SMB_TREE_QUOTA) 3059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States flags |= FILE_VOLUME_QUOTAS; 3069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 307fd9ee8b5Sjoyce mcintosh if (tree->t_flags & SMB_TREE_SPARSE) 308fd9ee8b5Sjoyce mcintosh flags |= FILE_SUPPORTS_SPARSE_FILES; 309fd9ee8b5Sjoyce mcintosh 3109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_mbc_encodef(&xa->rep_data_mb, encode_str, sr, 3119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States flags, 3129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States MAXNAMELEN, /* max name */ 3139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States length, /* label length */ 3149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fsname); 3159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 3169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_CONTROL_INFORMATION: 3189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_tree_has_feature(sr->tid_tree, SMB_TREE_QUOTA)) { 3199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, 3209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_NOT_SUPPORTED); 3219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 3229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 3239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_mbc_encodef(&xa->rep_data_mb, "qqqqqll", 3259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* free space start filtering - MUST be 0 */ 3269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* free space threshold - MUST be 0 */ 3279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* free space stop filtering - MUST be 0 */ 3289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States SMB_QUOTA_UNLIMITED, /* default quota threshold */ 3299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States SMB_QUOTA_UNLIMITED, /* default quota limit */ 3309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States FILE_VC_QUOTA_ENFORCE, /* fs control flag */ 3319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0); /* pad bytes */ 3329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 3339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_FULLSIZE_INFORMATION: 3359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_fssize(sr, &fssize) != 0) 3369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 3379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_mbc_encodef(&xa->rep_data_mb, "qqqll", 3399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_units, 3409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_caller_avail, 3419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_volume_avail, 3429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_sectors_per_unit, 3439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize.fs_bytes_per_sector); 3449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 3459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_LABEL_INFORMATION: 3479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_OBJECTID_INFORMATION: 3489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_DRIVERPATH_INFORMATION: 3499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, 3509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_NOT_SUPPORTED); 3519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 3529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States default: 3549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_INVALID_LEVEL, 3559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_INVALID_LEVEL); 3569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 3579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 3589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_SUCCESS); 3609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 3619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 3639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * smb_fssize 3649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 3659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * File system size information, for the volume and for the user 3669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * initiating the request. 3679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 3689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * If there's no quota entry for the user initiating the request, 3699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * caller_units and caller_avail are the total and available units 3709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * for the volume (volume_units, volume_avail). 3719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * If there is a quota entry for the user initiating the request, 3729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * and it is not SMB_QUOTA_UNLIMITED, calculate caller_units and 3739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * caller_avail as follows: 3749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * caller_units = quota limit / bytes_per_unit 3759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * caller_avail = remaining quota / bytes_per_unit 3769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 3779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * A quota limit of SMB_QUOTA_UNLIMITED means that the user's quota 3789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * is specfied as unlimited. A quota limit of 0 means there is no 3799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * quota specified for the user. 3809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 381*a90cf9f2SGordon Ross * Returns: 0 (success) or an errno value 3829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 383*a90cf9f2SGordon Ross int 3849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_fssize(smb_request_t *sr, smb_fssize_t *fssize) 3859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 3869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_node_t *node; 3879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States struct statvfs64 df; 3889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uid_t uid; 3899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_quota_t quota; 390*a90cf9f2SGordon Ross int spu; /* sectors per unit */ 391*a90cf9f2SGordon Ross int rc; 3929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(fssize, sizeof (smb_fssize_t)); 3949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States node = sr->tid_tree->t_snode; 395*a90cf9f2SGordon Ross if ((rc = smb_fsop_statfs(sr->user_cr, node, &df)) != 0) 396*a90cf9f2SGordon Ross return (rc); 3979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 398*a90cf9f2SGordon Ross if (df.f_frsize < DEV_BSIZE) 399*a90cf9f2SGordon Ross df.f_frsize = DEV_BSIZE; 400*a90cf9f2SGordon Ross if (df.f_bsize < df.f_frsize) 401*a90cf9f2SGordon Ross df.f_bsize = df.f_frsize; 402*a90cf9f2SGordon Ross spu = df.f_bsize / df.f_frsize; 403*a90cf9f2SGordon Ross 404*a90cf9f2SGordon Ross fssize->fs_bytes_per_sector = (uint16_t)df.f_frsize; 405*a90cf9f2SGordon Ross fssize->fs_sectors_per_unit = spu; 406*a90cf9f2SGordon Ross 4079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (df.f_bavail > df.f_blocks) 4089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States df.f_bavail = 0; 4099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 410*a90cf9f2SGordon Ross fssize->fs_volume_units = df.f_blocks / spu; 411*a90cf9f2SGordon Ross fssize->fs_volume_avail = df.f_bavail / spu; 412*a90cf9f2SGordon Ross fssize->fs_caller_units = df.f_blocks / spu; 413*a90cf9f2SGordon Ross fssize->fs_caller_avail = df.f_bavail / spu; 4149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_tree_has_feature(sr->tid_tree, SMB_TREE_QUOTA)) 4169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (0); 4179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uid = crgetuid(sr->uid_user->u_cred); 4199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_quota_query_user_quota(sr, uid, "a) != NT_STATUS_SUCCESS) 4209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (0); 4219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((quota.q_limit != SMB_QUOTA_UNLIMITED) && (quota.q_limit != 0)) { 423*a90cf9f2SGordon Ross fssize->fs_caller_units = quota.q_limit / df.f_bsize; 4249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (quota.q_limit <= quota.q_used) 4259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize->fs_caller_avail = 0; 4269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 4279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fssize->fs_caller_avail = 428*a90cf9f2SGordon Ross (quota.q_limit - quota.q_used) / df.f_bsize; 4299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (0); 4329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 4359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * smb_com_trans2_set_fs_information 4369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 4379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * This transaction sets filesystem information. 4389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * The following information levels are supported: 4399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 4409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * InformationLevel Value 4419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * ================================== ====== 4429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_FILE_FS_CONTROL_INFORMATION 1006 4439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 4449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_sdrc_t 4459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_com_trans2_set_fs_information(smb_request_t *sr, smb_xa_t *xa) 4469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 4479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_tree_t *tree; 4489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint16_t infolev; 4499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States tree = sr->tid_tree; 4519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!STYPE_ISDSK(tree->t_res_type)) { 4529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 4539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_ACCESS_DENIED); 4549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 4559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_mbc_decodef(&xa->req_param_mb, "ww", 4589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States &sr->smb_fid, &infolev) != 0) 4599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 4609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (infolev) { 4629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_CONTROL_INFORMATION: 4639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (smb_trans2_set_fs_ctrl_info(sr, xa) != 0) 4649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 4659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 4669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_VOLUME_INFORMATION: 4689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_LABEL_INFORMATION: 4699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_SIZE_INFORMATION: 4709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_DEVICE_INFORMATION: 4719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_ATTRIBUTE_INFORMATION: 4729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_FULLSIZE_INFORMATION: 4739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_OBJECTID_INFORMATION: 4749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case SMB_FILE_FS_DRIVERPATH_INFORMATION: 4759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, 4769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_NOT_SUPPORTED); 4779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 4789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States default: 4809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_INVALID_LEVEL, 4819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_INVALID_LEVEL); 4829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR); 4839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_SUCCESS); 4869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 4899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * smb_trans2_set_fs_ctrl_info 4909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 4919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Only users with Admin privileges (i.e. of the BUILTIN/Administrators 4929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * group) will be allowed to set quotas. 4939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 4949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Currently QUOTAS are always ENFORCED and the default values 4959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * are always SMB_QUOTA_UNLIMITED (none). Any attempt to set 4969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * values other than these will result in NT_STATUS_NOT_SUPPORTED. 4979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 4989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int 4999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_trans2_set_fs_ctrl_info(smb_request_t *sr, smb_xa_t *xa) 5009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 5019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States int rc; 5029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint64_t fstart, fthresh, fstop, qthresh, qlimit; 5039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t qctrl, qpad; 5049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_tree_has_feature(sr->tid_tree, SMB_TREE_QUOTA)) { 5069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, 5079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_NOT_SUPPORTED); 5089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (-1); 5099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_user_is_admin(sr->uid_user)) { 5129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_ACCESS_DENIED, 5139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_ACCESS_DENIED); 5149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (-1); 5159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_mbc_decodef(&xa->req_data_mb, "qqqqqll", &fstart, 5189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States &fthresh, &fstop, &qthresh, &qlimit, &qctrl, &qpad); 5199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((rc != 0) || (fstart != 0) || (fthresh != 0) || (fstop != 0)) { 5219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_INVALID_PARAMETER, 5229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_INVALID_PARAMETER); 5239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (-1); 5249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* Only support ENFORCED quotas with UNLIMITED default */ 5279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((qctrl != FILE_VC_QUOTA_ENFORCE) || 5289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (qlimit != SMB_QUOTA_UNLIMITED) || 5299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (qthresh != SMB_QUOTA_UNLIMITED)) { 5309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, 5319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_NOT_SUPPORTED); 5329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (-1); 5339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (0); 5369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 537