1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

s3: Pass smb_filename through the is_offline vfs op

This commit is contained in:
Volker Lendecke 2011-02-25 06:37:34 -07:00 committed by Volker Lendecke
parent 48f6b4d6fc
commit c9d1e16c2c
8 changed files with 53 additions and 14 deletions

View File

@ -401,7 +401,9 @@ struct vfs_fn_pointers {
bool (*aio_force)(struct vfs_handle_struct *handle, struct files_struct *fsp);
/* offline operations */
bool (*is_offline)(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf);
bool (*is_offline)(struct vfs_handle_struct *handle,
const struct smb_filename *fname,
SMB_STRUCT_STAT *sbuf);
int (*set_offline)(struct vfs_handle_struct *handle, const char *path);
};
@ -815,7 +817,8 @@ int smb_vfs_call_aio_suspend(struct vfs_handle_struct *handle,
bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
struct files_struct *fsp);
bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
const char *path, SMB_STRUCT_STAT *sbuf);
const struct smb_filename *fname,
SMB_STRUCT_STAT *sbuf);
int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,
const char *path);

View File

@ -602,10 +602,10 @@
#define SMB_VFS_NEXT_AIO_FORCE(handle,fsp) \
smb_vfs_call_aio_force((handle)->next,(fsp))
#define SMB_VFS_IS_OFFLINE(conn,path,sbuf) \
smb_vfs_call_is_offline((conn)->vfs_handles,(path),(sbuf))
#define SMB_VFS_NEXT_IS_OFFLINE(handle,path,sbuf) \
smb_vfs_call_is_offline((handle)->next,(path),(sbuf))
#define SMB_VFS_IS_OFFLINE(conn,fname,sbuf) \
smb_vfs_call_is_offline((conn)->vfs_handles,(fname),(sbuf))
#define SMB_VFS_NEXT_IS_OFFLINE(handle,fname,sbuf) \
smb_vfs_call_is_offline((handle)->next,(fname),(sbuf))
#define SMB_VFS_SET_OFFLINE(conn,path) \
smb_vfs_call_set_offline((conn)->vfs_handles,(path))

View File

@ -1607,9 +1607,14 @@ static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_str
return false;
}
static bool vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
static bool vfswrap_is_offline(struct vfs_handle_struct *handle,
const struct smb_filename *fname,
SMB_STRUCT_STAT *sbuf)
{
if (ISDOT(path) || ISDOTDOT(path)) {
NTSTATUS status;
char *path;
if (ISDOT(fname->base_name) || ISDOTDOT(fname->base_name)) {
return false;
}
@ -1620,6 +1625,12 @@ static bool vfswrap_is_offline(struct vfs_handle_struct *handle, const char *pat
return false;
}
status = get_full_smb_filename(talloc_tos(), fname, &path);
if (!NT_STATUS_IS_OK(status)) {
errno = map_errno_from_nt_status(status);
return false;
}
return (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0;
}

View File

@ -2203,6 +2203,18 @@ static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
return result;
}
static bool smb_full_audit_is_offline(struct vfs_handle_struct *handle,
const struct smb_filename *fname,
SMB_STRUCT_STAT *sbuf)
{
bool result;
result = SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
do_log(SMB_VFS_OP_IS_OFFLINE, result, handle, "%s",
smb_fname_str_do_log(fname));
return result;
}
static struct vfs_fn_pointers vfs_full_audit_fns = {
/* Disk operations */
@ -2320,6 +2332,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
.aio_fsync = smb_full_audit_aio_fsync,
.aio_suspend = smb_full_audit_aio_suspend,
.aio_force = smb_full_audit_aio_force,
.is_offline = smb_full_audit_is_offline,
};
NTSTATUS vfs_full_audit_init(void)

View File

@ -634,8 +634,10 @@ onefs_shadow_copy_lsetxattr(vfs_handle_struct *handle, const char *path,
static bool
onefs_shadow_copy_is_offline(struct vfs_handle_struct *handle,
const char *path, SMB_STRUCT_STAT *sbuf)
const struct smb_fname *fname,
SMB_STRUCT_STAT *sbuf)
{
#error Isilon, please convert "char *path" to "struct smb_fname *fname"
SHADOW_NEXT(IS_OFFLINE,
(handle, cpath ?: path, sbuf),
bool);

View File

@ -146,8 +146,9 @@ static int tsmsm_connect(struct vfs_handle_struct *handle,
}
static bool tsmsm_is_offline(struct vfs_handle_struct *handle,
const char *path,
SMB_STRUCT_STAT *stbuf) {
const struct smb_filename *fname,
SMB_STRUCT_STAT *stbuf)
{
struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data;
const dm_sessid_t *dmsession_id;
void *dmhandle = NULL;
@ -158,6 +159,14 @@ static bool tsmsm_is_offline(struct vfs_handle_struct *handle,
bool offline;
char *buf = NULL;
size_t buflen;
NTSTATUS status;
char *path;
status = get_full_smb_filename(talloc_tos(), fname, &path);
if (!NT_STATUS_IS_OK(status)) {
errno = map_errno_from_nt_status(status);
return false;
}
/* if the file has more than FILE_IS_ONLINE_RATIO of blocks available,
then assume it is not offline (it may not be 100%, as it could be sparse) */

View File

@ -648,7 +648,7 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
}
}
offline = SMB_VFS_IS_OFFLINE(conn, smb_fname->base_name, &smb_fname->st);
offline = SMB_VFS_IS_OFFLINE(conn, smb_fname, &smb_fname->st);
if (S_ISREG(smb_fname->st.st_ex_mode) && offline) {
result |= FILE_ATTRIBUTE_OFFLINE;
}

View File

@ -2006,10 +2006,11 @@ bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
}
bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
const char *path, SMB_STRUCT_STAT *sbuf)
const struct smb_filename *fname,
SMB_STRUCT_STAT *sbuf)
{
VFS_FIND(is_offline);
return handle->fns->is_offline(handle, path, sbuf);
return handle->fns->is_offline(handle, fname, sbuf);
}
int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,