smb_quota.c revision a90cf9f29973990687fa61de9f1f6ea22e924e40
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
#include <smbsrv/smb_share.h>
#include <smbsrv/smb_door.h>
#include <smbsrv/smb_idmap.h>
/*
* - next offset (uint32_t)
* - length of SID (uint32_t)
* - last modified time (uint64_t)
* - quota used (uint64_t)
* - quota limit (uint64_t)
* - quota threahold (uint64_t)
* - variable length sid - max = 32 bytes
* SMB_QUOTA_SIZE_NO_SID is the size of the above, excluding the sid.
*/
#define SMB_QUOTA_SIZE_NO_SID \
/*
* smb_quota_init_sids
*
* If the query is of type SMB_QUOTA_QUERY_SIDLIST or
* SMB_QUOTA_QUERY_STARTSID decode the list of sids from
* the client request into request->qq_sid_list.
* Otherwise (type SMB_QUOTA_QUERY_ALL) find the resume sid
* and insert it into request->qq_sid_list, or reset the
* resume sid to NULL if request->qq_restart.
*
* Returns: NT_STATUS codes
*/
{
switch (request->qq_query_op) {
case SMB_QUOTA_QUERY_SIDLIST:
case SMB_QUOTA_QUERY_STARTSID:
break;
case SMB_QUOTA_QUERY_ALL:
if (request->qq_restart)
else {
}
break;
default:
break;
}
return (status);
}
/*
* smb_quota_free_sids
*/
void
{
}
}
/*
* smb_quota_decode_sids
*
* Decode the SIDs from the data block and stores them in string form in list.
* Eaxh sid entry comprises:
* next_offset (4 bytes) - offset of next entry
* sid length (4 bytes)
* sid (variable length = sidlen)
* The last entry will have a next_offset value of 0.
*
* Returns NT_STATUS codes.
*/
{
struct mbuf_chain sidbuf;
int rc;
offset = 0;
do {
if (rc != 0) {
break;
}
break;
}
break;
}
offset += next_offset;
} while ((next_offset != 0) && (bytes_left > 0));
return (status);
}
/*
* smb_quota_max_quota
*
* If the query is if type SMB_QUOTA_QUERY_SIDLIST a quota entry
* is returned for each sid in the sidlist. request->qr_max_quota
* is set to 0 and is unused.
* Otherwise (for SMB_QUOTA_QUERY_STARTSID and SMB_QUOTA_QUERY_ALL)
* max_quota is the maximum number of quota entries requested from
* the file system (via door call smb_quota_query()).
* If single is set max_quota is set to 1. If single is not set
* max quota is calculated as the number of quotas of size
* SMB_QUOTA_EST_SIZE that would fit in the response buffer.
*/
void
{
request->qq_max_quota = 0;
else
}
/*
* smb_quota_decode_quotas
*
* Decode the quota entries into a list_t of smb_quota_t.
* SMB_QUOTA_SIZE_NO_SID is the size of a quota entry,
* excluding the sid.
* The last entry will have a next_offset value of 0.
*
* Returns NT_STATUS codes.
*/
{
struct mbuf_chain quotabuf;
int rc;
offset = 0;
do {
if (rc != 0) {
break;
}
break;
}
break;
}
offset += next_offset;
} while ((next_offset != 0) && (bytes_left > 0));
return (status);
}
/*
* smb_quota_free_quotas
*/
void
{
}
}
/*
* smb_quota_encode_quotas
*
* Encode the quota entries from a list_t of smb_quota_t.
* SMB_QUOTA_SIZE_NO_SID is the size of a quota entry,
* excluding the sid.
* The last entry will have a next_offset value of 0.
* Sets the last encoded SID as the resume sid.
*/
{
int rc;
while (quota) {
quota = next_quota;
continue;
}
next_offset += pad;
break;
}
if (!MBC_ROOM_FOR(mbc,
next_quota = NULL;
}
if (rc == 0) {
}
if (rc != 0) {
break;
}
quota = next_quota;
}
if ((status == NT_STATUS_SUCCESS) &&
}
return (status);
}
/*
* smb_quota_query_user_quota
*
* Get user quota information for a single user (uid)
* for the current file system.
* Find the user's sid, insert it in the sidlist of a
* smb_quota_query_t request and invoke the door call
* smb_quota_query() to obtain the quota information.
*
* Returns: NT_STATUS codes.
*/
{
smb_quota_t *q;
return (NT_STATUS_INTERNAL_ERROR);
return (NT_STATUS_INTERNAL_ERROR);
}
} else {
} else {
if ((q == NULL) ||
/* should never happen */
} else {
}
}
}
return (status);
}
/*
* smb_quota_query
*
* Door call to query quotas for the provided filesystem path.
* 0 - success. Status set in reply.
*/
int
{
int rc;
return (rc);
}
/*
* smb_quota_set
*
* Door call to set quotas for the provided filesystem path.
* 0 - success. Status set in reply.
*/
int
{
int rc;
return (rc);
}