}
static uint64_t skel_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
*bsize = 0;
*dfree = 0;
}
static uint64_t skel_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
- return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize);
}
static int skel_get_quota(vfs_handle_struct *handle,
* Version 52 - Remove connectpath
* Version 52 - Remove audit_file
* Version 52 - Add VFS_OPEN_HOW_RESOLVE_NO_XDEV for SMB_VFS_OPENAT()
+ * Change to Version 53 - will ship with 4.25
+ * Version 53 - Change DISK_FREE to take a fsp instead of a name
*/
-#define SMB_VFS_INTERFACE_VERSION 52
+#define SMB_VFS_INTERFACE_VERSION 53
/*
All intercepted VFS operations must be declared as static functions inside module source
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 struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize);
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ 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,
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 struct smb_filename *smb_filename,
+ struct files_struct *fsp,
uint64_t *bsize,
uint64_t *dfree,
uint64_t *dsize);
const char *user);
void vfs_not_implemented_disconnect(vfs_handle_struct *handle);
uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize);
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ 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,
#define SMB_VFS_NEXT_DISCONNECT(handle) \
smb_vfs_call_disconnect((handle)->next)
-#define SMB_VFS_DISK_FREE(conn, smb_fname, bsize, dfree ,dsize) \
- smb_vfs_call_disk_free((conn)->vfs_handles, (smb_fname), (bsize), (dfree), (dsize))
-#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_DISK_FREE(conn, fsp, bsize, dfree, dsize) \
+ smb_vfs_call_disk_free( \
+ (conn)->vfs_handles, (fsp), (bsize), (dfree), (dsize))
+#define SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize) \
+ 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))
static char *capdecode(TALLOC_CTX *ctx, const char *from);
static uint64_t cap_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
char *capname = capencode(talloc_tos(), smb_fname->base_name);
struct smb_filename *cap_smb_fname = NULL;
+ NTSTATUS status;
+ uint64_t ret;
if (!capname) {
errno = ENOMEM;
return (uint64_t)-1;
}
- cap_smb_fname = synthetic_smb_fname(talloc_tos(),
- capname,
- NULL,
- NULL,
- smb_fname->twrp,
- smb_fname->flags);
- if (cap_smb_fname == NULL) {
+
+ status = synthetic_pathref(capname,
+ handle->conn->cwd_fsp,
+ capname,
+ NULL,
+ NULL,
+ smb_fname->twrp,
+ smb_fname->flags,
+ &cap_smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(capname);
- errno = ENOMEM;
+ errno = map_errno_from_nt_status(status);
return (uint64_t)-1;
}
- return SMB_VFS_NEXT_DISK_FREE(handle, cap_smb_fname,
- bsize, dfree, dsize);
+ ret = SMB_VFS_NEXT_DISK_FREE(
+ handle, cap_smb_fname->fsp, bsize, dfree, dsize);
+ TALLOC_FREE(cap_smb_fname);
+ return ret;
}
static int cap_get_quota(vfs_handle_struct *handle,
/* Disk operations */
static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
struct statvfs statvfs_buf = { 0 };
int ret;
/* Disk operations */
static uint64_t vfs_ceph_disk_free(struct vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
struct statvfs statvfs_buf = { 0 };
int ret;
struct vfs_ceph_config *config = NULL;
}
static uint64_t ceph_snap_gmt_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *csmb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_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,
- csmb_fname,
- ×tamp, stripped, sizeof(stripped));
+ ret = ceph_snap_gmt_strip_snapshot(
+ handle, smb_fname, ×tamp, stripped, sizeof(stripped));
if (ret < 0) {
errno = -ret;
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_DISK_FREE(handle, csmb_fname,
- bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
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(),
+ handle->conn->cwd_fsp,
+ conv,
+ smb_fname->stream_name,
+ &smb_fname->st,
+ smb_fname->twrp,
+ smb_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_DISK_FREE(handle, new_fname,
- bsize, dfree, dsize);
+ ret = SMB_VFS_NEXT_DISK_FREE(
+ handle, new_fname->fsp, bsize, dfree, dsize);
saved_errno = errno;
TALLOC_FREE(new_fname);
errno = saved_errno;
/* Disk operations */
static uint64_t vfswrap_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
+
if (sys_fsusage(smb_fname->base_name, dfree, dsize) != 0) {
return (uint64_t)-1;
}
}
static uint64_t dfq_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
uint64_t free_1k;
int snum = SNUM(handle->conn);
uint64_t dfq_bsize = 0;
}
if (dfq_bsize == 0) {
TALLOC_FREE(rpath_fname);
- return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree,
- dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
*bsize = dfq_bsize;
* - calculate used size of all bands: band_count * band_size
**/
static uint64_t fruit_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
+ struct files_struct *fsp,
uint64_t *_bsize,
uint64_t *_dfree,
uint64_t *_dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
struct fruit_config_data *config = NULL;
struct fruit_disk_free_state state = {0};
struct smb_Dir *dir_hnd = NULL;
if (!config->time_machine ||
config->time_machine_max_size == 0)
{
- return SMB_VFS_NEXT_DISK_FREE(handle,
- smb_fname,
- _bsize,
- _dfree,
- _dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, _bsize, _dfree, _dsize);
}
status = OpenDir(talloc_tos(),
}
static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
uint64_t result;
- result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
+ result = SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize);
/* Don't have a reasonable notion of failure here */
NULL,
handle,
"%s",
- smb_fname_str_do_log(handle->conn, smb_fname));
+ smb_fname_str_do_log(handle->conn, fsp->fsp_name));
return result;
}
}
static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize_p,
- uint64_t *dfree_p,
- uint64_t *dsize_p)
+ struct files_struct *fsp,
+ uint64_t *bsize_p,
+ uint64_t *dfree_p,
+ uint64_t *dsize_p)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
struct statvfs statvfs = { 0, };
int ret;
}
static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
struct security_unix_token *utok;
struct gpfs_quotaInfo qi_user = { 0 }, qi_group = { 0 };
struct gpfs_config_data *config;
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, smb_fname,
- bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
err = sys_fsusage(smb_fname->base_name, dfree, dsize);
if (err) {
DEBUG (0, ("Could not get fs usage, errno %d\n", errno));
- return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
- bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
/* sys_fsusage returns units of 512 bytes */
err = get_gpfs_quota(smb_fname->base_name,
GPFS_USRQUOTA, utok->uid, &qi_user);
if (err) {
- return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
- bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
/*
}
if (err) {
- return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
- bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
cur_time = time(NULL);
_PUBLIC_
uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
*bsize = 0;
*dfree = 0;
}
static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
time_t timestamp = 0;
char *stripped = NULL;
int saved_errno = 0;
char *conv = NULL;
struct smb_filename *conv_smb_fname = NULL;
uint64_t ret = (uint64_t)-1;
+ NTSTATUS status;
if (!shadow_copy2_strip_snapshot(talloc_tos(),
handle,
return (uint64_t)-1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
- bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return (uint64_t)-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(),
+ handle->conn->cwd_fsp,
+ conv,
+ NULL,
+ NULL,
+ 0,
+ smb_fname->flags,
+ &conv_smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(conv);
return (uint64_t)-1;
}
- ret = SMB_VFS_NEXT_DISK_FREE(handle, conv_smb_fname,
- bsize, dfree, dsize);
+ ret = SMB_VFS_NEXT_DISK_FREE(
+ handle, conv_smb_fname->fsp, bsize, dfree, dsize);
if (ret == (uint64_t)-1) {
saved_errno = errno;
}
}
static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
+ const struct smb_filename *smb_fname = fsp->fsp_name;
time_t timestamp = 0;
char *stripped = NULL;
uint64_t 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 (uint64_t)-1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
- bsize, dfree, dsize);
+ return SMB_VFS_NEXT_DISK_FREE(
+ handle, fsp, bsize, dfree, dsize);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
if (conv == NULL) {
return (uint64_t)-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(),
+ handle->conn->cwd_fsp,
+ conv,
+ NULL,
+ NULL,
+ 0,
+ smb_fname->flags,
+ &conv_smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(conv);
- errno = ENOMEM;
+ errno = map_errno_from_nt_status(status);
return (uint64_t)-1;
}
- ret = SMB_VFS_NEXT_DISK_FREE(handle, conv_smb_fname,
- bsize, dfree, dsize);
+ ret = SMB_VFS_NEXT_DISK_FREE(
+ handle, conv_smb_fname->fsp, bsize, dfree, dsize);
if (ret == (uint64_t)-1) {
saved_errno = errno;
}
static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+ struct files_struct *fsp,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
uint64_t result;
struct timespec ts1,ts2;
double timediff;
clock_gettime_mono(&ts1);
- result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
+ result = SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
/* Don't have a reasonable notion of failure here */
if (timediff > audit_timeout) {
smb_time_audit_log_fname("disk_free",
- timediff,
- smb_fname->base_name);
+ timediff,
+ fsp->fsp_name->base_name);
}
return result;
goto dfree_done;
}
- if (SMB_VFS_DISK_FREE(conn, fname, bsize, dfree, dsize) ==
- (uint64_t)-1) {
+ if (SMB_VFS_DISK_FREE(conn, fsp, bsize, dfree, dsize) == (uint64_t)-1)
+ {
DBG_ERR("VFS disk_free failed. Error was : %s\n",
strerror(errno));
return (uint64_t)-1;
int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
{
int ret;
- connection_struct *conn = fsp->conn;
uint64_t space_avail;
uint64_t bsize,dfree,dsize;
NTSTATUS status;
}
uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
+ struct files_struct *fsp,
uint64_t *bsize,
uint64_t *dfree,
uint64_t *dsize)
{
VFS_FIND(disk_free);
- return handle->fns->disk_free_fn(handle, smb_fname,
- bsize, dfree, dsize);
+ return handle->fns->disk_free_fn(handle, fsp, bsize, dfree, dsize);
}
int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
{
struct smb_filename *smb_fname = NULL;
uint64_t diskfree, bsize, dfree, dsize;
+ NTSTATUS status;
+
if (argc != 2) {
printf("Usage: disk_free <path>\n");
return NT_STATUS_OK;
}
- smb_fname = synthetic_smb_fname(talloc_tos(),
- argv[1],
- NULL,
- NULL,
- 0,
- ssf_flags());
- if (smb_fname == NULL) {
- return NT_STATUS_NO_MEMORY;
+ status = synthetic_pathref(talloc_tos(),
+ vfs->conn->cwd_fsp,
+ argv[1],
+ NULL,
+ NULL,
+ 0,
+ ssf_flags(),
+ &smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- diskfree = SMB_VFS_DISK_FREE(vfs->conn, smb_fname,
- &bsize, &dfree, &dsize);
+ diskfree = SMB_VFS_DISK_FREE(
+ vfs->conn, smb_fname->fsp, &bsize, &dfree, &dsize);
+ TALLOC_FREE(smb_fname);
printf("disk_free: %" PRIu64 ", bsize = %" PRIu64 ", dfree = %" PRIu64
", dsize = %" PRIu64 "\n",
diskfree,