Author: metze Date: 2007-08-02 08:59:17 +0000 (Thu, 02 Aug 2007) New Revision: 24122
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24122 Log: merge from SAMBA_3_2: add a file_id_create() hook into the VFS layer it's needed for some cluster filesystems to overload this function. metze Modified: branches/SAMBA_3_2_0/source/include/vfs.h branches/SAMBA_3_2_0/source/include/vfs_macros.h branches/SAMBA_3_2_0/source/lib/file_id.c branches/SAMBA_3_2_0/source/modules/vfs_default.c branches/SAMBA_3_2_0/source/printing/printfsp.c branches/SAMBA_3_2_0/source/smbd/close.c branches/SAMBA_3_2_0/source/smbd/filename.c branches/SAMBA_3_2_0/source/smbd/open.c branches/SAMBA_3_2_0/source/smbd/reply.c branches/SAMBA_3_2_0/source/smbd/trans2.c Changeset: Modified: branches/SAMBA_3_2_0/source/include/vfs.h =================================================================== --- branches/SAMBA_3_2_0/source/include/vfs.h 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/include/vfs.h 2007-08-02 08:59:17 UTC (rev 24122) @@ -71,6 +71,7 @@ /* Changed to version21 to add chflags operation -- jpeach */ /* Changed to version22 to add lchown operation -- jra */ /* Leave at 22 - not yet released. But change set_nt_acl to return an NTSTATUS. jra. */ +/* Leave at 22 - not yet released. Add file_id_create operation. --metze */ #define SMB_VFS_INTERFACE_VERSION 22 @@ -162,6 +163,7 @@ SMB_VFS_OP_REALPATH, SMB_VFS_OP_NOTIFY_WATCH, SMB_VFS_OP_CHFLAGS, + SMB_VFS_OP_FILE_ID_CREATE, /* NT ACL operations. */ @@ -295,7 +297,8 @@ struct notify_event *ev), void *private_data, void *handle_p); int (*chflags)(struct vfs_handle_struct *handle, const char *path, uint flags); - + struct file_id (*file_id_create)(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode); + /* NT ACL operations. */ size_t (*fget_nt_acl)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, uint32 security_info, struct security_descriptor **ppdesc); @@ -414,6 +417,7 @@ struct vfs_handle_struct *realpath; struct vfs_handle_struct *notify_watch; struct vfs_handle_struct *chflags; + struct vfs_handle_struct *file_id_create; /* NT ACL operations. */ Modified: branches/SAMBA_3_2_0/source/include/vfs_macros.h =================================================================== --- branches/SAMBA_3_2_0/source/include/vfs_macros.h 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/include/vfs_macros.h 2007-08-02 08:59:17 UTC (rev 24122) @@ -80,6 +80,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))) /* NT ACL operations. */ #define SMB_VFS_FGET_NT_ACL(fsp, fd, security_info, ppdesc) ((fsp)->conn->vfs.ops.fget_nt_acl((fsp)->conn->vfs.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc))) @@ -197,6 +198,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))) /* NT ACL operations. */ #define SMB_VFS_OPAQUE_FGET_NT_ACL(fsp, fd, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.fget_nt_acl((fsp)->conn->vfs_opaque.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc))) @@ -315,6 +317,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))) /* NT ACL operations. */ #define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info, ppdesc) ((handle)->vfs_next.ops.fget_nt_acl((handle)->vfs_next.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc))) Modified: branches/SAMBA_3_2_0/source/lib/file_id.c =================================================================== --- branches/SAMBA_3_2_0/source/lib/file_id.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/lib/file_id.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -25,7 +25,7 @@ return a file_id which gives a unique ID for a file given the device and inode numbers */ -struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode) +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 @@ -39,12 +39,11 @@ /* generate a file_id from a stat structure */ -struct file_id file_id_sbuf(const SMB_STRUCT_STAT *sbuf) +struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf) { - return file_id_create(sbuf->st_dev, sbuf->st_ino); + return SMB_VFS_FILE_ID_CREATE(conn, sbuf->st_dev, sbuf->st_ino); } - /* return True if two file_id structures are equal */ Modified: branches/SAMBA_3_2_0/source/modules/vfs_default.c =================================================================== --- branches/SAMBA_3_2_0/source/modules/vfs_default.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/modules/vfs_default.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -923,6 +923,11 @@ #endif } +static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode) +{ + return file_id_create_dev(dev, inode); +} + static size_t vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info, SEC_DESC **ppdesc) { size_t result; @@ -1310,6 +1315,8 @@ SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_chflags), SMB_VFS_OP_CHFLAGS, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_file_id_create), SMB_VFS_OP_FILE_ID_CREATE, + SMB_VFS_LAYER_OPAQUE}, /* NT ACL operations. */ Modified: branches/SAMBA_3_2_0/source/printing/printfsp.c =================================================================== --- branches/SAMBA_3_2_0/source/printing/printfsp.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/printing/printfsp.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -86,7 +86,7 @@ fsp->wcp = NULL; SMB_VFS_FSTAT(fsp,fsp->fh->fd, &sbuf); fsp->mode = sbuf.st_mode; - fsp->file_id = file_id_sbuf(&sbuf); + fsp->file_id = vfs_file_id_from_sbuf(conn, &sbuf); conn->num_files_open++; Modified: branches/SAMBA_3_2_0/source/smbd/close.c =================================================================== --- branches/SAMBA_3_2_0/source/smbd/close.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/smbd/close.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -265,7 +265,7 @@ goto done; } - id = file_id_sbuf(&sbuf); + id = vfs_file_id_from_sbuf(conn, &sbuf); if (!file_id_equal(&fsp->file_id, &id)) { DEBUG(5,("close_remove_share_mode: file %s. Delete on close " Modified: branches/SAMBA_3_2_0/source/smbd/filename.c =================================================================== --- branches/SAMBA_3_2_0/source/smbd/filename.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/smbd/filename.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -540,7 +540,8 @@ } /* end else */ #ifdef DEVELOPER - if (VALID_STAT(st) && get_delete_on_close_flag(file_id_sbuf(&st))) { + if (VALID_STAT(st) && + get_delete_on_close_flag(vfs_file_id_from_sbuf(conn, &st))) { result = NT_STATUS_DELETE_PENDING; goto fail; } Modified: branches/SAMBA_3_2_0/source/smbd/open.c =================================================================== --- branches/SAMBA_3_2_0/source/smbd/open.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/smbd/open.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -357,7 +357,7 @@ } fsp->mode = psbuf->st_mode; - fsp->file_id = file_id_sbuf(psbuf); + fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf); fsp->vuid = req ? req->vuid : UID_FIELD_INVALID; fsp->file_pid = req ? req->smbpid : 0; fsp->can_lock = True; @@ -1420,7 +1420,7 @@ return status; } - fsp->file_id = file_id_sbuf(psbuf); + fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf); fsp->share_access = share_access; fsp->fh->private_options = create_options; fsp->access_mask = open_access_mask; /* We change this to the @@ -1436,7 +1436,7 @@ } if (file_existed) { - id = file_id_sbuf(psbuf); + id = vfs_file_id_from_sbuf(conn, psbuf); lck = get_share_mode_lock(NULL, id, conn->connectpath, @@ -2164,7 +2164,7 @@ */ fsp->mode = psbuf->st_mode; - fsp->file_id = file_id_sbuf(psbuf); + fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf); fsp->vuid = req ? req->vuid : UID_FIELD_INVALID; fsp->file_pid = req ? req->smbpid : 0; fsp->can_lock = False; @@ -2292,7 +2292,7 @@ */ fsp->mode = psbuf->st_mode; - fsp->file_id = file_id_sbuf(psbuf); + fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf); fsp->vuid = req ? req->vuid : UID_FIELD_INVALID; fsp->file_pid = req ? req->smbpid : 0; fsp->can_lock = False; Modified: branches/SAMBA_3_2_0/source/smbd/reply.c =================================================================== --- branches/SAMBA_3_2_0/source/smbd/reply.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/smbd/reply.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -4447,7 +4447,8 @@ } if (dst_exists) { - files_struct *dst_fsp = file_find_di_first(file_id_sbuf(&sbuf1)); + struct file_id fileid = vfs_file_id_from_sbuf(conn, &sbuf1); + files_struct *dst_fsp = file_find_di_first(fileid); if (dst_fsp) { DEBUG(3, ("rename_internals_fsp: Target file open\n")); return NT_STATUS_ACCESS_DENIED; Modified: branches/SAMBA_3_2_0/source/smbd/trans2.c =================================================================== --- branches/SAMBA_3_2_0/source/smbd/trans2.c 2007-08-02 08:56:10 UTC (rev 24121) +++ branches/SAMBA_3_2_0/source/smbd/trans2.c 2007-08-02 08:59:17 UTC (rev 24122) @@ -3258,6 +3258,7 @@ time_t create_time, mtime, atime; struct timespec create_time_ts, mtime_ts, atime_ts; files_struct *fsp = NULL; + struct file_id fileid; TALLOC_CTX *data_ctx = NULL; struct ea_list *ea_list = NULL; uint32 access_mask = 0x12019F; /* Default - GENERIC_EXECUTE mapping from Windows */ @@ -3324,7 +3325,8 @@ return UNIXERROR(ERRDOS,ERRbadpath); } - delete_pending = get_delete_on_close_flag(file_id_sbuf(&sbuf)); + fileid = vfs_file_id_from_sbuf(conn, &sbuf); + delete_pending = get_delete_on_close_flag(fileid); } else { /* * Original code - this is an open file. @@ -3337,7 +3339,8 @@ return(UNIXERROR(ERRDOS,ERRbadfid)); } pos = fsp->fh->position_information; - delete_pending = get_delete_on_close_flag(file_id_sbuf(&sbuf)); + fileid = vfs_file_id_from_sbuf(conn, &sbuf); + delete_pending = get_delete_on_close_flag(fileid); access_mask = fsp->access_mask; } } else { @@ -3392,7 +3395,8 @@ return UNIXERROR(ERRDOS,ERRbadpath); } - delete_pending = get_delete_on_close_flag(file_id_sbuf(&sbuf)); + fileid = vfs_file_id_from_sbuf(conn, &sbuf); + delete_pending = get_delete_on_close_flag(fileid); if (delete_pending) { return ERROR_NT(NT_STATUS_DELETE_PENDING); } @@ -3518,8 +3522,10 @@ mtime_ts = fsp->pending_modtime; } } else { + files_struct *fsp1; /* Do we have this path open ? */ - files_struct *fsp1 = file_find_di_first(file_id_sbuf(&sbuf)); + fileid = vfs_file_id_from_sbuf(conn, &sbuf); + fsp1 = file_find_di_first(fileid); if (fsp1 && !null_timespec(fsp1->pending_modtime)) { /* the pending modtime overrides the current modtime */ mtime_ts = fsp1->pending_modtime;