}
static uint64_t skel_disk_free(vfs_handle_struct *handle, const char *path,
- bool small_query, uint64_t *bsize,
+ uint64_t *bsize,
uint64_t *dfree, uint64_t *dsize)
{
*bsize = 0;
}
static uint64_t skel_disk_free(vfs_handle_struct *handle, const char *path,
- bool small_query, uint64_t *bsize,
+ uint64_t *bsize,
uint64_t *dfree, uint64_t *dsize)
{
- return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
- dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree, dsize);
}
static int skel_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
/* Version 32 - Add "lease" to CREATE_FILE operation */
/* Version 32 - Add "lease" to struct files_struct */
/* Version 32 - Add SMB_VFS_READDIR_ATTR() */
-/* Version 32 - Add in and our create context blobs to create_file */
+/* Version 32 - Add in and out create context blobs to create_file */
+/* Version 32 - Remove unnecessary SMB_VFS_DISK_FREE() small_query parameter */
#define SMB_VFS_INTERFACE_VERSION 32
int (*connect_fn)(struct vfs_handle_struct *handle, const char *service, const char *user);
void (*disconnect_fn)(struct vfs_handle_struct *handle);
- uint64_t (*disk_free_fn)(struct vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,
+ uint64_t (*disk_free_fn)(struct vfs_handle_struct *handle, const char *path, uint64_t *bsize,
uint64_t *dfree, uint64_t *dsize);
int (*get_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
int (*set_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
const char *service, const char *user);
void smb_vfs_call_disconnect(struct vfs_handle_struct *handle);
uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
- const char *path, bool small_query,
- uint64_t *bsize, uint64_t *dfree,
- uint64_t *dsize);
+ const char *path, uint64_t *bsize,
+ uint64_t *dfree, uint64_t *dsize);
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
enum SMB_QUOTA_TYPE qtype, unid_t id,
SMB_DISK_QUOTA *qt);
#define SMB_VFS_NEXT_DISCONNECT(handle) \
smb_vfs_call_disconnect((handle)->next)
-#define SMB_VFS_DISK_FREE(conn, path, small_query, bsize, dfree ,dsize) \
- smb_vfs_call_disk_free((conn)->vfs_handles, (path), (small_query), (bsize), (dfree), (dsize))
-#define SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize, dfree ,dsize)\
- smb_vfs_call_disk_free((handle)->next, (path), (small_query), (bsize), (dfree), (dsize))
+#define SMB_VFS_DISK_FREE(conn, path, bsize, dfree ,dsize) \
+ smb_vfs_call_disk_free((conn)->vfs_handles, (path), (bsize), (dfree), (dsize))
+#define SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree ,dsize)\
+ smb_vfs_call_disk_free((handle)->next, (path), (bsize), (dfree), (dsize))
#define SMB_VFS_GET_QUOTA(conn, qtype, id, qt) \
smb_vfs_call_get_quota((conn)->vfs_handles, (qtype), (id), (qt))
static char *capdecode(TALLOC_CTX *ctx, const char *from);
static uint64_t cap_disk_free(vfs_handle_struct *handle, const char *path,
- bool small_query, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
char *cappath = capencode(talloc_tos(), path);
errno = ENOMEM;
return (uint64_t)-1;
}
- return SMB_VFS_NEXT_DISK_FREE(handle, cappath, small_query, bsize,
- dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(handle, cappath, bsize, dfree, dsize);
}
static DIR *cap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
/* Disk operations */
-static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
+ const char *path, uint64_t *bsize,
+ uint64_t *dfree, uint64_t *dsize)
{
struct statvfs statvfs_buf;
int ret;
*bsize = statvfs_buf.f_bsize;
*dfree = statvfs_buf.f_bavail;
*dsize = statvfs_buf.f_blocks;
- disk_norm(small_query, bsize, dfree, dsize);
+ disk_norm(bsize, dfree, dsize);
DEBUG(10, ("[CEPH] bsize: %llu, dfree: %llu, dsize: %llu\n",
llu(*bsize), llu(*dfree), llu(*dsize)));
return *dfree;
/* available disk space is enough or not? */
space_avail = get_dfree_info(fsp->conn,
- fsp->fsp_name->base_name, false,
- &bsize,&dfree,&dsize);
+ fsp->fsp_name->base_name,
+ &bsize, &dfree, &dsize);
/* space_avail is 1k blocks */
if (space_avail == (uint64_t)-1 ||
((uint64_t)space_to_write/1024 > space_avail) ) {
/* Disk operations */
-static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path,
+ uint64_t *bsize, uint64_t *dfree,
+ uint64_t *dsize)
{
uint64_t result;
- result = sys_disk_free(handle->conn, path, small_query, bsize, dfree, dsize);
+ result = sys_disk_free(handle->conn, path, bsize, dfree, dsize);
return result;
}
/* available disk space is enough or not? */
space_avail = get_dfree_info(fsp->conn,
- fsp->fsp_name->base_name, false,
- &bsize,&dfree,&dsize);
+ fsp->fsp_name->base_name,
+ &bsize, &dfree, &dsize);
/* space_avail is 1k blocks */
if (space_avail == (uint64_t)-1 ||
((uint64_t)space_to_write/1024 > space_avail) ) {
}
static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
- const char *path,
- bool small_query, uint64_t *bsize,
+ const char *path, uint64_t *bsize,
uint64_t *dfree, uint64_t *dsize)
{
uint64_t result;
- result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
- dfree, dsize);
+ result = SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree, dsize);
/* Don't have a reasonable notion of failure here */
}
static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
- const char *path, bool small_query,
- uint64_t *bsize_p, uint64_t *dfree_p,
- uint64_t *dsize_p)
+ const char *path, uint64_t *bsize_p,
+ uint64_t *dfree_p, uint64_t *dsize_p)
{
struct statvfs statvfs = { 0, };
int ret;
}
static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, const char *path,
- bool small_query, uint64_t *bsize,
+ uint64_t *bsize,
uint64_t *dfree, uint64_t *dsize)
{
struct security_unix_token *utok;
SMB_VFS_HANDLE_GET_DATA(handle, config, struct gpfs_config_data,
return (uint64_t)-1);
if (!config->dfreequota) {
- return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
+ return SMB_VFS_NEXT_DISK_FREE(handle, path,
bsize, dfree, dsize);
}
err = sys_fsusage(path, dfree, dsize);
if (err) {
DEBUG (0, ("Could not get fs usage, errno %d\n", errno));
- return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
+ return SMB_VFS_NEXT_DISK_FREE(handle, path,
bsize, dfree, dsize);
}
err = vfs_gpfs_get_quotas(path, utok->uid, utok->gid, &fset_id,
&qi_user, &qi_group, &qi_fset);
if (err) {
- return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
+ return SMB_VFS_NEXT_DISK_FREE(handle, path,
bsize, dfree, dsize);
}
vfs_gpfs_disk_free_quota(qi_fset, cur_time, dfree, dsize);
}
- disk_norm(small_query, bsize, dfree, dsize);
+ disk_norm(bsize, dfree, dsize);
return *dfree;
}
}
static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
- const char *path, bool small_query,
- uint64_t *bsize, uint64_t *dfree,
- uint64_t *dsize)
+ const char *path, uint64_t *bsize,
+ uint64_t *dfree, uint64_t *dsize)
{
time_t timestamp;
char *stripped;
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
+ return SMB_VFS_NEXT_DISK_FREE(handle, path,
bsize, dfree, dsize);
}
return -1;
}
- ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, small_query, bsize, dfree,
- dsize);
+ ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, bsize, dfree, dsize);
saved_errno = errno;
TALLOC_FREE(conv);
}
static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle,
- const char *path, bool small_query,
- uint64_t *bsize, uint64_t *dfree,
- uint64_t *dsize)
+ const char *path, uint64_t *bsize,
+ uint64_t *dfree, uint64_t *dsize)
{
time_t timestamp;
char *stripped;
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
+ return SMB_VFS_NEXT_DISK_FREE(handle, path,
bsize, dfree, dsize);
}
return -1;
}
- ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, small_query, bsize, dfree,
- dsize);
+ ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, bsize, dfree, dsize);
saved_errno = errno;
TALLOC_FREE(conv);
}
static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
- const char *path,
- bool small_query, uint64_t *bsize,
+ const char *path, uint64_t *bsize,
uint64_t *dfree, uint64_t *dsize)
{
uint64_t result;
double timediff;
clock_gettime_mono(&ts1);
- result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
- dfree, dsize);
+ result = SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree, dsize);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
Normalise for DOS usage.
****************************************************************************/
-void disk_norm(bool small_query, uint64_t *bsize,uint64_t *dfree,uint64_t *dsize)
+void disk_norm(uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
/* check if the disk is beyond the max disk size */
uint64_t maxdisksize = lp_max_disk_size();
if (maxdisksize) {
/* convert to blocks - and don't overflow */
maxdisksize = ((maxdisksize*1024)/(*bsize))*1024;
- if (*dsize > maxdisksize) *dsize = maxdisksize;
- if (*dfree > maxdisksize) *dfree = maxdisksize-1;
+ if (*dsize > maxdisksize) {
+ *dsize = maxdisksize;
+ }
+ if (*dfree > maxdisksize) {
+ *dfree = maxdisksize - 1;
+ }
/* the -1 should stop applications getting div by 0
errors */
- }
-
- if(small_query) {
- while (*dfree > WORDMAX || *dsize > WORDMAX || *bsize < 512) {
- *dfree /= 2;
- *dsize /= 2;
- *bsize *= 2;
- /*
- * Force max to fit in 16 bit fields.
- */
- if (*bsize > (WORDMAX*512)) {
- *bsize = (WORDMAX*512);
- if (*dsize > WORDMAX)
- *dsize = WORDMAX;
- if (*dfree > WORDMAX)
- *dfree = WORDMAX;
- break;
- }
- }
}
}
Return number of 1K blocks available on a path and total number.
****************************************************************************/
-uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_query,
- uint64_t *bsize,uint64_t *dfree,uint64_t *dsize)
+uint64_t sys_disk_free(connection_struct *conn, const char *path,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
uint64_t dfree_retval;
uint64_t dfree_q = 0;
*dfree = MAX(1,*dfree);
}
- disk_norm(small_query,bsize,dfree,dsize);
+ disk_norm(bsize, dfree, dsize);
if ((*bsize) < 1024) {
dfree_retval = (*dfree)/(1024/(*bsize));
uint64_t get_dfree_info(connection_struct *conn,
const char *path,
- bool small_query,
uint64_t *bsize,
uint64_t *dfree,
uint64_t *dsize)
uint64_t dfree_ret;
if (!dfree_cache_time) {
- return SMB_VFS_DISK_FREE(conn,path,small_query,bsize,dfree,dsize);
+ return SMB_VFS_DISK_FREE(conn, path, bsize, dfree, dsize);
}
if (dfc && (conn->lastused - dfc->last_dfree_time < dfree_cache_time)) {
return dfc->dfree_ret;
}
- dfree_ret = SMB_VFS_DISK_FREE(conn,path,small_query,bsize,dfree,dsize);
+ dfree_ret = SMB_VFS_DISK_FREE(conn, path, bsize, dfree, dsize);
if (dfree_ret == (uint64_t)-1) {
/* Don't cache bad data. */
/* The following definitions come from smbd/dfree.c */
-void disk_norm(bool small_query, uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
-uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_query,
+void disk_norm(uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
+uint64_t sys_disk_free(connection_struct *conn, const char *path,
uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
uint64_t get_dfree_info(connection_struct *conn,
const char *path,
- bool small_query,
uint64_t *bsize,
uint64_t *dfree,
uint64_t *dsize);
uint64_t dfree,dsize,bsize;
START_PROFILE(SMBdskattr);
- ret = get_dfree_info(conn, ".", false, &bsize, &dfree, &dsize);
+ ret = get_dfree_info(conn, ".", &bsize, &dfree, &dsize);
if (ret == (uint64_t)-1) {
reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBdskattr);
struct smb_filename smb_fname;
SMB_STRUCT_STAT st;
NTSTATUS status = NT_STATUS_OK;
+ uint64_t df_ret;
if (fname == NULL || fname->base_name == NULL) {
filename = ".";
{
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 18;
- if (get_dfree_info(conn,filename,False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
+ df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
+ &dsize);
+ if (df_ret == (uint64_t)-1) {
return map_nt_error_from_unix(errno);
}
{
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 24;
- if (get_dfree_info(conn,filename,False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
+ df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
+ &dsize);
+ if (df_ret == (uint64_t)-1) {
return map_nt_error_from_unix(errno);
}
block_size = lp_block_size(snum);
{
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 32;
- if (get_dfree_info(conn,filename,False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
+ df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
+ &dsize);
+ if (df_ret == (uint64_t)-1) {
return map_nt_error_from_unix(errno);
}
block_size = lp_block_size(snum);
len -= fsp->fsp_name->st.st_ex_size;
len /= 1024; /* Len is now number of 1k blocks needed. */
- space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, false,
+ space_avail = get_dfree_info(conn, fsp->fsp_name->base_name,
&bsize, &dfree, &dsize);
if (space_avail == (uint64_t)-1) {
return -1;
}
uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
- const char *path, bool small_query,
- uint64_t *bsize, uint64_t *dfree,
- uint64_t *dsize)
+ const char *path, uint64_t *bsize,
+ uint64_t *dfree, uint64_t *dsize)
{
VFS_FIND(disk_free);
- return handle->fns->disk_free_fn(handle, path, small_query, bsize,
- dfree, dsize);
+ return handle->fns->disk_free_fn(handle, path, bsize, dfree, dsize);
}
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
return NT_STATUS_OK;
}
- diskfree = SMB_VFS_DISK_FREE(vfs->conn, argv[1], False, &bsize, &dfree, &dsize);
+ diskfree = SMB_VFS_DISK_FREE(vfs->conn, argv[1], &bsize, &dfree, &dsize);
printf("disk_free: %lu, bsize = %lu, dfree = %lu, dsize = %lu\n",
(unsigned long)diskfree,
(unsigned long)bsize,