1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-24 13:57:43 +03:00

s3: VFS: Change SMB_VFS_GET_QUOTA to use const struct smb_filename * instead of const char *.

We need to migrate all pathname based VFS calls to use a struct
to finish modernising the VFS with extra timestamp and flags parameters.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
This commit is contained in:
Jeremy Allison 2017-06-01 11:45:25 -07:00
parent 0037815453
commit 0da76414fd
18 changed files with 187 additions and 91 deletions

View File

@ -56,8 +56,10 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle,
return 0;
}
static int skel_get_quota(vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int skel_get_quota(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *dq)
{
errno = ENOSYS;

View File

@ -57,11 +57,13 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle,
return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
}
static int skel_get_quota(vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int skel_get_quota(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *dq)
{
return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
}
static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,

View File

@ -218,6 +218,8 @@
to const struct smb_filename * */
/* Version 37 - Change disk_free from const char *
to const struct smb_filename * */
/* Version 37 - Change get_quota from const char *
to const struct smb_filename * */
#define SMB_VFS_INTERFACE_VERSION 37
@ -607,8 +609,10 @@ struct vfs_fn_pointers {
uint64_t *bsize,
uint64_t *dfree,
uint64_t *dsize);
int (*get_quota_fn)(struct vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
int (*get_quota_fn)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
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);
@ -1065,8 +1069,10 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
uint64_t *bsize,
uint64_t *dfree,
uint64_t *dsize);
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
const struct smb_filename *smb_filename,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *qt);
int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
enum SMB_QUOTA_TYPE qtype, unid_t id,

View File

@ -44,10 +44,10 @@
#define SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree ,dsize)\
smb_vfs_call_disk_free((handle)->next, (smb_fname), (bsize), (dfree), (dsize))
#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_GET_QUOTA(conn, smb_fname, qtype, id, qt) \
smb_vfs_call_get_quota((conn)->vfs_handles, (smb_fname), (qtype), (id), (qt))
#define SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt) \
smb_vfs_call_get_quota((handle)->next, (smb_fname), (qtype), (id), (qt))
#define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) \
smb_vfs_call_set_quota((conn)->vfs_handles, (qtype), (id), (qt))

View File

@ -56,17 +56,30 @@ static uint64_t cap_disk_free(vfs_handle_struct *handle,
bsize, dfree, dsize);
}
static int cap_get_quota(vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int cap_get_quota(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *dq)
{
char *cappath = capencode(talloc_tos(), path);
char *cappath = capencode(talloc_tos(), smb_fname->base_name);
struct smb_filename *cap_smb_fname = NULL;
if (!cappath) {
errno = ENOMEM;
return -1;
}
return SMB_VFS_NEXT_GET_QUOTA(handle, cappath, qtype, id, dq);
cap_smb_fname = synthetic_smb_fname(talloc_tos(),
cappath,
NULL,
NULL,
smb_fname->flags);
if (cap_smb_fname == NULL) {
TALLOC_FREE(cappath);
errno = ENOMEM;
return -1;
}
return SMB_VFS_NEXT_GET_QUOTA(handle, cap_smb_fname, qtype, id, dq);
}
static DIR *cap_opendir(vfs_handle_struct *handle,

View File

@ -201,8 +201,10 @@ static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
}
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)
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *qt)
{
/* libceph: Ceph does not implement this */
#if 0

View File

@ -69,15 +69,17 @@ static uint64_t vfswrap_disk_free(vfs_handle_struct *handle,
return *dfree / 2;
}
static int vfswrap_get_quota(struct vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int vfswrap_get_quota(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
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(path, qtype, id, qt);
result = sys_get_quota(smb_fname->base_name, qtype, id, qt);
END_PROFILE(syscall_get_quota);
return result;
#else

View File

@ -92,13 +92,16 @@
#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, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int default_quota_get_quota(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *dq)
{
int ret = -1;
if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq)) != 0) {
if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
qtype, id, dq)) != 0) {
return ret;
}
@ -124,8 +127,8 @@ static int default_quota_get_quota(vfs_handle_struct *handle, const char *path,
unid_t qid;
uint32_t qflags = dq->qflags;
qid.uid = DEFAULT_QUOTA_UID(handle);
SMB_VFS_NEXT_GET_QUOTA(
handle, path, SMB_USER_QUOTA_TYPE, qid, dq);
SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
SMB_USER_QUOTA_TYPE, qid, dq);
dq->qflags = qflags;
}
break;
@ -135,7 +138,7 @@ static int default_quota_get_quota(vfs_handle_struct *handle, const char *path,
unid_t qid;
uint32_t qflags = dq->qflags;
qid.gid = DEFAULT_QUOTA_GID(handle);
SMB_VFS_NEXT_GET_QUOTA(handle, path,
SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
SMB_GROUP_QUOTA_TYPE,
qid, dq);
dq->qflags = qflags;

View File

@ -27,8 +27,10 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int dfq_get_quota(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
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,
@ -88,8 +90,10 @@ static uint64_t dfq_disk_free(vfs_handle_struct *handle,
return free_1k;
}
static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int dfq_get_quota(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *qt)
{
int rc = 0;
@ -99,7 +103,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
uint64_t bsize = 0;
char *rpath = NULL;
rpath = SMB_VFS_NEXT_REALPATH(handle, path);
rpath = SMB_VFS_NEXT_REALPATH(handle, smb_fname->base_name);
if (rpath == NULL) {
goto dflt;
}
@ -160,7 +164,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
goto out;
dflt:
rc = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
rc = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
out:
save_errno = errno;

View File

@ -693,14 +693,17 @@ static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
}
static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
const char *path, enum SMB_QUOTA_TYPE qtype,
unid_t id, SMB_DISK_QUOTA *qt)
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *qt)
{
int result;
result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s", path);
do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s",
smb_fname->base_name);
return result;
}

View File

@ -402,8 +402,9 @@ static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
}
static int vfs_gluster_get_quota(struct vfs_handle_struct *handle,
const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *qt)
{
errno = ENOSYS;

View File

@ -2217,8 +2217,10 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle,
return *dfree / 2;
}
static int vfs_gpfs_get_quota(vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int vfs_gpfs_get_quota(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *dq)
{
switch(qtype) {
@ -2237,7 +2239,8 @@ static int vfs_gpfs_get_quota(vfs_handle_struct *handle, const char *path,
errno = ENOSYS;
return -1;
default:
return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
qtype, id, dq);
}
}

View File

@ -2792,8 +2792,10 @@ static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
return ret;
}
static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int shadow_copy2_get_quota(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *dq)
{
time_t timestamp = 0;
@ -2801,13 +2803,17 @@ static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path,
int ret;
int saved_errno = 0;
char *conv;
struct smb_filename *conv_smb_fname = NULL;
if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path, &timestamp,
if (!shadow_copy2_strip_snapshot(talloc_tos(),
handle,
smb_fname->base_name,
&timestamp,
&stripped)) {
return -1;
}
if (timestamp == 0) {
return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
@ -2815,13 +2821,22 @@ static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path,
if (conv == NULL) {
return -1;
}
ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv, qtype, id, dq);
conv_smb_fname = synthetic_smb_fname(talloc_tos(),
conv,
NULL,
NULL,
smb_fname->flags);
if (conv_smb_fname == NULL) {
TALLOC_FREE(conv);
return -1;
}
ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
if (ret == -1) {
saved_errno = errno;
}
TALLOC_FREE(conv);
TALLOC_FREE(conv_smb_fname);
if (saved_errno != 0) {
errno = saved_errno;
}

View File

@ -3032,22 +3032,25 @@ static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle,
return ret;
}
static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
static int snapper_gmt_get_quota(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *dq)
{
time_t timestamp;
char *stripped;
time_t timestamp = 0;
char *stripped = NULL;
int ret;
int saved_errno;
char *conv;
int saved_errno = 0;
char *conv = NULL;
struct smb_filename *conv_smb_fname = NULL;
if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, path, &timestamp,
&stripped)) {
if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
smb_fname->base_name, &timestamp, &stripped)) {
return -1;
}
if (timestamp == 0) {
return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
@ -3055,13 +3058,26 @@ static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path,
if (conv == NULL) {
return -1;
}
ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv, qtype, id, dq);
saved_errno = errno;
conv_smb_fname = synthetic_smb_fname(talloc_tos(),
conv,
NULL,
NULL,
smb_fname->flags);
TALLOC_FREE(conv);
errno = saved_errno;
if (conv_smb_fname == NULL) {
errno = ENOMEM;
return -1;
}
ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
if (ret == -1) {
saved_errno = errno;
}
TALLOC_FREE(conv_smb_fname);
if (saved_errno != 0) {
errno = saved_errno;
}
return ret;
}

View File

@ -182,20 +182,24 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
}
static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
const char *path, enum SMB_QUOTA_TYPE qtype,
unid_t id, SMB_DISK_QUOTA *qt)
const struct smb_filename *smb_fname,
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, path, qtype, id, qt);
result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
smb_time_audit_log("get_quota", timediff);
smb_time_audit_log_fname("get_quota",
timediff,
smb_fname->base_name);
}
return result;
}

View File

@ -74,6 +74,8 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype,
int ret;
SMB_DISK_QUOTA D;
unid_t id;
struct smb_filename *smb_fname_cwd = NULL;
int saved_errno = 0;
ZERO_STRUCT(D);
@ -91,7 +93,23 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype,
return NT_STATUS_NO_SUCH_USER;
}
ret = SMB_VFS_GET_QUOTA(fsp->conn, ".", qtype, id, &D);
smb_fname_cwd = synthetic_smb_fname(talloc_tos(),
".",
NULL,
NULL,
0);
if (smb_fname_cwd == NULL) {
return NT_STATUS_NO_MEMORY;
}
ret = SMB_VFS_GET_QUOTA(fsp->conn, smb_fname_cwd, qtype, id, &D);
if (ret == -1) {
saved_errno = errno;
}
TALLOC_FREE(smb_fname_cwd);
if (saved_errno != 0) {
errno = saved_errno;
}
if (psid)
qt->sid = *psid;

View File

@ -494,7 +494,7 @@ bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
*/
ZERO_STRUCT(D);
id.uid = -1;
r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_USER_FS_QUOTA_TYPE,
r = SMB_VFS_GET_QUOTA(conn, fname, SMB_USER_FS_QUOTA_TYPE,
id, &D);
if (r == -1 && errno != ENOSYS) {
goto try_group_quota;
@ -516,13 +516,13 @@ bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
id.uid = fname->st.st_ex_uid;
become_root();
r = SMB_VFS_GET_QUOTA(conn, fname->base_name,
r = SMB_VFS_GET_QUOTA(conn, fname,
SMB_USER_QUOTA_TYPE, id, &D);
save_errno = errno;
unbecome_root();
errno = save_errno;
} else {
r = SMB_VFS_GET_QUOTA(conn, fname->base_name,
r = SMB_VFS_GET_QUOTA(conn, fname,
SMB_USER_QUOTA_TYPE, id, &D);
}
@ -560,7 +560,7 @@ try_group_quota:
*/
ZERO_STRUCT(D);
id.gid = -1;
r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_FS_QUOTA_TYPE,
r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_FS_QUOTA_TYPE,
id, &D);
if (r == -1 && errno != ENOSYS) {
return false;
@ -572,7 +572,7 @@ try_group_quota:
id.gid = getegid();
ZERO_STRUCT(D);
r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_QUOTA_TYPE, id,
r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id,
&D);
if (r == -1) {

View File

@ -1478,12 +1478,14 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
bsize, dfree, dsize);
}
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
enum SMB_QUOTA_TYPE qtype, unid_t id,
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
enum SMB_QUOTA_TYPE qtype,
unid_t id,
SMB_DISK_QUOTA *qt)
{
VFS_FIND(get_quota);
return handle->fns->get_quota_fn(handle, path, qtype, id, qt);
return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt);
}
int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,