mirror of
https://github.com/samba-team/samba.git
synced 2025-02-24 13:57:43 +03:00
vfs: add path parameter to get_quota
Adding a path parameter would allow the VFS get_quota function to be used for determining the quota/usage when calculating size and free spacei. Signed-off-by: Uri Simchoni <uri@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
parent
f71761c47a
commit
c464b9e460
@ -54,8 +54,9 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, const char *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int skel_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
|
||||
unid_t id, SMB_DISK_QUOTA *dq)
|
||||
static int skel_get_quota(vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *dq)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
@ -55,10 +55,11 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle, const char *path,
|
||||
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,
|
||||
unid_t id, SMB_DISK_QUOTA *dq)
|
||||
static int skel_get_quota(vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *dq)
|
||||
{
|
||||
return SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, dq);
|
||||
return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
|
||||
}
|
||||
|
||||
static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
|
||||
|
@ -526,7 +526,9 @@ struct vfs_fn_pointers {
|
||||
void (*disconnect_fn)(struct vfs_handle_struct *handle);
|
||||
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 (*get_quota_fn)(struct vfs_handle_struct *handle, const char *path,
|
||||
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);
|
||||
int (*get_shadow_copy_data_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels);
|
||||
int (*statvfs_fn)(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf);
|
||||
@ -931,7 +933,7 @@ 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, uint64_t *bsize,
|
||||
uint64_t *dfree, uint64_t *dsize);
|
||||
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
|
||||
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt);
|
||||
int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
|
||||
|
@ -44,10 +44,10 @@
|
||||
#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))
|
||||
#define SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt) \
|
||||
smb_vfs_call_get_quota((handle)->next, (qtype), (id), (qt))
|
||||
#define SMB_VFS_GET_QUOTA(conn, path, qtype, id, qt) \
|
||||
smb_vfs_call_get_quota((conn)->vfs_handles, (path), (qtype), (id), (qt))
|
||||
#define SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt) \
|
||||
smb_vfs_call_get_quota((handle)->next, (path), (qtype), (id), (qt))
|
||||
|
||||
#define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) \
|
||||
smb_vfs_call_set_quota((conn)->vfs_handles, (qtype), (id), (qt))
|
||||
|
@ -185,7 +185,9 @@ static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
|
||||
}
|
||||
}
|
||||
|
||||
static int cephwrap_get_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
|
||||
static int cephwrap_get_quota(struct vfs_handle_struct *handle,
|
||||
const char *path, enum SMB_QUOTA_TYPE qtype,
|
||||
unid_t id, SMB_DISK_QUOTA *qt)
|
||||
{
|
||||
/* libceph: Ceph does not implement this */
|
||||
#if 0
|
||||
|
@ -64,13 +64,15 @@ static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path,
|
||||
return result;
|
||||
}
|
||||
|
||||
static int vfswrap_get_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
|
||||
static int vfswrap_get_quota(struct vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt)
|
||||
{
|
||||
#ifdef HAVE_SYS_QUOTAS
|
||||
int result;
|
||||
|
||||
START_PROFILE(syscall_get_quota);
|
||||
result = sys_get_quota(handle->conn->connectpath, qtype, id, qt);
|
||||
result = sys_get_quota(path, qtype, id, qt);
|
||||
END_PROFILE(syscall_get_quota);
|
||||
return result;
|
||||
#else
|
||||
|
@ -92,11 +92,13 @@
|
||||
#define DEFAULT_QUOTA_GID_NOLIMIT(handle) \
|
||||
lp_parm_bool(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"gid nolimit",DEFAULT_QUOTA_GID_NOLIMIT_DEFAULT)
|
||||
|
||||
static int default_quota_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq)
|
||||
static int default_quota_get_quota(vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *dq)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if ((ret=SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, dq))!=0) {
|
||||
if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -122,7 +124,8 @@ static int default_quota_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYP
|
||||
unid_t qid;
|
||||
uint32_t qflags = dq->qflags;
|
||||
qid.uid = DEFAULT_QUOTA_UID(handle);
|
||||
SMB_VFS_NEXT_GET_QUOTA(handle, SMB_USER_QUOTA_TYPE, qid, dq);
|
||||
SMB_VFS_NEXT_GET_QUOTA(
|
||||
handle, path, SMB_USER_QUOTA_TYPE, qid, dq);
|
||||
dq->qflags = qflags;
|
||||
}
|
||||
break;
|
||||
@ -132,7 +135,9 @@ static int default_quota_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYP
|
||||
unid_t qid;
|
||||
uint32_t qflags = dq->qflags;
|
||||
qid.gid = DEFAULT_QUOTA_GID(handle);
|
||||
SMB_VFS_NEXT_GET_QUOTA(handle, SMB_GROUP_QUOTA_TYPE, qid, dq);
|
||||
SMB_VFS_NEXT_GET_QUOTA(handle, path,
|
||||
SMB_GROUP_QUOTA_TYPE,
|
||||
qid, dq);
|
||||
dq->qflags = qflags;
|
||||
}
|
||||
break;
|
||||
|
@ -27,9 +27,9 @@
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_VFS
|
||||
|
||||
static int dfq_get_quota_do(struct vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt);
|
||||
static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt);
|
||||
|
||||
static uint64_t dfq_load_param(int snum, const char *path, const char *section,
|
||||
const char *param, uint64_t def_val)
|
||||
@ -60,7 +60,7 @@ static bool dfq_disk_quotas(vfs_handle_struct *handle, const char *path,
|
||||
id.uid = geteuid();
|
||||
|
||||
ZERO_STRUCT(D);
|
||||
r = dfq_get_quota_do(handle, path, SMB_USER_QUOTA_TYPE, id, &D);
|
||||
r = dfq_get_quota(handle, path, SMB_USER_QUOTA_TYPE, id, &D);
|
||||
|
||||
/* Use softlimit to determine disk space, except when it has been
|
||||
* exceeded */
|
||||
@ -99,7 +99,7 @@ try_group_quota:
|
||||
id.gid = getegid();
|
||||
|
||||
ZERO_STRUCT(D);
|
||||
r = dfq_get_quota_do(handle, path, SMB_GROUP_QUOTA_TYPE, id, &D);
|
||||
r = dfq_get_quota(handle, path, SMB_GROUP_QUOTA_TYPE, id, &D);
|
||||
|
||||
/* Use softlimit to determine disk space, except when it has been
|
||||
* exceeded */
|
||||
@ -181,9 +181,9 @@ static uint64_t dfq_disk_free(vfs_handle_struct *handle, const char *path,
|
||||
return free_1k;
|
||||
}
|
||||
|
||||
static int dfq_get_quota_do(struct vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt)
|
||||
static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt)
|
||||
{
|
||||
int rc = 0;
|
||||
int save_errno;
|
||||
@ -245,7 +245,7 @@ static int dfq_get_quota_do(struct vfs_handle_struct *handle, const char *path,
|
||||
goto out;
|
||||
|
||||
dflt:
|
||||
rc = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
|
||||
rc = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
|
||||
|
||||
out:
|
||||
save_errno = errno;
|
||||
@ -255,14 +255,6 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int dfq_get_quota(struct vfs_handle_struct *handle,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt)
|
||||
{
|
||||
return dfq_get_quota_do(handle, handle->conn->connectpath, qtype, id,
|
||||
qt);
|
||||
}
|
||||
|
||||
struct vfs_fn_pointers vfs_fake_dfq_fns = {
|
||||
/* Disk operations */
|
||||
|
||||
|
@ -666,14 +666,14 @@ static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt)
|
||||
const char *path, enum SMB_QUOTA_TYPE qtype,
|
||||
unid_t id, SMB_DISK_QUOTA *qt)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
|
||||
result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
|
||||
|
||||
do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
|
||||
do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s", path);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -178,15 +178,15 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt)
|
||||
const char *path, enum SMB_QUOTA_TYPE qtype,
|
||||
unid_t id, SMB_DISK_QUOTA *qt)
|
||||
{
|
||||
int result;
|
||||
struct timespec ts1,ts2;
|
||||
double timediff;
|
||||
|
||||
clock_gettime_mono(&ts1);
|
||||
result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
|
||||
result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
|
||||
clock_gettime_mono(&ts2);
|
||||
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
|
||||
|
||||
|
@ -96,7 +96,7 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid
|
||||
sid_string_dbg(psid)));
|
||||
}
|
||||
|
||||
ret = SMB_VFS_GET_QUOTA(fsp->conn, qtype, id, &D);
|
||||
ret = SMB_VFS_GET_QUOTA(fsp->conn, ".", qtype, id, &D);
|
||||
|
||||
if (psid)
|
||||
qt->sid = *psid;
|
||||
|
@ -1404,12 +1404,12 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
|
||||
return handle->fns->disk_free_fn(handle, path, bsize, dfree, dsize);
|
||||
}
|
||||
|
||||
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
|
||||
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
|
||||
enum SMB_QUOTA_TYPE qtype, unid_t id,
|
||||
SMB_DISK_QUOTA *qt)
|
||||
{
|
||||
VFS_FIND(get_quota);
|
||||
return handle->fns->get_quota_fn(handle, qtype, id, qt);
|
||||
return handle->fns->get_quota_fn(handle, path, qtype, id, qt);
|
||||
}
|
||||
|
||||
int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
|
||||
|
Loading…
x
Reference in New Issue
Block a user