return 0;
}
-static int skel_get_quota(vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *dq)
+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;
return -1;
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,
- SMB_DISK_QUOTA *dq)
+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,
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
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,
- SMB_DISK_QUOTA *qt);
+ 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);
int (*statvfs_fn)(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf);
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,
- SMB_DISK_QUOTA *qt);
+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,
SMB_DISK_QUOTA *qt);
#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))
bsize, dfree, dsize);
}
-static int cap_get_quota(vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *dq)
+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,
}
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
return *dfree / 2;
}
-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)
+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
#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,
- SMB_DISK_QUOTA *dq)
+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;
}
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;
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;
#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,
- SMB_DISK_QUOTA *qt);
+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,
const char *param, uint64_t def_val)
return free_1k;
}
-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 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;
int save_errno;
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;
}
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;
}
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;
}
}
static int vfs_gluster_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)
{
errno = ENOSYS;
return -1;
return *dfree / 2;
}
-static int vfs_gpfs_get_quota(vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *dq)
+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) {
/*
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);
}
}
return ret;
}
-static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *dq)
+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;
char *stripped = NULL;
int ret;
int saved_errno = 0;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path, ×tamp,
- &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &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);
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;
}
return ret;
}
-static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *dq)
+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, ×tamp,
- &stripped)) {
+ if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
+ smb_fname->base_name, ×tamp, &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);
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;
}
}
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;
}
int ret;
SMB_DISK_QUOTA D;
unid_t id;
+ struct smb_filename *smb_fname_cwd = NULL;
+ int saved_errno = 0;
ZERO_STRUCT(D);
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;
*/
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;
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);
}
*/
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;
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) {
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,
- SMB_DISK_QUOTA *qt)
+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,