*/
#include "includes.h"
+#include "smbd/smbd.h"
#include "onefs.h"
#include "onefs_config.h"
static int onefs_connect(struct vfs_handle_struct *handle, const char *service,
const char *user)
{
- int ret;
+ int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
+
+ if (ret < 0) {
+ return ret;
+ }
ret = onefs_load_config(handle->conn);
if (ret) {
+ SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(3, ("Load config failed: %s\n", strerror(errno)));
return ret;
}
- return SMB_VFS_NEXT_CONNECT(handle, service, user);
+ return 0;
}
static int onefs_mkdir(vfs_handle_struct *handle, const char *path,
return SMB_VFS_NEXT_MKDIR(handle, path, mode);
}
-static int onefs_open(vfs_handle_struct *handle, const char *fname,
+static int onefs_open(vfs_handle_struct *handle,
+ struct smb_filename *smb_fname,
files_struct *fsp, int flags, mode_t mode)
{
/* SMB_VFS_OPEN should never be called in vfs_onefs */
SMB_ASSERT(false);
- return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
+ return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
}
static ssize_t onefs_sendfile(vfs_handle_struct *handle, int tofd,
files_struct *fromfsp, const DATA_BLOB *header,
- SMB_OFF_T offset, size_t count)
+ off_t offset, size_t count)
{
ssize_t result;
}
static ssize_t onefs_recvfile(vfs_handle_struct *handle, int fromfd,
- files_struct *tofsp, SMB_OFF_T offset,
+ files_struct *tofsp, off_t offset,
size_t count)
{
ssize_t result;
START_PROFILE(syscall_get_alloc_size);
- if(S_ISDIR(sbuf->st_mode)) {
+ if(S_ISDIR(sbuf->st_ex_mode)) {
result = 0;
goto out;
}
}
static struct file_id onefs_file_id_create(struct vfs_handle_struct *handle,
- SMB_STRUCT_STAT *sbuf)
+ const SMB_STRUCT_STAT *sbuf)
{
struct file_id key;
* blob */
ZERO_STRUCT(key);
- key.devid = sbuf->st_dev;
- key.inode = sbuf->st_ino;
- key.extid = sbuf->st_snapid;
+ key.devid = sbuf->st_ex_dev;
+ key.inode = sbuf->st_ex_ino;
+ key.extid = sbuf->vfs_private;
return key;
}
const char *name, TALLOC_CTX *mem_ctx,
char **found_name)
{
- SMB_STRUCT_STAT sb;
+ struct stat sb;
struct connection_struct *conn = handle->conn;
struct stat_extra se;
int result;
return result;
}
-static int onefs_ntimes(vfs_handle_struct *handle, const char *fname,
+static int onefs_ntimes(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
struct smb_file_time *ft)
{
int flags = 0;
ft->create_time.tv_nsec));
}
- return onefs_vtimes_streams(handle, fname, flags, times);
+ return onefs_vtimes_streams(handle, smb_fname, flags, times);
}
-static uint32_t onefs_fs_capabilities(struct vfs_handle_struct *handle)
+static uint32_t onefs_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res)
{
uint32_t result = 0;
result |= FILE_NAMED_STREAMS;
}
- return result | SMB_VFS_NEXT_FS_CAPABILITIES(handle);
+ result |= SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
+ *p_ts_res = TIMESTAMP_SET_MSEC;
+ return result;
}
-static vfs_op_tuple onefs_ops[] = {
- {SMB_VFS_OP(onefs_connect), SMB_VFS_OP_CONNECT,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_opendir), SMB_VFS_OP_OPENDIR,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_readdir), SMB_VFS_OP_READDIR,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_seekdir), SMB_VFS_OP_SEEKDIR,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_telldir), SMB_VFS_OP_TELLDIR,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_rewinddir), SMB_VFS_OP_REWINDDIR,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_mkdir), SMB_VFS_OP_MKDIR,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_closedir), SMB_VFS_OP_CLOSEDIR,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_open), SMB_VFS_OP_OPEN,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_create_file), SMB_VFS_OP_CREATE_FILE,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_close), SMB_VFS_OP_CLOSE,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_sendfile), SMB_VFS_OP_SENDFILE,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_recvfile), SMB_VFS_OP_RECVFILE,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_rename), SMB_VFS_OP_RENAME,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_stat), SMB_VFS_OP_STAT,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_fstat), SMB_VFS_OP_FSTAT,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_lstat), SMB_VFS_OP_LSTAT,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_unlink), SMB_VFS_OP_UNLINK,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_ntimes), SMB_VFS_OP_NTIMES,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_chflags), SMB_VFS_OP_CHFLAGS,
- SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(onefs_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_streaminfo), SMB_VFS_OP_STREAMINFO,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_brl_lock_windows), SMB_VFS_OP_BRL_LOCK_WINDOWS,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_brl_unlock_windows), SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_strict_lock), SMB_VFS_OP_STRICT_LOCK,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_notify_watch), SMB_VFS_OP_NOTIFY_WATCH,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_statvfs), SMB_VFS_OP_STATVFS,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(onefs_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
- SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
+static struct vfs_fn_pointers onefs_fns = {
+ .connect_fn = onefs_connect,
+ .fs_capabilities_fn = onefs_fs_capabilities,
+ .opendir_fn = onefs_opendir,
+ .readdir_fn = onefs_readdir,
+ .seekdir_fn = onefs_seekdir,
+ .telldir_fn = onefs_telldir,
+ .rewind_dir_fn = onefs_rewinddir,
+ .mkdir_fn = onefs_mkdir,
+ .closedir_fn = onefs_closedir,
+ .init_search_op_fn = onefs_init_search_op,
+ .open_fn = onefs_open,
+ .create_file_fn = onefs_create_file,
+ .close_fn = onefs_close,
+ .sendfile_fn = onefs_sendfile,
+ .recvfile_fn = onefs_recvfile,
+ .rename_fn = onefs_rename,
+ .stat_fn = onefs_stat,
+ .fstat_fn = onefs_fstat,
+ .lstat_fn = onefs_lstat,
+ .get_alloc_size_fn = onefs_get_alloc_size,
+ .unlink_fn = onefs_unlink,
+ .ntimes_fn = onefs_ntimes,
+ .file_id_create_fn = onefs_file_id_create,
+ .streaminfo_fn = onefs_streaminfo,
+ .brl_lock_windows_fn = onefs_brl_lock_windows,
+ .brl_unlock_windows_fn = onefs_brl_unlock_windows,
+ .brl_cancel_windows_fn = onefs_brl_cancel_windows,
+ .strict_lock_fn = onefs_strict_lock,
+ .strict_unlock_fn = onefs_strict_unlock,
+ .notify_watch_fn = onefs_notify_watch,
+ .fget_nt_acl_fn = onefs_fget_nt_acl,
+ .get_nt_acl_fn = onefs_get_nt_acl,
+ .fset_nt_acl_fn = onefs_fset_nt_acl,
+ .statvfs_fn = onefs_statvfs,
+ .get_real_filename_fn = onefs_get_real_filename,
};
NTSTATUS vfs_onefs_init(void)
{
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "onefs",
- onefs_ops);
+ &onefs_fns);
}