s3: Modify SMB_VFS_FILE_ID_CREATE to take a stat struct
authorTim Prouty <tprouty@samba.org>
Mon, 16 Feb 2009 07:38:53 +0000 (23:38 -0800)
committerTim Prouty <tprouty@samba.org>
Wed, 18 Feb 2009 01:53:01 +0000 (17:53 -0800)
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.

12 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/proto.h
source3/include/vfs.h
source3/include/vfs_macros.h
source3/lib/file_id.c
source3/modules/vfs_default.c
source3/modules/vfs_fileid.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_streams_depot.c
source3/modules/vfs_xattr_tdb.c
source3/smbd/oplock_irix.c

index 2eb7a9477634729ad266037ffd77496d43928e24..5845f62e341762edee987ca3a805a705012a0cce 100644 (file)
@@ -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);
index 5670965417277617b7c4cf0a8ee416750365b2e5..7036c730dd6673974f32f50b4a337eb4c5e5e7c7 100644 (file)
@@ -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,
index 3baa8c0fc460be9fae11a22928dae6d336400a22..411be15a53fbf7ac016b4b372d7982c003c807a5 100644 (file)
@@ -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);
index ffa1a95ed0281326a2c8fe3801cd33af73ae8cd2..0ee7f236b07346d780f1401cbcb3ad78b1cbf9da 100644 (file)
@@ -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,
index 3af612375b0f3218b985f80083f7a997058c8b9f..7dacd2319ab980ee932ba2614582d6975178f535 100644 (file)
@@ -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)))
 #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)))
 #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)))
index 0633d4b88d6e1136c609ac74de0eff5d70d48f2f..355aafa344b4ff7cea9a5044a58766e6c9e102cc 100644 (file)
 
 #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);
 }
 
 /*
index f52ca09c0846a56c1866a21dd62c83af6d590f7d..c18ec268d3f0819fcdd23968e4fdd8645d3326ec 100644 (file)
@@ -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,
index 787a49f36b6e6d76c996d289b5bff59cc456d314..8152c5477e8e2ee93c9ee746df7ed95d92f5a8c8 100644 (file)
@@ -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;
 }
index 15eafc1b56a5117826a2bf0178b258f3e8a85b97..3c159f10eb1ec1369873fe493134ad155e8a382d 100644 (file)
@@ -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),
index 1c2c0e5f77cfd2977b6e5dfa79d139892c3baf16..9329be7a9c110a94c8a8d60f2745b2b2ce8dbf65 100644 (file)
@@ -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);
 
index 44bfffb94eaf33255e55fbc1b6d7407fa1b83fb3..908a2a3872dbd84aa906aa5f33fc6800487547f4 100644 (file)
@@ -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);
 
index bbc9132a08f8e628888de920f49ce8f9a13fad13..89b8e0f7b58489c738c8d1f693c24e06f222bd72 100644 (file)
@@ -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.