}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
errno = ENOSYS;
return -1;
}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
- return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
+ return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
}
static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
* Version 53 - Change DISK_FREE to take a fsp instead of a name
* Version 53 - Add fstatvfs
* Version 53 - Remove statvfs
+ * Version 53 - Change GET_QUOTA to take a fsp instead of a name
*/
#define SMB_VFS_INTERFACE_VERSION 53
uint64_t *dfree,
uint64_t *dsize);
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);
+ struct files_struct *fsp,
+ 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 (*fstatvfs_fn)(struct vfs_handle_struct *handle,
uint64_t *dfree,
uint64_t *dsize);
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);
+ struct files_struct *fsp,
+ 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);
uint64_t *dfree,
uint64_t *dsize);
int vfs_not_implemented_get_quota(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- enum SMB_QUOTA_TYPE qtype,
- unid_t id,
- SMB_DISK_QUOTA *dq);
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq);
int vfs_not_implemented_set_quota(vfs_handle_struct *handle,
enum SMB_QUOTA_TYPE qtype,
unid_t id, SMB_DISK_QUOTA *dq);
smb_vfs_call_disk_free( \
(handle)->next, (fsp), (bsize), (dfree), (dsize))
-#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_GET_QUOTA(fsp, qtype, id, qt) \
+ smb_vfs_call_get_quota( \
+ (fsp)->conn->vfs_handles, (fsp), (qtype), (id), (qt))
+#define SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt) \
+ smb_vfs_call_get_quota((handle)->next, (fsp), (qtype), (id), (qt))
#define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) \
smb_vfs_call_set_quota((conn)->vfs_handles, (qtype), (id), (qt))
}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
+ struct smb_filename *smb_fname = fsp->fsp_name;
char *cappath = capencode(talloc_tos(), smb_fname->base_name);
struct smb_filename *cap_smb_fname = NULL;
+ NTSTATUS status;
+ int ret;
if (!cappath) {
errno = ENOMEM;
return -1;
}
- cap_smb_fname = synthetic_smb_fname(talloc_tos(),
- cappath,
- NULL,
- NULL,
- smb_fname->twrp,
- smb_fname->flags);
- if (cap_smb_fname == NULL) {
- TALLOC_FREE(cappath);
- errno = ENOMEM;
+ status = synthetic_pathref(talloc_tos(),
+ fsp->conn->cwd_fsp,
+ cappath,
+ NULL,
+ NULL,
+ smb_fname->twrp,
+ smb_fname->flags,
+ &cap_smb_fname);
+ TALLOC_FREE(cappath);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
return -1;
}
- return SMB_VFS_NEXT_GET_QUOTA(handle, cap_smb_fname, qtype, id, dq);
+ ret = SMB_VFS_NEXT_GET_QUOTA(
+ handle, cap_smb_fname->fsp, qtype, id, dq);
+ {
+ int err = errno;
+ TALLOC_FREE(cap_smb_fname);
+ errno = err;
+ }
+ return ret;
}
static struct dirent *
}
static int ceph_snap_gmt_get_quota(vfs_handle_struct *handle,
- const struct smb_filename *csmb_fname,
- enum SMB_QUOTA_TYPE qtype,
- unid_t id,
- SMB_DISK_QUOTA *dq)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
+ struct smb_filename *csmb_fname = fsp->fsp_name;
time_t timestamp = 0;
char stripped[PATH_MAX + 1];
char conv[PATH_MAX + 1];
int ret;
struct smb_filename *new_fname;
+ NTSTATUS status;
int saved_errno;
ret = ceph_snap_gmt_strip_snapshot(handle,
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_GET_QUOTA(handle, csmb_fname, qtype, id, dq);
+ return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
}
ret = ceph_snap_gmt_convert(handle, stripped,
timestamp, conv, sizeof(conv));
errno = -ret;
return -1;
}
- new_fname = cp_smb_filename(talloc_tos(), csmb_fname);
- if (new_fname == NULL) {
- errno = ENOMEM;
+
+ status = synthetic_pathref(talloc_tos(),
+ fsp->conn->cwd_fsp,
+ conv,
+ csmb_fname->stream_name,
+ NULL,
+ csmb_fname->twrp,
+ csmb_fname->flags,
+ &new_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
return -1;
}
- new_fname->base_name = conv;
- ret = SMB_VFS_NEXT_GET_QUOTA(handle, new_fname, qtype, id, dq);
+ ret = SMB_VFS_NEXT_GET_QUOTA(handle, new_fname->fsp, qtype, id, dq);
saved_errno = errno;
TALLOC_FREE(new_fname);
errno = saved_errno;
}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *qt)
{
#ifdef HAVE_SYS_QUOTAS
+ struct smb_filename *smb_fname = fsp->fsp_name;
int result;
START_PROFILE_X(SNUM(handle->conn), syscall_get_quota);
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 struct smb_filename *smb_fname,
- enum SMB_QUOTA_TYPE qtype,
- unid_t id,
- SMB_DISK_QUOTA *dq)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
int ret = -1;
- if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
- qtype, id, dq)) != 0) {
+ if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, 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, smb_fname,
- SMB_USER_QUOTA_TYPE, qid, dq);
+ SMB_VFS_NEXT_GET_QUOTA(handle,
+ fsp,
+ 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, smb_fname,
+ SMB_VFS_NEXT_GET_QUOTA(handle,
+ fsp,
SMB_GROUP_QUOTA_TYPE,
- qid, dq);
+ qid,
+ dq);
dq->qflags = qflags;
}
break;
#define DBGC_CLASS DBGC_VFS
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);
+ struct files_struct *fsp,
+ 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)
}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *qt)
{
+ struct smb_filename *smb_fname = fsp->fsp_name;
int rc = 0;
int save_errno;
char *section = NULL;
goto out;
dflt:
- rc = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
+ rc = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt);
out:
save_errno = errno;
}
static int smb_full_audit_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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *qt)
{
int result;
- result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
+ result = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt);
do_log(SMB_VFS_OP_GET_QUOTA,
errmsg_unix(result),
handle,
"%s",
- smb_fname_str_do_log(handle->conn, smb_fname));
+ smb_fname_str_do_log(handle->conn, fsp->fsp_name));
return result;
}
}
static int vfs_gluster_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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *qt)
{
errno = ENOSYS;
return -1;
}
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)
+ struct files_struct *fsp,
+ 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, smb_fname,
- qtype, id, dq);
+ return SMB_VFS_NEXT_GET_QUOTA(
+ handle, fsp, qtype, id, dq);
}
}
_PUBLIC_
int vfs_not_implemented_get_quota(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- enum SMB_QUOTA_TYPE qtype,
- unid_t id,
- SMB_DISK_QUOTA *dq)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
errno = ENOSYS;
return -1;
}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
+ struct smb_filename *smb_fname = fsp->fsp_name;
time_t timestamp = 0;
char *stripped = NULL;
int ret;
int saved_errno = 0;
char *conv;
struct smb_filename *conv_smb_fname = NULL;
+ NTSTATUS status;
if (!shadow_copy2_strip_snapshot(talloc_tos(),
handle,
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
+ return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
+ errno = ENOMEM;
return -1;
}
- conv_smb_fname = synthetic_smb_fname(talloc_tos(),
- conv,
- NULL,
- NULL,
- 0,
- smb_fname->flags);
- if (conv_smb_fname == NULL) {
+
+ status = synthetic_pathref(talloc_tos(),
+ fsp->conn->cwd_fsp,
+ conv,
+ NULL,
+ NULL,
+ 0,
+ smb_fname->flags,
+ &conv_smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(conv);
+ errno = map_errno_from_nt_status(status);
return -1;
}
- ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
+ ret = SMB_VFS_NEXT_GET_QUOTA(
+ handle, conv_smb_fname->fsp, qtype, id, dq);
if (ret == -1) {
saved_errno = errno;
}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
+ struct smb_filename *smb_fname = fsp->fsp_name;
time_t timestamp = 0;
char *stripped = NULL;
int ret;
int saved_errno = 0;
char *conv = NULL;
struct smb_filename *conv_smb_fname = NULL;
+ NTSTATUS status;
if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
smb_fname, ×tamp, &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
+ return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
if (conv == NULL) {
return -1;
}
- conv_smb_fname = synthetic_smb_fname(talloc_tos(),
- conv,
- NULL,
- NULL,
- 0,
- smb_fname->flags);
+
+ status = synthetic_pathref(talloc_tos(),
+ fsp->conn->cwd_fsp,
+ conv,
+ NULL,
+ NULL,
+ 0,
+ smb_fname->flags,
+ &conv_smb_fname);
TALLOC_FREE(conv);
- if (conv_smb_fname == NULL) {
- errno = ENOMEM;
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
return -1;
}
- ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
+ ret = SMB_VFS_NEXT_GET_QUOTA(
+ handle, conv_smb_fname->fsp, qtype, id, dq);
if (ret == -1) {
saved_errno = errno;
}
static int smb_time_audit_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)
+ struct files_struct *fsp,
+ 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, smb_fname, qtype, id, qt);
+ result = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
smb_time_audit_log_fname("get_quota",
- timediff,
- smb_fname->base_name);
+ timediff,
+ fsp->fsp_name->base_name);
}
return result;
}
unid_t id;
struct smb_filename *smb_fname_cwd = NULL;
int saved_errno = 0;
+ NTSTATUS status;
ZERO_STRUCT(D);
return NT_STATUS_NO_SUCH_USER;
}
- smb_fname_cwd = cp_smb_basename(talloc_tos(), ".");
- if (smb_fname_cwd == NULL) {
- return NT_STATUS_NO_MEMORY;
+ /*
+ * SMB_VFS_GET_QUOTA needs a "real" fsp, not a fake file one.
+ */
+ status = openat_pathref_fsp_dot(talloc_tos(),
+ fsp->conn->cwd_fsp,
+ 0,
+ &smb_fname_cwd);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- ret = SMB_VFS_GET_QUOTA(fsp->conn, smb_fname_cwd, qtype, id, &D);
+ ret = SMB_VFS_GET_QUOTA(smb_fname_cwd->fsp, qtype, id, &D);
if (ret == -1) {
saved_errno = errno;
}
*/
ZERO_STRUCT(D);
id.uid = -1;
- r = SMB_VFS_GET_QUOTA(conn, fname, SMB_USER_FS_QUOTA_TYPE,
- id, &D);
+ r = SMB_VFS_GET_QUOTA(fsp, 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,
- SMB_USER_QUOTA_TYPE, id, &D);
+ r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_QUOTA_TYPE, id, &D);
save_errno = errno;
unbecome_root();
errno = save_errno;
} else {
- r = SMB_VFS_GET_QUOTA(conn, fname,
- SMB_USER_QUOTA_TYPE, id, &D);
+ r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_QUOTA_TYPE, id, &D);
}
if (r == -1) {
*/
ZERO_STRUCT(D);
id.gid = -1;
- r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_FS_QUOTA_TYPE,
- id, &D);
+ r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_FS_QUOTA_TYPE, id, &D);
if (r == -1 && errno != ENOSYS) {
return false;
}
fname->st.st_ex_mode & S_ISGID) {
id.gid = fname->st.st_ex_gid;
become_root();
- r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id,
- &D);
+ r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_QUOTA_TYPE, id, &D);
unbecome_root();
} else {
id.gid = getegid();
- r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id,
- &D);
+ r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_QUOTA_TYPE, id, &D);
}
if (r == -1) {
}
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)
+ struct files_struct *fsp,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *qt)
{
VFS_FIND(get_quota);
- return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt);
+ return handle->fns->get_quota_fn(handle, fsp, qtype, id, qt);
}
int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,