mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
s3: Modify SMB_VFS_FILE_ID_CREATE to take a stat struct
Since file_id_create_dev is incompatible with the concept of file_ids, it is now static and in the one file that needs it.
This commit is contained in:
parent
669f2a02e2
commit
6fbebb5369
@ -292,7 +292,7 @@ static int skel_chflags(vfs_handle_struct *handle, const char *path, uint flags
|
||||
}
|
||||
|
||||
static struct file_id skel_file_id_create(vfs_handle_struct *handle,
|
||||
SMB_DEV_T dev, SMB_INO_T inode)
|
||||
const SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
struct file_id id_zero;
|
||||
ZERO_STRUCT(id_zero);
|
||||
|
@ -284,9 +284,9 @@ static int skel_chflags(vfs_handle_struct *handle, const char *path, uint flags
|
||||
}
|
||||
|
||||
static struct file_id skel_file_id_create(vfs_handle_struct *handle,
|
||||
SMB_DEV_T dev, SMB_INO_T inode)
|
||||
const SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
return SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode);
|
||||
return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
|
||||
}
|
||||
|
||||
static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
|
||||
|
@ -508,7 +508,6 @@ void dump_core_setup(const char *progname);
|
||||
|
||||
/* The following definitions come from lib/file_id.c */
|
||||
|
||||
struct file_id file_id_create_dev(SMB_DEV_T dev, SMB_INO_T inode);
|
||||
struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf);
|
||||
bool file_id_equal(const struct file_id *id1, const struct file_id *id2);
|
||||
const char *file_id_string_tos(const struct file_id *id);
|
||||
|
@ -383,7 +383,8 @@ struct vfs_ops {
|
||||
struct notify_event *ev),
|
||||
void *private_data, void *handle_p);
|
||||
int (*chflags)(struct vfs_handle_struct *handle, const char *path, unsigned int flags);
|
||||
struct file_id (*file_id_create)(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode);
|
||||
struct file_id (*file_id_create)(struct vfs_handle_struct *handle,
|
||||
const SMB_STRUCT_STAT *sbuf);
|
||||
|
||||
NTSTATUS (*streaminfo)(struct vfs_handle_struct *handle,
|
||||
struct files_struct *fsp,
|
||||
|
@ -85,7 +85,7 @@
|
||||
#define SMB_VFS_REALPATH(conn, path, resolved_path) ((conn)->vfs.ops.realpath((conn)->vfs.handles.realpath, (path), (resolved_path)))
|
||||
#define SMB_VFS_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs.ops.notify_watch((conn)->vfs.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
|
||||
#define SMB_VFS_CHFLAGS(conn, path, flags) ((conn)->vfs.ops.chflags((conn)->vfs.handles.chflags, (path), (flags)))
|
||||
#define SMB_VFS_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops.file_id_create((conn)->vfs.handles.file_id_create, (dev), (inode)))
|
||||
#define SMB_VFS_FILE_ID_CREATE(conn, sbuf) ((conn)->vfs.ops.file_id_create((conn)->vfs.handles.file_id_create, (sbuf)))
|
||||
#define SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs.ops.streaminfo((conn)->vfs.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
|
||||
#define SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) ((conn)->vfs.ops.get_real_filename((conn)->vfs.handles.get_real_filename, (path), (name), (mem_ctx), (found_name)))
|
||||
#define SMB_VFS_BRL_LOCK_WINDOWS(conn, br_lck, plock, blocking_lock, blr) ((conn)->vfs.ops.brl_lock_windows((conn)->vfs.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr)))
|
||||
@ -217,7 +217,7 @@
|
||||
#define SMB_VFS_OPAQUE_REALPATH(conn, path, resolved_path) ((conn)->vfs_opaque.ops.realpath((conn)->vfs_opaque.handles.realpath, (path), (resolved_path)))
|
||||
#define SMB_VFS_OPAQUE_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs_opaque.ops.notify_watch((conn)->vfs_opaque.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
|
||||
#define SMB_VFS_OPAQUE_CHFLAGS(conn, path, flags) ((conn)->vfs_opaque.ops.chflags((conn)->vfs_opaque.handles.chflags, (path), (flags)))
|
||||
#define SMB_VFS_OPAQUE_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops_opaque.file_id_create((conn)->vfs_opaque.handles.file_id_create, (dev), (inode)))
|
||||
#define SMB_VFS_OPAQUE_FILE_ID_CREATE(conn, sbuf) ((conn)->vfs.ops_opaque.file_id_create((conn)->vfs_opaque.handles.file_id_create, (sbuf)))
|
||||
#define SMB_VFS_OPAQUE_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs_opaque.ops.streaminfo((conn)->vfs_opaque.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
|
||||
#define SMB_VFS_OPAQUE_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) ((conn)->vfs_opaque.ops.get_real_filename((conn)->vfs_opaque.handles.get_real_filename, (path), (name), (mem_ctx), (found_name)))
|
||||
#define SMB_VFS_OPAQUE_BRL_LOCK_WINDOWS(conn, br_lck, plock, blocking_lock, blr) ((conn)->vfs_opaque.ops.brl_lock_windows((conn)->vfs_opaque.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr)))
|
||||
@ -350,7 +350,7 @@
|
||||
#define SMB_VFS_NEXT_REALPATH(handle, path, resolved_path) ((handle)->vfs_next.ops.realpath((handle)->vfs_next.handles.realpath, (path), (resolved_path)))
|
||||
#define SMB_VFS_NEXT_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs_next.ops.notify_watch((conn)->vfs_next.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
|
||||
#define SMB_VFS_NEXT_CHFLAGS(handle, path, flags) ((handle)->vfs_next.ops.chflags((handle)->vfs_next.handles.chflags, (path), (flags)))
|
||||
#define SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode) ((handle)->vfs_next.ops.file_id_create((handle)->vfs_next.handles.file_id_create, (dev), (inode)))
|
||||
#define SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf) ((handle)->vfs_next.ops.file_id_create((handle)->vfs_next.handles.file_id_create, (sbuf)))
|
||||
#define SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, num_streams, streams) ((handle)->vfs_next.ops.streaminfo((handle)->vfs_next.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
|
||||
#define SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx, found_name) ((handle)->vfs_next.ops.get_real_filename((handle)->vfs_next.handles.get_real_filename, (path), (name), (mem_ctx), (found_name)))
|
||||
#define SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock, blocking_lock, blr) ((handle)->vfs_next.ops.brl_lock_windows((handle)->vfs_next.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr)))
|
||||
|
@ -21,27 +21,12 @@
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/*
|
||||
return a file_id which gives a unique ID for a file given the device and
|
||||
inode numbers
|
||||
*/
|
||||
struct file_id file_id_create_dev(SMB_DEV_T dev, SMB_INO_T inode)
|
||||
{
|
||||
struct file_id key;
|
||||
/* the ZERO_STRUCT ensures padding doesn't break using the key as a
|
||||
* blob */
|
||||
ZERO_STRUCT(key);
|
||||
key.devid = dev;
|
||||
key.inode = inode;
|
||||
return key;
|
||||
}
|
||||
|
||||
/*
|
||||
generate a file_id from a stat structure
|
||||
*/
|
||||
struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
return SMB_VFS_FILE_ID_CREATE(conn, sbuf->st_dev, sbuf->st_ino);
|
||||
return SMB_VFS_FILE_ID_CREATE(conn, sbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1042,9 +1042,19 @@ static int vfswrap_chflags(vfs_handle_struct *handle, const char *path, int flag
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode)
|
||||
static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle,
|
||||
SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
return file_id_create_dev(dev, inode);
|
||||
struct file_id key;
|
||||
|
||||
/* the ZERO_STRUCT ensures padding doesn't break using the key as a
|
||||
* blob */
|
||||
ZERO_STRUCT(key);
|
||||
|
||||
key.devid = sbuf->st_dev;
|
||||
key.inode = sbuf->st_ino;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
|
||||
|
@ -226,7 +226,7 @@ static void fileid_disconnect(struct vfs_handle_struct *handle)
|
||||
}
|
||||
|
||||
static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
|
||||
SMB_DEV_T dev, SMB_INO_T inode)
|
||||
const SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
struct fileid_handle_data *data;
|
||||
struct file_id id;
|
||||
@ -237,8 +237,8 @@ static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
|
||||
struct fileid_handle_data,
|
||||
return id);
|
||||
|
||||
id.devid = data->device_mapping_fn(data, dev);
|
||||
id.inode = inode;
|
||||
id.devid = data->device_mapping_fn(data, sbuf->st_dev);
|
||||
id.inode = sbuf->st_ino;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
|
||||
static int smb_full_audit_chflags(vfs_handle_struct *handle,
|
||||
const char *path, unsigned int flags);
|
||||
static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
|
||||
SMB_DEV_T dev, SMB_INO_T inode);
|
||||
const SMB_STRUCT_STAT *sbuf);
|
||||
static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
|
||||
struct files_struct *fsp,
|
||||
const char *fname,
|
||||
@ -1664,14 +1664,14 @@ static int smb_full_audit_chflags(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
|
||||
SMB_DEV_T dev, SMB_INO_T inode)
|
||||
const SMB_STRUCT_STAT *sbuf)
|
||||
{
|
||||
struct file_id id_zero;
|
||||
struct file_id result;
|
||||
|
||||
ZERO_STRUCT(id_zero);
|
||||
|
||||
result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode);
|
||||
result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
|
||||
|
||||
do_log(SMB_VFS_OP_FILE_ID_CREATE,
|
||||
!file_id_equal(&id_zero, &result),
|
||||
|
@ -153,8 +153,7 @@ static char *stream_dir(vfs_handle_struct *handle, const char *base_path,
|
||||
base_sbuf = &sbuf;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, base_sbuf->st_dev,
|
||||
base_sbuf->st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, base_sbuf);
|
||||
|
||||
push_file_id_16((char *)id_buf, &id);
|
||||
|
||||
|
@ -216,7 +216,7 @@ static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_getattr(db, &id, name, value, size);
|
||||
}
|
||||
@ -235,7 +235,7 @@ static ssize_t xattr_tdb_fgetxattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_getattr(db, &id, name, value, size);
|
||||
}
|
||||
@ -338,7 +338,7 @@ static int xattr_tdb_setxattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_setattr(db, &id, name, value, size, flags);
|
||||
}
|
||||
@ -358,7 +358,7 @@ static int xattr_tdb_fsetxattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_setattr(db, &id, name, value, size, flags);
|
||||
}
|
||||
@ -443,7 +443,7 @@ static ssize_t xattr_tdb_listxattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_listattr(db, &id, list, size);
|
||||
}
|
||||
@ -462,7 +462,7 @@ static ssize_t xattr_tdb_flistxattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_listattr(db, &id, list, size);
|
||||
}
|
||||
@ -543,7 +543,7 @@ static int xattr_tdb_removexattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_removeattr(db, &id, name);
|
||||
}
|
||||
@ -561,7 +561,7 @@ static int xattr_tdb_fremovexattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
return xattr_tdb_removeattr(db, &id, name);
|
||||
}
|
||||
@ -628,7 +628,7 @@ static int xattr_tdb_unlink(vfs_handle_struct *handle, const char *path)
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
rec = xattr_tdb_lock_attrs(talloc_tos(), db, &id);
|
||||
|
||||
@ -667,7 +667,7 @@ static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path)
|
||||
return -1;
|
||||
}
|
||||
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino);
|
||||
id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
|
||||
|
||||
rec = xattr_tdb_lock_attrs(talloc_tos(), db, &id);
|
||||
|
||||
|
@ -103,6 +103,24 @@ static bool irix_oplocks_available(void)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is bad because the file_id should always be created through the vfs
|
||||
* layer! Unfortunately, a conn struct isn't available here.
|
||||
*/
|
||||
static struct file_id file_id_create_dev(SMB_DEV_T dev, SMB_INO_T inode)
|
||||
{
|
||||
struct file_id key;
|
||||
|
||||
/* the ZERO_STRUCT ensures padding doesn't break using the key as a
|
||||
* blob */
|
||||
ZERO_STRUCT(key);
|
||||
|
||||
key.devid = dev;
|
||||
key.inode = inode;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Deal with the IRIX kernel <--> smbd
|
||||
* oplock break protocol.
|
||||
|
Loading…
x
Reference in New Issue
Block a user