From 8e2323e391e312e0f0284c918e2bb8567c035e20 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 6 Nov 2007 08:01:31 +0100 Subject: Split get_nt_acl() into two functions: fsp- and non-fsp variant. Replace smbd/posix_acls.c:get_nt_acl() by two funcions: posix_get_nt_acl() and posix_fget_nt_acl(). The first takes a connection struct and a file name instead of a files_struct pointer. This is in preparation of changing the vfs api for SMB_VFS_GET_NT_ACL. Michael (This used to be commit 50c82cc1456736fa634fb656e63555319742f725) --- source3/modules/vfs_aixacl2.c | 2 +- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_gpfs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index 756977df4f..ab7c75691c 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -170,7 +170,7 @@ static NTSTATUS aixjfs2_get_nt_acl_common(files_struct *fsp, if (retryPosix) { DEBUG(10, ("retrying with posix acl...\n")); - return get_nt_acl(fsp, security_info, ppdesc); + return posix_fget_nt_acl(fsp, security_info, ppdesc); } if (result==False) return NT_STATUS_ACCESS_DENIED; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index cce5430493..3dd3727340 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -950,7 +950,7 @@ static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, NTSTATUS result; START_PROFILE(fget_nt_acl); - result = get_nt_acl(fsp, security_info, ppdesc); + result = posix_fget_nt_acl(fsp, security_info, ppdesc); END_PROFILE(fget_nt_acl); return result; } @@ -962,7 +962,7 @@ static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle, NTSTATUS result; START_PROFILE(get_nt_acl); - result = get_nt_acl(fsp, security_info, ppdesc); + result = posix_get_nt_acl(fsp->conn, fsp->fsp_name, security_info, ppdesc); END_PROFILE(get_nt_acl); return result; } diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index c207bbfe2d..91d38874b9 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -240,7 +240,7 @@ static NTSTATUS gpfsacl_get_nt_acl_common(files_struct *fsp, if (result > 0) { DEBUG(10, ("retrying with posix acl...\n")); - return get_nt_acl(fsp, security_info, ppdesc); + return posix_fget_nt_acl(fsp, security_info, ppdesc); } /* GPFS ACL was not read, something wrong happened, error code is set in errno */ -- cgit From cb69a78505854342013f67630bfd38a3c5cd7857 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 9 Nov 2007 01:01:55 +0100 Subject: Split smbacl4_GetFileOwner into two (f- and non-f-variant). This is in preparation of a get_nt_acl prototype change. (This used to be commit e0672a46a2e5e655da32499ca7f52a9156e9b7f0) --- source3/modules/nfs4_acls.c | 48 +++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index edcc52261c..94666ba00d 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -161,24 +161,35 @@ uint32 smb_get_naces(SMB4ACL_T *acl) return aclint->naces; } -static int smbacl4_GetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf) +static int smbacl4_GetFileOwner(struct connection_struct *conn, + const char *filename, + SMB_STRUCT_STAT *psbuf) { memset(psbuf, 0, sizeof(SMB_STRUCT_STAT)); + + /* Get the stat struct for the owner info. */ + if (SMB_VFS_STAT(conn, filename, psbuf) != 0) + { + DEBUG(8, ("SMB_VFS_STAT failed with error %s\n", + strerror(errno))); + return -1; + } + + return 0; +} + +static int smbacl4_fGetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf) +{ + memset(psbuf, 0, sizeof(SMB_STRUCT_STAT)); + if (fsp->is_directory || fsp->fh->fd == -1) { - /* Get the stat struct for the owner info. */ - if (SMB_VFS_STAT(fsp->conn,fsp->fsp_name, psbuf) != 0) - { - DEBUG(8, ("SMB_VFS_STAT failed with error %s\n", - strerror(errno))); - return -1; - } - } else { - if (SMB_VFS_FSTAT(fsp,fsp->fh->fd, psbuf) != 0) - { - DEBUG(8, ("SMB_VFS_FSTAT failed with error %s\n", - strerror(errno))); - return -1; - } + return smbacl4_GetFileOwner(fsp->conn, fsp->fsp_name, psbuf); + } + if (SMB_VFS_FSTAT(fsp,fsp->fh->fd, psbuf) != 0) + { + DEBUG(8, ("SMB_VFS_FSTAT failed with error %s\n", + strerror(errno))); + return -1; } return 0; @@ -276,9 +287,8 @@ NTSTATUS smb_get_nt_acl_nfs4(files_struct *fsp, * shouldn't alloc 0 for * win */ - if (smbacl4_GetFileOwner(fsp, &sbuf)) + if (smbacl4_fGetFileOwner(fsp, &sbuf)) return map_nt_error_from_unix(errno); - uid_to_sid(&sid_owner, sbuf.st_uid); gid_to_sid(&sid_group, sbuf.st_gid); @@ -588,7 +598,7 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, if (smbacl4_get_vfs_params(SMBACL4_PARAM_TYPE_NAME, fsp, ¶ms)) return NT_STATUS_NO_MEMORY; - if (smbacl4_GetFileOwner(fsp, &sbuf)) + if (smbacl4_fGetFileOwner(fsp, &sbuf)) return map_nt_error_from_unix(errno); if (params.do_chown) { @@ -610,7 +620,7 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, } DEBUG(10,("chown %s, %u, %u succeeded.\n", fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); - if (smbacl4_GetFileOwner(fsp, &sbuf)) + if (smbacl4_fGetFileOwner(fsp, &sbuf)) return map_nt_error_from_unix(errno); } } -- cgit From c650857fac826697cb1d9441b9ea869b85190d25 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 Nov 2007 00:46:20 +0100 Subject: Split smb_get_nt_acl_nfs4 into two (f- and non-f-variant). This is the next step in preparation of a get_nt_acl prototype change. Michael (This used to be commit 7afeb1c6cb1bdb58d1e61c54ae215d947d8dc3ea) --- source3/modules/nfs4_acls.c | 44 ++++++++++++++++++++++++++++++++++--------- source3/modules/nfs4_acls.h | 7 ++++++- source3/modules/vfs_aixacl2.c | 2 +- source3/modules/vfs_gpfs.c | 2 +- source3/modules/vfs_zfsacl.c | 2 +- 5 files changed, 44 insertions(+), 13 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 94666ba00d..70bb6a02e8 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -268,29 +268,24 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *acl, /* in */ return True; } -NTSTATUS smb_get_nt_acl_nfs4(files_struct *fsp, +static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf, uint32 security_info, SEC_DESC **ppdesc, SMB4ACL_T *acl) { int good_aces = 0; - SMB_STRUCT_STAT sbuf; DOM_SID sid_owner, sid_group; size_t sd_size = 0; SEC_ACE *nt_ace_list = NULL; SEC_ACL *psa = NULL; TALLOC_CTX *mem_ctx = talloc_tos(); - DEBUG(10, ("smb_get_nt_acl_nfs4 invoked for %s\n", fsp->fsp_name)); - if (acl==NULL || smb_get_naces(acl)==0) return NT_STATUS_ACCESS_DENIED; /* special because we * shouldn't alloc 0 for * win */ - if (smbacl4_fGetFileOwner(fsp, &sbuf)) - return map_nt_error_from_unix(errno); - uid_to_sid(&sid_owner, sbuf.st_uid); - gid_to_sid(&sid_group, sbuf.st_gid); + uid_to_sid(&sid_owner, sbuf->st_uid); + gid_to_sid(&sid_group, sbuf->st_gid); if (smbacl4_nfs42win(mem_ctx, acl, &sid_owner, &sid_group, &nt_ace_list, &good_aces)==False) { DEBUG(8,("smbacl4_nfs42win failed\n")); @@ -313,12 +308,43 @@ NTSTATUS smb_get_nt_acl_nfs4(files_struct *fsp, return NT_STATUS_NO_MEMORY; } - DEBUG(10, ("smb_get_nt_acl_nfs4 successfully exited with sd_size %d\n", + DEBUG(10, ("smb_get_nt_acl_nfs4_common successfully exited with sd_size %d\n", sec_desc_size(*ppdesc))); return NT_STATUS_OK; } +NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp, + uint32 security_info, + SEC_DESC **ppdesc, SMB4ACL_T *acl) +{ + SMB_STRUCT_STAT sbuf; + + DEBUG(10, ("smb_fget_nt_acl_nfs4 invoked for %s\n", fsp->fsp_name)); + + if (smbacl4_fGetFileOwner(fsp, &sbuf)) { + return map_nt_error_from_unix(errno); + } + + return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc, acl); +} + +NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn, + const char *name, + uint32 security_info, + SEC_DESC **ppdesc, SMB4ACL_T *acl) +{ + SMB_STRUCT_STAT sbuf; + + DEBUG(10, ("smb_get_nt_acl_nfs4 invoked for %s\n", name)); + + if (smbacl4_GetFileOwner(conn, name, &sbuf)) { + return map_nt_error_from_unix(errno); + } + + return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc, acl); +} + enum smbacl4_mode_enum {e_simple=0, e_special=1}; enum smbacl4_acedup_enum {e_dontcare=0, e_reject=1, e_ignore=2, e_merge=3}; diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h index ceb66ec094..0f783aa977 100644 --- a/source3/modules/nfs4_acls.h +++ b/source3/modules/nfs4_acls.h @@ -129,7 +129,12 @@ SMB4ACE_T *smb_next_ace4(SMB4ACE_T *ace); uint32 smb_get_naces(SMB4ACL_T *acl); -NTSTATUS smb_get_nt_acl_nfs4(files_struct *fsp, +NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp, + uint32 security_info, + SEC_DESC **ppdesc, SMB4ACL_T *acl); + +NTSTATUS smb_get_nt_acl_nfs4(connection_struct *conn, + const char *name, uint32 security_info, SEC_DESC **ppdesc, SMB4ACL_T *acl); diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index ab7c75691c..0cb40a2214 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -175,7 +175,7 @@ static NTSTATUS aixjfs2_get_nt_acl_common(files_struct *fsp, if (result==False) return NT_STATUS_ACCESS_DENIED; - return smb_get_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); + return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); } NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle, diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 91d38874b9..418a81ffb4 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -236,7 +236,7 @@ static NTSTATUS gpfsacl_get_nt_acl_common(files_struct *fsp, result = gpfs_get_nfs4_acl(fsp->fsp_name, &pacl); if (result == 0) - return smb_get_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); + return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); if (result > 0) { DEBUG(10, ("retrying with posix acl...\n")); diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 0fe21b2909..88cd0879cf 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -92,7 +92,7 @@ static NTSTATUS zfs_get_nt_acl(struct files_struct *fsp, uint32 security_info, return NT_STATUS_NO_MEMORY; } - return smb_get_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); + return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); } /* call-back function processing the NT acl -> ZFS acl using NFSv4 conv. */ -- cgit From 010056a5e6c8b94d858575210b5544e5bbcd32b3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 16 Nov 2007 18:33:39 +0100 Subject: Prepare the gpfs acl module for the api change in get_nt_acl(). This moves functionality from gpfsacl_get_nt_acl_common() back to gpfsacl_get_nt_acl() and gpfsacl_fget_nt_acl(), making both these functions more specific (calling the corresponding fsp- and non-fsp functions). gpfsacl_get_nt_acl_common(). is removed. Michael (This used to be commit d6043c1066322d2c567aedc5eae1a9d46c8fc396) --- source3/modules/vfs_gpfs.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 418a81ffb4..e7331bef29 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -226,8 +226,9 @@ static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl) return 0; } -static NTSTATUS gpfsacl_get_nt_acl_common(files_struct *fsp, - uint32 security_info, SEC_DESC **ppdesc) +static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle, + files_struct *fsp, int fd, uint32 security_info, + SEC_DESC **ppdesc) { SMB4ACL_T *pacl = NULL; int result; @@ -242,23 +243,31 @@ static NTSTATUS gpfsacl_get_nt_acl_common(files_struct *fsp, DEBUG(10, ("retrying with posix acl...\n")); return posix_fget_nt_acl(fsp, security_info, ppdesc); } - + /* GPFS ACL was not read, something wrong happened, error code is set in errno */ return map_nt_error_from_unix(errno); } -NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle, - files_struct *fsp, int fd, uint32 security_info, - SEC_DESC **ppdesc) -{ - return gpfsacl_get_nt_acl_common(fsp, security_info, ppdesc); -} - -NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle, +static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, SEC_DESC **ppdesc) { - return gpfsacl_get_nt_acl_common(fsp, security_info, ppdesc); + SMB4ACL_T *pacl = NULL; + int result; + + *ppdesc = NULL; + result = gpfs_get_nfs4_acl(fsp->fsp_name, &pacl); + + if (result == 0) + return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc, pacl); + + if (result > 0) { + DEBUG(10, ("retrying with posix acl...\n")); + return posix_get_nt_acl(handle->conn, name, security_info, ppdesc); + } + + /* GPFS ACL was not read, something wrong happened, error code is set in errno */ + return map_nt_error_from_unix(errno); } static bool gpfsacl_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl) -- cgit From c8fc49ff1b18606577c12fd0d89b94378c25f0be Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 16 Nov 2007 18:33:39 +0100 Subject: Prepare the zfs acl module for the api change in get_nt_acl(). Michael (This used to be commit 04258231dc654df077638edb7cb08542e39b7547) --- source3/modules/vfs_zfsacl.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 88cd0879cf..e4b38f88ab 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -34,8 +34,9 @@ * read the local file's acls and return it in NT form * using the NFSv4 format conversion */ -static NTSTATUS zfs_get_nt_acl(struct files_struct *fsp, uint32 security_info, - struct security_descriptor **ppdesc) +static NTSTATUS zfs_get_nt_acl_common(const char *name, + uint32 security_info, + SMB4ACL_T **ppacl) { int naces, i; ace_t *acebuf; @@ -43,11 +44,11 @@ static NTSTATUS zfs_get_nt_acl(struct files_struct *fsp, uint32 security_info, TALLOC_CTX *mem_ctx; /* read the number of file aces */ - if((naces = acl(fsp->fsp_name, ACE_GETACLCNT, 0, NULL)) == -1) { + if((naces = acl(name, ACE_GETACLCNT, 0, NULL)) == -1) { if(errno == ENOSYS) { DEBUG(9, ("acl(ACE_GETACLCNT, %s): Operation is not supported on the filesystem where the file reside")); } else { - DEBUG(9, ("acl(ACE_GETACLCNT, %s): %s ", fsp->fsp_name, + DEBUG(9, ("acl(ACE_GETACLCNT, %s): %s ", name, strerror(errno))); } return map_nt_error_from_unix(errno); @@ -59,8 +60,8 @@ static NTSTATUS zfs_get_nt_acl(struct files_struct *fsp, uint32 security_info, return NT_STATUS_NO_MEMORY; } /* read the aces into the field */ - if(acl(fsp->fsp_name, ACE_GETACL, naces, acebuf) < 0) { - DEBUG(9, ("acl(ACE_GETACL, %s): %s ", fsp->fsp_name, + if(acl(name, ACE_GETACL, naces, acebuf) < 0) { + DEBUG(9, ("acl(ACE_GETACL, %s): %s ", name, strerror(errno))); return map_nt_error_from_unix(errno); } @@ -92,7 +93,8 @@ static NTSTATUS zfs_get_nt_acl(struct files_struct *fsp, uint32 security_info, return NT_STATUS_NO_MEMORY; } - return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); + *ppacl = pacl; + return NT_STATUS_OK; } /* call-back function processing the NT acl -> ZFS acl using NFSv4 conv. */ @@ -171,7 +173,15 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, int fd, uint32 security_info, struct security_descriptor **ppdesc) { - return zfs_get_nt_acl(fsp, security_info, ppdesc); + SMB4ACL_T *pacl; + NTSTATUS status; + + status = zfs_get_nt_acl_common(fsp->fsp_name, security_info, &pacl); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); } static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle, @@ -179,7 +189,16 @@ static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle, const char *name, uint32 security_info, struct security_descriptor **ppdesc) { - return zfs_get_nt_acl(fsp, security_info, ppdesc); + SMB4ACL_T *pacl; + NTSTATUS status; + + status = zfs_get_nt_acl_common(name, security_info, &pacl); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc, + pacl); } static NTSTATUS zfsacl_fset_nt_acl(vfs_handle_struct *handle, -- cgit From 35f13ae58958e00aeb81bfe6cb5cf3c9dec3f62f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 4 Dec 2007 08:19:40 +0100 Subject: Reformatting: wrap long lines and remove trailing spaces. Michael (This used to be commit f6db5a0d0571130f765d8a0fb4e20e61cc8b2487) --- source3/modules/vfs_zfsacl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index e4b38f88ab..307fa9977f 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -46,7 +46,9 @@ static NTSTATUS zfs_get_nt_acl_common(const char *name, /* read the number of file aces */ if((naces = acl(name, ACE_GETACLCNT, 0, NULL)) == -1) { if(errno == ENOSYS) { - DEBUG(9, ("acl(ACE_GETACLCNT, %s): Operation is not supported on the filesystem where the file reside")); + DEBUG(9, ("acl(ACE_GETACLCNT, %s): Operation is not " + "supported on the filesystem where the file " + "reside")); } else { DEBUG(9, ("acl(ACE_GETACLCNT, %s): %s ", name, strerror(errno))); @@ -145,7 +147,9 @@ static bool zfs_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl) /* store acl */ if(acl(fsp->fsp_name, ACE_SETACL, naces, acebuf)) { if(errno == ENOSYS) { - DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not supported on the filesystem where the file reside")); + DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not " + "supported on the filesystem where the file " + "reside")); } else { DEBUG(9, ("acl(ACE_SETACL, %s): %s ", fsp->fsp_name, strerror(errno))); @@ -219,7 +223,7 @@ static NTSTATUS zfsacl_set_nt_acl(vfs_handle_struct *handle, /* VFS operations structure */ -static vfs_op_tuple zfsacl_ops[] = { +static vfs_op_tuple zfsacl_ops[] = { {SMB_VFS_OP(zfsacl_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(zfsacl_get_nt_acl), SMB_VFS_OP_GET_NT_ACL, -- cgit From 65b3065a4b31102e332de7d6008941847d5f97b3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 4 Dec 2007 08:25:21 +0100 Subject: Fix two debug statements: Add missing printf parameter. Michael (This used to be commit 1c4f74551f48429ee3af2022101a97679e25cdea) --- source3/modules/vfs_zfsacl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 307fa9977f..83893c7aea 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -48,7 +48,7 @@ static NTSTATUS zfs_get_nt_acl_common(const char *name, if(errno == ENOSYS) { DEBUG(9, ("acl(ACE_GETACLCNT, %s): Operation is not " "supported on the filesystem where the file " - "reside")); + "reside", name)); } else { DEBUG(9, ("acl(ACE_GETACLCNT, %s): %s ", name, strerror(errno))); @@ -149,7 +149,7 @@ static bool zfs_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl) if(errno == ENOSYS) { DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not " "supported on the filesystem where the file " - "reside")); + "reside", fsp->fsp_name)); } else { DEBUG(9, ("acl(ACE_SETACL, %s): %s ", fsp->fsp_name, strerror(errno))); -- cgit From fcee8ccdcdec341f758fb8aa30d5eb432430005d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 3 Dec 2007 18:24:56 +0100 Subject: Change aixjfs2_get_nfs4_acl() to take file name instead of fsp. In preparation of the api change in api change in get_nt_acl(). Michael (This used to be commit 40a1438e17c462990e6b71b544c39f093236d5be) --- source3/modules/vfs_aixacl2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index 0cb40a2214..289f4af9e6 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -98,7 +98,7 @@ static AIXJFS2_ACL_T *aixjfs2_getacl_alloc(const char *fname, acl_type_t *type) return acl; } -static bool aixjfs2_get_nfs4_acl(files_struct *fsp, +static bool aixjfs2_get_nfs4_acl(const char *name, SMB4ACL_T **ppacl, bool *pretryPosix) { int32_t i; @@ -108,15 +108,15 @@ static bool aixjfs2_get_nfs4_acl(files_struct *fsp, nfs4_ace_int_t *jfs2_ace = NULL; acl_type_t type; - DEBUG(10,("jfs2 get_nt_acl invoked for %s\n", fsp->fsp_name)); + DEBUG(10,("jfs2 get_nt_acl invoked for %s\n", name)); memset(&type, 0, sizeof(acl_type_t)); type.u64 = ACL_NFS4; - pacl = aixjfs2_getacl_alloc(fsp->fsp_name, &type); + pacl = aixjfs2_getacl_alloc(name, &type); if (pacl == NULL) { DEBUG(9, ("aixjfs2_getacl_alloc failed for %s with %s\n", - fsp->fsp_name, strerror(errno))); + name, strerror(errno))); if (errno==ENOSYS) *pretryPosix = True; return False; @@ -166,7 +166,7 @@ static NTSTATUS aixjfs2_get_nt_acl_common(files_struct *fsp, bool retryPosix = False; *ppdesc = NULL; - result = aixjfs2_get_nfs4_acl(fsp, &pacl, &retryPosix); + result = aixjfs2_get_nfs4_acl(fsp->fsp_name, &pacl, &retryPosix); if (retryPosix) { DEBUG(10, ("retrying with posix acl...\n")); -- cgit From aca40f29d5aa96c980fbe010e91be4c0dc608f5f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 3 Dec 2007 18:31:03 +0100 Subject: Prepare the aix2 acl module for the api change in get_nt_acl(). This makes both of aixjfs2_[f]get_nt_acl() more specific, eliminating the need for aixjfs2_get_nt_acl_common(). Michael (This used to be commit 36e2a814ba50feefa34c76353c0f5dec1d7cfff4) --- source3/modules/vfs_aixacl2.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index 289f4af9e6..d28efa55c6 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -158,8 +158,9 @@ static bool aixjfs2_get_nfs4_acl(const char *name, return True; } -static NTSTATUS aixjfs2_get_nt_acl_common(files_struct *fsp, - uint32 security_info, SEC_DESC **ppdesc) +static NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle, + files_struct *fsp, int fd, uint32 security_info, + SEC_DESC **ppdesc) { SMB4ACL_T *pacl = NULL; bool result; @@ -178,18 +179,27 @@ static NTSTATUS aixjfs2_get_nt_acl_common(files_struct *fsp, return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl); } -NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle, - files_struct *fsp, int fd, uint32 security_info, - SEC_DESC **ppdesc) -{ - return aixjfs2_get_nt_acl_common(fsp, security_info, ppdesc); -} - -NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle, +static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, SEC_DESC **ppdesc) { - return aixjfs2_get_nt_acl_common(fsp, security_info, ppdesc); + SMB4ACL_T *pacl = NULL; + bool result; + bool retryPosix = False; + + *ppdesc = NULL; + result = aixjfs2_get_nfs4_acl(name, &pacl, &retryPosix); + if (retryPosix) + { + DEBUG(10, ("retrying with posix acl...\n")); + return posix_get_nt_acl(handle->conn, name security_info, + ppdesc); + } + if (result==False) + return NT_STATUS_ACCESS_DENIED; + + return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc, + pacl); } static SMB_ACL_T aixjfs2_get_posix_acl(const char *path, acl_type_t type) -- cgit From 9460dfc93343f395f6a3867f9f8ec4dfb47bfbc7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 4 Dec 2007 09:45:14 +0100 Subject: Prepare the afs acl module for the api change in get_nt_acl(). This makes both of afsacl_[f]get_nt_acl() more specific, eliminating the need for afs_get_nt_acl(). Instead, split afs_to_nt_acl. Michael (This used to be commit 15caf58c81ce6b68eefa03c8f8510c2ecb5fdeb3) --- source3/modules/vfs_afsacl.c | 120 +++++++++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 43 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index a923ce188f..9dd4d7ec93 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -585,15 +585,14 @@ static uint32 nt_to_afs_file_rights(const char *filename, const SEC_ACE *ace) return result; } -static size_t afs_to_nt_acl(struct afs_acl *afs_acl, - struct files_struct *fsp, - uint32 security_info, - struct security_descriptor **ppdesc) +static size_t afs_to_nt_acl_common(struct afs_acl *afs_acl, + SMB_STRUCT_STAT *psbuf, + uint32 security_info, + struct security_descriptor **ppdesc) { SEC_ACE *nt_ace_list; DOM_SID owner_sid, group_sid; SEC_ACCESS mask; - SMB_STRUCT_STAT sbuf; SEC_ACL *psa = NULL; int good_aces; size_t sd_size; @@ -601,19 +600,8 @@ static size_t afs_to_nt_acl(struct afs_acl *afs_acl, struct afs_ace *afs_ace; - if (fsp->is_directory || fsp->fh->fd == -1) { - /* Get the stat struct for the owner info. */ - if(SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf) != 0) { - return 0; - } - } else { - if(SMB_VFS_FSTAT(fsp,fsp->fh->fd,&sbuf) != 0) { - return 0; - } - } - - uid_to_sid(&owner_sid, sbuf.st_uid); - gid_to_sid(&group_sid, sbuf.st_gid); + uid_to_sid(&owner_sid, psbuf->st_uid); + gid_to_sid(&group_sid, psbuf->st_gid); if (afs_acl->num_aces) { nt_ace_list = TALLOC_ARRAY(mem_ctx, SEC_ACE, afs_acl->num_aces); @@ -639,7 +627,7 @@ static size_t afs_to_nt_acl(struct afs_acl *afs_acl, continue; } - if (fsp->is_directory) + if (S_ISDIR(psbuf->st_mode)) afs_to_nt_dir_rights(afs_ace->rights, &nt_rights, &flag); else @@ -656,7 +644,6 @@ static size_t afs_to_nt_acl(struct afs_acl *afs_acl, if (psa == NULL) return 0; - *ppdesc = make_sec_desc(mem_ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, (security_info & OWNER_SECURITY_INFORMATION) @@ -668,6 +655,42 @@ static size_t afs_to_nt_acl(struct afs_acl *afs_acl, return sd_size; } +static size_t afs_to_nt_acl(struct afs_acl *afs_acl, + struct connection_struct *conn, + const char *name, + uint32 security_info, + struct security_descriptor **ppdesc) +{ + SMB_STRUCT_STAT sbuf; + + /* Get the stat struct for the owner info. */ + if(SMB_VFS_STAT(conn, name, &sbuf) != 0) { + return 0; + } + + return afs_to_nt_acl_common(afs_acl, &sbuf, security_info, ppdesc); +} + +static size_t afs_fto_nt_acl(struct afs_acl *afs_acl, + struct files_struct *fsp, + uint32 security_info, + struct security_descriptor **ppdesc) +{ + SMB_STRUCT_STAT sbuf; + + if (fsp->is_directory || fsp->fh->fd == -1) { + /* Get the stat struct for the owner info. */ + return afs_to_nt_acl(afs_acl, fsp->conn, fsp->fsp_name, + security_info, ppdesc); + } + + if(SMB_VFS_FSTAT(fsp,fsp->fh->fd,&sbuf) != 0) { + return 0; + } + + return afs_to_nt_acl_common(afs_acl, &sbuf, security_info, ppdesc); +} + static bool mappable_sid(const DOM_SID *sid) { DOM_SID domain_sid; @@ -830,27 +853,6 @@ static bool afs_get_afs_acl(char *filename, struct afs_acl *acl) return True; } -static NTSTATUS afs_get_nt_acl(struct files_struct *fsp, uint32 security_info, - struct security_descriptor **ppdesc) -{ - struct afs_acl acl; - size_t sd_size; - - DEBUG(5, ("afs_get_nt_acl: %s\n", fsp->fsp_name)); - - sidpts = lp_parm_bool(SNUM(fsp->conn), "afsacl", "sidpts", False); - - if (!afs_get_afs_acl(fsp->fsp_name, &acl)) { - return NT_STATUS_ACCESS_DENIED; - } - - sd_size = afs_to_nt_acl(&acl, fsp, security_info, ppdesc); - - free_afs_acl(&acl); - - return (sd_size != 0) ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; -} - /* For setting an AFS ACL we have to take care of the ACEs we could * not properly map to SIDs. Merge all of them into the new ACL. */ @@ -994,14 +996,46 @@ static NTSTATUS afsacl_fget_nt_acl(struct vfs_handle_struct *handle, int fd, uint32 security_info, struct security_descriptor **ppdesc) { - return afs_get_nt_acl(fsp, security_info, ppdesc); + struct afs_acl acl; + size_t sd_size; + + DEBUG(5, ("afsacl_fget_nt_acl: %s\n", fsp->fsp_name)); + + sidpts = lp_parm_bool(SNUM(fsp->conn), "afsacl", "sidpts", False); + + if (!afs_get_afs_acl(fsp->fsp_name, &acl)) { + return NT_STATUS_ACCESS_DENIED; + } + + sd_size = afs_fto_nt_acl(&acl, fsp, security_info, ppdesc); + + free_afs_acl(&acl); + + return (sd_size != 0) ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } + static NTSTATUS afsacl_get_nt_acl(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, uint32 security_info, struct security_descriptor **ppdesc) { - return afs_get_nt_acl(fsp, security_info, ppdesc); + struct afs_acl acl; + size_t sd_size; + + DEBUG(5, ("afsacl_get_nt_acl: %s\n", name)); + + sidpts = lp_parm_bool(SNUM(handle->conn), "afsacl", "sidpts", False); + + if (!afs_get_afs_acl(name, &acl)) { + return NT_STATUS_ACCESS_DENIED; + } + + sd_size = afs_to_nt_acl(&acl, handle->conn, name, security_info, + ppdesc); + + free_afs_acl(&acl); + + return (sd_size != 0) ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } NTSTATUS afsacl_fset_nt_acl(vfs_handle_struct *handle, -- cgit From 233eb0e560acb26f8706fd3ab96d4c6379458414 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 5 Dec 2007 09:53:10 +0100 Subject: Change the prototype of the vfs function get_nt_acl(). Up to now, get_nt_acl() took a files_struct pointer (fsp) and a file name. All the underlying functions should need and now do need (after the previous preparatory work), is a connection_struct and a file name. The connection_struct is already there in the vfs_handle passed to the vfs functions. So the files_struct argument can be eliminated. This eliminates the need of calling open_file_stat in a couple of places to produce the fsp needed. Michael (This used to be commit b5f600fab53c9d159a958c59795db3ba4a8acc63) --- source3/modules/vfs_afsacl.c | 1 - source3/modules/vfs_catia.c | 3 +-- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 3 +-- source3/modules/vfs_gpfs.c | 2 +- source3/modules/vfs_zfsacl.c | 1 - 6 files changed, 5 insertions(+), 9 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index 9dd4d7ec93..a14a117229 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -1015,7 +1015,6 @@ static NTSTATUS afsacl_fget_nt_acl(struct vfs_handle_struct *handle, } static NTSTATUS afsacl_get_nt_acl(struct vfs_handle_struct *handle, - struct files_struct *fsp, const char *name, uint32 security_info, struct security_descriptor **ppdesc) { diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 71f478a8a9..ab48c963ec 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -290,8 +290,7 @@ static NTSTATUS catia_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, struct security_descriptor **ppdesc) { - return SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info, - ppdesc); + return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc); } static NTSTATUS catia_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 3dd3727340..17b183600a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -956,13 +956,13 @@ static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, } static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle, - files_struct *fsp, const char *name, + const char *name, uint32 security_info, SEC_DESC **ppdesc) { NTSTATUS result; START_PROFILE(get_nt_acl); - result = posix_get_nt_acl(fsp->conn, fsp->fsp_name, security_info, ppdesc); + result = posix_get_nt_acl(handle->conn, name, security_info, ppdesc); END_PROFILE(get_nt_acl); return result; } diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index f4aeefbbf0..f6b6e85837 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -1547,8 +1547,7 @@ static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, { NTSTATUS result; - result = SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info, - ppdesc); + result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc); do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index e7331bef29..24ca3d5e42 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -249,7 +249,7 @@ static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle, } static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle, - files_struct *fsp, const char *name, + const char *name, uint32 security_info, SEC_DESC **ppdesc) { SMB4ACL_T *pacl = NULL; diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 83893c7aea..060d64cffb 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -189,7 +189,6 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, } static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle, - struct files_struct *fsp, const char *name, uint32 security_info, struct security_descriptor **ppdesc) { -- cgit From a32329297dbce22617960d112d94b6a5d2989e1f Mon Sep 17 00:00:00 2001 From: James Peach Date: Wed, 19 Dec 2007 22:39:40 -0800 Subject: Remove unused variable 'didmsg'. (This used to be commit 5de89dd6e0a8a56a5a0f998e3b1d3538367db7d6) --- source3/modules/vfs_readahead.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_readahead.c b/source3/modules/vfs_readahead.c index 5b663a7b26..8fdd6168fe 100644 --- a/source3/modules/vfs_readahead.c +++ b/source3/modules/vfs_readahead.c @@ -17,10 +17,6 @@ #include "includes.h" -#if !defined(HAVE_LINUX_READAHEAD) && !defined(HAVE_POSIX_FADVISE) -static bool didmsg; -#endif - struct readahead_data { SMB_OFF_T off_bound; SMB_OFF_T len; -- cgit From 23c965d9472058c566a1b9f8a44964acd5c8a446 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 27 Dec 2007 00:22:07 +0100 Subject: typos (This used to be commit 30fa3477c8f810d8f2b4c4be218509544735274c) --- source3/modules/vfs_solarisacl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_solarisacl.c b/source3/modules/vfs_solarisacl.c index 673b6805af..cda243f8c1 100644 --- a/source3/modules/vfs_solarisacl.c +++ b/source3/modules/vfs_solarisacl.c @@ -264,8 +264,8 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle, } done: - DEBUG(10, ("solarisacl_sys_acl_st_fd %s.\n", - ((ret == 0) ? "succeded" : "failed" ))); + DEBUG(10, ("solarisacl_sys_acl_set_fd %s.\n", + ((ret == 0) ? "succeeded" : "failed" ))); SAFE_FREE(solaris_acl); SAFE_FREE(default_acl); return ret; -- cgit From 7cbdb48475b0340154fad60cb4b7cc53dc2bbcfd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 29 Dec 2007 23:00:49 +0100 Subject: Remove tiny code duplication ndr_size_security_descriptor does the same as sec_desc_size (This used to be commit bc3bd7a8e7c6e9e27acb195c86abb92c0f53112f) --- source3/modules/nfs4_acls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 70bb6a02e8..6d2972d8ed 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -309,7 +309,7 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf, } DEBUG(10, ("smb_get_nt_acl_nfs4_common successfully exited with sd_size %d\n", - sec_desc_size(*ppdesc))); + ndr_size_security_descriptor(*ppdesc, 0))); return NT_STATUS_OK; } -- cgit From ee24c629a68e13764f78064121a6aea3d0e9240c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 5 Jan 2008 02:16:15 +0100 Subject: Remove superfluous fd parameter from SMB_VFS_FGET_NT_ACL(). Michael (This used to be commit c0c7c1223da29c68359dac64a340c1c710d5f3d2) --- source3/modules/vfs_afsacl.c | 2 +- source3/modules/vfs_aixacl2.c | 2 +- source3/modules/vfs_default.c | 2 +- source3/modules/vfs_full_audit.c | 7 +++---- source3/modules/vfs_gpfs.c | 2 +- source3/modules/vfs_zfsacl.c | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index a14a117229..cdfac3eece 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -993,7 +993,7 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, static NTSTATUS afsacl_fget_nt_acl(struct vfs_handle_struct *handle, struct files_struct *fsp, - int fd, uint32 security_info, + uint32 security_info, struct security_descriptor **ppdesc) { struct afs_acl acl; diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index d28efa55c6..9ea8414f79 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -159,7 +159,7 @@ static bool aixjfs2_get_nfs4_acl(const char *name, } static NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle, - files_struct *fsp, int fd, uint32 security_info, + files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc) { SMB4ACL_T *pacl = NULL; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 17b183600a..b31bc19815 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -944,7 +944,7 @@ static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle, S } static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, - files_struct *fsp, int fd, + files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc) { NTSTATUS result; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index f6b6e85837..8f90e0de87 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -191,7 +191,7 @@ 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); static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info, + uint32 security_info, SEC_DESC **ppdesc); static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, @@ -1525,13 +1525,12 @@ static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *ha } static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info, + uint32 security_info, SEC_DESC **ppdesc) { NTSTATUS result; - result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info, - ppdesc); + result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc); do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 24ca3d5e42..21e5a6bcfa 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -227,7 +227,7 @@ static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl) } static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle, - files_struct *fsp, int fd, uint32 security_info, + files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc) { SMB4ACL_T *pacl = NULL; diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 060d64cffb..6bf8352efd 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -174,7 +174,7 @@ static NTSTATUS zfs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, struct files_struct *fsp, - int fd, uint32 security_info, + uint32 security_info, struct security_descriptor **ppdesc) { SMB4ACL_T *pacl; -- cgit From 05352cf2cb7f9710444d340f3f14ac6917fb0416 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 6 Jan 2008 18:48:02 +0100 Subject: Remove superfluous parameter fd from SMB_VFS_FSET_NT_ACL(). Michael (This used to be commit 4f2d139a186048f08180378a877b69d2f80ad51f) --- source3/modules/vfs_afsacl.c | 2 +- source3/modules/vfs_aixacl2.c | 2 +- source3/modules/vfs_default.c | 2 +- source3/modules/vfs_full_audit.c | 7 +++---- source3/modules/vfs_gpfs.c | 2 +- source3/modules/vfs_zfsacl.c | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index cdfac3eece..90c6a589a1 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -1039,7 +1039,7 @@ static NTSTATUS afsacl_get_nt_acl(struct vfs_handle_struct *handle, NTSTATUS afsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info_sent, + uint32 security_info_sent, SEC_DESC *psd) { return afs_set_nt_acl(handle, fsp, security_info_sent, psd); diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index 9ea8414f79..d63886d68e 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -399,7 +399,7 @@ static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_inf return result; } -NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd) +NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) { return aixjfs2_set_nt_acl_common(fsp, security_info_sent, psd); } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index b31bc19815..3251c56061 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -967,7 +967,7 @@ static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle, return result; } -static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) { NTSTATUS result; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 8f90e0de87..bdbd84ab4f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -197,7 +197,7 @@ static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struc const char *name, uint32 security_info, SEC_DESC **ppdesc); static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info_sent, + uint32 security_info_sent, SEC_DESC *psd); static NTSTATUS smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, @@ -1555,13 +1555,12 @@ static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, } static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info_sent, + uint32 security_info_sent, SEC_DESC *psd) { NTSTATUS result; - result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent, - psd); + result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd); do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 21e5a6bcfa..0f7dc81ae6 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -363,7 +363,7 @@ static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_i return result; } -static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) { return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd); } diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 6bf8352efd..ce2e28771f 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -206,7 +206,7 @@ static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle, static NTSTATUS zfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info_sent, + uint32 security_info_sent, SEC_DESC *psd) { return zfs_set_nt_acl(handle, fsp, security_info_sent, psd); -- cgit From ca275e254985727c50b1b988c958a3743a7bc8ce Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 00:14:19 +0100 Subject: Remove unneeded parameter fd from SMB_VFS_PREAD(). Michael (This used to be commit 73e28806ce87d829ea7c38ed3440020845bb13bf) --- source3/modules/vfs_cacheprime.c | 5 ++--- source3/modules/vfs_default.c | 16 ++++++++-------- source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_readahead.c | 11 +++++------ 4 files changed, 18 insertions(+), 20 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cacheprime.c b/source3/modules/vfs_cacheprime.c index 9574087d9d..6eb74e66ed 100644 --- a/source3/modules/vfs_cacheprime.c +++ b/source3/modules/vfs_cacheprime.c @@ -160,16 +160,15 @@ static ssize_t cprime_read( static ssize_t cprime_pread( vfs_handle_struct * handle, files_struct * fsp, - int fd, void * data, size_t count, SMB_OFF_T offset) { if (g_readbuf) { - prime_cache(handle, fsp, fd, offset, count); + prime_cache(handle, fsp, fsp->fh->fd, offset, count); } - return SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, count, offset); + return SMB_VFS_NEXT_PREAD(handle, fsp, data, count, offset); } static vfs_op_tuple cprime_ops [] = diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 3251c56061..4f9d90abde 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -218,19 +218,19 @@ static ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, int fd return result; } -static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, +static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, SMB_OFF_T offset) { ssize_t result; #if defined(HAVE_PREAD) || defined(HAVE_PREAD64) START_PROFILE_BYTES(syscall_pread, n); - result = sys_pread(fd, data, n, offset); + result = sys_pread(fsp->fh->fd, data, n, offset); END_PROFILE(syscall_pread); if (result == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be seeked (sought?) on. */ - result = SMB_VFS_READ(fsp, fd, data, n); + result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); fsp->fh->pos = 0; } @@ -238,23 +238,23 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, int f SMB_OFF_T curr; int lerrno; - curr = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR); + curr = SMB_VFS_LSEEK(fsp, fsp->fh->fd, 0, SEEK_CUR); if (curr == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be seeked (sought?) on. */ - result = SMB_VFS_READ(fsp, fd, data, n); + result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); fsp->fh->pos = 0; return result; } - if (SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET) == -1) { + if (SMB_VFS_LSEEK(fsp, fsp->fh->fd, offset, SEEK_SET) == -1) { return -1; } errno = 0; - result = SMB_VFS_READ(fsp, fd, data, n); + result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); lerrno = errno; - SMB_VFS_LSEEK(fsp, fd, curr, SEEK_SET); + SMB_VFS_LSEEK(fsp, fsp->fh->fd, curr, SEEK_SET); errno = lerrno; #endif /* HAVE_PREAD */ diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index bdbd84ab4f..7acca905a0 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -115,7 +115,7 @@ static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, in static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n); static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp, - int fd, void *data, size_t n, SMB_OFF_T offset); + void *data, size_t n, SMB_OFF_T offset); static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n); static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp, @@ -1100,11 +1100,11 @@ static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp, } static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp, - int fd, void *data, size_t n, SMB_OFF_T offset) + void *data, size_t n, SMB_OFF_T offset) { ssize_t result; - result = SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset); + result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_readahead.c b/source3/modules/vfs_readahead.c index 8fdd6168fe..b3642d558f 100644 --- a/source3/modules/vfs_readahead.c +++ b/source3/modules/vfs_readahead.c @@ -80,7 +80,6 @@ static ssize_t readahead_sendfile(struct vfs_handle_struct *handle, static ssize_t readahead_pread(vfs_handle_struct *handle, files_struct *fsp, - int fd, void *data, size_t count, SMB_OFF_T offset) @@ -89,16 +88,16 @@ static ssize_t readahead_pread(vfs_handle_struct *handle, if ( offset % rhd->off_bound == 0) { #if defined(HAVE_LINUX_READAHEAD) - int err = readahead(fd, offset, (size_t)rhd->len); + int err = readahead(fsp->fh->fd, offset, (size_t)rhd->len); DEBUG(10,("readahead_pread: readahead on fd %u, offset %llu, len %u returned %d\n", - (unsigned int)fd, + (unsigned int)fsp->fh->fd, (unsigned long long)offset, (unsigned int)rhd->len, err )); #elif defined(HAVE_POSIX_FADVISE) - int err = posix_fadvise(fd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED); + int err = posix_fadvise(fsp->fh->fd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED); DEBUG(10,("readahead_pread: posix_fadvise on fd %u, offset %llu, len %u returned %d\n", - (unsigned int)fd, + (unsigned int)fsp->fh->fd, (unsigned long long)offset, (unsigned int)rhd->len, err )); @@ -109,7 +108,7 @@ static ssize_t readahead_pread(vfs_handle_struct *handle, } #endif } - return SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, count, offset); + return SMB_VFS_NEXT_PREAD(handle, fsp, data, count, offset); } /******************************************************************* -- cgit From a56b417809805f8872c1e3238cce5d006d6189e4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 09:23:04 +0100 Subject: Remove redundant parameter fd from SMB_VFS_PWRITE(). Michael (This used to be commit 8c4901a19ae2fd3ee085f9499f33aa7db016d182) --- source3/modules/vfs_commit.c | 3 +-- source3/modules/vfs_default.c | 14 +++++++------- source3/modules/vfs_full_audit.c | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index d7d81924f1..e445c43181 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -248,14 +248,13 @@ static ssize_t commit_write( static ssize_t commit_pwrite( vfs_handle_struct * handle, files_struct * fsp, - int fd, void * data, size_t count, SMB_OFF_T offset) { ssize_t ret; - ret = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, count, offset); + ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, count, offset); if (ret > 0) { if (commit(handle, fsp, offset, ret) == -1) { return -1; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 4f9d90abde..b4ce9346e2 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -272,38 +272,38 @@ static ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, int f return result; } -static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, +static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset) { ssize_t result; #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64) START_PROFILE_BYTES(syscall_pwrite, n); - result = sys_pwrite(fd, data, n, offset); + result = sys_pwrite(fsp->fh->fd, data, n, offset); END_PROFILE(syscall_pwrite); if (result == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be sought on. */ - result = SMB_VFS_WRITE(fsp, fd, data, n); + result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n); } #else /* HAVE_PWRITE */ SMB_OFF_T curr; int lerrno; - curr = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR); + curr = SMB_VFS_LSEEK(fsp, fsp->fh->fd, 0, SEEK_CUR); if (curr == -1) { return -1; } - if (SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET) == -1) { + if (SMB_VFS_LSEEK(fsp, fsp->fh->fd, offset, SEEK_SET) == -1) { return -1; } - result = SMB_VFS_WRITE(fsp, fd, data, n); + result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n); lerrno = errno; - SMB_VFS_LSEEK(fsp, fd, curr, SEEK_SET); + SMB_VFS_LSEEK(fsp, fsp->fh->fd, curr, SEEK_SET); errno = lerrno; #endif /* HAVE_PWRITE */ diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 7acca905a0..c0bc40cc67 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -119,7 +119,7 @@ static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n); static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp, - int fd, const void *data, size_t n, + const void *data, size_t n, SMB_OFF_T offset); static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence); @@ -1124,12 +1124,12 @@ static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp } static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp, - int fd, const void *data, size_t n, + const void *data, size_t n, SMB_OFF_T offset) { ssize_t result; - result = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset); + result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name); -- cgit From 6f657c873efa4779e762a8f9ede97e19da6fb7ec Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 10:15:08 +0100 Subject: Remove redundant parameter fd from SMB_VFS_LSEEK(). Michael (This used to be commit df929796f2698698d2875227bda8500589cca2df) --- source3/modules/vfs_default.c | 30 +++++++++++++++--------------- source3/modules/vfs_full_audit.c | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index b4ce9346e2..41162e67ca 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -238,7 +238,7 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void SMB_OFF_T curr; int lerrno; - curr = SMB_VFS_LSEEK(fsp, fsp->fh->fd, 0, SEEK_CUR); + curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); if (curr == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be seeked (sought?) on. */ result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); @@ -246,7 +246,7 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void return result; } - if (SMB_VFS_LSEEK(fsp, fsp->fh->fd, offset, SEEK_SET) == -1) { + if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) { return -1; } @@ -254,7 +254,7 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); lerrno = errno; - SMB_VFS_LSEEK(fsp, fsp->fh->fd, curr, SEEK_SET); + SMB_VFS_LSEEK(fsp, curr, SEEK_SET); errno = lerrno; #endif /* HAVE_PREAD */ @@ -291,19 +291,19 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons SMB_OFF_T curr; int lerrno; - curr = SMB_VFS_LSEEK(fsp, fsp->fh->fd, 0, SEEK_CUR); + curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); if (curr == -1) { return -1; } - if (SMB_VFS_LSEEK(fsp, fsp->fh->fd, offset, SEEK_SET) == -1) { + if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) { return -1; } result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n); lerrno = errno; - SMB_VFS_LSEEK(fsp, fsp->fh->fd, curr, SEEK_SET); + SMB_VFS_LSEEK(fsp, curr, SEEK_SET); errno = lerrno; #endif /* HAVE_PWRITE */ @@ -311,15 +311,15 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons return result; } -static SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence) +static SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset, int whence) { SMB_OFF_T result = 0; START_PROFILE(syscall_lseek); /* Cope with 'stat' file opens. */ - if (filedes != -1) - result = sys_lseek(filedes, offset, whence); + if (fsp->fh->fd != -1) + result = sys_lseek(fsp->fh->fd, offset, whence); /* * We want to maintain the fiction that we can seek @@ -677,7 +677,7 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, const char *path, const str static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len) { SMB_STRUCT_STAT st; - SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR); + SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); unsigned char zero_space[4096]; SMB_OFF_T space_to_write; @@ -702,7 +702,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs return sys_ftruncate(fd, len); /* Write out the real space on disk. */ - if (SMB_VFS_LSEEK(fsp, fd, st.st_size, SEEK_SET) != st.st_size) + if (SMB_VFS_LSEEK(fsp, st.st_size, SEEK_SET) != st.st_size) return -1; space_to_write = len - st.st_size; @@ -720,7 +720,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs } /* Seek to where we were */ - if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos) + if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos) return -1; return 0; @@ -754,7 +754,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot extend a file with ftruncate. Provide alternate implementation for this */ - currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR); + currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); if (currpos == -1) { goto done; } @@ -784,14 +784,14 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f goto done; } - if (SMB_VFS_LSEEK(fsp, fd, len-1, SEEK_SET) != len -1) + if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1) goto done; if (SMB_VFS_WRITE(fsp, fd, &c, 1)!=1) goto done; /* Seek to where we were */ - if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos) + if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos) goto done; result = 0; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index c0bc40cc67..b03f6b53f4 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -122,7 +122,7 @@ static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fs const void *data, size_t n, SMB_OFF_T offset); static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp, - int filedes, SMB_OFF_T offset, int whence); + SMB_OFF_T offset, int whence); static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr, SMB_OFF_T offset, @@ -1137,11 +1137,11 @@ static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fs } static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp, - int filedes, SMB_OFF_T offset, int whence) + SMB_OFF_T offset, int whence) { ssize_t result; - result = SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence); + result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence); do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle, "%s", fsp->fsp_name); -- cgit From 8dcce0d236b2102ca94fbcb7aa7126fe6733f2e7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 12:49:02 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FSYNC(). Michael (This used to be commit 8f83c9a7b245dbfef28195f9a7f33047a8ba95a0) --- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 41162e67ca..8aa1709647 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -467,13 +467,13 @@ static int vfswrap_rename(vfs_handle_struct *handle, const char *oldname, const return result; } -static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd) +static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp) { #ifdef HAVE_FSYNC int result; START_PROFILE(syscall_fsync); - result = fsync(fd); + result = fsync(fsp->fh->fd); END_PROFILE(syscall_fsync); return result; #else diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index b03f6b53f4..396b2bbb68 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -133,7 +133,7 @@ static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd, size_t n); static int smb_full_audit_rename(vfs_handle_struct *handle, const char *oldname, const char *newname); -static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd); +static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp); static int smb_full_audit_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf); static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, @@ -1193,11 +1193,11 @@ static int smb_full_audit_rename(vfs_handle_struct *handle, return result; } -static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd) +static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp) { int result; - result = SMB_VFS_NEXT_FSYNC(handle, fsp, fd); + result = SMB_VFS_NEXT_FSYNC(handle, fsp); do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name); -- cgit From 87a684f7fcfa8d9fabc42e33981299d0b33eeeb7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 13:21:26 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FSTAT(). Michael (This used to be commit 0b86c420be94d295f6917a220b5d699f65b46711) --- source3/modules/nfs4_acls.c | 2 +- source3/modules/vfs_afsacl.c | 2 +- source3/modules/vfs_commit.c | 2 +- source3/modules/vfs_default.c | 8 ++++---- source3/modules/vfs_fake_perms.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_gpfs.c | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 6d2972d8ed..52d3983fff 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -185,7 +185,7 @@ static int smbacl4_fGetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf) if (fsp->is_directory || fsp->fh->fd == -1) { return smbacl4_GetFileOwner(fsp->conn, fsp->fsp_name, psbuf); } - if (SMB_VFS_FSTAT(fsp,fsp->fh->fd, psbuf) != 0) + if (SMB_VFS_FSTAT(fsp, psbuf) != 0) { DEBUG(8, ("SMB_VFS_FSTAT failed with error %s\n", strerror(errno))); diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index 90c6a589a1..e35bfabb8c 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -684,7 +684,7 @@ static size_t afs_fto_nt_acl(struct afs_acl *afs_acl, security_info, ppdesc); } - if(SMB_VFS_FSTAT(fsp,fsp->fh->fd,&sbuf) != 0) { + if(SMB_VFS_FSTAT(fsp, &sbuf) != 0) { return 0; } diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index e445c43181..f79e68f49e 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -217,7 +217,7 @@ static int commit_open( /* EOF commit modes require us to know the initial file size. */ if (c && (c->on_eof != EOF_NONE)) { SMB_STRUCT_STAT st; - if (SMB_VFS_FSTAT(fsp, fd, &st) == -1) { + if (SMB_VFS_FSTAT(fsp, &st) == -1) { return -1; } c->eof = st.st_size; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 8aa1709647..dd3f4ba2cd 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -491,12 +491,12 @@ static int vfswrap_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUC return result; } -static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf) +static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf) { int result; START_PROFILE(syscall_fstat); - result = sys_fstat(fd, sbuf); + result = sys_fstat(fsp->fh->fd, sbuf); END_PROFILE(syscall_fstat); return result; } @@ -684,7 +684,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs if (currpos == -1) return -1; - if (SMB_VFS_FSTAT(fsp, fd, &st) == -1) + if (SMB_VFS_FSTAT(fsp, &st) == -1) return -1; space_to_write = len - st.st_size; @@ -763,7 +763,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f size in which case the ftruncate above should have succeeded or shorter, in which case seek to len - 1 and write 1 byte of zero */ - if (SMB_VFS_FSTAT(fsp, fd, &st) == -1) { + if (SMB_VFS_FSTAT(fsp, &st) == -1) { goto done; } diff --git a/source3/modules/vfs_fake_perms.c b/source3/modules/vfs_fake_perms.c index 8157f05d52..ddad0008a7 100644 --- a/source3/modules/vfs_fake_perms.c +++ b/source3/modules/vfs_fake_perms.c @@ -46,11 +46,11 @@ static int fake_perms_stat(vfs_handle_struct *handle, const char *fname, SMB_STR return ret; } -static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf) +static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf) { int ret = -1; - ret = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf); + ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); if (ret == 0) { if (S_ISDIR(sbuf->st_mode)) { sbuf->st_mode = S_IFDIR | S_IRWXU; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 396b2bbb68..7464bf80b3 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -136,7 +136,7 @@ static int smb_full_audit_rename(vfs_handle_struct *handle, static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp); static int smb_full_audit_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf); -static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf); static int smb_full_audit_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf); @@ -1216,12 +1216,12 @@ static int smb_full_audit_stat(vfs_handle_struct *handle, return result; } -static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf) { int result; - result = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf); + result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 0f7dc81ae6..500a6ee772 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -645,7 +645,7 @@ static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mo static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) { SMB_STRUCT_STAT st; - if (SMB_VFS_NEXT_FSTAT(handle, fsp, fd, &st) != 0) { + if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) { return -1; } /* avoid chmod() if possible, to preserve acls */ -- cgit From e614dec27f33c932c6c29c806d567fd6015cd5e6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 13:44:37 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FCHMOD(). Michael (This used to be commit a54d5604da556d1250ca9948d4acc4a187a9fede) --- source3/modules/vfs_audit.c | 6 +++--- source3/modules/vfs_default.c | 6 +++--- source3/modules/vfs_extd_audit.c | 6 +++--- source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_gpfs.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c index 91993a47d7..27e7f998ab 100644 --- a/source3/modules/vfs_audit.c +++ b/source3/modules/vfs_audit.c @@ -39,7 +39,7 @@ static int audit_rename(vfs_handle_struct *handle, const char *oldname, const ch static int audit_unlink(vfs_handle_struct *handle, const char *path); static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode); static int audit_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode); -static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode); +static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode); /* VFS operations */ @@ -268,11 +268,11 @@ static int audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t m return result; } -static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { int result; - result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode); + result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); syslog(audit_syslog_priority(handle), "fchmod %s mode 0x%x %s%s\n", fsp->fsp_name, mode, diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index dd3f4ba2cd..d296b5bd5b 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -549,7 +549,7 @@ static int vfswrap_chmod(vfs_handle_struct *handle, const char *path, mode_t mo return result; } -static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { int result; @@ -563,7 +563,7 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, { int saved_errno = errno; /* We might get ENOSYS */ - if ((result = SMB_VFS_FCHMOD_ACL(fsp, fd, mode)) == 0) { + if ((result = SMB_VFS_FCHMOD_ACL(fsp, fsp->fh->fd, mode)) == 0) { END_PROFILE(syscall_fchmod); return result; } @@ -572,7 +572,7 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, } #if defined(HAVE_FCHMOD) - result = fchmod(fd, mode); + result = fchmod(fsp->fh->fd, mode); #else result = -1; errno = ENOSYS; diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c index 552c64016e..f9b03731e7 100644 --- a/source3/modules/vfs_extd_audit.c +++ b/source3/modules/vfs_extd_audit.c @@ -42,7 +42,7 @@ static int audit_rename(vfs_handle_struct *handle, const char *oldname, const ch static int audit_unlink(vfs_handle_struct *handle, const char *path); static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode); static int audit_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode); -static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode); +static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode); /* VFS operations */ @@ -310,11 +310,11 @@ static int audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t m return result; } -static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { int result; - result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode); + result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); syslog(audit_syslog_priority(handle), "fchmod %s mode 0x%x %s%s\n", fsp->fsp_name, mode, diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 7464bf80b3..fee65ba53f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -144,7 +144,7 @@ static int smb_full_audit_unlink(vfs_handle_struct *handle, const char *path); static int smb_full_audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode); -static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); static int smb_full_audit_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid); @@ -1264,12 +1264,12 @@ static int smb_full_audit_chmod(vfs_handle_struct *handle, return result; } -static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { int result; - result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode); + result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle, "%s|%o", fsp->fsp_name, mode); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 500a6ee772..832dcbfcad 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -642,7 +642,7 @@ static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mo return SMB_VFS_NEXT_CHMOD(handle, path, mode); } -static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { SMB_STRUCT_STAT st; if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) { @@ -652,7 +652,7 @@ static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, if ((st.st_mode & ~S_IFMT) == mode) { return 0; } - return SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode); + return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); } /* VFS operations structure */ -- cgit From 670909cb07e38a06bf5db12342b3b1189f0e1ab7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 14:26:00 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FCHOWN(). Michael (This used to be commit fbb193db3e0dc51cb000ae406a68bc547f31d9ab) --- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index d296b5bd5b..f66f77cd47 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -592,13 +592,13 @@ static int vfswrap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, return result; } -static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid) +static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid) { #ifdef HAVE_FCHOWN int result; START_PROFILE(syscall_fchown); - result = fchown(fd, uid, gid); + result = fchown(fsp->fh->fd, uid, gid); END_PROFILE(syscall_fchown); return result; #else diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index fee65ba53f..f7796adba0 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -148,7 +148,7 @@ static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); static int smb_full_audit_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid); -static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid); static int smb_full_audit_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid); @@ -1290,12 +1290,12 @@ static int smb_full_audit_chown(vfs_handle_struct *handle, return result; } -static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid) { int result; - result = SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid); + result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid); do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld", fsp->fsp_name, (long int)uid, (long int)gid); -- cgit From b457b94bb86897b7020c6f300cd19a3d8e192610 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 15:55:09 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FTRUNCATE(). Michael (This used to be commit 2ad66050a0452b8e7e08b1e7a01efa00c72fd451) --- source3/modules/vfs_commit.c | 3 +-- source3/modules/vfs_default.c | 12 ++++++------ source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_prealloc.c | 3 +-- 4 files changed, 11 insertions(+), 13 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index f79e68f49e..fe7324122f 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -277,12 +277,11 @@ static int commit_close( static int commit_ftruncate( vfs_handle_struct * handle, files_struct * fsp, - int fd, SMB_OFF_T len) { int result; - result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len); + result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len); if (result == 0) { struct commit_info *c; if ((c = VFS_FETCH_FSP_EXTENSION(handle, fsp))) { diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f66f77cd47..6ac8cc5def 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -674,7 +674,7 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, const char *path, const str allocate is set. **********************************************************************/ -static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len) +static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T len) { SMB_STRUCT_STAT st; SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); @@ -699,7 +699,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs /* Shrink - just ftruncate. */ if (st.st_size > len) - return sys_ftruncate(fd, len); + return sys_ftruncate(fsp->fh->fd, len); /* Write out the real space on disk. */ if (SMB_VFS_LSEEK(fsp, st.st_size, SEEK_SET) != st.st_size) @@ -726,7 +726,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs return 0; } -static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len) +static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T len) { int result = -1; SMB_STRUCT_STAT st; @@ -736,7 +736,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f START_PROFILE(syscall_ftruncate); if (lp_strict_allocate(SNUM(fsp->conn))) { - result = strict_allocate_ftruncate(handle, fsp, fd, len); + result = strict_allocate_ftruncate(handle, fsp, fsp->fh->fd, len); END_PROFILE(syscall_ftruncate); return result; } @@ -747,7 +747,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f expansion and some that don't! On Linux fat can't do ftruncate extend but ext2 can. */ - result = sys_ftruncate(fd, len); + result = sys_ftruncate(fsp->fh->fd, len); if (result == 0) goto done; @@ -787,7 +787,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1) goto done; - if (SMB_VFS_WRITE(fsp, fd, &c, 1)!=1) + if (SMB_VFS_WRITE(fsp, fsp->fh->fd, &c, 1)!=1) goto done; /* Seek to where we were */ diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index f7796adba0..1384c16290 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -159,7 +159,7 @@ static char *smb_full_audit_getwd(vfs_handle_struct *handle, static int smb_full_audit_ntimes(vfs_handle_struct *handle, const char *path, const struct timespec ts[2]); static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_OFF_T len); + SMB_OFF_T len); static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle, @@ -1353,11 +1353,11 @@ static int smb_full_audit_ntimes(vfs_handle_struct *handle, } static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_OFF_T len) + SMB_OFF_T len) { int result; - result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len); + result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len); do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_prealloc.c b/source3/modules/vfs_prealloc.c index cebf3a3933..2d64bc0184 100644 --- a/source3/modules/vfs_prealloc.c +++ b/source3/modules/vfs_prealloc.c @@ -184,11 +184,10 @@ normal_open: static int prealloc_ftruncate(vfs_handle_struct * handle, files_struct * fsp, - int fd, SMB_OFF_T offset) { SMB_OFF_T *psize; - int ret = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, offset); + int ret = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset); /* Maintain the allocated space even in the face of truncates. */ if ((psize = VFS_FETCH_FSP_EXTENSION(handle, fsp))) { -- cgit From 299d24dbc1d2d8eb0b78800eb5a8643b10c80274 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 16:12:03 +0100 Subject: Fix the build: Fix caller of strict_allocate_ftruncate(). Michael (This used to be commit 20691272a1e2562ab8c6143978d324af0334f871) --- source3/modules/vfs_default.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 6ac8cc5def..4505695915 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -736,7 +736,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O START_PROFILE(syscall_ftruncate); if (lp_strict_allocate(SNUM(fsp->conn))) { - result = strict_allocate_ftruncate(handle, fsp, fsp->fh->fd, len); + result = strict_allocate_ftruncate(handle, fsp, len); END_PROFILE(syscall_ftruncate); return result; } -- cgit From edd30e716fb5133b269ef82358e95d187a107870 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 16:38:23 +0100 Subject: Remove redundant parameter fd from SMB_VFS_LOCK(). Michael (This used to be commit 4f3ab2c406072e0b43581057e7e785e8ad454cfa) --- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 4505695915..0076f8d1b4 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -801,12 +801,12 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O return result; } -static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) +static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) { bool result; START_PROFILE(syscall_fcntl_lock); - result = fcntl_lock(fd, op, offset, count, type); + result = fcntl_lock(fsp->fh->fd, op, offset, count, type); END_PROFILE(syscall_fcntl_lock); return result; } diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 1384c16290..13f442485f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -160,7 +160,7 @@ static int smb_full_audit_ntimes(vfs_handle_struct *handle, const char *path, const struct timespec ts[2]); static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T len); -static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, +static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, @@ -1365,12 +1365,12 @@ static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp return result; } -static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, +static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) { bool result; - result = SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type); + result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type); do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name); -- cgit From 327cc04da587fa54f28dafb00267fde79b858349 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 17:14:20 +0100 Subject: Remove redundant parameter fd from SMB_VFS_KERNEL_FLOCK(). Michael (This used to be commit 195c519377c2fdc655e25760b52bc0694b8dda81) --- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_gpfs.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 0076f8d1b4..96161ad273 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -811,11 +811,11 @@ static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, S return result; } -static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, uint32 share_mode) { START_PROFILE(syscall_kernel_flock); - kernel_flock(fd, share_mode); + kernel_flock(fsp->fh->fd, share_mode); END_PROFILE(syscall_kernel_flock); return 0; } diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 13f442485f..cc14597d97 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -163,7 +163,7 @@ static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, + struct files_struct *fsp, uint32 share_mode); static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, int fd, int leasetype); @@ -1378,12 +1378,12 @@ static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, } static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, + struct files_struct *fsp, uint32 share_mode) { int result; - result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, fd, share_mode); + result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode); do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 832dcbfcad..1dd2c5967e 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -33,7 +33,7 @@ static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 share_mode) + uint32 share_mode) { START_PROFILE(syscall_kernel_flock); -- cgit From 26169410cd3fa90be5740a913f027802488eca8d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 21:47:53 +0100 Subject: Remove redundant parameter fd from SMB_VFS_LINUX_SETLEASE(). Michael (This used to be commit 8880eb82f16d561a4023ec8426f8ea35c579a7a6) --- source3/modules/vfs_default.c | 6 +++--- source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_gpfs.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 96161ad273..712aae9fca 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -830,7 +830,7 @@ static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd return result; } -static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, int fd, +static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, int leasetype) { int result = -1; @@ -839,11 +839,11 @@ static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, #ifdef HAVE_KERNEL_OPLOCKS_LINUX /* first set the signal handler */ - if(linux_set_lease_sighandler(fd) == -1) { + if(linux_set_lease_sighandler(fsp->fh->fd) == -1) { return -1; } - result = linux_setlease(fd, leasetype); + result = linux_setlease(fsp->fh->fd, leasetype); #else errno = ENOSYS; #endif diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index cc14597d97..2f0935f4b4 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -166,7 +166,7 @@ static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32 share_mode); static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, - int fd, int leasetype); + int leasetype); static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid); static int smb_full_audit_symlink(vfs_handle_struct *handle, @@ -1392,11 +1392,11 @@ static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle, } static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, - int fd, int leasetype) + int leasetype) { int result; - result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, fd, leasetype); + result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype); do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 1dd2c5967e..f7605b20de 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -52,21 +52,21 @@ static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, } static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp, - int fd, int leasetype) + int leasetype) { int ret; START_PROFILE(syscall_linux_setlease); - if ( linux_set_lease_sighandler(fd) == -1) + if ( linux_set_lease_sighandler(fsp->fh->fd) == -1) return -1; - ret = set_gpfs_lease(fd,leasetype); + ret = set_gpfs_lease(fsp->fh->fd,leasetype); if ( ret < 0 ) { /* This must have come from GPFS not being available */ /* or some other error, hence call the default */ - ret = linux_setlease(fd, leasetype); + ret = linux_setlease(fsp->fh->fd, leasetype); } END_PROFILE(syscall_linux_setlease); -- cgit From f7bf4cb3f17b5356b93c4ec89c300ad5dc20d2bc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 22:18:50 +0100 Subject: Remove redundant parameter fd from SMB_VFS_GETLOCK(). Michael (This used to be commit ee5a20becdcdb20d7012732b324c6938fab44f67) --- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 712aae9fca..0054fb3646 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -820,12 +820,12 @@ static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, return 0; } -static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) +static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) { bool result; START_PROFILE(syscall_fcntl_getlock); - result = fcntl_getlock(fd, poffset, pcount, ptype, ppid); + result = fcntl_getlock(fsp->fh->fd, poffset, pcount, ptype, ppid); END_PROFILE(syscall_fcntl_getlock); return result; } diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 2f0935f4b4..54433347b8 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -167,7 +167,7 @@ static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle, uint32 share_mode); static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, int leasetype); -static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, +static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid); static int smb_full_audit_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath); @@ -1404,12 +1404,12 @@ static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct return result; } -static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, +static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) { bool result; - result = SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid); + result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid); do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name); -- cgit From 62e9d503d82d645cf29af643732ad97c0eb8b340 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 23:53:34 +0100 Subject: Remove redundant parameter fd from SMB_VFS_SYS_ACL_GET_FD(). Michael (This used to be commit 42663e8736e1a3dfb57e0aafdcbf5fec880da779) --- source3/modules/vfs_aixacl.c | 9 ++++----- source3/modules/vfs_aixacl2.c | 3 +-- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 9 ++++----- source3/modules/vfs_gpfs.c | 3 +-- source3/modules/vfs_hpuxacl.c | 5 ++--- source3/modules/vfs_irixacl.c | 3 +-- source3/modules/vfs_posixacl.c | 5 ++--- source3/modules/vfs_tru64acl.c | 5 ++--- 9 files changed, 19 insertions(+), 27 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_aixacl.c b/source3/modules/vfs_aixacl.c index a60470ffc9..1a76ed6878 100644 --- a/source3/modules/vfs_aixacl.c +++ b/source3/modules/vfs_aixacl.c @@ -80,8 +80,7 @@ SMB_ACL_T aixacl_sys_acl_get_file(vfs_handle_struct *handle, } SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { struct acl *file_acl = (struct acl *)NULL; @@ -93,7 +92,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle, /* Get the acl using fstatacl */ DEBUG(10,("Entering AIX sys_acl_get_fd\n")); - DEBUG(10,("fd is %d\n",fd)); + DEBUG(10,("fd is %d\n",fsp->fh->fd)); file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); if(file_acl == NULL) { @@ -104,7 +103,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle, memset(file_acl,0,BUFSIZ); - rc = fstatacl(fd,0,file_acl,BUFSIZ); + rc = fstatacl(fsp->fh->fd,0,file_acl,BUFSIZ); if( (rc == -1) && (errno == ENOSPC)) { struct acl *new_acl = SMB_MALLOC(file_acl->acl_len + sizeof(struct acl)); if( new_acl == NULL) { @@ -113,7 +112,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle, return NULL; } file_acl = new_acl; - rc = fstatacl(fd,0,file_acl,file_acl->acl_len + sizeof(struct acl)); + rc = fstatacl(fsp->fh->fd,0,file_acl,file_acl->acl_len + sizeof(struct acl)); if( rc == -1) { DEBUG(0,("fstatacl returned %d with errno %d\n",rc,errno)); SAFE_FREE(file_acl); diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index d63886d68e..42ecb9892c 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -258,8 +258,7 @@ SMB_ACL_T aixjfs2_sys_acl_get_file(vfs_handle_struct *handle, } SMB_ACL_T aixjfs2_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { acl_type_t aixjfs2_type; aixjfs2_type.u64 = ACL_AIXC; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 0054fb3646..d909b0475a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1042,9 +1042,9 @@ static SMB_ACL_T vfswrap_sys_acl_get_file(vfs_handle_struct *handle, const char return sys_acl_get_file(handle, path_p, type); } -static SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +static SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return sys_acl_get_fd(handle, fsp, fd); + return sys_acl_get_fd(handle, fsp); } static int vfswrap_sys_acl_clear_perms(vfs_handle_struct *handle, SMB_ACL_PERMSET_T permset) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 54433347b8..d572c155e2 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -221,8 +221,7 @@ static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle, const char *path_p, SMB_ACL_TYPE_T type); static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd); + files_struct *fsp); static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle, SMB_ACL_PERMSET_T permset); static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle, @@ -451,7 +450,7 @@ static vfs_op_tuple audit_op_tuples[] = { SMB_VFS_LAYER_LOGGER}, {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE, SMB_VFS_LAYER_LOGGER}, - {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD, +{SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD, SMB_VFS_LAYER_LOGGER}, {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, SMB_VFS_LAYER_LOGGER}, @@ -1684,11 +1683,11 @@ static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle, } static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, int fd) + files_struct *fsp) { SMB_ACL_T result; - result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, fd); + result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp); do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index f7605b20de..714f6e2917 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -501,8 +501,7 @@ SMB_ACL_T gpfsacl_sys_acl_get_file(vfs_handle_struct *handle, } SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { return gpfsacl_get_posix_acl(fsp->fsp_name, GPFS_ACL_TYPE_ACCESS); } diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c index edce161c19..67fbfe56f6 100644 --- a/source3/modules/vfs_hpuxacl.c +++ b/source3/modules/vfs_hpuxacl.c @@ -182,15 +182,14 @@ SMB_ACL_T hpuxacl_sys_acl_get_file(vfs_handle_struct *handle, * get the access ACL of a file referred to by a fd */ SMB_ACL_T hpuxacl_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { /* * HPUX doesn't have the facl call. Fake it using the path.... JRA. */ /* For all I see, the info should already be in the fsp * parameter, but get it again to be safe --- necessary? */ - files_struct *file_struct_p = file_find_fd(fd); + files_struct *file_struct_p = file_find_fd(fsp->fh->fd); if (file_struct_p == NULL) { errno = EBADF; return NULL; diff --git a/source3/modules/vfs_irixacl.c b/source3/modules/vfs_irixacl.c index dab6deb747..cf53633504 100644 --- a/source3/modules/vfs_irixacl.c +++ b/source3/modules/vfs_irixacl.c @@ -32,8 +32,7 @@ SMB_ACL_T irixacl_sys_acl_get_file(vfs_handle_struct *handle, } SMB_ACL_T irixacl_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { errno = ENOTSUP; return NULL; diff --git a/source3/modules/vfs_posixacl.c b/source3/modules/vfs_posixacl.c index fb0c0bc8e9..faa5e8e2ad 100644 --- a/source3/modules/vfs_posixacl.c +++ b/source3/modules/vfs_posixacl.c @@ -63,11 +63,10 @@ SMB_ACL_T posixacl_sys_acl_get_file(vfs_handle_struct *handle, } SMB_ACL_T posixacl_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { struct smb_acl_t *result; - acl_t acl = acl_get_fd(fd); + acl_t acl = acl_get_fd(fsp->fh->fd); if (acl == NULL) { return NULL; diff --git a/source3/modules/vfs_tru64acl.c b/source3/modules/vfs_tru64acl.c index 43cae0f826..ee81ee6021 100644 --- a/source3/modules/vfs_tru64acl.c +++ b/source3/modules/vfs_tru64acl.c @@ -67,11 +67,10 @@ SMB_ACL_T tru64acl_sys_acl_get_file(vfs_handle_struct *handle, } SMB_ACL_T tru64acl_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { struct smb_acl_t *result; - acl_t tru64_acl = acl_get_fd(fd, ACL_TYPE_ACCESS); + acl_t tru64_acl = acl_get_fd(fsp->fh->fd, ACL_TYPE_ACCESS); if (tru64_acl == NULL) { return NULL; -- cgit From b2182c11eab0e1b2f0acb5d82aec86d4598573eb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 01:14:24 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FCHMOD_ACL(). Michael (This used to be commit 7b201c177b3668f54751ba17d6a0b53ed913e7f7) --- source3/modules/vfs_audit.c | 6 +++--- source3/modules/vfs_default.c | 6 +++--- source3/modules/vfs_extd_audit.c | 6 +++--- source3/modules/vfs_full_audit.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c index 27e7f998ab..a63bf4f672 100644 --- a/source3/modules/vfs_audit.c +++ b/source3/modules/vfs_audit.c @@ -40,7 +40,7 @@ static int audit_unlink(vfs_handle_struct *handle, const char *path); static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode); static int audit_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode); static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); -static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode); +static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); /* VFS operations */ @@ -282,11 +282,11 @@ static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mod return result; } -static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { int result; - result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode); + result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode); syslog(audit_syslog_priority(handle), "fchmod_acl %s mode 0x%x %s%s\n", fsp->fsp_name, mode, diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index d909b0475a..f820d4b3e2 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -563,7 +563,7 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t m { int saved_errno = errno; /* We might get ENOSYS */ - if ((result = SMB_VFS_FCHMOD_ACL(fsp, fsp->fh->fd, mode)) == 0) { + if ((result = SMB_VFS_FCHMOD_ACL(fsp, mode)) == 0) { END_PROFILE(syscall_fchmod); return result; } @@ -1002,7 +1002,7 @@ static int vfswrap_chmod_acl(vfs_handle_struct *handle, const char *name, mode_ #endif } -static int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { #ifdef HAVE_NO_ACL errno = ENOSYS; @@ -1011,7 +1011,7 @@ static int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int int result; START_PROFILE(fchmod_acl); - result = fchmod_acl(fsp, fd, mode); + result = fchmod_acl(fsp, mode); END_PROFILE(fchmod_acl); return result; #endif diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c index f9b03731e7..a21e281e2c 100644 --- a/source3/modules/vfs_extd_audit.c +++ b/source3/modules/vfs_extd_audit.c @@ -43,7 +43,7 @@ static int audit_unlink(vfs_handle_struct *handle, const char *path); static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode); static int audit_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode); static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); -static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode); +static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode); /* VFS operations */ @@ -328,11 +328,11 @@ static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mod return result; } -static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { int result; - result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode); + result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode); syslog(audit_syslog_priority(handle), "fchmod_acl %s mode 0x%x %s%s\n", fsp->fsp_name, mode, diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index d572c155e2..4e70879dc2 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -205,7 +205,7 @@ static NTSTATUS smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struc static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode); static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, mode_t mode); + mode_t mode); static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p); @@ -1594,11 +1594,11 @@ static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, } static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, mode_t mode) + mode_t mode) { int result; - result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode); + result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode); do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle, "%s|%o", fsp->fsp_name, mode); -- cgit From 5921607f2647cec20a6bcebd17c5a0c53449c1ba Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 01:54:19 +0100 Subject: Remove redundant parameter fd from SMB_VFS_SYS_ACL_SET_FD(). Michael (This used to be commit 9296e93588c0e795cae770765050247ac1474a74) --- source3/modules/vfs_aixacl.c | 4 ++-- source3/modules/vfs_aixacl2.c | 4 ++-- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_gpfs.c | 2 +- source3/modules/vfs_hpuxacl.c | 6 +++--- source3/modules/vfs_irixacl.c | 4 ++-- source3/modules/vfs_posixacl.c | 4 ++-- source3/modules/vfs_solarisacl.c | 8 ++++---- source3/modules/vfs_tru64acl.c | 6 +++--- 10 files changed, 24 insertions(+), 24 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_aixacl.c b/source3/modules/vfs_aixacl.c index 1a76ed6878..726a7f485e 100644 --- a/source3/modules/vfs_aixacl.c +++ b/source3/modules/vfs_aixacl.c @@ -153,7 +153,7 @@ int aixacl_sys_acl_set_file(vfs_handle_struct *handle, int aixacl_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { struct acl *file_acl = NULL; unsigned int rc; @@ -162,7 +162,7 @@ int aixacl_sys_acl_set_fd(vfs_handle_struct *handle, if (!file_acl) return -1; - rc = fchacl(fd,file_acl,file_acl->acl_len); + rc = fchacl(fsp->fh->fd,file_acl,file_acl->acl_len); DEBUG(10,("errno is %d\n",errno)); DEBUG(10,("return code is %d\n",rc)); SAFE_FREE(file_acl); diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index 42ecb9892c..996adbbdfe 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -448,7 +448,7 @@ int aixjfs2_sys_acl_set_file(vfs_handle_struct *handle, int aixjfs2_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { struct acl *acl_aixc; acl_type_t acl_type_info; @@ -467,7 +467,7 @@ int aixjfs2_sys_acl_set_fd(vfs_handle_struct *handle, return -1; rc = aclx_fput( - fd, + fsp->fh->fd, SET_ACL, /* set only the ACL, not mode bits */ acl_type_info, acl_aixc, diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f820d4b3e2..a46c2a336f 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1097,9 +1097,9 @@ static int vfswrap_sys_acl_set_file(vfs_handle_struct *handle, const char *name return sys_acl_set_file(handle, name, acltype, theacl); } -static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl) +static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl) { - return sys_acl_set_fd(handle, fsp, fd, theacl); + return sys_acl_set_fd(handle, fsp, theacl); } static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 4e70879dc2..64c74df1ba 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -250,7 +250,7 @@ static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl); static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl); + SMB_ACL_T theacl); static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path); static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle, @@ -1843,11 +1843,11 @@ static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle, } static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { int result; - result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, fd, theacl); + result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl); do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle, "%s", fsp->fsp_name); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 714f6e2917..bcf61f3bc7 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -615,7 +615,7 @@ int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle, int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name, SMB_ACL_TYPE_ACCESS, theacl); } diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c index 67fbfe56f6..e101886450 100644 --- a/source3/modules/vfs_hpuxacl.c +++ b/source3/modules/vfs_hpuxacl.c @@ -1,7 +1,7 @@ /* * Unix SMB/Netbios implementation. * VFS module to get and set HP-UX ACLs - * Copyright (C) Michael Adam 2006 + * Copyright (C) Michael Adam 2006,2008 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -306,14 +306,14 @@ int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle, */ int hpuxacl_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { /* * HPUX doesn't have the facl call. Fake it using the path.... JRA. */ /* For all I see, the info should already be in the fsp * parameter, but get it again to be safe --- necessary? */ - files_struct *file_struct_p = file_find_fd(fd); + files_struct *file_struct_p = file_find_fd(fsp->fh->fd); if (file_struct_p == NULL) { errno = EBADF; return -1; diff --git a/source3/modules/vfs_irixacl.c b/source3/modules/vfs_irixacl.c index cf53633504..6484e8f3eb 100644 --- a/source3/modules/vfs_irixacl.c +++ b/source3/modules/vfs_irixacl.c @@ -1,7 +1,7 @@ /* Unix SMB/Netbios implementation. VFS module to get and set irix acls - Copyright (C) Michael Adam 2006 + Copyright (C) Michael Adam 2006,2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ int irixacl_sys_acl_set_file(vfs_handle_struct *handle, int irixacl_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { errno = ENOTSUP; return -1; diff --git a/source3/modules/vfs_posixacl.c b/source3/modules/vfs_posixacl.c index faa5e8e2ad..21fb2ada31 100644 --- a/source3/modules/vfs_posixacl.c +++ b/source3/modules/vfs_posixacl.c @@ -113,14 +113,14 @@ int posixacl_sys_acl_set_file(vfs_handle_struct *handle, int posixacl_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { int res; acl_t acl = smb_acl_to_posix(theacl); if (acl == NULL) { return -1; } - res = acl_set_fd(fd, acl); + res = acl_set_fd(fsp->fh->fd, acl); acl_free(acl); return res; } diff --git a/source3/modules/vfs_solarisacl.c b/source3/modules/vfs_solarisacl.c index cda243f8c1..ce763f07e7 100644 --- a/source3/modules/vfs_solarisacl.c +++ b/source3/modules/vfs_solarisacl.c @@ -1,7 +1,7 @@ /* Unix SMB/Netbios implementation. VFS module to get and set Solaris ACLs - Copyright (C) Michael Adam 2006 + Copyright (C) Michael Adam 2006,2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -219,7 +219,7 @@ int solarisacl_sys_acl_set_file(vfs_handle_struct *handle, */ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { SOLARIS_ACL_T solaris_acl = NULL; SOLARIS_ACL_T default_acl = NULL; @@ -242,7 +242,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle, strerror(errno))); goto done; } - if (!solaris_acl_get_fd(fd, &default_acl, &default_count)) { + if (!solaris_acl_get_fd(fsp->fh->fd, &default_acl, &default_count)) { DEBUG(10, ("error getting (default) acl from fd\n")); goto done; } @@ -258,7 +258,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle, goto done; } - ret = facl(fd, SETACL, count, solaris_acl); + ret = facl(fsp->fh->fd, SETACL, count, solaris_acl); if (ret != 0) { DEBUG(10, ("call of facl failed (%s).\n", strerror(errno))); } diff --git a/source3/modules/vfs_tru64acl.c b/source3/modules/vfs_tru64acl.c index ee81ee6021..b23a7ddcfa 100644 --- a/source3/modules/vfs_tru64acl.c +++ b/source3/modules/vfs_tru64acl.c @@ -1,7 +1,7 @@ /* Unix SMB/Netbios implementation. VFS module to get and set Tru64 acls - Copyright (C) Michael Adam 2006 + Copyright (C) Michael Adam 2006,2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -128,14 +128,14 @@ fail: int tru64acl_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T theacl) + SMB_ACL_T theacl) { int res; acl_t tru64_acl = smb_acl_to_tru64_acl(theacl); if (tru64_acl == NULL) { return -1; } - res = acl_set_fd(fd, ACL_TYPE_ACCESS, tru64_acl); + res = acl_set_fd(fsp->fh->fd, ACL_TYPE_ACCESS, tru64_acl); acl_free(tru64_acl); return res; -- cgit From 66273a795328768647c1be0d90885b15a095a011 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 01:56:56 +0100 Subject: Remove forgotton fd from solarisacl_sys_acl_get_fd(). Michael (This used to be commit 38f34b1d743caaf9f2d750580b991958d260fead) --- source3/modules/vfs_solarisacl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_solarisacl.c b/source3/modules/vfs_solarisacl.c index ce763f07e7..7bdfe8465b 100644 --- a/source3/modules/vfs_solarisacl.c +++ b/source3/modules/vfs_solarisacl.c @@ -100,8 +100,7 @@ SMB_ACL_T solarisacl_sys_acl_get_file(vfs_handle_struct *handle, * get the access ACL of a file referred to by a fd */ SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle, - files_struct *fsp, - int fd) + files_struct *fsp) { SMB_ACL_T result = NULL; int count; @@ -109,7 +108,7 @@ SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle, DEBUG(10, ("entering solarisacl_sys_acl_get_fd.\n")); - if (!solaris_acl_get_fd(fd, &solaris_acl, &count)) { + if (!solaris_acl_get_fd(fsp->fh->fd, &solaris_acl, &count)) { goto done; } /* -- cgit From 50ee744fa445b74136a8f2cef36c2b48ba7ee5f6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 10:00:47 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FGETXATTR(). Michael (This used to be commit 2cb739a82dc6bb194d60718cc74b26ee7c1c46a7) --- source3/modules/vfs_cap.c | 4 ++-- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index f99891cb32..56ab48f9e2 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -363,7 +363,7 @@ size) return SMB_VFS_NEXT_LGETXATTR(handle, cappath, capname, value, size); } -static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *path, void *value, size_t size) +static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path, void *value, size_t size) { char *cappath = capencode(talloc_tos(), path); @@ -371,7 +371,7 @@ static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp errno = ENOMEM; return -1; } - return SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, cappath, value, size); + return SMB_VFS_NEXT_FGETXATTR(handle, fsp, cappath, value, size); } static ssize_t cap_listxattr(vfs_handle_struct *handle, const char *path, char *list, size_t size) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index a46c2a336f..ec6e6e912a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1141,9 +1141,9 @@ static ssize_t vfswrap_lgetxattr(struct vfs_handle_struct *handle,const char *pa return sys_lgetxattr(path, name, value, size); } -static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size) +static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size) { - return sys_fgetxattr(fd, name, value, size); + return sys_fgetxattr(fsp->fh->fd, name, value, size); } static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 64c74df1ba..82e212ed0a 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -270,7 +270,7 @@ static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size); static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, + struct files_struct *fsp, const char *name, void *value, size_t size); static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size); @@ -1956,12 +1956,12 @@ static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle, } static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, + struct files_struct *fsp, const char *name, void *value, size_t size) { ssize_t result; - result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, name, value, size); + result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size); do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle, "%s|%s", fsp->fsp_name, name); -- cgit From 9f691df852581b1ae4fab7cb9907606f4dcab291 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 10:51:40 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FLISTXATTR(). Michael (This used to be commit 167649b3b8bc293f8434ffc9fb5f80463e4e75be) --- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index ec6e6e912a..b96a2d201c 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1156,9 +1156,9 @@ ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, c return sys_llistxattr(path, list, size); } -ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, char *list, size_t size) +ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size) { - return sys_flistxattr(fd, list, size); + return sys_flistxattr(fsp->fh->fd, list, size); } static int vfswrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 82e212ed0a..ecf136347c 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -277,7 +277,7 @@ static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle, static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size); static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, char *list, + struct files_struct *fsp, char *list, size_t size); static int smb_full_audit_removexattr(struct vfs_handle_struct *handle, const char *path, @@ -1994,12 +1994,12 @@ static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle, } static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, char *list, + struct files_struct *fsp, char *list, size_t size) { ssize_t result; - result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, fd, list, size); + result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size); do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle, "%s", fsp->fsp_name); -- cgit From 1590dd32cfccd9ce73cd798330b5207bcc48bfaf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 11:29:09 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FREMOVEXATTR(). Michael (This used to be commit bfc3b5a27f707d3e4b8d5d66192891e22365fbb3) --- source3/modules/vfs_cap.c | 4 ++-- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index 56ab48f9e2..ab76722f4c 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -420,7 +420,7 @@ static int cap_lremovexattr(vfs_handle_struct *handle, const char *path, const c return SMB_VFS_NEXT_LREMOVEXATTR(handle, cappath, capname); } -static int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *path) +static int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path) { char *cappath = capencode(talloc_tos(), path); @@ -428,7 +428,7 @@ static int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, errno = ENOMEM; return -1; } - return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, cappath); + return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, cappath); } static int cap_setxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index b96a2d201c..fecf0562b8 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1171,9 +1171,9 @@ static int vfswrap_lremovexattr(struct vfs_handle_struct *handle, const char *pa return sys_lremovexattr(path, name); } -static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name) +static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name) { - return sys_fremovexattr(fd, name); + return sys_fremovexattr(fsp->fh->fd, name); } static int vfswrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index ecf136347c..6517c17256 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -286,7 +286,7 @@ static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle, const char *path, const char *name); static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, + struct files_struct *fsp, const char *name); static int smb_full_audit_setxattr(struct vfs_handle_struct *handle, const char *path, @@ -2036,12 +2036,12 @@ static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle, } static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, + struct files_struct *fsp, const char *name) { int result; - result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, name); + result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name); do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle, "%s|%s", fsp->fsp_name, name); -- cgit From aab6704ce803a738ba125895b20a31f242fe2885 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 11:47:33 +0100 Subject: Remove redundant parameter fd from SMB_VFS_FSETXATTR(). Michael (This used to be commit 0bd2643463a9160c8a1c7e1c2f8cca7b89060e09) --- source3/modules/vfs_cap.c | 4 ++-- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index ab76722f4c..2f2d6a7182 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -455,7 +455,7 @@ static int cap_lsetxattr(vfs_handle_struct *handle, const char *path, const char return SMB_VFS_NEXT_LSETXATTR(handle, cappath, capname, value, size, flags); } -static int cap_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *path, const void *value, size_t size, int flags) +static int cap_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path, const void *value, size_t size, int flags) { char *cappath = capencode(talloc_tos(), path); @@ -463,7 +463,7 @@ static int cap_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int errno = ENOMEM; return -1; } - return SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, cappath, value, size, flags); + return SMB_VFS_NEXT_FSETXATTR(handle, fsp, cappath, value, size, flags); } /* VFS operations structure */ diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index fecf0562b8..3abe1483bb 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1186,9 +1186,9 @@ static int vfswrap_lsetxattr(struct vfs_handle_struct *handle, const char *path, return sys_lsetxattr(path, name, value, size, flags); } -static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags) +static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags) { - return sys_fsetxattr(fd, name, value, size, flags); + return sys_fsetxattr(fsp->fh->fd, name, value, size, flags); } static int vfswrap_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 6517c17256..ffa2c52da1 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -297,7 +297,7 @@ static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle, const char *name, const void *value, size_t size, int flags); static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, const char *name, + struct files_struct *fsp, const char *name, const void *value, size_t size, int flags); static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb); @@ -2082,13 +2082,12 @@ static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle, } static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, int fd, const char *name, + struct files_struct *fsp, const char *name, const void *value, size_t size, int flags) { int result; - result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, name, value, size, - flags); + result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags); do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle, "%s|%s", fsp->fsp_name, name); -- cgit From 4a056e127ac35d640d899cd8a4735b927aa8d005 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 12:20:51 +0100 Subject: Remove redundant parameter fd from SMB_VFS_AIO_CANCEL(). Michael (This used to be commit 3c997ae0002d4c50e8899600c17ddf74ac61f6f0) --- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 3abe1483bb..97138bdacf 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1206,9 +1206,9 @@ static ssize_t vfswrap_aio_return(struct vfs_handle_struct *handle, struct files return sys_aio_return(aiocb); } -static int vfswrap_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb) +static int vfswrap_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) { - return sys_aio_cancel(fd, aiocb); + return sys_aio_cancel(fsp->fh->fd, aiocb); } static int vfswrap_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index ffa2c52da1..95fdc17d56 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -303,7 +303,7 @@ static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle, static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb); static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb); static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb); -static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb); +static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb); static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb); static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb); static int smb_full_audit_aio_suspend(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *ts); @@ -2128,11 +2128,11 @@ static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struc return result; } -static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb) +static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) { int result; - result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, fd, aiocb); + result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb); do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle, "%s", fsp->fsp_name); -- cgit From 1d66f4d58b5fdd9c4e0c022cd2724e05d144510b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 10 Jan 2008 15:33:51 +0100 Subject: Remove redundant parameter fd from SMB_VFS_READ(). Michael (This used to be commit a8fc2ddad8d5f7c6c00cb36c74a32a02d69d1d04) --- source3/modules/vfs_cacheprime.c | 2 +- source3/modules/vfs_default.c | 10 +++++----- source3/modules/vfs_full_audit.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cacheprime.c b/source3/modules/vfs_cacheprime.c index 6eb74e66ed..4ac78437c3 100644 --- a/source3/modules/vfs_cacheprime.c +++ b/source3/modules/vfs_cacheprime.c @@ -154,7 +154,7 @@ static ssize_t cprime_read( SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET); } - return SMB_VFS_NEXT_READ(handle, fsp, fd, data, count); + return SMB_VFS_NEXT_READ(handle, fsp, data, count); } static ssize_t cprime_pread( diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 97138bdacf..920c05c338 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -208,12 +208,12 @@ static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp, int fd) return result; } -static ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n) +static ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n) { ssize_t result; START_PROFILE_BYTES(syscall_read, n); - result = sys_read(fd, data, n); + result = sys_read(fsp->fh->fd, data, n); END_PROFILE(syscall_read); return result; } @@ -230,7 +230,7 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void if (result == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be seeked (sought?) on. */ - result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); + result = SMB_VFS_READ(fsp, data, n); fsp->fh->pos = 0; } @@ -241,7 +241,7 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); if (curr == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be seeked (sought?) on. */ - result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); + result = SMB_VFS_READ(fsp, data, n); fsp->fh->pos = 0; return result; } @@ -251,7 +251,7 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void } errno = 0; - result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n); + result = SMB_VFS_READ(fsp, data, n); lerrno = errno; SMB_VFS_LSEEK(fsp, curr, SEEK_SET); diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 95fdc17d56..18ee5ba50f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -113,7 +113,7 @@ static int smb_full_audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode); static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd); static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp, - int fd, void *data, size_t n); + void *data, size_t n); static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, SMB_OFF_T offset); static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp, @@ -1087,11 +1087,11 @@ static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, in } static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp, - int fd, void *data, size_t n) + void *data, size_t n) { ssize_t result; - result = SMB_VFS_NEXT_READ(handle, fsp, fd, data, n); + result = SMB_VFS_NEXT_READ(handle, fsp, data, n); do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name); -- cgit From e9a3a62e7448bef72d9c17c90ff2b404082f067c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 10 Jan 2008 15:49:35 +0100 Subject: Remove redundant parameter fd from SMB_VFS_WRITE(). Michael (This used to be commit c8ae7d095a2a6a7eac920a68ca7244e3a423e1b1) --- source3/modules/vfs_commit.c | 3 +-- source3/modules/vfs_default.c | 12 ++++++------ source3/modules/vfs_full_audit.c | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index fe7324122f..ac391cf007 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -229,12 +229,11 @@ static int commit_open( static ssize_t commit_write( vfs_handle_struct * handle, files_struct * fsp, - int fd, void * data, size_t count) { ssize_t ret; - ret = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, count); + ret = SMB_VFS_NEXT_WRITE(handle, fsp, data, count); if (ret > 0) { if (commit(handle, fsp, fsp->fh->pos, ret) == -1) { diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 920c05c338..e57d24cb1a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -262,12 +262,12 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void return result; } -static ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n) +static ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n) { ssize_t result; START_PROFILE_BYTES(syscall_write, n); - result = sys_write(fd, data, n); + result = sys_write(fsp->fh->fd, data, n); END_PROFILE(syscall_write); return result; } @@ -284,7 +284,7 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons if (result == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be sought on. */ - result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n); + result = SMB_VFS_WRITE(fsp, data, n); } #else /* HAVE_PWRITE */ @@ -300,7 +300,7 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons return -1; } - result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n); + result = SMB_VFS_WRITE(fsp, data, n); lerrno = errno; SMB_VFS_LSEEK(fsp, curr, SEEK_SET); @@ -712,7 +712,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs SMB_OFF_T retlen; SMB_OFF_T current_len_to_write = MIN(sizeof(zero_space),space_to_write); - retlen = SMB_VFS_WRITE(fsp,fsp->fh->fd,(char *)zero_space,current_len_to_write); + retlen = SMB_VFS_WRITE(fsp,(char *)zero_space,current_len_to_write); if (retlen <= 0) return -1; @@ -787,7 +787,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1) goto done; - if (SMB_VFS_WRITE(fsp, fsp->fh->fd, &c, 1)!=1) + if (SMB_VFS_WRITE(fsp, &c, 1)!=1) goto done; /* Seek to where we were */ diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 18ee5ba50f..00512678b1 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -117,7 +117,7 @@ static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp, static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, SMB_OFF_T offset); static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp, - int fd, const void *data, size_t n); + const void *data, size_t n); static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset); @@ -1111,11 +1111,11 @@ static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp } static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp, - int fd, const void *data, size_t n) + const void *data, size_t n) { ssize_t result; - result = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n); + result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n); do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name); -- cgit From e17642e849b28c323ba6bd7cc212455d727901db Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 10 Jan 2008 23:40:13 +0100 Subject: Fix the build of the cacheprime VFS module after API changes. Sorry, that had escaped my attention. Michael (This used to be commit 88102b5b7c4eaad5445e9cb96e547dd918abc0c2) --- source3/modules/vfs_cacheprime.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cacheprime.c b/source3/modules/vfs_cacheprime.c index 4ac78437c3..5675108f1e 100644 --- a/source3/modules/vfs_cacheprime.c +++ b/source3/modules/vfs_cacheprime.c @@ -142,16 +142,15 @@ static ssize_t cprime_sendfile( static ssize_t cprime_read( vfs_handle_struct * handle, files_struct * fsp, - int fd, void * data, size_t count) { SMB_OFF_T offset; - offset = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR); + offset = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); if (offset >= 0 && g_readbuf) { - prime_cache(handle, fsp, fd, offset, count); - SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET); + prime_cache(handle, fsp, fsp->fh->fd, offset, count); + SMB_VFS_LSEEK(fsp, offset, SEEK_SET); } return SMB_VFS_NEXT_READ(handle, fsp, data, count); -- cgit From 4caab9ca25e1163378714de825d835e79e27dd4f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 00:51:19 +0100 Subject: Combine fsp and fromfd to fromfsp in SMB_VFS_SENDFILE(). Michael (This used to be commit a52cfb7d777157c93c9dc26c67f457be592dd537) --- source3/modules/vfs_cacheprime.c | 7 +++---- source3/modules/vfs_default.c | 4 ++-- source3/modules/vfs_full_audit.c | 9 ++++----- source3/modules/vfs_readahead.c | 14 ++++++-------- 4 files changed, 15 insertions(+), 19 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cacheprime.c b/source3/modules/vfs_cacheprime.c index 5675108f1e..15c8167a07 100644 --- a/source3/modules/vfs_cacheprime.c +++ b/source3/modules/vfs_cacheprime.c @@ -125,17 +125,16 @@ static int cprime_connect( static ssize_t cprime_sendfile( struct vfs_handle_struct * handle, int tofd, - files_struct * fsp, - int fromfd, + files_struct * fromfsp, const DATA_BLOB * header, SMB_OFF_T offset, size_t count) { if (g_readbuf && offset == 0) { - prime_cache(handle, fsp, fromfd, offset, count); + prime_cache(handle, fromfsp, fromfsp->fh->fd, offset, count); } - return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, + return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, header, offset, count); } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index e57d24cb1a..3a0ed0bebd 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -337,13 +337,13 @@ static SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB return result; } -static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr, +static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n) { ssize_t result; START_PROFILE_BYTES(syscall_sendfile, n); - result = sys_sendfile(tofd, fromfd, hdr, offset, n); + result = sys_sendfile(tofd, fromfsp->fh->fd, hdr, offset, n); END_PROFILE(syscall_sendfile); return result; } diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 00512678b1..baa5d24a33 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -124,7 +124,7 @@ static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fs static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset, int whence); static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd, - files_struct *fsp, int fromfd, + files_struct *fromfsp, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n); static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd, @@ -1149,17 +1149,16 @@ static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *f } static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd, - files_struct *fsp, int fromfd, + files_struct *fromfsp, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n) { ssize_t result; - result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr, - offset, n); + result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n); do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle, - "%s", fsp->fsp_name); + "%s", fromfsp->fsp_name); return result; } diff --git a/source3/modules/vfs_readahead.c b/source3/modules/vfs_readahead.c index b3642d558f..df75814b72 100644 --- a/source3/modules/vfs_readahead.c +++ b/source3/modules/vfs_readahead.c @@ -35,8 +35,7 @@ struct readahead_data { static ssize_t readahead_sendfile(struct vfs_handle_struct *handle, int tofd, - files_struct *fsp, - int fromfd, + files_struct *fromfsp, const DATA_BLOB *header, SMB_OFF_T offset, size_t count) @@ -45,16 +44,16 @@ static ssize_t readahead_sendfile(struct vfs_handle_struct *handle, if ( offset % rhd->off_bound == 0) { #if defined(HAVE_LINUX_READAHEAD) - int err = readahead(fromfd, offset, (size_t)rhd->len); + int err = readahead(fromfsp->fh->fd, offset, (size_t)rhd->len); DEBUG(10,("readahead_sendfile: readahead on fd %u, offset %llu, len %u returned %d\n", - (unsigned int)fromfd, + (unsigned int)fromfsp->fh->fd, (unsigned long long)offset, (unsigned int)rhd->len, err )); #elif defined(HAVE_POSIX_FADVISE) - int err = posix_fadvise(fromfd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED); + int err = posix_fadvise(fromfsp->fh->fd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED); DEBUG(10,("readahead_sendfile: posix_fadvise on fd %u, offset %llu, len %u returned %d\n", - (unsigned int)fromfd, + (unsigned int)fromfsp->fh->fd, (unsigned long long)offset, (unsigned int)rhd->len, err )); @@ -67,8 +66,7 @@ static ssize_t readahead_sendfile(struct vfs_handle_struct *handle, } return SMB_VFS_NEXT_SENDFILE(handle, tofd, - fsp, - fromfd, + fromfsp, header, offset, count); -- cgit From 14d45bedfa844dfbf646e792d1cf84544997de25 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 00:56:06 +0100 Subject: Remove now redundant parameter fd from prime_cache(). Michael (This used to be commit 63acaf1b9755cd5be5342929e1210afa06e170f3) --- source3/modules/vfs_cacheprime.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_cacheprime.c b/source3/modules/vfs_cacheprime.c index 15c8167a07..be934f6bd6 100644 --- a/source3/modules/vfs_cacheprime.c +++ b/source3/modules/vfs_cacheprime.c @@ -48,7 +48,6 @@ static void * g_readbuf = NULL; static bool prime_cache( struct vfs_handle_struct * handle, files_struct * fsp, - int fd, SMB_OFF_T offset, size_t count) { @@ -75,7 +74,7 @@ static bool prime_cache( MODULE, (long long)g_readsz, (long long)*last, fsp->fsp_name)); - nread = sys_pread(fd, g_readbuf, g_readsz, *last); + nread = sys_pread(fsp->fh->fd, g_readbuf, g_readsz, *last); if (nread < 0) { *last = -1; return False; @@ -131,7 +130,7 @@ static ssize_t cprime_sendfile( size_t count) { if (g_readbuf && offset == 0) { - prime_cache(handle, fromfsp, fromfsp->fh->fd, offset, count); + prime_cache(handle, fromfsp, offset, count); } return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, @@ -148,7 +147,7 @@ static ssize_t cprime_read( offset = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR); if (offset >= 0 && g_readbuf) { - prime_cache(handle, fsp, fsp->fh->fd, offset, count); + prime_cache(handle, fsp, offset, count); SMB_VFS_LSEEK(fsp, offset, SEEK_SET); } @@ -163,7 +162,7 @@ static ssize_t cprime_pread( SMB_OFF_T offset) { if (g_readbuf) { - prime_cache(handle, fsp, fsp->fh->fd, offset, count); + prime_cache(handle, fsp, offset, count); } return SMB_VFS_NEXT_PREAD(handle, fsp, data, count, offset); -- cgit From fef9cf00e1e110ff5872f1c368d080fe4f7939d6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 01:26:54 +0100 Subject: Combine fsp and tofd to tofsp in SMB_VFS_RECVFILE(). Michael (This used to be commit 3958abffaf2866c69ad9e13ec345364fde5c78bb) --- source3/modules/vfs_default.c | 5 ++--- source3/modules/vfs_full_audit.c | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 3a0ed0bebd..e21136ccee 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -350,15 +350,14 @@ static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struc static ssize_t vfswrap_recvfile(vfs_handle_struct *handle, int fromfd, - files_struct *fsp, - int tofd, + files_struct *tofsp, SMB_OFF_T offset, size_t n) { ssize_t result; START_PROFILE_BYTES(syscall_recvfile, n); - result = sys_recvfile(fromfd, tofd, offset, n); + result = sys_recvfile(fromfd, tofsp->fh->fd, offset, n); END_PROFILE(syscall_recvfile); return result; } diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index baa5d24a33..5aa9bab5b5 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -128,7 +128,7 @@ static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n); static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd, - files_struct *fsp, int tofd, + files_struct *tofsp, SMB_OFF_T offset, size_t n); static int smb_full_audit_rename(vfs_handle_struct *handle, @@ -1164,17 +1164,16 @@ static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd, } static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd, - files_struct *fsp, int tofd, + files_struct *tofsp, SMB_OFF_T offset, size_t n) { ssize_t result; - result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, fsp, tofd, - offset, n); + result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n); do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle, - "%s", fsp->fsp_name); + "%s", tofsp->fsp_name); return result; } -- cgit From 57cc992e0f9a5d729ecf3c8effc862542ef7a84e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 22 Oct 2007 18:14:57 +0200 Subject: Implement vfs_ea_tdb This is an option for file systems that do not implement xattrs: in lockdir/eas.tdb an array of xatts per inode is stored. It can not solve the problem that xattrs might reappear if a posix-level process deletes a file and happens to re-create it under the same name. On file systems with birthtime we might have a chance to detect this, but not with standard posix. A future version might put relief on file systems that do have xattrs but where these are severely limited in size/speed/whatever: We can put a simple marker as a native xattr, but the xattrs proper are stored in the tdb. Volker (This used to be commit 2036b4c5ad677b8a477b34b0f076febab0abff5e) --- source3/modules/vfs_ea_tdb.c | 736 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 736 insertions(+) create mode 100644 source3/modules/vfs_ea_tdb.c (limited to 'source3/modules') diff --git a/source3/modules/vfs_ea_tdb.c b/source3/modules/vfs_ea_tdb.c new file mode 100644 index 0000000000..8cf04d79ad --- /dev/null +++ b/source3/modules/vfs_ea_tdb.c @@ -0,0 +1,736 @@ +/* + * Store posix-level xattrs in a tdb + * + * Copyright (C) Volker Lendecke, 2007 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "includes.h" +#include "librpc/gen_ndr/xattr.h" +#include "librpc/gen_ndr/ndr_xattr.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +/* + * unmarshall tdb_xattrs + */ + +static NTSTATUS ea_tdb_pull_attrs(TALLOC_CTX *mem_ctx, + const TDB_DATA *data, + struct tdb_xattrs **presult) +{ + DATA_BLOB blob; + enum ndr_err_code ndr_err; + struct tdb_xattrs *result; + + if (!(result = TALLOC_ZERO_P(mem_ctx, struct tdb_xattrs))) { + return NT_STATUS_NO_MEMORY; + } + + if (data->dsize == 0) { + *presult = result; + return NT_STATUS_OK; + } + + blob = data_blob_const(data->dptr, data->dsize); + + ndr_err = ndr_pull_struct_blob( + &blob, result, result, + (ndr_pull_flags_fn_t)ndr_pull_tdb_xattrs); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0, ("ndr_pull_tdb_xattrs failed: %s\n", + ndr_errstr(ndr_err))); + TALLOC_FREE(result); + return ndr_map_error2ntstatus(ndr_err);; + } + + *presult = result; + return NT_STATUS_OK; +} + +/* + * marshall tdb_xattrs + */ + +static NTSTATUS ea_tdb_push_attrs(TALLOC_CTX *mem_ctx, + const struct tdb_xattrs *attribs, + TDB_DATA *data) +{ + DATA_BLOB blob; + enum ndr_err_code ndr_err; + + ndr_err = ndr_push_struct_blob( + &blob, mem_ctx, attribs, + (ndr_push_flags_fn_t)ndr_push_tdb_xattrs); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0, ("ndr_push_tdb_xattrs failed: %s\n", + ndr_errstr(ndr_err))); + return ndr_map_error2ntstatus(ndr_err);; + } + + *data = make_tdb_data(blob.data, blob.length); + return NT_STATUS_OK; +} + +/* + * Load tdb_xattrs for a file from the tdb + */ + +static NTSTATUS ea_tdb_load_attrs(TALLOC_CTX *mem_ctx, + struct db_context *db_ctx, + const struct file_id *id, + struct tdb_xattrs **presult) +{ + uint8 id_buf[16]; + NTSTATUS status; + TDB_DATA data; + + push_file_id_16((char *)id_buf, id); + + if (db_ctx->fetch(db_ctx, mem_ctx, + make_tdb_data(id_buf, sizeof(id_buf)), + &data) == -1) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + status = ea_tdb_pull_attrs(mem_ctx, &data, presult); + TALLOC_FREE(data.dptr); + return NT_STATUS_OK; +} + +/* + * fetch_lock the tdb_ea record for a file + */ + +static struct db_record *ea_tdb_lock_attrs(TALLOC_CTX *mem_ctx, + struct db_context *db_ctx, + const struct file_id *id) +{ + uint8 id_buf[16]; + push_file_id_16((char *)id_buf, id); + return db_ctx->fetch_locked(db_ctx, mem_ctx, + make_tdb_data(id_buf, sizeof(id_buf))); +} + +/* + * Save tdb_xattrs to a previously fetch_locked record + */ + +static NTSTATUS ea_tdb_save_attrs(struct db_record *rec, + const struct tdb_xattrs *attribs) +{ + TDB_DATA data; + NTSTATUS status; + + status = ea_tdb_push_attrs(talloc_tos(), attribs, &data); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("ea_tdb_push_attrs failed: %s\n", + nt_errstr(status))); + return status; + } + + status = rec->store(rec, data, 0); + + TALLOC_FREE(data.dptr); + + return status; +} + +/* + * Worker routine for getxattr and fgetxattr + */ + +static ssize_t ea_tdb_getattr(struct db_context *db_ctx, + const struct file_id *id, + const char *name, void *value, size_t size) +{ + struct tdb_xattrs *attribs; + uint32_t i; + ssize_t result = -1; + NTSTATUS status; + + status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + errno = EINVAL; + return -1; + } + + for (i=0; inum_xattrs; i++) { + if (strcmp(attribs->xattrs[i].name, name) == 0) { + break; + } + } + + if (i == attribs->num_xattrs) { + errno = ENOATTR; + goto fail; + } + + if (attribs->xattrs[i].value.length > size) { + errno = ERANGE; + goto fail; + } + + memcpy(value, attribs->xattrs[i].value.data, + attribs->xattrs[i].value.length); + result = attribs->xattrs[i].value.length; + + fail: + TALLOC_FREE(attribs); + return result; +} + +static ssize_t ea_tdb_getxattr(struct vfs_handle_struct *handle, + const char *path, const char *name, + void *value, size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_getattr(db, &id, name, value, size); +} + +static ssize_t ea_tdb_fgetxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, + const char *name, void *value, size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_getattr(db, &id, name, value, size); +} + +/* + * Worker routine for setxattr and fsetxattr + */ + +static int ea_tdb_setattr(struct db_context *db_ctx, + const struct file_id *id, const char *name, + const void *value, size_t size, int flags) +{ + NTSTATUS status; + struct db_record *rec; + struct tdb_xattrs *attribs; + uint32_t i; + + rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); + + if (rec == NULL) { + DEBUG(0, ("ea_tdb_lock_attrs failed\n")); + errno = EINVAL; + return -1; + } + + status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(rec); + return -1; + } + + for (i=0; inum_xattrs; i++) { + if (strcmp(attribs->xattrs[i].name, name) == 0) { + break; + } + } + + if (i == attribs->num_xattrs) { + struct tdb_xattr *tmp; + + tmp = TALLOC_REALLOC_ARRAY( + attribs, attribs->xattrs, struct tdb_xattr, + attribs->num_xattrs + 1); + + if (tmp == NULL) { + DEBUG(0, ("TALLOC_REALLOC_ARRAY failed\n")); + TALLOC_FREE(rec); + errno = ENOMEM; + return -1; + } + + attribs->xattrs = tmp; + attribs->num_xattrs += 1; + } + + attribs->xattrs[i].name = name; + attribs->xattrs[i].value.data = CONST_DISCARD(uint8 *, value); + attribs->xattrs[i].value.length = size; + + status = ea_tdb_save_attrs(rec, attribs); + + TALLOC_FREE(rec); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("save failed: %s\n", nt_errstr(status))); + return -1; + } + + return 0; +} + +static int ea_tdb_setxattr(struct vfs_handle_struct *handle, + const char *path, const char *name, + const void *value, size_t size, int flags) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_setattr(db, &id, name, value, size, flags); +} + +static int ea_tdb_fsetxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, + const char *name, const void *value, + size_t size, int flags) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_setattr(db, &id, name, value, size, flags); +} + +/* + * Worker routine for listxattr and flistxattr + */ + +static ssize_t ea_tdb_listattr(struct db_context *db_ctx, + const struct file_id *id, char *list, + size_t size) +{ + NTSTATUS status; + struct tdb_xattrs *attribs; + uint32_t i; + size_t len = 0; + + status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + errno = EINVAL; + return -1; + } + + DEBUG(10, ("ea_tdb_listattr: Found %d xattrs\n", attribs->num_xattrs)); + + for (i=0; inum_xattrs; i++) { + size_t tmp; + + DEBUG(10, ("ea_tdb_listattr: xattrs[i].name: %s\n", + attribs->xattrs[i].name)); + + tmp = strlen(attribs->xattrs[i].name); + + /* + * Try to protect against overflow + */ + + if (len + (tmp+1) < len) { + TALLOC_FREE(attribs); + errno = EINVAL; + return -1; + } + + /* + * Take care of the terminating NULL + */ + len += (tmp + 1); + } + + if (len > size) { + TALLOC_FREE(attribs); + errno = ERANGE; + return -1; + } + + len = 0; + + for (i=0; inum_xattrs; i++) { + strlcpy(list+len, attribs->xattrs[i].name, + size-len); + len += (strlen(attribs->xattrs[i].name) + 1); + } + + TALLOC_FREE(attribs); + return len; +} + +static ssize_t ea_tdb_listxattr(struct vfs_handle_struct *handle, + const char *path, char *list, size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_listattr(db, &id, list, size); +} + +static ssize_t ea_tdb_flistxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, char *list, + size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_listattr(db, &id, list, size); +} + +/* + * Worker routine for removexattr and fremovexattr + */ + +static int ea_tdb_removeattr(struct db_context *db_ctx, + const struct file_id *id, const char *name) +{ + NTSTATUS status; + struct db_record *rec; + struct tdb_xattrs *attribs; + uint32_t i; + + rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); + + if (rec == NULL) { + DEBUG(0, ("ea_tdb_lock_attrs failed\n")); + errno = EINVAL; + return -1; + } + + status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(rec); + return -1; + } + + for (i=0; inum_xattrs; i++) { + if (strcmp(attribs->xattrs[i].name, name) == 0) { + break; + } + } + + if (i == attribs->num_xattrs) { + TALLOC_FREE(rec); + errno = ENOATTR; + return -1; + } + + attribs->xattrs[i] = + attribs->xattrs[attribs->num_xattrs-1]; + attribs->num_xattrs -= 1; + + if (attribs->num_xattrs == 0) { + rec->delete_rec(rec); + TALLOC_FREE(rec); + return 0; + } + + status = ea_tdb_save_attrs(rec, attribs); + + TALLOC_FREE(rec); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("save failed: %s\n", nt_errstr(status))); + return -1; + } + + return 0; +} + +static int ea_tdb_removexattr(struct vfs_handle_struct *handle, + const char *path, const char *name) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_removeattr(db, &id, name); +} + +static int ea_tdb_fremovexattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, const char *name) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_removeattr(db, &id, name); +} + +/* + * Open the tdb file upon VFS_CONNECT + */ + +static bool ea_tdb_init(int snum, struct db_context **p_db) +{ + struct db_context *db; + const char *dbname; + + dbname = lp_parm_const_string(snum, "ea", "tdb", lock_path("eas.tdb")); + + if (dbname == NULL) { + errno = ENOTSUP; + return false; + } + + become_root(); + db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); + unbecome_root(); + + if (db == NULL) { + errno = ENOTSUP; + return false; + } + + *p_db = db; + return true; +} + +/* + * On unlink we need to delete the tdb record + */ +static int ea_tdb_unlink(vfs_handle_struct *handle, const char *path) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + struct db_record *rec; + int ret; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + ret = SMB_VFS_NEXT_UNLINK(handle, path); + + if (ret == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); + + /* + * If rec == NULL there's not much we can do about it + */ + + if (rec != NULL) { + rec->delete_rec(rec); + TALLOC_FREE(rec); + } + + return 0; +} + +/* + * On rmdir we need to delete the tdb record + */ +static int ea_tdb_rmdir(vfs_handle_struct *handle, const char *path) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + struct db_record *rec; + int ret; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + ret = SMB_VFS_NEXT_RMDIR(handle, path); + + if (ret == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); + + /* + * If rec == NULL there's not much we can do about it + */ + + if (rec != NULL) { + rec->delete_rec(rec); + TALLOC_FREE(rec); + } + + return 0; +} + +/* + * Destructor for the VFS private data + */ + +static void close_ea_db(void **data) +{ + struct db_context **p_db = (struct db_context **)data; + TALLOC_FREE(*p_db); +} + +static int ea_tdb_connect(vfs_handle_struct *handle, const char *service, + const char *user) +{ + fstring sname; + int res, snum; + struct db_context *db; + + res = SMB_VFS_NEXT_CONNECT(handle, service, user); + if (res < 0) { + return res; + } + + fstrcpy(sname, service); + snum = find_service(sname); + if (snum == -1) { + /* + * Should not happen, but we should not fail just *here*. + */ + return 0; + } + + if (!ea_tdb_init(snum, &db)) { + DEBUG(5, ("Could not init ea tdb\n")); + lp_do_parameter(snum, "ea support", "False"); + return 0; + } + + lp_do_parameter(snum, "ea support", "True"); + + SMB_VFS_HANDLE_SET_DATA(handle, db, close_ea_db, + struct db_context, return -1); + + return 0; +} + +/* VFS operations structure */ + +static const vfs_op_tuple ea_tdb_ops[] = { + {SMB_VFS_OP(ea_tdb_getxattr), SMB_VFS_OP_GETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_fgetxattr), SMB_VFS_OP_FGETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_setxattr), SMB_VFS_OP_SETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_fsetxattr), SMB_VFS_OP_FSETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_listxattr), SMB_VFS_OP_LISTXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_flistxattr), SMB_VFS_OP_FLISTXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_removexattr), SMB_VFS_OP_REMOVEXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_fremovexattr), SMB_VFS_OP_FREMOVEXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_unlink), SMB_VFS_OP_UNLINK, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_rmdir), SMB_VFS_OP_RMDIR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_connect), SMB_VFS_OP_CONNECT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_ea_tdb_init(void); +NTSTATUS vfs_ea_tdb_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "ea_tdb", + ea_tdb_ops); +} -- cgit From c2acec43aed4fe9cca51a4227457accafeeb950b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 15 Jan 2008 17:03:17 +0100 Subject: rename vfs_ea_tdb to vfs_xattr_tdb (This used to be commit 151b42a150a17f566e7b4055bbdbc0564a3c106d) --- source3/modules/vfs_ea_tdb.c | 736 ---------------------------------------- source3/modules/vfs_xattr_tdb.c | 736 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 736 insertions(+), 736 deletions(-) delete mode 100644 source3/modules/vfs_ea_tdb.c create mode 100644 source3/modules/vfs_xattr_tdb.c (limited to 'source3/modules') diff --git a/source3/modules/vfs_ea_tdb.c b/source3/modules/vfs_ea_tdb.c deleted file mode 100644 index 8cf04d79ad..0000000000 --- a/source3/modules/vfs_ea_tdb.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Store posix-level xattrs in a tdb - * - * Copyright (C) Volker Lendecke, 2007 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -#include "includes.h" -#include "librpc/gen_ndr/xattr.h" -#include "librpc/gen_ndr/ndr_xattr.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_VFS - -/* - * unmarshall tdb_xattrs - */ - -static NTSTATUS ea_tdb_pull_attrs(TALLOC_CTX *mem_ctx, - const TDB_DATA *data, - struct tdb_xattrs **presult) -{ - DATA_BLOB blob; - enum ndr_err_code ndr_err; - struct tdb_xattrs *result; - - if (!(result = TALLOC_ZERO_P(mem_ctx, struct tdb_xattrs))) { - return NT_STATUS_NO_MEMORY; - } - - if (data->dsize == 0) { - *presult = result; - return NT_STATUS_OK; - } - - blob = data_blob_const(data->dptr, data->dsize); - - ndr_err = ndr_pull_struct_blob( - &blob, result, result, - (ndr_pull_flags_fn_t)ndr_pull_tdb_xattrs); - - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - DEBUG(0, ("ndr_pull_tdb_xattrs failed: %s\n", - ndr_errstr(ndr_err))); - TALLOC_FREE(result); - return ndr_map_error2ntstatus(ndr_err);; - } - - *presult = result; - return NT_STATUS_OK; -} - -/* - * marshall tdb_xattrs - */ - -static NTSTATUS ea_tdb_push_attrs(TALLOC_CTX *mem_ctx, - const struct tdb_xattrs *attribs, - TDB_DATA *data) -{ - DATA_BLOB blob; - enum ndr_err_code ndr_err; - - ndr_err = ndr_push_struct_blob( - &blob, mem_ctx, attribs, - (ndr_push_flags_fn_t)ndr_push_tdb_xattrs); - - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - DEBUG(0, ("ndr_push_tdb_xattrs failed: %s\n", - ndr_errstr(ndr_err))); - return ndr_map_error2ntstatus(ndr_err);; - } - - *data = make_tdb_data(blob.data, blob.length); - return NT_STATUS_OK; -} - -/* - * Load tdb_xattrs for a file from the tdb - */ - -static NTSTATUS ea_tdb_load_attrs(TALLOC_CTX *mem_ctx, - struct db_context *db_ctx, - const struct file_id *id, - struct tdb_xattrs **presult) -{ - uint8 id_buf[16]; - NTSTATUS status; - TDB_DATA data; - - push_file_id_16((char *)id_buf, id); - - if (db_ctx->fetch(db_ctx, mem_ctx, - make_tdb_data(id_buf, sizeof(id_buf)), - &data) == -1) { - return NT_STATUS_INTERNAL_DB_CORRUPTION; - } - - status = ea_tdb_pull_attrs(mem_ctx, &data, presult); - TALLOC_FREE(data.dptr); - return NT_STATUS_OK; -} - -/* - * fetch_lock the tdb_ea record for a file - */ - -static struct db_record *ea_tdb_lock_attrs(TALLOC_CTX *mem_ctx, - struct db_context *db_ctx, - const struct file_id *id) -{ - uint8 id_buf[16]; - push_file_id_16((char *)id_buf, id); - return db_ctx->fetch_locked(db_ctx, mem_ctx, - make_tdb_data(id_buf, sizeof(id_buf))); -} - -/* - * Save tdb_xattrs to a previously fetch_locked record - */ - -static NTSTATUS ea_tdb_save_attrs(struct db_record *rec, - const struct tdb_xattrs *attribs) -{ - TDB_DATA data; - NTSTATUS status; - - status = ea_tdb_push_attrs(talloc_tos(), attribs, &data); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("ea_tdb_push_attrs failed: %s\n", - nt_errstr(status))); - return status; - } - - status = rec->store(rec, data, 0); - - TALLOC_FREE(data.dptr); - - return status; -} - -/* - * Worker routine for getxattr and fgetxattr - */ - -static ssize_t ea_tdb_getattr(struct db_context *db_ctx, - const struct file_id *id, - const char *name, void *value, size_t size) -{ - struct tdb_xattrs *attribs; - uint32_t i; - ssize_t result = -1; - NTSTATUS status; - - status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", - nt_errstr(status))); - errno = EINVAL; - return -1; - } - - for (i=0; inum_xattrs; i++) { - if (strcmp(attribs->xattrs[i].name, name) == 0) { - break; - } - } - - if (i == attribs->num_xattrs) { - errno = ENOATTR; - goto fail; - } - - if (attribs->xattrs[i].value.length > size) { - errno = ERANGE; - goto fail; - } - - memcpy(value, attribs->xattrs[i].value.data, - attribs->xattrs[i].value.length); - result = attribs->xattrs[i].value.length; - - fail: - TALLOC_FREE(attribs); - return result; -} - -static ssize_t ea_tdb_getxattr(struct vfs_handle_struct *handle, - const char *path, const char *name, - void *value, size_t size) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_getattr(db, &id, name, value, size); -} - -static ssize_t ea_tdb_fgetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, - const char *name, void *value, size_t size) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_getattr(db, &id, name, value, size); -} - -/* - * Worker routine for setxattr and fsetxattr - */ - -static int ea_tdb_setattr(struct db_context *db_ctx, - const struct file_id *id, const char *name, - const void *value, size_t size, int flags) -{ - NTSTATUS status; - struct db_record *rec; - struct tdb_xattrs *attribs; - uint32_t i; - - rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); - - if (rec == NULL) { - DEBUG(0, ("ea_tdb_lock_attrs failed\n")); - errno = EINVAL; - return -1; - } - - status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", - nt_errstr(status))); - TALLOC_FREE(rec); - return -1; - } - - for (i=0; inum_xattrs; i++) { - if (strcmp(attribs->xattrs[i].name, name) == 0) { - break; - } - } - - if (i == attribs->num_xattrs) { - struct tdb_xattr *tmp; - - tmp = TALLOC_REALLOC_ARRAY( - attribs, attribs->xattrs, struct tdb_xattr, - attribs->num_xattrs + 1); - - if (tmp == NULL) { - DEBUG(0, ("TALLOC_REALLOC_ARRAY failed\n")); - TALLOC_FREE(rec); - errno = ENOMEM; - return -1; - } - - attribs->xattrs = tmp; - attribs->num_xattrs += 1; - } - - attribs->xattrs[i].name = name; - attribs->xattrs[i].value.data = CONST_DISCARD(uint8 *, value); - attribs->xattrs[i].value.length = size; - - status = ea_tdb_save_attrs(rec, attribs); - - TALLOC_FREE(rec); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("save failed: %s\n", nt_errstr(status))); - return -1; - } - - return 0; -} - -static int ea_tdb_setxattr(struct vfs_handle_struct *handle, - const char *path, const char *name, - const void *value, size_t size, int flags) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_setattr(db, &id, name, value, size, flags); -} - -static int ea_tdb_fsetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, - const char *name, const void *value, - size_t size, int flags) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_setattr(db, &id, name, value, size, flags); -} - -/* - * Worker routine for listxattr and flistxattr - */ - -static ssize_t ea_tdb_listattr(struct db_context *db_ctx, - const struct file_id *id, char *list, - size_t size) -{ - NTSTATUS status; - struct tdb_xattrs *attribs; - uint32_t i; - size_t len = 0; - - status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", - nt_errstr(status))); - errno = EINVAL; - return -1; - } - - DEBUG(10, ("ea_tdb_listattr: Found %d xattrs\n", attribs->num_xattrs)); - - for (i=0; inum_xattrs; i++) { - size_t tmp; - - DEBUG(10, ("ea_tdb_listattr: xattrs[i].name: %s\n", - attribs->xattrs[i].name)); - - tmp = strlen(attribs->xattrs[i].name); - - /* - * Try to protect against overflow - */ - - if (len + (tmp+1) < len) { - TALLOC_FREE(attribs); - errno = EINVAL; - return -1; - } - - /* - * Take care of the terminating NULL - */ - len += (tmp + 1); - } - - if (len > size) { - TALLOC_FREE(attribs); - errno = ERANGE; - return -1; - } - - len = 0; - - for (i=0; inum_xattrs; i++) { - strlcpy(list+len, attribs->xattrs[i].name, - size-len); - len += (strlen(attribs->xattrs[i].name) + 1); - } - - TALLOC_FREE(attribs); - return len; -} - -static ssize_t ea_tdb_listxattr(struct vfs_handle_struct *handle, - const char *path, char *list, size_t size) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_listattr(db, &id, list, size); -} - -static ssize_t ea_tdb_flistxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, char *list, - size_t size) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_listattr(db, &id, list, size); -} - -/* - * Worker routine for removexattr and fremovexattr - */ - -static int ea_tdb_removeattr(struct db_context *db_ctx, - const struct file_id *id, const char *name) -{ - NTSTATUS status; - struct db_record *rec; - struct tdb_xattrs *attribs; - uint32_t i; - - rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); - - if (rec == NULL) { - DEBUG(0, ("ea_tdb_lock_attrs failed\n")); - errno = EINVAL; - return -1; - } - - status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", - nt_errstr(status))); - TALLOC_FREE(rec); - return -1; - } - - for (i=0; inum_xattrs; i++) { - if (strcmp(attribs->xattrs[i].name, name) == 0) { - break; - } - } - - if (i == attribs->num_xattrs) { - TALLOC_FREE(rec); - errno = ENOATTR; - return -1; - } - - attribs->xattrs[i] = - attribs->xattrs[attribs->num_xattrs-1]; - attribs->num_xattrs -= 1; - - if (attribs->num_xattrs == 0) { - rec->delete_rec(rec); - TALLOC_FREE(rec); - return 0; - } - - status = ea_tdb_save_attrs(rec, attribs); - - TALLOC_FREE(rec); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("save failed: %s\n", nt_errstr(status))); - return -1; - } - - return 0; -} - -static int ea_tdb_removexattr(struct vfs_handle_struct *handle, - const char *path, const char *name) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_removeattr(db, &id, name); -} - -static int ea_tdb_fremovexattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, const char *name) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - return ea_tdb_removeattr(db, &id, name); -} - -/* - * Open the tdb file upon VFS_CONNECT - */ - -static bool ea_tdb_init(int snum, struct db_context **p_db) -{ - struct db_context *db; - const char *dbname; - - dbname = lp_parm_const_string(snum, "ea", "tdb", lock_path("eas.tdb")); - - if (dbname == NULL) { - errno = ENOTSUP; - return false; - } - - become_root(); - db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); - unbecome_root(); - - if (db == NULL) { - errno = ENOTSUP; - return false; - } - - *p_db = db; - return true; -} - -/* - * On unlink we need to delete the tdb record - */ -static int ea_tdb_unlink(vfs_handle_struct *handle, const char *path) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - struct db_record *rec; - int ret; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { - return -1; - } - - ret = SMB_VFS_NEXT_UNLINK(handle, path); - - if (ret == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); - - /* - * If rec == NULL there's not much we can do about it - */ - - if (rec != NULL) { - rec->delete_rec(rec); - TALLOC_FREE(rec); - } - - return 0; -} - -/* - * On rmdir we need to delete the tdb record - */ -static int ea_tdb_rmdir(vfs_handle_struct *handle, const char *path) -{ - SMB_STRUCT_STAT sbuf; - struct file_id id; - struct db_context *db; - struct db_record *rec; - int ret; - - SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); - - if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { - return -1; - } - - ret = SMB_VFS_NEXT_RMDIR(handle, path); - - if (ret == -1) { - return -1; - } - - id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - - rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); - - /* - * If rec == NULL there's not much we can do about it - */ - - if (rec != NULL) { - rec->delete_rec(rec); - TALLOC_FREE(rec); - } - - return 0; -} - -/* - * Destructor for the VFS private data - */ - -static void close_ea_db(void **data) -{ - struct db_context **p_db = (struct db_context **)data; - TALLOC_FREE(*p_db); -} - -static int ea_tdb_connect(vfs_handle_struct *handle, const char *service, - const char *user) -{ - fstring sname; - int res, snum; - struct db_context *db; - - res = SMB_VFS_NEXT_CONNECT(handle, service, user); - if (res < 0) { - return res; - } - - fstrcpy(sname, service); - snum = find_service(sname); - if (snum == -1) { - /* - * Should not happen, but we should not fail just *here*. - */ - return 0; - } - - if (!ea_tdb_init(snum, &db)) { - DEBUG(5, ("Could not init ea tdb\n")); - lp_do_parameter(snum, "ea support", "False"); - return 0; - } - - lp_do_parameter(snum, "ea support", "True"); - - SMB_VFS_HANDLE_SET_DATA(handle, db, close_ea_db, - struct db_context, return -1); - - return 0; -} - -/* VFS operations structure */ - -static const vfs_op_tuple ea_tdb_ops[] = { - {SMB_VFS_OP(ea_tdb_getxattr), SMB_VFS_OP_GETXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_fgetxattr), SMB_VFS_OP_FGETXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_setxattr), SMB_VFS_OP_SETXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_fsetxattr), SMB_VFS_OP_FSETXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_listxattr), SMB_VFS_OP_LISTXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_flistxattr), SMB_VFS_OP_FLISTXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_removexattr), SMB_VFS_OP_REMOVEXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_fremovexattr), SMB_VFS_OP_FREMOVEXATTR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_unlink), SMB_VFS_OP_UNLINK, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_rmdir), SMB_VFS_OP_RMDIR, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_connect), SMB_VFS_OP_CONNECT, - SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} -}; - -NTSTATUS vfs_ea_tdb_init(void); -NTSTATUS vfs_ea_tdb_init(void) -{ - return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "ea_tdb", - ea_tdb_ops); -} diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c new file mode 100644 index 0000000000..8cf04d79ad --- /dev/null +++ b/source3/modules/vfs_xattr_tdb.c @@ -0,0 +1,736 @@ +/* + * Store posix-level xattrs in a tdb + * + * Copyright (C) Volker Lendecke, 2007 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "includes.h" +#include "librpc/gen_ndr/xattr.h" +#include "librpc/gen_ndr/ndr_xattr.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +/* + * unmarshall tdb_xattrs + */ + +static NTSTATUS ea_tdb_pull_attrs(TALLOC_CTX *mem_ctx, + const TDB_DATA *data, + struct tdb_xattrs **presult) +{ + DATA_BLOB blob; + enum ndr_err_code ndr_err; + struct tdb_xattrs *result; + + if (!(result = TALLOC_ZERO_P(mem_ctx, struct tdb_xattrs))) { + return NT_STATUS_NO_MEMORY; + } + + if (data->dsize == 0) { + *presult = result; + return NT_STATUS_OK; + } + + blob = data_blob_const(data->dptr, data->dsize); + + ndr_err = ndr_pull_struct_blob( + &blob, result, result, + (ndr_pull_flags_fn_t)ndr_pull_tdb_xattrs); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0, ("ndr_pull_tdb_xattrs failed: %s\n", + ndr_errstr(ndr_err))); + TALLOC_FREE(result); + return ndr_map_error2ntstatus(ndr_err);; + } + + *presult = result; + return NT_STATUS_OK; +} + +/* + * marshall tdb_xattrs + */ + +static NTSTATUS ea_tdb_push_attrs(TALLOC_CTX *mem_ctx, + const struct tdb_xattrs *attribs, + TDB_DATA *data) +{ + DATA_BLOB blob; + enum ndr_err_code ndr_err; + + ndr_err = ndr_push_struct_blob( + &blob, mem_ctx, attribs, + (ndr_push_flags_fn_t)ndr_push_tdb_xattrs); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0, ("ndr_push_tdb_xattrs failed: %s\n", + ndr_errstr(ndr_err))); + return ndr_map_error2ntstatus(ndr_err);; + } + + *data = make_tdb_data(blob.data, blob.length); + return NT_STATUS_OK; +} + +/* + * Load tdb_xattrs for a file from the tdb + */ + +static NTSTATUS ea_tdb_load_attrs(TALLOC_CTX *mem_ctx, + struct db_context *db_ctx, + const struct file_id *id, + struct tdb_xattrs **presult) +{ + uint8 id_buf[16]; + NTSTATUS status; + TDB_DATA data; + + push_file_id_16((char *)id_buf, id); + + if (db_ctx->fetch(db_ctx, mem_ctx, + make_tdb_data(id_buf, sizeof(id_buf)), + &data) == -1) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + status = ea_tdb_pull_attrs(mem_ctx, &data, presult); + TALLOC_FREE(data.dptr); + return NT_STATUS_OK; +} + +/* + * fetch_lock the tdb_ea record for a file + */ + +static struct db_record *ea_tdb_lock_attrs(TALLOC_CTX *mem_ctx, + struct db_context *db_ctx, + const struct file_id *id) +{ + uint8 id_buf[16]; + push_file_id_16((char *)id_buf, id); + return db_ctx->fetch_locked(db_ctx, mem_ctx, + make_tdb_data(id_buf, sizeof(id_buf))); +} + +/* + * Save tdb_xattrs to a previously fetch_locked record + */ + +static NTSTATUS ea_tdb_save_attrs(struct db_record *rec, + const struct tdb_xattrs *attribs) +{ + TDB_DATA data; + NTSTATUS status; + + status = ea_tdb_push_attrs(talloc_tos(), attribs, &data); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("ea_tdb_push_attrs failed: %s\n", + nt_errstr(status))); + return status; + } + + status = rec->store(rec, data, 0); + + TALLOC_FREE(data.dptr); + + return status; +} + +/* + * Worker routine for getxattr and fgetxattr + */ + +static ssize_t ea_tdb_getattr(struct db_context *db_ctx, + const struct file_id *id, + const char *name, void *value, size_t size) +{ + struct tdb_xattrs *attribs; + uint32_t i; + ssize_t result = -1; + NTSTATUS status; + + status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + errno = EINVAL; + return -1; + } + + for (i=0; inum_xattrs; i++) { + if (strcmp(attribs->xattrs[i].name, name) == 0) { + break; + } + } + + if (i == attribs->num_xattrs) { + errno = ENOATTR; + goto fail; + } + + if (attribs->xattrs[i].value.length > size) { + errno = ERANGE; + goto fail; + } + + memcpy(value, attribs->xattrs[i].value.data, + attribs->xattrs[i].value.length); + result = attribs->xattrs[i].value.length; + + fail: + TALLOC_FREE(attribs); + return result; +} + +static ssize_t ea_tdb_getxattr(struct vfs_handle_struct *handle, + const char *path, const char *name, + void *value, size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_getattr(db, &id, name, value, size); +} + +static ssize_t ea_tdb_fgetxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, + const char *name, void *value, size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_getattr(db, &id, name, value, size); +} + +/* + * Worker routine for setxattr and fsetxattr + */ + +static int ea_tdb_setattr(struct db_context *db_ctx, + const struct file_id *id, const char *name, + const void *value, size_t size, int flags) +{ + NTSTATUS status; + struct db_record *rec; + struct tdb_xattrs *attribs; + uint32_t i; + + rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); + + if (rec == NULL) { + DEBUG(0, ("ea_tdb_lock_attrs failed\n")); + errno = EINVAL; + return -1; + } + + status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(rec); + return -1; + } + + for (i=0; inum_xattrs; i++) { + if (strcmp(attribs->xattrs[i].name, name) == 0) { + break; + } + } + + if (i == attribs->num_xattrs) { + struct tdb_xattr *tmp; + + tmp = TALLOC_REALLOC_ARRAY( + attribs, attribs->xattrs, struct tdb_xattr, + attribs->num_xattrs + 1); + + if (tmp == NULL) { + DEBUG(0, ("TALLOC_REALLOC_ARRAY failed\n")); + TALLOC_FREE(rec); + errno = ENOMEM; + return -1; + } + + attribs->xattrs = tmp; + attribs->num_xattrs += 1; + } + + attribs->xattrs[i].name = name; + attribs->xattrs[i].value.data = CONST_DISCARD(uint8 *, value); + attribs->xattrs[i].value.length = size; + + status = ea_tdb_save_attrs(rec, attribs); + + TALLOC_FREE(rec); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("save failed: %s\n", nt_errstr(status))); + return -1; + } + + return 0; +} + +static int ea_tdb_setxattr(struct vfs_handle_struct *handle, + const char *path, const char *name, + const void *value, size_t size, int flags) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_setattr(db, &id, name, value, size, flags); +} + +static int ea_tdb_fsetxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, + const char *name, const void *value, + size_t size, int flags) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_setattr(db, &id, name, value, size, flags); +} + +/* + * Worker routine for listxattr and flistxattr + */ + +static ssize_t ea_tdb_listattr(struct db_context *db_ctx, + const struct file_id *id, char *list, + size_t size) +{ + NTSTATUS status; + struct tdb_xattrs *attribs; + uint32_t i; + size_t len = 0; + + status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + errno = EINVAL; + return -1; + } + + DEBUG(10, ("ea_tdb_listattr: Found %d xattrs\n", attribs->num_xattrs)); + + for (i=0; inum_xattrs; i++) { + size_t tmp; + + DEBUG(10, ("ea_tdb_listattr: xattrs[i].name: %s\n", + attribs->xattrs[i].name)); + + tmp = strlen(attribs->xattrs[i].name); + + /* + * Try to protect against overflow + */ + + if (len + (tmp+1) < len) { + TALLOC_FREE(attribs); + errno = EINVAL; + return -1; + } + + /* + * Take care of the terminating NULL + */ + len += (tmp + 1); + } + + if (len > size) { + TALLOC_FREE(attribs); + errno = ERANGE; + return -1; + } + + len = 0; + + for (i=0; inum_xattrs; i++) { + strlcpy(list+len, attribs->xattrs[i].name, + size-len); + len += (strlen(attribs->xattrs[i].name) + 1); + } + + TALLOC_FREE(attribs); + return len; +} + +static ssize_t ea_tdb_listxattr(struct vfs_handle_struct *handle, + const char *path, char *list, size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_listattr(db, &id, list, size); +} + +static ssize_t ea_tdb_flistxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, char *list, + size_t size) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_listattr(db, &id, list, size); +} + +/* + * Worker routine for removexattr and fremovexattr + */ + +static int ea_tdb_removeattr(struct db_context *db_ctx, + const struct file_id *id, const char *name) +{ + NTSTATUS status; + struct db_record *rec; + struct tdb_xattrs *attribs; + uint32_t i; + + rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); + + if (rec == NULL) { + DEBUG(0, ("ea_tdb_lock_attrs failed\n")); + errno = EINVAL; + return -1; + } + + status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(rec); + return -1; + } + + for (i=0; inum_xattrs; i++) { + if (strcmp(attribs->xattrs[i].name, name) == 0) { + break; + } + } + + if (i == attribs->num_xattrs) { + TALLOC_FREE(rec); + errno = ENOATTR; + return -1; + } + + attribs->xattrs[i] = + attribs->xattrs[attribs->num_xattrs-1]; + attribs->num_xattrs -= 1; + + if (attribs->num_xattrs == 0) { + rec->delete_rec(rec); + TALLOC_FREE(rec); + return 0; + } + + status = ea_tdb_save_attrs(rec, attribs); + + TALLOC_FREE(rec); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("save failed: %s\n", nt_errstr(status))); + return -1; + } + + return 0; +} + +static int ea_tdb_removexattr(struct vfs_handle_struct *handle, + const char *path, const char *name) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_removeattr(db, &id, name); +} + +static int ea_tdb_fremovexattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, const char *name) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + return ea_tdb_removeattr(db, &id, name); +} + +/* + * Open the tdb file upon VFS_CONNECT + */ + +static bool ea_tdb_init(int snum, struct db_context **p_db) +{ + struct db_context *db; + const char *dbname; + + dbname = lp_parm_const_string(snum, "ea", "tdb", lock_path("eas.tdb")); + + if (dbname == NULL) { + errno = ENOTSUP; + return false; + } + + become_root(); + db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); + unbecome_root(); + + if (db == NULL) { + errno = ENOTSUP; + return false; + } + + *p_db = db; + return true; +} + +/* + * On unlink we need to delete the tdb record + */ +static int ea_tdb_unlink(vfs_handle_struct *handle, const char *path) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + struct db_record *rec; + int ret; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + ret = SMB_VFS_NEXT_UNLINK(handle, path); + + if (ret == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); + + /* + * If rec == NULL there's not much we can do about it + */ + + if (rec != NULL) { + rec->delete_rec(rec); + TALLOC_FREE(rec); + } + + return 0; +} + +/* + * On rmdir we need to delete the tdb record + */ +static int ea_tdb_rmdir(vfs_handle_struct *handle, const char *path) +{ + SMB_STRUCT_STAT sbuf; + struct file_id id; + struct db_context *db; + struct db_record *rec; + int ret; + + SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1); + + if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) { + return -1; + } + + ret = SMB_VFS_NEXT_RMDIR(handle, path); + + if (ret == -1) { + return -1; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); + + rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); + + /* + * If rec == NULL there's not much we can do about it + */ + + if (rec != NULL) { + rec->delete_rec(rec); + TALLOC_FREE(rec); + } + + return 0; +} + +/* + * Destructor for the VFS private data + */ + +static void close_ea_db(void **data) +{ + struct db_context **p_db = (struct db_context **)data; + TALLOC_FREE(*p_db); +} + +static int ea_tdb_connect(vfs_handle_struct *handle, const char *service, + const char *user) +{ + fstring sname; + int res, snum; + struct db_context *db; + + res = SMB_VFS_NEXT_CONNECT(handle, service, user); + if (res < 0) { + return res; + } + + fstrcpy(sname, service); + snum = find_service(sname); + if (snum == -1) { + /* + * Should not happen, but we should not fail just *here*. + */ + return 0; + } + + if (!ea_tdb_init(snum, &db)) { + DEBUG(5, ("Could not init ea tdb\n")); + lp_do_parameter(snum, "ea support", "False"); + return 0; + } + + lp_do_parameter(snum, "ea support", "True"); + + SMB_VFS_HANDLE_SET_DATA(handle, db, close_ea_db, + struct db_context, return -1); + + return 0; +} + +/* VFS operations structure */ + +static const vfs_op_tuple ea_tdb_ops[] = { + {SMB_VFS_OP(ea_tdb_getxattr), SMB_VFS_OP_GETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_fgetxattr), SMB_VFS_OP_FGETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_setxattr), SMB_VFS_OP_SETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_fsetxattr), SMB_VFS_OP_FSETXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_listxattr), SMB_VFS_OP_LISTXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_flistxattr), SMB_VFS_OP_FLISTXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_removexattr), SMB_VFS_OP_REMOVEXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_fremovexattr), SMB_VFS_OP_FREMOVEXATTR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_unlink), SMB_VFS_OP_UNLINK, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_rmdir), SMB_VFS_OP_RMDIR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(ea_tdb_connect), SMB_VFS_OP_CONNECT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_ea_tdb_init(void); +NTSTATUS vfs_ea_tdb_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "ea_tdb", + ea_tdb_ops); +} -- cgit From ee8cf0ce40820b3e1ec025339f2b25c0001fda13 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 15 Jan 2008 17:06:12 +0100 Subject: ea_tdb->xattr_tdb also inside the module itself (This used to be commit 642424b3779dd33cd2b5049789aa16e678438bb9) --- source3/modules/vfs_xattr_tdb.c | 197 ++++++++++++++++++++-------------------- 1 file changed, 99 insertions(+), 98 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 8cf04d79ad..3a72831b5b 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -28,9 +28,9 @@ * unmarshall tdb_xattrs */ -static NTSTATUS ea_tdb_pull_attrs(TALLOC_CTX *mem_ctx, - const TDB_DATA *data, - struct tdb_xattrs **presult) +static NTSTATUS xattr_tdb_pull_attrs(TALLOC_CTX *mem_ctx, + const TDB_DATA *data, + struct tdb_xattrs **presult) { DATA_BLOB blob; enum ndr_err_code ndr_err; @@ -66,9 +66,9 @@ static NTSTATUS ea_tdb_pull_attrs(TALLOC_CTX *mem_ctx, * marshall tdb_xattrs */ -static NTSTATUS ea_tdb_push_attrs(TALLOC_CTX *mem_ctx, - const struct tdb_xattrs *attribs, - TDB_DATA *data) +static NTSTATUS xattr_tdb_push_attrs(TALLOC_CTX *mem_ctx, + const struct tdb_xattrs *attribs, + TDB_DATA *data) { DATA_BLOB blob; enum ndr_err_code ndr_err; @@ -91,10 +91,10 @@ static NTSTATUS ea_tdb_push_attrs(TALLOC_CTX *mem_ctx, * Load tdb_xattrs for a file from the tdb */ -static NTSTATUS ea_tdb_load_attrs(TALLOC_CTX *mem_ctx, - struct db_context *db_ctx, - const struct file_id *id, - struct tdb_xattrs **presult) +static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx, + struct db_context *db_ctx, + const struct file_id *id, + struct tdb_xattrs **presult) { uint8 id_buf[16]; NTSTATUS status; @@ -108,7 +108,7 @@ static NTSTATUS ea_tdb_load_attrs(TALLOC_CTX *mem_ctx, return NT_STATUS_INTERNAL_DB_CORRUPTION; } - status = ea_tdb_pull_attrs(mem_ctx, &data, presult); + status = xattr_tdb_pull_attrs(mem_ctx, &data, presult); TALLOC_FREE(data.dptr); return NT_STATUS_OK; } @@ -117,9 +117,9 @@ static NTSTATUS ea_tdb_load_attrs(TALLOC_CTX *mem_ctx, * fetch_lock the tdb_ea record for a file */ -static struct db_record *ea_tdb_lock_attrs(TALLOC_CTX *mem_ctx, - struct db_context *db_ctx, - const struct file_id *id) +static struct db_record *xattr_tdb_lock_attrs(TALLOC_CTX *mem_ctx, + struct db_context *db_ctx, + const struct file_id *id) { uint8 id_buf[16]; push_file_id_16((char *)id_buf, id); @@ -131,16 +131,16 @@ static struct db_record *ea_tdb_lock_attrs(TALLOC_CTX *mem_ctx, * Save tdb_xattrs to a previously fetch_locked record */ -static NTSTATUS ea_tdb_save_attrs(struct db_record *rec, - const struct tdb_xattrs *attribs) +static NTSTATUS xattr_tdb_save_attrs(struct db_record *rec, + const struct tdb_xattrs *attribs) { TDB_DATA data; NTSTATUS status; - status = ea_tdb_push_attrs(talloc_tos(), attribs, &data); + status = xattr_tdb_push_attrs(talloc_tos(), attribs, &data); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("ea_tdb_push_attrs failed: %s\n", + DEBUG(0, ("xattr_tdb_push_attrs failed: %s\n", nt_errstr(status))); return status; } @@ -156,19 +156,19 @@ static NTSTATUS ea_tdb_save_attrs(struct db_record *rec, * Worker routine for getxattr and fgetxattr */ -static ssize_t ea_tdb_getattr(struct db_context *db_ctx, - const struct file_id *id, - const char *name, void *value, size_t size) +static ssize_t xattr_tdb_getattr(struct db_context *db_ctx, + const struct file_id *id, + const char *name, void *value, size_t size) { struct tdb_xattrs *attribs; uint32_t i; ssize_t result = -1; NTSTATUS status; - status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); + status = xattr_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n", nt_errstr(status))); errno = EINVAL; return -1; @@ -199,9 +199,9 @@ static ssize_t ea_tdb_getattr(struct db_context *db_ctx, return result; } -static ssize_t ea_tdb_getxattr(struct vfs_handle_struct *handle, - const char *path, const char *name, - void *value, size_t size) +static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle, + const char *path, const char *name, + void *value, size_t size) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -215,12 +215,12 @@ static ssize_t ea_tdb_getxattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_getattr(db, &id, name, value, size); + return xattr_tdb_getattr(db, &id, name, value, size); } -static ssize_t ea_tdb_fgetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, - const char *name, void *value, size_t size) +static ssize_t xattr_tdb_fgetxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, + const char *name, void *value, size_t size) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -234,34 +234,34 @@ static ssize_t ea_tdb_fgetxattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_getattr(db, &id, name, value, size); + return xattr_tdb_getattr(db, &id, name, value, size); } /* * Worker routine for setxattr and fsetxattr */ -static int ea_tdb_setattr(struct db_context *db_ctx, - const struct file_id *id, const char *name, - const void *value, size_t size, int flags) +static int xattr_tdb_setattr(struct db_context *db_ctx, + const struct file_id *id, const char *name, + const void *value, size_t size, int flags) { NTSTATUS status; struct db_record *rec; struct tdb_xattrs *attribs; uint32_t i; - rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); + rec = xattr_tdb_lock_attrs(talloc_tos(), db_ctx, id); if (rec == NULL) { - DEBUG(0, ("ea_tdb_lock_attrs failed\n")); + DEBUG(0, ("xattr_tdb_lock_attrs failed\n")); errno = EINVAL; return -1; } - status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); + status = xattr_tdb_pull_attrs(rec, &rec->value, &attribs); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n", nt_errstr(status))); TALLOC_FREE(rec); return -1; @@ -295,7 +295,7 @@ static int ea_tdb_setattr(struct db_context *db_ctx, attribs->xattrs[i].value.data = CONST_DISCARD(uint8 *, value); attribs->xattrs[i].value.length = size; - status = ea_tdb_save_attrs(rec, attribs); + status = xattr_tdb_save_attrs(rec, attribs); TALLOC_FREE(rec); @@ -307,9 +307,9 @@ static int ea_tdb_setattr(struct db_context *db_ctx, return 0; } -static int ea_tdb_setxattr(struct vfs_handle_struct *handle, - const char *path, const char *name, - const void *value, size_t size, int flags) +static int xattr_tdb_setxattr(struct vfs_handle_struct *handle, + const char *path, const char *name, + const void *value, size_t size, int flags) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -323,13 +323,13 @@ static int ea_tdb_setxattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_setattr(db, &id, name, value, size, flags); + return xattr_tdb_setattr(db, &id, name, value, size, flags); } -static int ea_tdb_fsetxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, - const char *name, const void *value, - size_t size, int flags) +static int xattr_tdb_fsetxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, + const char *name, const void *value, + size_t size, int flags) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -343,37 +343,38 @@ static int ea_tdb_fsetxattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_setattr(db, &id, name, value, size, flags); + return xattr_tdb_setattr(db, &id, name, value, size, flags); } /* * Worker routine for listxattr and flistxattr */ -static ssize_t ea_tdb_listattr(struct db_context *db_ctx, - const struct file_id *id, char *list, - size_t size) +static ssize_t xattr_tdb_listattr(struct db_context *db_ctx, + const struct file_id *id, char *list, + size_t size) { NTSTATUS status; struct tdb_xattrs *attribs; uint32_t i; size_t len = 0; - status = ea_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); + status = xattr_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n", nt_errstr(status))); errno = EINVAL; return -1; } - DEBUG(10, ("ea_tdb_listattr: Found %d xattrs\n", attribs->num_xattrs)); + DEBUG(10, ("xattr_tdb_listattr: Found %d xattrs\n", + attribs->num_xattrs)); for (i=0; inum_xattrs; i++) { size_t tmp; - DEBUG(10, ("ea_tdb_listattr: xattrs[i].name: %s\n", + DEBUG(10, ("xattr_tdb_listattr: xattrs[i].name: %s\n", attribs->xattrs[i].name)); tmp = strlen(attribs->xattrs[i].name); @@ -412,8 +413,8 @@ static ssize_t ea_tdb_listattr(struct db_context *db_ctx, return len; } -static ssize_t ea_tdb_listxattr(struct vfs_handle_struct *handle, - const char *path, char *list, size_t size) +static ssize_t xattr_tdb_listxattr(struct vfs_handle_struct *handle, + const char *path, char *list, size_t size) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -427,12 +428,12 @@ static ssize_t ea_tdb_listxattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_listattr(db, &id, list, size); + return xattr_tdb_listattr(db, &id, list, size); } -static ssize_t ea_tdb_flistxattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, char *list, - size_t size) +static ssize_t xattr_tdb_flistxattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, char *list, + size_t size) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -446,33 +447,33 @@ static ssize_t ea_tdb_flistxattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_listattr(db, &id, list, size); + return xattr_tdb_listattr(db, &id, list, size); } /* * Worker routine for removexattr and fremovexattr */ -static int ea_tdb_removeattr(struct db_context *db_ctx, - const struct file_id *id, const char *name) +static int xattr_tdb_removeattr(struct db_context *db_ctx, + const struct file_id *id, const char *name) { NTSTATUS status; struct db_record *rec; struct tdb_xattrs *attribs; uint32_t i; - rec = ea_tdb_lock_attrs(talloc_tos(), db_ctx, id); + rec = xattr_tdb_lock_attrs(talloc_tos(), db_ctx, id); if (rec == NULL) { - DEBUG(0, ("ea_tdb_lock_attrs failed\n")); + DEBUG(0, ("xattr_tdb_lock_attrs failed\n")); errno = EINVAL; return -1; } - status = ea_tdb_pull_attrs(rec, &rec->value, &attribs); + status = xattr_tdb_pull_attrs(rec, &rec->value, &attribs); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ea_tdb_fetch_attrs failed: %s\n", + DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n", nt_errstr(status))); TALLOC_FREE(rec); return -1; @@ -500,7 +501,7 @@ static int ea_tdb_removeattr(struct db_context *db_ctx, return 0; } - status = ea_tdb_save_attrs(rec, attribs); + status = xattr_tdb_save_attrs(rec, attribs); TALLOC_FREE(rec); @@ -512,8 +513,8 @@ static int ea_tdb_removeattr(struct db_context *db_ctx, return 0; } -static int ea_tdb_removexattr(struct vfs_handle_struct *handle, - const char *path, const char *name) +static int xattr_tdb_removexattr(struct vfs_handle_struct *handle, + const char *path, const char *name) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -527,11 +528,11 @@ static int ea_tdb_removexattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_removeattr(db, &id, name); + return xattr_tdb_removeattr(db, &id, name); } -static int ea_tdb_fremovexattr(struct vfs_handle_struct *handle, - struct files_struct *fsp, const char *name) +static int xattr_tdb_fremovexattr(struct vfs_handle_struct *handle, + struct files_struct *fsp, const char *name) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -545,14 +546,14 @@ static int ea_tdb_fremovexattr(struct vfs_handle_struct *handle, id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - return ea_tdb_removeattr(db, &id, name); + return xattr_tdb_removeattr(db, &id, name); } /* * Open the tdb file upon VFS_CONNECT */ -static bool ea_tdb_init(int snum, struct db_context **p_db) +static bool xattr_tdb_init(int snum, struct db_context **p_db) { struct db_context *db; const char *dbname; @@ -580,7 +581,7 @@ static bool ea_tdb_init(int snum, struct db_context **p_db) /* * On unlink we need to delete the tdb record */ -static int ea_tdb_unlink(vfs_handle_struct *handle, const char *path) +static int xattr_tdb_unlink(vfs_handle_struct *handle, const char *path) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -602,7 +603,7 @@ static int ea_tdb_unlink(vfs_handle_struct *handle, const char *path) id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); + rec = xattr_tdb_lock_attrs(talloc_tos(), db, &id); /* * If rec == NULL there's not much we can do about it @@ -619,7 +620,7 @@ static int ea_tdb_unlink(vfs_handle_struct *handle, const char *path) /* * On rmdir we need to delete the tdb record */ -static int ea_tdb_rmdir(vfs_handle_struct *handle, const char *path) +static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path) { SMB_STRUCT_STAT sbuf; struct file_id id; @@ -641,7 +642,7 @@ static int ea_tdb_rmdir(vfs_handle_struct *handle, const char *path) id = SMB_VFS_FILE_ID_CREATE(handle->conn, sbuf.st_dev, sbuf.st_ino); - rec = ea_tdb_lock_attrs(talloc_tos(), db, &id); + rec = xattr_tdb_lock_attrs(talloc_tos(), db, &id); /* * If rec == NULL there's not much we can do about it @@ -665,7 +666,7 @@ static void close_ea_db(void **data) TALLOC_FREE(*p_db); } -static int ea_tdb_connect(vfs_handle_struct *handle, const char *service, +static int xattr_tdb_connect(vfs_handle_struct *handle, const char *service, const char *user) { fstring sname; @@ -686,7 +687,7 @@ static int ea_tdb_connect(vfs_handle_struct *handle, const char *service, return 0; } - if (!ea_tdb_init(snum, &db)) { + if (!xattr_tdb_init(snum, &db)) { DEBUG(5, ("Could not init ea tdb\n")); lp_do_parameter(snum, "ea support", "False"); return 0; @@ -702,35 +703,35 @@ static int ea_tdb_connect(vfs_handle_struct *handle, const char *service, /* VFS operations structure */ -static const vfs_op_tuple ea_tdb_ops[] = { - {SMB_VFS_OP(ea_tdb_getxattr), SMB_VFS_OP_GETXATTR, +static const vfs_op_tuple xattr_tdb_ops[] = { + {SMB_VFS_OP(xattr_tdb_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_fgetxattr), SMB_VFS_OP_FGETXATTR, + {SMB_VFS_OP(xattr_tdb_fgetxattr), SMB_VFS_OP_FGETXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_setxattr), SMB_VFS_OP_SETXATTR, + {SMB_VFS_OP(xattr_tdb_setxattr), SMB_VFS_OP_SETXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_fsetxattr), SMB_VFS_OP_FSETXATTR, + {SMB_VFS_OP(xattr_tdb_fsetxattr), SMB_VFS_OP_FSETXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_listxattr), SMB_VFS_OP_LISTXATTR, + {SMB_VFS_OP(xattr_tdb_listxattr), SMB_VFS_OP_LISTXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_flistxattr), SMB_VFS_OP_FLISTXATTR, + {SMB_VFS_OP(xattr_tdb_flistxattr), SMB_VFS_OP_FLISTXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_removexattr), SMB_VFS_OP_REMOVEXATTR, + {SMB_VFS_OP(xattr_tdb_removexattr), SMB_VFS_OP_REMOVEXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_fremovexattr), SMB_VFS_OP_FREMOVEXATTR, + {SMB_VFS_OP(xattr_tdb_fremovexattr), SMB_VFS_OP_FREMOVEXATTR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_unlink), SMB_VFS_OP_UNLINK, + {SMB_VFS_OP(xattr_tdb_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_rmdir), SMB_VFS_OP_RMDIR, + {SMB_VFS_OP(xattr_tdb_rmdir), SMB_VFS_OP_RMDIR, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(ea_tdb_connect), SMB_VFS_OP_CONNECT, + {SMB_VFS_OP(xattr_tdb_connect), SMB_VFS_OP_CONNECT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} }; -NTSTATUS vfs_ea_tdb_init(void); -NTSTATUS vfs_ea_tdb_init(void) +NTSTATUS vfs_xattr_tdb_init(void); +NTSTATUS vfs_xattr_tdb_init(void) { - return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "ea_tdb", - ea_tdb_ops); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "xattr_tdb", + xattr_tdb_ops); } -- cgit From d86fc3ec8c99aaa5ffaa14a97525154507c39df7 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 16 Jan 2008 12:17:03 +0300 Subject: Add support for offline files support, remote storage, and Async I/O force operations to VFS Offline files support and remote storage are for allowing communication with backup and archiving tools that mark files moved to a tape library as offline. We translate this info into corresponding CIFS offline file attribute and mark an exported volume as remote storage. Async I/O force is to allow selective redirection of I/O operations to asynchronous processing in case it is viable at VFS module discretion. It is needed for proper handling of offline files as performing regular I/O on offline file will block smbd. Signed-off-by: Alexander Bokovoy (This used to be commit 875208724e39564fe81385dfe36e6c963e79e101) --- source3/modules/vfs_default.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index e21136ccee..3e78c69a5e 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1225,6 +1225,38 @@ static int vfswrap_aio_suspend(struct vfs_handle_struct *handle, struct files_st return sys_aio_suspend(aiocb, n, timeout); } +static int vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp) +{ + return False; +} + +static int vfswrap_is_offline(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline) +{ + if (ISDOT(path) || ISDOTDOT(path)) { + return 1; + } + + if (!lp_dmapi_support(SNUM(conn)) || !dmapi_have_session()) { + return -1; + } + + *offline = (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0; + return 0; +} + +static int vfswrap_set_offline(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) +{ + /* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */ + return -1; +} + +static bool vfswrap_is_remotestorage(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) +{ + /* We don't know how to detect that volume is remote storage. VFS modules should redefine it. */ + return False; +} + + static vfs_op_tuple vfs_default_ops[] = { /* Disk operations */ @@ -1442,6 +1474,16 @@ static vfs_op_tuple vfs_default_ops[] = { {SMB_VFS_OP(vfswrap_aio_suspend),SMB_VFS_OP_AIO_SUSPEND, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_aio_force), SMB_VFS_OP_AIO_FORCE, + SMB_VFS_LAYER_OPAQUE}, + + {SMB_VFS_OP(vfswrap_is_offline),SMB_VFS_OP_IS_OFFLINE, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_set_offline),SMB_VFS_OP_SET_OFFLINE, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_is_remotestorage),SMB_VFS_OP_IS_REMOTESTORAGE, + SMB_VFS_LAYER_OPAQUE}, + /* Finish VFS operations definition */ {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, -- cgit From 313f7d10b884d083ef9488db739465c54c3f6515 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 16 Jan 2008 12:18:57 +0300 Subject: Merge latest fixes to vfs_gpfs and NFS4 ACLs from Samba 3.0 CTDB branch (from http://samba.org/~tridge/3_0-ctdb) Signed-off-by: Alexander Bokovoy (This used to be commit 1daad835cbfb4615a8fe7a241f4d578f7e69f214) --- source3/modules/gpfs.c | 20 ++-- source3/modules/nfs4_acls.c | 187 +++++++++++++++++++++++------ source3/modules/vfs_gpfs.c | 281 +++++++++++++++++++++++++++++++++++--------- source3/modules/vfs_gpfs.h | 32 +++++ 4 files changed, 423 insertions(+), 97 deletions(-) create mode 100644 source3/modules/vfs_gpfs.h (limited to 'source3/modules') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index 300e90fa69..590dbac26f 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -22,9 +22,11 @@ #ifdef HAVE_GPFS #include "gpfs_gpl.h" +#include "vfs_gpfs.h" static void *libgpfs_handle = NULL; static bool gpfs_share_modes; +static bool gpfs_leases; static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType); @@ -42,7 +44,7 @@ bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, if (!gpfs_share_modes) { return True; } - + if (gpfs_set_share_fn == NULL) { return False; } @@ -88,7 +90,7 @@ int set_gpfs_lease(int fd, int leasetype) { int gpfs_type = GPFS_LEASE_NONE; - if (!gpfs_share_modes) { + if (!gpfs_leases) { return True; } @@ -103,6 +105,13 @@ int set_gpfs_lease(int fd, int leasetype) if (leasetype == F_WRLCK) { gpfs_type = GPFS_LEASE_WRITE; } + + /* we unconditionally set CAP_LEASE, rather than looking for + -1/EACCES as there is a bug in some versions of + libgpfs_gpl.so which results in a leaked fd on /dev/ss0 + each time we try this with the wrong capabilities set + */ + linux_set_lease_capability(); return gpfs_set_lease_fn(fd, gpfs_type); } @@ -172,11 +181,8 @@ void init_gpfs(void) goto failed; } - if (lp_parm_bool(-1, "gpfs", "sharemodes", True)) { - gpfs_share_modes = True; - } else { - gpfs_share_modes = False; - } + gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True); + gpfs_leases = lp_parm_bool(-1, "gpfs", "leases", True); return; diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 52d3983fff..0c3d010dcd 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -20,6 +20,9 @@ #include "includes.h" #include "nfs4_acls.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_ACLS + #define SMBACL4_PARAM_TYPE_NAME "nfs4" #define SMB_ACE4_INT_MAGIC 0x76F8A967 @@ -352,6 +355,7 @@ typedef struct _smbacl4_vfs_params { enum smbacl4_mode_enum mode; bool do_chown; enum smbacl4_acedup_enum acedup; + struct db_context *sid_mapping_table; } smbacl4_vfs_params; /* @@ -451,8 +455,65 @@ static SMB_ACE4PROP_T *smbacl4_find_equal_special( return NULL; } -static int smbacl4_fill_ace4( +static bool nfs4_map_sid(smbacl4_vfs_params *params, const DOM_SID *src, + DOM_SID *dst) +{ + static struct db_context *mapping_db = NULL; + TDB_DATA data; + + if (mapping_db == NULL) { + const char *dbname = lp_parm_const_string( + -1, SMBACL4_PARAM_TYPE_NAME, "sidmap", NULL); + + if (dbname == NULL) { + DEBUG(10, ("%s:sidmap not defined\n", + SMBACL4_PARAM_TYPE_NAME)); + return False; + } + + become_root(); + mapping_db = db_open(NULL, dbname, 0, TDB_DEFAULT, + O_RDONLY, 0600); + unbecome_root(); + + if (mapping_db == NULL) { + DEBUG(1, ("could not open sidmap: %s\n", + strerror(errno))); + return False; + } + } + + if (mapping_db->fetch(mapping_db, NULL, + string_term_tdb_data(sid_string_tos(src)), + &data) == -1) { + DEBUG(10, ("could not find mapping for SID %s\n", + sid_string_dbg(src))); + return False; + } + + if ((data.dptr == NULL) || (data.dsize <= 0) + || (data.dptr[data.dsize-1] != '\0')) { + DEBUG(5, ("invalid mapping for SID %s\n", + sid_string_dbg(src))); + TALLOC_FREE(data.dptr); + return False; + } + + if (!string_to_sid(dst, (char *)data.dptr)) { + DEBUG(1, ("invalid mapping %s for SID %s\n", + (char *)data.dptr, sid_string_dbg(src))); + TALLOC_FREE(data.dptr); + return False; + } + + TALLOC_FREE(data.dptr); + + return True; +} + +static bool smbacl4_fill_ace4( TALLOC_CTX *mem_ctx, + const char *filename, smbacl4_vfs_params *params, uid_t ownerUID, gid_t ownerGID, @@ -460,11 +521,6 @@ static int smbacl4_fill_ace4( SMB_ACE4PROP_T *ace_v4 /* output */ ) { - const char *dom, *name; - enum lsa_SidType type; - uid_t uid; - gid_t gid; - DEBUG(10, ("got ace for %s\n", sid_string_dbg(&ace_nt->trustee))); memset(ace_v4, 0, sizeof(SMB_ACE4PROP_T)); @@ -485,18 +541,46 @@ static int smbacl4_fill_ace4( ace_v4->who.special_id = SMB_ACE4_WHO_EVERYONE; ace_v4->flags |= SMB_ACE4_ID_SPECIAL; } else { - if (!lookup_sid(mem_ctx, &ace_nt->trustee, &dom, &name, &type)) { - DEBUG(8, ("Could not find %s' type\n", - sid_string_dbg(&ace_nt->trustee))); - errno = EINVAL; - return -1; + const char *dom, *name; + enum lsa_SidType type; + uid_t uid; + gid_t gid; + DOM_SID sid; + + sid_copy(&sid, &ace_nt->trustee); + + if (!lookup_sid(mem_ctx, &sid, &dom, &name, &type)) { + + DOM_SID mapped; + + if (!nfs4_map_sid(params, &sid, &mapped)) { + DEBUG(1, ("nfs4_acls.c: file [%s]: SID %s " + "unknown\n", filename, sid_string_dbg(&sid))); + errno = EINVAL; + return False; + } + + DEBUG(2, ("nfs4_acls.c: file [%s]: mapped SID %s " + "to %s\n", filename, sid_string_dbg(&sid), sid_string_dbg(&mapped))); + + if (!lookup_sid(mem_ctx, &mapped, &dom, + &name, &type)) { + DEBUG(1, ("nfs4_acls.c: file [%s]: SID %s " + "mapped from %s is unknown\n", + filename, sid_string_dbg(&mapped), sid_string_dbg(&sid))); + errno = EINVAL; + return False; + } + + sid_copy(&sid, &mapped); } - + if (type == SID_NAME_USER) { - if (!sid_to_uid(&ace_nt->trustee, &uid)) { - DEBUG(2, ("Could not convert %s to uid\n", - sid_string_dbg(&ace_nt->trustee))); - return -1; + if (!sid_to_uid(&sid, &uid)) { + DEBUG(1, ("nfs4_acls.c: file [%s]: could not " + "convert %s to uid\n", filename, + sid_string_dbg(&sid))); + return False; } if (params->mode==e_special && uid==ownerUID) { @@ -506,11 +590,13 @@ static int smbacl4_fill_ace4( ace_v4->who.uid = uid; } } else { /* else group? - TODO check it... */ - if (!sid_to_gid(&ace_nt->trustee, &gid)) { - DEBUG(2, ("Could not convert %s to gid\n", - sid_string_dbg(&ace_nt->trustee))); - return -1; + if (!sid_to_gid(&sid, &gid)) { + DEBUG(1, ("nfs4_acls.c: file [%s]: could not " + "convert %s to gid\n", filename, + sid_string_dbg(&sid))); + return False; } + ace_v4->aceFlags |= SMB_ACE4_IDENTIFIER_GROUP; if (params->mode==e_special && gid==ownerGID) { @@ -522,7 +608,7 @@ static int smbacl4_fill_ace4( } } - return 0; /* OK */ + return True; /* OK */ } static int smbacl4_MergeIgnoreReject( @@ -560,6 +646,7 @@ static int smbacl4_MergeIgnoreReject( } static SMB4ACL_T *smbacl4_win2nfs4( + const char *filename, SEC_ACL *dacl, smbacl4_vfs_params *pparams, uid_t ownerUID, @@ -580,9 +667,14 @@ static SMB4ACL_T *smbacl4_win2nfs4( SMB_ACE4PROP_T ace_v4; bool addNewACE = True; - if (smbacl4_fill_ace4(mem_ctx, pparams, ownerUID, ownerGID, - dacl->aces + i, &ace_v4)) - return NULL; + if (!smbacl4_fill_ace4(mem_ctx, filename, pparams, + ownerUID, ownerGID, + dacl->aces + i, &ace_v4)) { + DEBUG(3, ("Could not fill ace for file %s, SID %s\n", + filename, + sid_string_dbg(&((dacl->aces+i)->trustee)))); + continue; + } if (pparams->acedup!=e_dontcare) { if (smbacl4_MergeIgnoreReject(pparams->acedup, acl, @@ -607,6 +699,7 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, bool result; SMB_STRUCT_STAT sbuf; + bool need_chown = False; uid_t newUID = (uid_t)-1; gid_t newGID = (gid_t)-1; @@ -635,25 +728,33 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, return status; } if (((newUID != (uid_t)-1) && (sbuf.st_uid != newUID)) || - ((newGID != (gid_t)-1) && (sbuf.st_gid != newGID))) { - if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { - DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n", - fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, strerror(errno) )); - if (errno == EPERM) { - return NT_STATUS_INVALID_OWNER; + ((newGID != (gid_t)-1) && (sbuf.st_gid != newGID))) { + need_chown = True; + } + if (need_chown) { + if ((newUID == (uid_t)-1 || newUID == current_user.ut.uid)) { + if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { + DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n", + fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, + strerror(errno))); + return map_nt_error_from_unix(errno); } - return map_nt_error_from_unix(errno); + + DEBUG(10,("chown %s, %u, %u succeeded.\n", + fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); + if (smbacl4_GetFileOwner(fsp->conn, fsp->fsp_name, &sbuf)) + return map_nt_error_from_unix(errno); + need_chown = False; + } else { /* chown is needed, but _after_ changing acl */ + sbuf.st_uid = newUID; /* OWNER@ in case of e_special */ + sbuf.st_gid = newGID; /* GROUP@ in case of e_special */ } - DEBUG(10,("chown %s, %u, %u succeeded.\n", - fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); - if (smbacl4_fGetFileOwner(fsp, &sbuf)) - return map_nt_error_from_unix(errno); } } if ((security_info_sent & DACL_SECURITY_INFORMATION)!=0 && psd->dacl!=NULL) { - acl = smbacl4_win2nfs4(psd->dacl, ¶ms, sbuf.st_uid, sbuf.st_gid); + acl = smbacl4_win2nfs4(fsp->fsp_name, psd->dacl, ¶ms, sbuf.st_uid, sbuf.st_gid); if (!acl) return map_nt_error_from_unix(errno); @@ -668,6 +769,20 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, } else DEBUG(10, ("no dacl found; security_info_sent = 0x%x\n", security_info_sent)); + /* Any chown pending? */ + if (need_chown) { + DEBUG(3,("chown#2 %s. uid = %u, gid = %u.\n", + fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); + if (try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { + DEBUG(2,("chown#2 %s, %u, %u failed. Error = %s.\n", + fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, + strerror(errno))); + return map_nt_error_from_unix(errno); + } + DEBUG(10,("chown#2 %s, %u, %u succeeded.\n", + fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); + } + DEBUG(10, ("smb_set_nt_acl_nfs4 succeeded\n")); return NT_STATUS_OK; } diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index bcf61f3bc7..d10906dfb1 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -30,7 +30,7 @@ #include #include "nfs4_acls.h" - +#include "vfs_gpfs.h" static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, uint32 share_mode) @@ -153,7 +153,7 @@ static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl) DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname)); /* First get the real acl length */ - gacl = gpfs_getacl_alloc(fname, GPFS_ACL_TYPE_NFS4); + gacl = gpfs_getacl_alloc(fname, 0); if (gacl == NULL) { DEBUG(9, ("gpfs_getacl failed for %s with %s\n", fname, strerror(errno))); @@ -208,10 +208,10 @@ static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl) if (i > 0 && gace->aceType == SMB_ACE4_ACCESS_DENIED_ACE_TYPE) { struct gpfs_ace_v4 *prev = &gacl->ace_v4[i-1]; if (prev->aceType == SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE && - prev->aceFlags == gace->aceFlags && - prev->aceIFlags == gace->aceIFlags && - (gace->aceMask & prev->aceMask) == 0 && - gace->aceWho == prev->aceWho) { + prev->aceFlags == gace->aceFlags && + prev->aceIFlags == gace->aceIFlags && + (gace->aceMask & prev->aceMask) == 0 && + gace->aceWho == prev->aceWho) { /* its redundent - skip it */ continue; } @@ -256,7 +256,7 @@ static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle, int result; *ppdesc = NULL; - result = gpfs_get_nfs4_acl(fsp->fsp_name, &pacl); + result = gpfs_get_nfs4_acl(name, &pacl); if (result == 0) return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc, pacl); @@ -301,8 +301,31 @@ static bool gpfsacl_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl) gace->aceType = aceprop->aceType; gace->aceFlags = aceprop->aceFlags; gace->aceMask = aceprop->aceMask; + + /* + * GPFS can't distinguish between WRITE and APPEND on + * files, so one being set without the other is an + * error. Sorry for the many ()'s :-) + */ + + if (!fsp->is_directory + && + ((((gace->aceMask & ACE4_MASK_WRITE) == 0) + && ((gace->aceMask & ACE4_MASK_APPEND) != 0)) + || + (((gace->aceMask & ACE4_MASK_WRITE) != 0) + && ((gace->aceMask & ACE4_MASK_APPEND) == 0))) + && + lp_parm_bool(fsp->conn->params->service, "gpfs", + "merge_writeappend", True)) { + DEBUG(2, ("vfs_gpfs.c: file [%s]: ACE contains " + "WRITE^APPEND, setting WRITE|APPEND\n", + fsp->fsp_name)); + gace->aceMask |= ACE4_MASK_WRITE|ACE4_MASK_APPEND; + } + gace->aceIFlags = (aceprop->flags&SMB_ACE4_ID_SPECIAL) ? ACE4_IFLAG_SPECIAL_ID : 0; - + if (aceprop->flags&SMB_ACE4_ID_SPECIAL) { switch(aceprop->who.special_id) @@ -347,7 +370,7 @@ static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_i struct gpfs_acl *acl; NTSTATUS result = NT_STATUS_ACCESS_DENIED; - acl = gpfs_getacl_alloc(fsp->fsp_name, GPFS_ACL_TYPE_ACCESS); + acl = gpfs_getacl_alloc(fsp->fsp_name, 0); if (acl == NULL) return result; @@ -628,75 +651,225 @@ int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle, return -1; } +/* + * Assumed: mode bits are shiftable and standard + * Output: the new aceMask field for an smb nfs4 ace + */ +static uint32 gpfsacl_mask_filter(uint32 aceType, uint32 aceMask, uint32 rwx) +{ + const uint32 posix_nfs4map[3] = { + SMB_ACE4_EXECUTE, /* execute */ + SMB_ACE4_WRITE_DATA | SMB_ACE4_APPEND_DATA, /* write; GPFS specific */ + SMB_ACE4_READ_DATA /* read */ + }; + int i; + uint32_t posix_mask = 0x01; + uint32_t posix_bit; + uint32_t nfs4_bits; + + for(i=0; i<3; i++) { + nfs4_bits = posix_nfs4map[i]; + posix_bit = rwx & posix_mask; + + if (aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE) { + if (posix_bit) + aceMask |= nfs4_bits; + else + aceMask &= ~nfs4_bits; + } else { + /* add deny bits when suitable */ + if (!posix_bit) + aceMask |= nfs4_bits; + else + aceMask &= ~nfs4_bits; + } /* other ace types are unexpected */ + + posix_mask <<= 1; + } + + return aceMask; +} + +static int gpfsacl_emu_chmod(const char *path, mode_t mode) +{ + SMB4ACL_T *pacl = NULL; + int result; + bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False}; + int i; + files_struct fake_fsp; /* TODO: rationalize parametrization */ + SMB4ACE_T *smbace; + + DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode)); + + result = gpfs_get_nfs4_acl(path, &pacl); + if (result) + return result; + + if (mode & ~(S_IRWXU | S_IRWXG | S_IRWXO)) { + DEBUG(2, ("WARNING: cutting extra mode bits %o on %s\n", mode, path)); + } + + for (smbace=smb_first_ace4(pacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) { + SMB_ACE4PROP_T *ace = smb_get_ace4(smbace); + uint32_t specid = ace->who.special_id; + + if (ace->flags&SMB_ACE4_ID_SPECIAL && + ace->aceType<=SMB_ACE4_ACCESS_DENIED_ACE_TYPE && + specid <= SMB_ACE4_WHO_EVERYONE) { + + uint32_t newMask; + + if (ace->aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE) + haveAllowEntry[specid] = True; + + /* mode >> 6 for @owner, mode >> 3 for @group, + * mode >> 0 for @everyone */ + newMask = gpfsacl_mask_filter(ace->aceType, ace->aceMask, + mode >> ((SMB_ACE4_WHO_EVERYONE - specid) * 3)); + if (ace->aceMask!=newMask) { + DEBUG(10, ("ace changed for %s (%o -> %o) id=%d\n", + path, ace->aceMask, newMask, specid)); + } + ace->aceMask = newMask; + } + } + + /* make sure we have at least ALLOW entries + * for all the 3 special ids (@EVERYONE, @OWNER, @GROUP) + * - if necessary + */ + for(i = SMB_ACE4_WHO_OWNER; i<=SMB_ACE4_WHO_EVERYONE; i++) { + SMB_ACE4PROP_T ace; + + if (haveAllowEntry[i]==True) + continue; + + memset(&ace, 0, sizeof(SMB_ACE4PROP_T)); + ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE; + ace.flags |= SMB_ACE4_ID_SPECIAL; + ace.who.special_id = i; + + if (i==SMB_ACE4_WHO_GROUP) /* not sure it's necessary... */ + ace.aceFlags |= SMB_ACE4_IDENTIFIER_GROUP; + + ace.aceMask = gpfsacl_mask_filter(ace.aceType, ace.aceMask, + mode >> ((SMB_ACE4_WHO_EVERYONE - i) * 3)); + + /* don't add unnecessary aces */ + if (!ace.aceMask) + continue; + + /* we add it to the END - as windows expects allow aces */ + smb_add_ace4(pacl, &ace); + DEBUG(10, ("Added ALLOW ace for %s, mode=%o, id=%d, aceMask=%x\n", + path, mode, i, ace.aceMask)); + } + + /* don't add complementary DENY ACEs here */ + memset(&fake_fsp, 0, sizeof(struct files_struct)); + fake_fsp.fsp_name = (char *)path; /* no file_new is needed here */ + + /* put the acl */ + if (gpfsacl_process_smbacl(&fake_fsp, pacl) == False) + return -1; + return 0; /* ok for [f]chmod */ +} + static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mode) { SMB_STRUCT_STAT st; + int rc; + if (SMB_VFS_NEXT_STAT(handle, path, &st) != 0) { - return -1; + return -1; } + /* avoid chmod() if possible, to preserve acls */ if ((st.st_mode & ~S_IFMT) == mode) { - return 0; + return 0; } - return SMB_VFS_NEXT_CHMOD(handle, path, mode); + + rc = gpfsacl_emu_chmod(path, mode); + if (rc == 1) + return SMB_VFS_NEXT_CHMOD(handle, path, mode); + return rc; } static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { SMB_STRUCT_STAT st; + int rc; + if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) { - return -1; + return -1; } + /* avoid chmod() if possible, to preserve acls */ if ((st.st_mode & ~S_IFMT) == mode) { - return 0; + return 0; } - return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); + + rc = gpfsacl_emu_chmod(fsp->fsp_name, mode); + if (rc == 1) + return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); + return rc; } /* VFS operations structure */ static vfs_op_tuple gpfs_op_tuples[] = { - - { SMB_VFS_OP(vfs_gpfs_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK, - SMB_VFS_LAYER_OPAQUE }, - - { SMB_VFS_OP(vfs_gpfs_setlease), SMB_VFS_OP_LINUX_SETLEASE, - SMB_VFS_LAYER_OPAQUE }, - - { SMB_VFS_OP(gpfsacl_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(gpfsacl_get_nt_acl), SMB_VFS_OP_GET_NT_ACL, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(gpfsacl_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(gpfsacl_set_nt_acl), SMB_VFS_OP_SET_NT_ACL, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(gpfsacl_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(gpfsacl_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(gpfsacl_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(gpfsacl_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD, - SMB_VFS_LAYER_TRANSPARENT }, - + + { SMB_VFS_OP(vfs_gpfs_kernel_flock), + SMB_VFS_OP_KERNEL_FLOCK, + SMB_VFS_LAYER_OPAQUE }, + + { SMB_VFS_OP(vfs_gpfs_setlease), + SMB_VFS_OP_LINUX_SETLEASE, + SMB_VFS_LAYER_OPAQUE }, + + { SMB_VFS_OP(gpfsacl_fget_nt_acl), + SMB_VFS_OP_FGET_NT_ACL, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(gpfsacl_get_nt_acl), + SMB_VFS_OP_GET_NT_ACL, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(gpfsacl_fset_nt_acl), + SMB_VFS_OP_FSET_NT_ACL, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(gpfsacl_set_nt_acl), + SMB_VFS_OP_SET_NT_ACL, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(gpfsacl_sys_acl_get_file), + SMB_VFS_OP_SYS_ACL_GET_FILE, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(gpfsacl_sys_acl_get_fd), + SMB_VFS_OP_SYS_ACL_GET_FD, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(gpfsacl_sys_acl_set_file), + SMB_VFS_OP_SYS_ACL_SET_FILE, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(gpfsacl_sys_acl_set_fd), + SMB_VFS_OP_SYS_ACL_SET_FD, + SMB_VFS_LAYER_TRANSPARENT }, + { SMB_VFS_OP(gpfsacl_sys_acl_delete_def_file), - SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(vfs_gpfs_chmod), SMB_VFS_OP_CHMOD, - SMB_VFS_LAYER_TRANSPARENT }, - - { SMB_VFS_OP(vfs_gpfs_fchmod), SMB_VFS_OP_FCHMOD, - SMB_VFS_LAYER_TRANSPARENT }, + SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(vfs_gpfs_chmod), + SMB_VFS_OP_CHMOD, + SMB_VFS_LAYER_TRANSPARENT }, + + { SMB_VFS_OP(vfs_gpfs_fchmod), + SMB_VFS_OP_FCHMOD, + SMB_VFS_LAYER_TRANSPARENT }, { SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP } diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h new file mode 100644 index 0000000000..3c499b0850 --- /dev/null +++ b/source3/modules/vfs_gpfs.h @@ -0,0 +1,32 @@ +/* + Unix SMB/CIFS implementation. + Wrap gpfs calls in vfs functions. + + Copyright (C) Christian Ambach 2006 + + Major code contributions by Chetan Shringarpure + and Gomati Mohanan + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + +*/ + +bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, + uint32 share_access); +int set_gpfs_lease(int fd, int leasetype); +int smbd_gpfs_getacl(char *pathname, int flags, void *acl); +int smbd_gpfs_putacl(char *pathname, int flags, void *acl); +void init_gpfs(void); -- cgit From c283c1bb8b3a167ab20140dac914f3b6ddc21aec Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 16 Jan 2008 12:19:51 +0300 Subject: Support GPFS prealloc interface Signed-off-by: Alexander Bokovoy (This used to be commit c26e355533e473c4386d0e6d651637e71d4231dc) --- source3/modules/vfs_prealloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/modules') diff --git a/source3/modules/vfs_prealloc.c b/source3/modules/vfs_prealloc.c index 2d64bc0184..cb3508dc30 100644 --- a/source3/modules/vfs_prealloc.c +++ b/source3/modules/vfs_prealloc.c @@ -47,11 +47,16 @@ #define lock_type struct flock64 #endif +#ifdef HAVE_GPFS +#include "gpfs_gpl.h" +#endif + #define MODULE "prealloc" static int module_debug; static int preallocate_space(int fd, SMB_OFF_T size) { +#ifndef HAVE_GPFS lock_type fl = {0}; int err; @@ -78,6 +83,9 @@ static int preallocate_space(int fd, SMB_OFF_T size) err = -1; errno = ENOSYS; #endif +#else /* GPFS uses completely different interface */ + err = gpfs_prealloc(fd, (gpfs_off64_t)0, (gpfs_off64_t)size); +#endif if (err) { DEBUG(module_debug, -- cgit From d52b66daac5ffdedb11dc0e346d55d94890d9fbf Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 16 Jan 2008 12:21:38 +0300 Subject: Merge a variant of Shadow Copy module for exposing snapshots to windows clients as shadow copies from Samba 3.0 CTDB This is a 2nd implemetation of a shadow copy module for exposing snapshots to windows clients as shadow copies. This version has the following features: 1) you don't need to populate your shares with symlinks to the snapshots. This can be very important when you have thousands of shares, or use [homes] 2) the inode number of the files is altered so it is different from the original. This allows the 'restore' button to work without a sharing violation Signed-off-by: Alexander Bokovoy (This used to be commit 10c2ae1efd799b44255ce82c3bb0c7c9df0ec634) --- source3/modules/vfs_shadow_copy2.c | 637 +++++++++++++++++++++++++++++++++++++ 1 file changed, 637 insertions(+) create mode 100644 source3/modules/vfs_shadow_copy2.c (limited to 'source3/modules') diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c new file mode 100644 index 0000000000..54fc672b9c --- /dev/null +++ b/source3/modules/vfs_shadow_copy2.c @@ -0,0 +1,637 @@ +/* + * implementation of an Shadow Copy module - version 2 + * + * Copyright (C) Andrew Tridgell 2007 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +/* + + This is a 2nd implemetation of a shadow copy module for exposing + snapshots to windows clients as shadow copies. This version has the + following features: + + 1) you don't need to populate your shares with symlinks to the + snapshots. This can be very important when you have thousands of + shares, or use [homes] + + 2) the inode number of the files is altered so it is different + from the original. This allows the 'restore' button to work + without a sharing violation + + Module options: + + shadow:snapdir = + + This is the directory containing the @GMT-* snapshot directories. If it is an absolute + path it is used as-is. If it is a relative path, then it is taken relative to the mount + point of the filesystem that the root of this share is on + + shadow:basedir = + + This is an optional parameter that specifies the directory that + the snapshots are relative to. It defaults to the filesystem + mount point + + shadow:fixinodes = yes/no + + If you enable shadow:fixinodes then this module will modify the + apparent inode number of files in the snapshot directories using + a hash of the files path. This is needed for snapshot systems + where the snapshots have the same device:inode number as the + original files (such as happens with GPFS snapshots). If you + don't set this option then the 'restore' button in the shadow + copy UI will fail with a sharing violation. + + Note that the directory names in the snapshot directory must take the form + @GMT-YYYY.MM.DD-HH.MM.SS + + The following command would generate a correctly formatted directory name: + date -u +@GMT-%Y.%m.%d-%H.%M.%S + + */ + +static int vfs_shadow_copy2_debug_level = DBGC_VFS; + +#undef DBGC_CLASS +#define DBGC_CLASS vfs_shadow_copy2_debug_level + +#define GMT_NAME_LEN 24 /* length of a @GMT- name */ + +/* + make very sure it is one of our special names + */ +static inline bool shadow_copy2_match_name(const char *name) +{ + unsigned year, month, day, hr, min, sec; + if (name[0] != '@') return False; + if (strncmp(name, "@GMT-", 5) != 0) return False; + if (sscanf(name, "@GMT-%04u.%02u.%02u-%02u.%02u.%02u", &year, &month, + &day, &hr, &min, &sec) != 6) { + return False; + } + if (name[24] != 0 && name[24] != '/') { + return False; + } + return True; +} + +/* + convert a name to the shadow directory + */ + +#define _SHADOW2_NEXT(op, args, rtype, eret, extra) do { \ + const char *name = fname; \ + if (shadow_copy2_match_name(fname)) { \ + char *name2; \ + rtype ret; \ + name2 = convert_shadow2_name(handle, fname); \ + if (name2 == NULL) { \ + errno = EINVAL; \ + return eret; \ + } \ + name = name2; \ + ret = SMB_VFS_NEXT_ ## op args; \ + talloc_free(name2); \ + if (ret != eret) extra; \ + return ret; \ + } else { \ + return SMB_VFS_NEXT_ ## op args; \ + } \ +} while (0) + +/* + convert a name to the shadow directory: NTSTATUS-specific handling + */ + +#define _SHADOW2_NTSTATUS_NEXT(op, args, eret, extra) do { \ + const char *name = fname; \ + if (shadow_copy2_match_name(fname)) { \ + char *name2; \ + NTSTATUS ret; \ + name2 = convert_shadow2_name(handle, fname); \ + if (name2 == NULL) { \ + errno = EINVAL; \ + return eret; \ + } \ + name = name2; \ + ret = SMB_VFS_NEXT_ ## op args; \ + talloc_free(name2); \ + if (!NT_STATUS_EQUAL(ret, eret)) extra; \ + return ret; \ + } else { \ + return SMB_VFS_NEXT_ ## op args; \ + } \ +} while (0) + +#define SHADOW2_NTSTATUS_NEXT(op, args, eret) _SHADOW2_NTSTATUS_NEXT(op, args, eret, ) + +#define SHADOW2_NEXT(op, args, rtype, eret) _SHADOW2_NEXT(op, args, rtype, eret, ) + +#define SHADOW2_NEXT2(op, args) do { \ + if (shadow_copy2_match_name(oldname) || shadow_copy2_match_name(newname)) { \ + errno = EROFS; \ + return -1; \ + } else { \ + return SMB_VFS_NEXT_ ## op args; \ + } \ +} while (0) + + +/* + find the mount point of a filesystem + */ +static char *find_mount_point(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle) +{ + char *path = talloc_strdup(mem_ctx, handle->conn->connectpath); + dev_t dev; + struct stat st; + char *p; + + if (stat(path, &st) != 0) { + talloc_free(path); + return NULL; + } + + dev = st.st_dev; + + while ((p = strrchr(path, '/')) && p > path) { + *p = 0; + if (stat(path, &st) != 0) { + talloc_free(path); + return NULL; + } + if (st.st_dev != dev) { + *p = '/'; + break; + } + } + + return path; +} + +/* + work out the location of the snapshot for this share + */ +static const char *shadow_copy2_find_snapdir(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle) +{ + const char *snapdir; + char *mount_point; + const char *ret; + + snapdir = lp_parm_const_string(SNUM(handle->conn), "shadow", "snapdir", NULL); + if (snapdir == NULL) { + return NULL; + } + /* if its an absolute path, we're done */ + if (*snapdir == '/') { + return snapdir; + } + + /* other its relative to the filesystem mount point */ + mount_point = find_mount_point(mem_ctx, handle); + if (mount_point == NULL) { + return NULL; + } + + ret = talloc_asprintf(mem_ctx, "%s/%s", mount_point, snapdir); + talloc_free(mount_point); + return ret; +} + +/* + work out the location of the base directory for snapshots of this share + */ +static const char *shadow_copy2_find_basedir(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle) +{ + const char *basedir = lp_parm_const_string(SNUM(handle->conn), "shadow", "basedir", NULL); + + /* other its the filesystem mount point */ + if (basedir == NULL) { + basedir = find_mount_point(mem_ctx, handle); + } + + return basedir; +} + +/* + convert a filename from a share relative path, to a path in the + snapshot directory + */ +static char *convert_shadow2_name(vfs_handle_struct *handle, const char *fname) +{ + TALLOC_CTX *tmp_ctx = talloc_new(handle->data); + const char *snapdir, *relpath, *baseoffset, *basedir; + size_t baselen; + char *ret; + + snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle); + if (snapdir == NULL) { + DEBUG(2,("no snapdir found for share at %s\n", handle->conn->connectpath)); + talloc_free(tmp_ctx); + return NULL; + } + + basedir = shadow_copy2_find_basedir(tmp_ctx, handle); + if (basedir == NULL) { + DEBUG(2,("no basedir found for share at %s\n", handle->conn->connectpath)); + talloc_free(tmp_ctx); + return NULL; + } + + relpath = fname + GMT_NAME_LEN; + baselen = strlen(basedir); + baseoffset = handle->conn->connectpath + baselen; + + /* some sanity checks */ + if (strncmp(basedir, handle->conn->connectpath, baselen) != 0 || + (handle->conn->connectpath[baselen] != 0 && handle->conn->connectpath[baselen] != '/')) { + DEBUG(0,("convert_shadow2_name: basedir %s is not a parent of %s\n", + basedir, handle->conn->connectpath)); + talloc_free(tmp_ctx); + return NULL; + } + + if (*relpath == '/') relpath++; + if (*baseoffset == '/') baseoffset++; + + ret = talloc_asprintf(handle->data, "%s/%.*s/%s/%s", + snapdir, + GMT_NAME_LEN, fname, + baseoffset, + relpath); + DEBUG(6,("convert_shadow2_name: '%s' -> '%s'\n", fname, ret)); + talloc_free(tmp_ctx); + return ret; +} + + +/* + simple string hash + */ +static uint32 string_hash(const char *s) +{ + uint32 n = 0; + while (*s) { + n = ((n << 5) + n) ^ (uint32)(*s++); + } + return n; +} + +/* + modify a sbuf return to ensure that inodes in the shadow directory + are different from those in the main directory + */ +static void convert_sbuf(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf) +{ + if (lp_parm_bool(SNUM(handle->conn), "shadow", "fixinodes", False)) { + /* some snapshot systems, like GPFS, return the name + device:inode for the snapshot files as the current + files. That breaks the 'restore' button in the shadow copy + GUI, as the client gets a sharing violation. + + This is a crude way of allowing both files to be + open at once. It has a slight chance of inode + number collision, but I can't see a better approach + without significant VFS changes + */ + uint32_t shash = string_hash(fname) & 0xFF000000; + if (shash == 0) { + shash = 1; + } + sbuf->st_ino ^= shash; + } +} + +static int shadow_copy2_rename(vfs_handle_struct *handle, + const char *oldname, const char *newname) +{ + SHADOW2_NEXT2(RENAME, (handle, oldname, newname)); +} + +static int shadow_copy2_symlink(vfs_handle_struct *handle, + const char *oldname, const char *newname) +{ + SHADOW2_NEXT2(SYMLINK, (handle, oldname, newname)); +} + +static int shadow_copy2_link(vfs_handle_struct *handle, + const char *oldname, const char *newname) +{ + SHADOW2_NEXT2(LINK, (handle, oldname, newname)); +} + +static int shadow_copy2_open(vfs_handle_struct *handle, + const char *fname, files_struct *fsp, int flags, mode_t mode) +{ + SHADOW2_NEXT(OPEN, (handle, name, fsp, flags, mode), int, -1); +} + +static SMB_STRUCT_DIR *shadow_copy2_opendir(vfs_handle_struct *handle, + const char *fname, const char *mask, uint32 attr) +{ + SHADOW2_NEXT(OPENDIR, (handle, name, mask, attr), void*, NULL); +} + +static int shadow_copy2_stat(vfs_handle_struct *handle, + const char *fname, SMB_STRUCT_STAT *sbuf) +{ + _SHADOW2_NEXT(STAT, (handle, name, sbuf), int, -1, convert_sbuf(handle, fname, sbuf)); +} + +static int shadow_copy2_lstat(vfs_handle_struct *handle, + const char *fname, SMB_STRUCT_STAT *sbuf) +{ + _SHADOW2_NEXT(LSTAT, (handle, name, sbuf), int, -1, convert_sbuf(handle, fname, sbuf)); +} + +static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf) +{ + int ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); + if (ret == 0 && shadow_copy2_match_name(fsp->fsp_name)) { + convert_sbuf(handle, fsp->fsp_name, sbuf); + } + return ret; +} + +static int shadow_copy2_unlink(vfs_handle_struct *handle, const char *fname) +{ + SHADOW2_NEXT(UNLINK, (handle, name), int, -1); +} + +static int shadow_copy2_chmod(vfs_handle_struct *handle, + const char *fname, mode_t mode) +{ + SHADOW2_NEXT(CHMOD, (handle, name, mode), int, -1); +} + +static int shadow_copy2_chown(vfs_handle_struct *handle, + const char *fname, uid_t uid, gid_t gid) +{ + SHADOW2_NEXT(CHOWN, (handle, name, uid, gid), int, -1); +} + +static int shadow_copy2_chdir(vfs_handle_struct *handle, + const char *fname) +{ + SHADOW2_NEXT(CHDIR, (handle, name), int, -1); +} + +static int shadow_copy2_ntimes(vfs_handle_struct *handle, + const char *fname, const struct timespec ts[2]) +{ + SHADOW2_NEXT(NTIMES, (handle, name, ts), int, -1); +} + +static int shadow_copy2_readlink(vfs_handle_struct *handle, + const char *fname, char *buf, size_t bufsiz) +{ + SHADOW2_NEXT(READLINK, (handle, name, buf, bufsiz), int, -1); +} + +static int shadow_copy2_mknod(vfs_handle_struct *handle, + const char *fname, mode_t mode, SMB_DEV_T dev) +{ + SHADOW2_NEXT(MKNOD, (handle, name, mode, dev), int, -1); +} + +static char *shadow_copy2_realpath(vfs_handle_struct *handle, + const char *fname, char *resolved_path) +{ + SHADOW2_NEXT(REALPATH, (handle, name, resolved_path), void*, NULL); +} + +static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle, + const char *fname, uint32 security_info, + struct security_descriptor **ppdesc) +{ + SHADOW2_NTSTATUS_NEXT(GET_NT_ACL, (handle, name, security_info, ppdesc), NT_STATUS_ACCESS_DENIED); +} + +static NTSTATUS shadow_copy2_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, + const char *fname, uint32 security_info_sent, + struct security_descriptor *psd) +{ + SHADOW2_NTSTATUS_NEXT(SET_NT_ACL, (handle, fsp, name, security_info_sent, psd), NT_STATUS_ACCESS_DENIED); +} + +static int shadow_copy2_mkdir(vfs_handle_struct *handle, const char *fname, mode_t mode) +{ + SHADOW2_NEXT(MKDIR, (handle, name, mode), int, -1); +} + +static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname) +{ + SHADOW2_NEXT(RMDIR, (handle, name), int, -1); +} + +static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname, int flags) +{ + SHADOW2_NEXT(CHFLAGS, (handle, name, flags), int, -1); +} + +static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle, + const char *fname, const char *aname, void *value, size_t size) +{ + SHADOW2_NEXT(GETXATTR, (handle, name, aname, value, size), ssize_t, -1); +} + +static ssize_t shadow_copy2_lgetxattr(vfs_handle_struct *handle, + const char *fname, const char *aname, void *value, size_t size) +{ + SHADOW2_NEXT(LGETXATTR, (handle, name, aname, value, size), ssize_t, -1); +} + +static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle, const char *fname, + char *list, size_t size) +{ + SHADOW2_NEXT(LISTXATTR, (handle, name, list, size), ssize_t, -1); +} + +static int shadow_copy2_removexattr(struct vfs_handle_struct *handle, const char *fname, + const char *aname) +{ + SHADOW2_NEXT(REMOVEXATTR, (handle, name, aname), int, -1); +} + +static int shadow_copy2_lremovexattr(struct vfs_handle_struct *handle, const char *fname, + const char *aname) +{ + SHADOW2_NEXT(LREMOVEXATTR, (handle, name, aname), int, -1); +} + +static int shadow_copy2_setxattr(struct vfs_handle_struct *handle, const char *fname, + const char *aname, const void *value, size_t size, int flags) +{ + SHADOW2_NEXT(SETXATTR, (handle, name, aname, value, size, flags), int, -1); +} + +static int shadow_copy2_lsetxattr(struct vfs_handle_struct *handle, const char *fname, + const char *aname, const void *value, size_t size, int flags) +{ + SHADOW2_NEXT(LSETXATTR, (handle, name, aname, value, size, flags), int, -1); +} + +static int shadow_copy2_chmod_acl(vfs_handle_struct *handle, + const char *fname, mode_t mode) +{ + /* If the underlying VFS doesn't have ACL support... */ + if (!handle->vfs_next.ops.chmod_acl) { + errno = ENOSYS; + return -1; + } + SHADOW2_NEXT(CHMOD_ACL, (handle, name, mode), int, -1); +} + +static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle, + files_struct *fsp, + SHADOW_COPY_DATA *shadow_copy2_data, + bool labels) +{ + SMB_STRUCT_DIR *p; + const char *snapdir; + SMB_STRUCT_DIRENT *d; + TALLOC_CTX *tmp_ctx = talloc_new(handle->data); + + snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle); + if (snapdir == NULL) { + DEBUG(0,("shadow:snapdir not found for %s in get_shadow_copy_data\n", + handle->conn->connectpath)); + errno = EINVAL; + talloc_free(tmp_ctx); + return -1; + } + + p = SMB_VFS_NEXT_OPENDIR(handle, snapdir, NULL, 0); + + if (!p) { + DEBUG(0,("shadow_copy2: SMB_VFS_NEXT_OPENDIR() failed for '%s' - %s\n", + snapdir, strerror(errno))); + talloc_free(tmp_ctx); + return -1; + } + + talloc_free(tmp_ctx); + + shadow_copy2_data->num_volumes = 0; + shadow_copy2_data->labels = NULL; + + while ((d = SMB_VFS_NEXT_READDIR(handle, p))) { + SHADOW_COPY_LABEL *tlabels; + + /* ignore names not of the right form in the snapshot directory */ + if (!shadow_copy2_match_name(d->d_name)) { + continue; + } + + if (!labels) { + /* the caller doesn't want the labels */ + shadow_copy2_data->num_volumes++; + continue; + } + + tlabels = talloc_realloc(shadow_copy2_data->mem_ctx, + shadow_copy2_data->labels, + SHADOW_COPY_LABEL, shadow_copy2_data->num_volumes+1); + if (tlabels == NULL) { + DEBUG(0,("shadow_copy2: out of memory\n")); + SMB_VFS_NEXT_CLOSEDIR(handle, p); + return -1; + } + + strlcpy(tlabels[shadow_copy2_data->num_volumes], d->d_name, sizeof(*tlabels)); + shadow_copy2_data->num_volumes++; + shadow_copy2_data->labels = tlabels; + } + + SMB_VFS_NEXT_CLOSEDIR(handle,p); + return 0; +} + +/* VFS operations structure */ + +static vfs_op_tuple shadow_copy2_ops[] = { + {SMB_VFS_OP(shadow_copy2_opendir), SMB_VFS_OP_OPENDIR, SMB_VFS_LAYER_TRANSPARENT}, + + /* directory operations */ + {SMB_VFS_OP(shadow_copy2_mkdir), SMB_VFS_OP_MKDIR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_rmdir), SMB_VFS_OP_RMDIR, SMB_VFS_LAYER_TRANSPARENT}, + + /* xattr and flags operations */ + {SMB_VFS_OP(shadow_copy2_chflags), SMB_VFS_OP_CHFLAGS, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_listxattr), SMB_VFS_OP_LISTXATTR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_removexattr), SMB_VFS_OP_REMOVEXATTR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_lremovexattr),SMB_VFS_OP_LREMOVEXATTR,SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_setxattr), SMB_VFS_OP_SETXATTR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_lsetxattr), SMB_VFS_OP_LSETXATTR, SMB_VFS_LAYER_TRANSPARENT}, + + /* File operations */ + {SMB_VFS_OP(shadow_copy2_open), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_lstat), SMB_VFS_OP_LSTAT, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_fstat), SMB_VFS_OP_FSTAT, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_chmod), SMB_VFS_OP_CHMOD, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_ntimes), SMB_VFS_OP_NTIMES, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_symlink), SMB_VFS_OP_SYMLINK, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_readlink), SMB_VFS_OP_READLINK, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_link), SMB_VFS_OP_LINK, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_mknod), SMB_VFS_OP_MKNOD, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_realpath), SMB_VFS_OP_REALPATH, SMB_VFS_LAYER_TRANSPARENT}, + + /* NT File ACL operations */ + {SMB_VFS_OP(shadow_copy2_get_nt_acl), SMB_VFS_OP_GET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(shadow_copy2_set_nt_acl), SMB_VFS_OP_SET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT}, + + /* POSIX ACL operations */ + {SMB_VFS_OP(shadow_copy2_chmod_acl), SMB_VFS_OP_CHMOD_ACL, SMB_VFS_LAYER_TRANSPARENT}, + + /* special shadown copy op */ + {SMB_VFS_OP(shadow_copy2_get_shadow_copy2_data), + SMB_VFS_OP_GET_SHADOW_COPY_DATA,SMB_VFS_LAYER_OPAQUE}, + + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_shadow_copy2_init(void); +NTSTATUS vfs_shadow_copy2_init(void) +{ + NTSTATUS ret; + + ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "shadow_copy2", shadow_copy2_ops); + + if (!NT_STATUS_IS_OK(ret)) + return ret; + + vfs_shadow_copy2_debug_level = debug_add_class("shadow_copy2"); + if (vfs_shadow_copy2_debug_level == -1) { + vfs_shadow_copy2_debug_level = DBGC_VFS; + DEBUG(0, ("%s: Couldn't register custom debugging class!\n", + "vfs_shadow_copy2_init")); + } else { + DEBUG(10, ("%s: Debug class number of '%s': %d\n", + "vfs_shadow_copy2_init","shadow_copy2",vfs_shadow_copy2_debug_level)); + } + + return ret; +} -- cgit From e633e4ddab68212b47f9ce44d8194007f245b5f1 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 16 Jan 2008 12:26:35 +0300 Subject: Add offline storage support with Tivoli Storage Manager Space Manager Signed-off-by: Alexander Bokovoy (This used to be commit d7752449f38747d59c93869656a5f7c02ebdf084) --- source3/modules/vfs_tsmsm.c | 338 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 338 insertions(+) create mode 100644 source3/modules/vfs_tsmsm.c (limited to 'source3/modules') diff --git a/source3/modules/vfs_tsmsm.c b/source3/modules/vfs_tsmsm.c new file mode 100644 index 0000000000..fe791b24bf --- /dev/null +++ b/source3/modules/vfs_tsmsm.c @@ -0,0 +1,338 @@ +/* + Unix SMB/CIFS implementation. + Samba VFS module for handling offline files + with Tivoli Storage Manager Space Management + + (c) Alexander Bokovoy, 2007 + (c) Andrew Tridgell, 2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/* + This VFS module accepts following options: + tsmsm: hsm script = (/bin/true by default, i.e. does nothing) + hsm script should point to a shell script which accepts two arguments: + + where is currently 'offline' to set offline status of the + + tsmsm: online ratio = ratio to check reported size against actual file size (0.5 by default) + + The TSMSM VFS module tries to avoid calling expensive DMAPI calls with some heuristics + based on the fact that number of blocks reported of a file multiplied by 512 will be + bigger than 'online ratio' of actual size for online (non-migrated) files. + + If checks fail, we call DMAPI and ask for specific IBM attribute which present for + offline (migrated) files. If this attribute presents, we consider file offline. + */ + +#include "includes.h" + +#ifndef USE_DMAPI +#error "This module requires DMAPI support!" +#endif + +#ifdef HAVE_XFS_DMAPI_H +#include +#elif defined(HAVE_SYS_DMI_H) +#include +#elif defined(HAVE_SYS_JFSDMAPI_H) +#include +#elif defined(HAVE_SYS_DMAPI_H) +#include +#elif defined(HAVE_DMAPI_H) +#include +#endif + +#ifndef _ISOC99_SOURCE +#define _ISOC99_SOURCE +#endif + +#include + +/* optimisation tunables - used to avoid the DMAPI slow path */ +#define FILE_IS_ONLINE_RATIO 0.5 +#define DM_ATTRIB_OBJECT "IBMObj" +#define DM_ATTRIB_MIGRATED "IBMMig" + +struct tsmsm_struct { + dm_sessid_t sid; + float online_ratio; + char *hsmscript; +}; + +#define TSM_STRINGIFY(a) #a +#define TSM_TOSTRING(a) TSM_STRINGIFY(a) + +static void tsmsm_free_data(void **pptr) { + struct tsmsm_struct **tsmd = (struct tsmsm_struct **)pptr; + if(!tsmd) return; + TALLOC_FREE(*tsmd); +} + +static int tsmsm_connect(struct vfs_handle_struct *handle, + const char *service, + const char *user) { + struct tsmsm_struct *tsmd = TALLOC_ZERO_P(handle, struct tsmsm_struct); + const char *hsmscript, *tsmname; + const char *fres; + + if (!tsmd) { + DEBUG(0,("tsmsm_connect: out of memory!\n")); + return -1; + } + + tsmd->sid = *(dm_sessid_t*) dmapi_get_current_session(); + + if (tsmd->sid == DM_NO_SESSION) { + DEBUG(0,("tsmsm_connect: no DMAPI session for Samba is available!\n")); + TALLOC_FREE(tsmd); + return -1; + } + + tsmname = (handle->param ? handle->param : "tsmsm"); + hsmscript = lp_parm_const_string(SNUM(handle->conn), tsmname, + "hsm script", NULL); + if (hsmscript) { + tsmd->hsmscript = talloc_strdup(tsmd, hsmscript); + if(!tsmd->hsmscript) { + DEBUG(1, ("tsmsm_connect: can't allocate memory for hsm script path")); + TALLOC_FREE(tsmd); + return -1; + } + } else { + DEBUG(1, ("tsmsm_connect: can't call hsm script because it " + "is not set to anything in the smb.conf\n" + "Use %s: 'hsm script = path' to set it\n", + tsmname)); + TALLOC_FREE(tsmd); + return -1; + } + + fres = lp_parm_const_string(SNUM(handle->conn), tsmname, + "online ratio", TSM_TOSTRING(FILE_IS_ONLINE_RATIO)); + tsmd->online_ratio = strtof(fres, NULL); + if((tsmd->online_ratio == (float)0) || ((errno == ERANGE) && + ((tsmd->online_ratio == HUGE_VALF) || + (tsmd->online_ratio == HUGE_VALL)))) { + DEBUG(1, ("tsmsm_connect: error while getting online ratio from smb.conf." + "Default to %s.\n", TSM_TOSTRING(FILE_IS_ONLINE_RATIO))); + tsmd->online_ratio = FILE_IS_ONLINE_RATIO; + } + + /* Store the private data. */ + SMB_VFS_HANDLE_SET_DATA(handle, tsmd, tsmsm_free_data, + struct tsmsm_struct, return -1); + return SMB_VFS_NEXT_CONNECT(handle, service, user); +} + +static int tsmsm_is_offline(struct vfs_handle_struct *handle, + struct connection_struct *conn, + const char *path, + SMB_STRUCT_STAT *stbuf, + bool *offline) { + struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data; + void *dmhandle = NULL; + size_t dmhandle_len = 0; + size_t rlen; + dm_attrname_t dmname; + int ret; + + /* 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) */ + if (512 * (off_t)stbuf->st_blocks >= stbuf->st_size * tsmd->online_ratio) { + *offline = false; + DEBUG(10,("%s not offline: st_blocks=%ld st_size=%ld online_ratio=%.2f\n", + path, stbuf->st_blocks, stbuf->st_size, tsmd->online_ratio)); + return 0; + } + + /* using POSIX capabilities does not work here. It's a slow path, so + * become_root() is just as good anyway (tridge) + */ + + /* Also, AIX has DMAPI but no POSIX capablities support. In this case, + * we need to be root to do DMAPI manipulations. + */ + become_root(); + + /* go the slow DMAPI route */ + if (dm_path_to_handle((char*)path, &dmhandle, &dmhandle_len) != 0) { + ret = -1; + DEBUG(2,("dm_path_to_handle failed - assuming offline (%s) - %s\n", + path, strerror(errno))); + *offline = True; + goto done; + } + + memset(&dmname, 0, sizeof(dmname)); + strlcpy((char *)&dmname.an_chars[0], DM_ATTRIB_OBJECT, sizeof(dmname.an_chars)); + + ret = dm_get_dmattr(tsmd->sid, dmhandle, dmhandle_len, + DM_NO_TOKEN, &dmname, 0, NULL, &rlen); + + /* its offline if the IBMObj attribute exists */ + *offline = (ret == 0 || (ret == -1 && errno == E2BIG)); + + DEBUG(10,("dm_get_dmattr %s ret=%d (%s)\n", path, ret, strerror(errno))); + + ret = 0; + + dm_handle_free(dmhandle, dmhandle_len); + +done: + unbecome_root(); + return ret; +} + + +static bool tsmsm_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp) +{ + SMB_STRUCT_STAT sbuf; + struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data; + /* see if the file might be offline. This is called before each IO + to ensure we use AIO if the file is offline. We don't do the full dmapi + call as that would be too slow, instead we err on the side of using AIO + if the file might be offline + */ + if(SMB_VFS_FSTAT(fsp, &sbuf) == 0) { + DEBUG(10,("tsmsm_aio_force st_blocks=%ld st_size=%ld online_ratio=%.2f\n", + sbuf.st_blocks, sbuf.st_size, tsmd->online_ratio)); + return !(512 * (off_t)sbuf.st_blocks >= sbuf.st_size * tsmd->online_ratio); + } + return False; +} + +static ssize_t tsmsm_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, + SMB_STRUCT_AIOCB *aiocb) +{ + ssize_t result; + + result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb); + if(result >= 0) { + notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_ATTRIBUTES, + fsp->fsp_name); + } + + return result; +} + +static ssize_t tsmsm_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, const DATA_BLOB *hdr, + SMB_OFF_T offset, size_t n) +{ + bool file_online = tsmsm_aio_force(handle, fsp); + + if(!file_online) + return ENOSYS; + + return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n); +} + +/* We do overload pread to allow notification when file becomes online after offline status */ +/* We don't intercept SMB_VFS_READ here because all file I/O now goes through SMB_VFS_PREAD instead */ +static ssize_t tsmsm_pread(struct vfs_handle_struct *handle, struct files_struct *fsp, + void *data, size_t n, SMB_OFF_T offset) { + ssize_t result; + bool notify_online = tsmsm_aio_force(handle, fsp); + + result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); + if((result != -1) && notify_online) { + /* We can't actually force AIO at this point (came here not from reply_read_and_X) + what we can do is to send notification that file became online + */ + notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_ATTRIBUTES, + fsp->fsp_name); + } + + return result; +} + +static ssize_t tsmsm_pwrite(struct vfs_handle_struct *handle, struct files_struct *fsp, + void *data, size_t n, SMB_OFF_T offset) { + ssize_t result; + bool notify_online = tsmsm_aio_force(handle, fsp); + + result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); + if((result != -1) && notify_online) { + /* We can't actually force AIO at this point (came here not from reply_read_and_X) + what we can do is to send notification that file became online + */ + notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_ATTRIBUTES, + fsp->fsp_name); + } + + return result; +} + +static int tsmsm_set_offline(struct vfs_handle_struct *handle, struct connection_struct *conn, + const char *path) { + struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data; + int result = 0; + char *command; + + /* Now, call the script */ + command = talloc_asprintf(tsmd, "%s offline \"%s\"", tsmd->hsmscript, path); + if(!command) { + DEBUG(1, ("tsmsm_set_offline: can't allocate memory to run hsm script")); + return -1; + } + DEBUG(10, ("tsmsm_set_offline: Running [%s]\n", command)); + if((result = smbrun(command, NULL)) != 0) { + DEBUG(1,("tsmsm_set_offline: Running [%s] returned %d\n", command, result)); + } + TALLOC_FREE(command); + return result; +} + +static bool tsmsm_is_remotestorage(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) { + return True; +} + +static vfs_op_tuple vfs_tsmsm_ops[] = { + + /* Disk operations */ + + {SMB_VFS_OP(tsmsm_connect), SMB_VFS_OP_CONNECT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(tsmsm_aio_force), SMB_VFS_OP_AIO_FORCE, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(tsmsm_aio_return), SMB_VFS_OP_AIO_RETURN, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(tsmsm_pread), SMB_VFS_OP_PREAD, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(tsmsm_pwrite), SMB_VFS_OP_PWRITE, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(tsmsm_sendfile), SMB_VFS_OP_SENDFILE, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(tsmsm_is_offline),SMB_VFS_OP_IS_OFFLINE, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(tsmsm_set_offline),SMB_VFS_OP_SET_OFFLINE, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(tsmsm_is_remotestorage),SMB_VFS_OP_IS_REMOTESTORAGE, + SMB_VFS_LAYER_OPAQUE}, + + /* Finish VFS operations definition */ + + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, + SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_tsmsm_init(void); +NTSTATUS vfs_tsmsm_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, + "tsmsm", vfs_tsmsm_ops); +} -- cgit From c308d76305d0a598ce03c516ff0c3b3a8875c89c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 16 Jan 2008 20:29:41 +0100 Subject: Fix some C++ warnings (This used to be commit 625241c4773ae5c80dd0cb0c07a86aff633c1ede) --- source3/modules/vfs_shadow_copy2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 54fc672b9c..ddbc5aab18 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -345,7 +345,7 @@ static int shadow_copy2_open(vfs_handle_struct *handle, static SMB_STRUCT_DIR *shadow_copy2_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr) { - SHADOW2_NEXT(OPENDIR, (handle, name, mask, attr), void*, NULL); + SHADOW2_NEXT(OPENDIR, (handle, name, mask, attr), SMB_STRUCT_DIR *, NULL); } static int shadow_copy2_stat(vfs_handle_struct *handle, @@ -413,7 +413,7 @@ static int shadow_copy2_mknod(vfs_handle_struct *handle, static char *shadow_copy2_realpath(vfs_handle_struct *handle, const char *fname, char *resolved_path) { - SHADOW2_NEXT(REALPATH, (handle, name, resolved_path), void*, NULL); + SHADOW2_NEXT(REALPATH, (handle, name, resolved_path), char *, NULL); } static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle, -- cgit From 9158169c97295de8a0cb31c841d20727b1755851 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 16 Jan 2008 20:31:02 +0100 Subject: Fix an uninitialized variable warning (This used to be commit dcb7fb2c0d8e4b798b36e8caf480d198f3e08d00) --- source3/modules/vfs_xattr_tdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 3a72831b5b..29864a8f94 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -134,7 +134,7 @@ static struct db_record *xattr_tdb_lock_attrs(TALLOC_CTX *mem_ctx, static NTSTATUS xattr_tdb_save_attrs(struct db_record *rec, const struct tdb_xattrs *attribs) { - TDB_DATA data; + TDB_DATA data = tdb_null; NTSTATUS status; status = xattr_tdb_push_attrs(talloc_tos(), attribs, &data); -- cgit From 3020ec12a39276eaf3978323f4048b8a2e430bea Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Jan 2008 17:22:31 -0800 Subject: Fix the mess that ab just made of the new VFS code. NEEDS MORE TESTING ! Jeremy. (This used to be commit bcc94aed6f03211866aa85753a90fece87846ba9) --- source3/modules/vfs_default.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 3e78c69a5e..d4ba4dc611 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1225,35 +1225,42 @@ static int vfswrap_aio_suspend(struct vfs_handle_struct *handle, struct files_st return sys_aio_suspend(aiocb, n, timeout); } -static int vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp) +static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp) { - return False; + return false; } -static int vfswrap_is_offline(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline) +static int vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline) { if (ISDOT(path) || ISDOTDOT(path)) { - return 1; + *offline = false; + return 0; } - - if (!lp_dmapi_support(SNUM(conn)) || !dmapi_have_session()) { + + if (!lp_dmapi_support(SNUM(handle->conn)) || !dmapi_have_session()) { +#if defined(ENOTSUP) + errno = ENOTSUP; +#endif return -1; } - + *offline = (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0; return 0; } -static int vfswrap_set_offline(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) +static int vfswrap_set_offline(struct vfs_handle_struct *handle, const char *path) { /* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */ +#if defined(ENOTSUP) + errno = ENOTSUP; +#endif return -1; } -static bool vfswrap_is_remotestorage(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) +static bool vfswrap_is_remotestorage(struct vfs_handle_struct *handle, const char *path) { /* We don't know how to detect that volume is remote storage. VFS modules should redefine it. */ - return False; + return false; } @@ -1476,14 +1483,14 @@ static vfs_op_tuple vfs_default_ops[] = { {SMB_VFS_OP(vfswrap_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_OPAQUE}, - + {SMB_VFS_OP(vfswrap_is_offline),SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_set_offline),SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_is_remotestorage),SMB_VFS_OP_IS_REMOTESTORAGE, SMB_VFS_LAYER_OPAQUE}, - + /* Finish VFS operations definition */ {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, -- cgit From 6de904b836f4fdf5b0b027a09554afe3c13e05ca Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Thu, 17 Jan 2008 07:34:33 +0300 Subject: Fix more VFS API mixup with offline files I'm sorry for this mess. :-( (This used to be commit e1f5a8f10795831d3c7902d9803c9571c8ac811a) --- source3/modules/vfs_tsmsm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_tsmsm.c b/source3/modules/vfs_tsmsm.c index fe791b24bf..c2d826f818 100644 --- a/source3/modules/vfs_tsmsm.c +++ b/source3/modules/vfs_tsmsm.c @@ -137,7 +137,6 @@ static int tsmsm_connect(struct vfs_handle_struct *handle, } static int tsmsm_is_offline(struct vfs_handle_struct *handle, - struct connection_struct *conn, const char *path, SMB_STRUCT_STAT *stbuf, bool *offline) { @@ -171,7 +170,7 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle, ret = -1; DEBUG(2,("dm_path_to_handle failed - assuming offline (%s) - %s\n", path, strerror(errno))); - *offline = True; + *offline = true; goto done; } @@ -210,7 +209,7 @@ static bool tsmsm_aio_force(struct vfs_handle_struct *handle, struct files_struc sbuf.st_blocks, sbuf.st_size, tsmd->online_ratio)); return !(512 * (off_t)sbuf.st_blocks >= sbuf.st_size * tsmd->online_ratio); } - return False; + return false; } static ssize_t tsmsm_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, @@ -277,7 +276,7 @@ static ssize_t tsmsm_pwrite(struct vfs_handle_struct *handle, struct files_struc return result; } -static int tsmsm_set_offline(struct vfs_handle_struct *handle, struct connection_struct *conn, +static int tsmsm_set_offline(struct vfs_handle_struct *handle, const char *path) { struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data; int result = 0; @@ -297,7 +296,7 @@ static int tsmsm_set_offline(struct vfs_handle_struct *handle, struct connection return result; } -static bool tsmsm_is_remotestorage(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) { +static bool tsmsm_is_remotestorage(struct vfs_handle_struct *handle, const char *path) { return True; } -- cgit From 026a66abecea3e3a54cdbfb97129d5e65608e5df Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Thu, 17 Jan 2008 14:57:35 +0300 Subject: Rework of VFS is_offline() function to only return boolean offline/online result for a file. This makes sense as upper levels are only taking returned result of 0 (no error) into consideration when deciding whether to mark file offline/online as returned from is_offline. That means that we simply can move the decision down to VFS module and clean up upper levels so that they always see only file status. If there is an error when trying to identify file status, then VFS module could decide what to return (offline or online) by itself -- after all, it ought to have system-specific knowledge anyway. (This used to be commit 75cc08661473cce62756fa062071bb2bc1fb39ec) --- source3/modules/vfs_default.c | 10 ++++------ source3/modules/vfs_tsmsm.c | 16 +++++++--------- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index d4ba4dc611..755bcdeefa 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1230,22 +1230,20 @@ static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_str return false; } -static int vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline) +static bool vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf) { if (ISDOT(path) || ISDOTDOT(path)) { - *offline = false; - return 0; + return false; } if (!lp_dmapi_support(SNUM(handle->conn)) || !dmapi_have_session()) { #if defined(ENOTSUP) errno = ENOTSUP; #endif - return -1; + return false; } - *offline = (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0; - return 0; + return (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0; } static int vfswrap_set_offline(struct vfs_handle_struct *handle, const char *path) diff --git a/source3/modules/vfs_tsmsm.c b/source3/modules/vfs_tsmsm.c index c2d826f818..c737032907 100644 --- a/source3/modules/vfs_tsmsm.c +++ b/source3/modules/vfs_tsmsm.c @@ -136,24 +136,23 @@ static int tsmsm_connect(struct vfs_handle_struct *handle, return SMB_VFS_NEXT_CONNECT(handle, service, user); } -static int tsmsm_is_offline(struct vfs_handle_struct *handle, +static bool tsmsm_is_offline(struct vfs_handle_struct *handle, const char *path, - SMB_STRUCT_STAT *stbuf, - bool *offline) { + SMB_STRUCT_STAT *stbuf) { struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data; void *dmhandle = NULL; size_t dmhandle_len = 0; size_t rlen; dm_attrname_t dmname; int ret; + bool offline; /* 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) */ if (512 * (off_t)stbuf->st_blocks >= stbuf->st_size * tsmd->online_ratio) { - *offline = false; DEBUG(10,("%s not offline: st_blocks=%ld st_size=%ld online_ratio=%.2f\n", path, stbuf->st_blocks, stbuf->st_size, tsmd->online_ratio)); - return 0; + return false; } /* using POSIX capabilities does not work here. It's a slow path, so @@ -167,10 +166,9 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle, /* go the slow DMAPI route */ if (dm_path_to_handle((char*)path, &dmhandle, &dmhandle_len) != 0) { - ret = -1; DEBUG(2,("dm_path_to_handle failed - assuming offline (%s) - %s\n", path, strerror(errno))); - *offline = true; + offline = true; goto done; } @@ -181,7 +179,7 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle, DM_NO_TOKEN, &dmname, 0, NULL, &rlen); /* its offline if the IBMObj attribute exists */ - *offline = (ret == 0 || (ret == -1 && errno == E2BIG)); + offline = (ret == 0 || (ret == -1 && errno == E2BIG)); DEBUG(10,("dm_get_dmattr %s ret=%d (%s)\n", path, ret, strerror(errno))); @@ -191,7 +189,7 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle, done: unbecome_root(); - return ret; + return offline; } -- cgit From 03387a0f5886d449eda359a5acecd830f3bd35bc Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Thu, 17 Jan 2008 16:51:14 +0300 Subject: Remove is_remotestorage() call from VFS. We already have statvfs() there to handle FS capabilities. As discussed with Volker, it is better to calculate FS capabilities at connection time. We already do this with help of VFS statvfs() call which allows to fill-in system-specific attributes including FS capabilities. So just re-use it if you want to represent additional capabilities in your modules. The only caution is that you need to call underlying statvfs() call to actually get system-specific capabilities (and other fields) added. Then add module-specific ones. (This used to be commit e342ca0d931f9a5c8ec9e472dc9c63f1fe012b3a) --- source3/modules/vfs_default.c | 9 --------- source3/modules/vfs_tsmsm.c | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 755bcdeefa..31234f23ec 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1255,13 +1255,6 @@ static int vfswrap_set_offline(struct vfs_handle_struct *handle, const char *pat return -1; } -static bool vfswrap_is_remotestorage(struct vfs_handle_struct *handle, const char *path) -{ - /* We don't know how to detect that volume is remote storage. VFS modules should redefine it. */ - return false; -} - - static vfs_op_tuple vfs_default_ops[] = { /* Disk operations */ @@ -1486,8 +1479,6 @@ static vfs_op_tuple vfs_default_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_set_offline),SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_OPAQUE}, - {SMB_VFS_OP(vfswrap_is_remotestorage),SMB_VFS_OP_IS_REMOTESTORAGE, - SMB_VFS_LAYER_OPAQUE}, /* Finish VFS operations definition */ diff --git a/source3/modules/vfs_tsmsm.c b/source3/modules/vfs_tsmsm.c index c737032907..2805488e8b 100644 --- a/source3/modules/vfs_tsmsm.c +++ b/source3/modules/vfs_tsmsm.c @@ -294,8 +294,14 @@ static int tsmsm_set_offline(struct vfs_handle_struct *handle, return result; } -static bool tsmsm_is_remotestorage(struct vfs_handle_struct *handle, const char *path) { - return True; +static bool tsmsm_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf) +{ + bool result; + + result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + statbuf->FsCapabilities | = FILE_SUPPORTS_REMOTE_STORAGE | FILE_SUPPORTS_REPARSE_POINTS; + + return result; } static vfs_op_tuple vfs_tsmsm_ops[] = { @@ -304,6 +310,8 @@ static vfs_op_tuple vfs_tsmsm_ops[] = { {SMB_VFS_OP(tsmsm_connect), SMB_VFS_OP_CONNECT, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(tsmsm_statvfs), SMB_VFS_OP_STATVFS, + SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(tsmsm_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(tsmsm_aio_return), SMB_VFS_OP_AIO_RETURN, @@ -314,11 +322,9 @@ static vfs_op_tuple vfs_tsmsm_ops[] = { SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(tsmsm_sendfile), SMB_VFS_OP_SENDFILE, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(tsmsm_is_offline),SMB_VFS_OP_IS_OFFLINE, - SMB_VFS_LAYER_OPAQUE}, - {SMB_VFS_OP(tsmsm_set_offline),SMB_VFS_OP_SET_OFFLINE, + {SMB_VFS_OP(tsmsm_is_offline), SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_OPAQUE}, - {SMB_VFS_OP(tsmsm_is_remotestorage),SMB_VFS_OP_IS_REMOTESTORAGE, + {SMB_VFS_OP(tsmsm_set_offline), SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_OPAQUE}, /* Finish VFS operations definition */ -- cgit From 9e3634fb63f6dec1a3c820a462b5f732e7d09206 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 17 Jan 2008 17:17:52 +0100 Subject: Fix two uninitialized variables in vfs_hpuxacl.c Thanks to David Leonard , this fixes bug 5208. Volker (This used to be commit a3b36c3cb0fe5f3e78c200290afa59829934f496) --- source3/modules/vfs_hpuxacl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c index e101886450..f9293405fb 100644 --- a/source3/modules/vfs_hpuxacl.c +++ b/source3/modules/vfs_hpuxacl.c @@ -140,7 +140,7 @@ SMB_ACL_T hpuxacl_sys_acl_get_file(vfs_handle_struct *handle, { SMB_ACL_T result = NULL; int count; - HPUX_ACL_T hpux_acl; + HPUX_ACL_T hpux_acl = NULL; DEBUG(10, ("hpuxacl_sys_acl_get_file called for file '%s'.\n", path_p)); @@ -213,7 +213,7 @@ int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle, { int ret = -1; SMB_STRUCT_STAT s; - HPUX_ACL_T hpux_acl; + HPUX_ACL_T hpux_acl = NULL; int count; DEBUG(10, ("hpuxacl_sys_acl_set_file called for file '%s'\n", -- cgit From 70f88005c77cee0848a495da139144206b53eb3f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 15:44:48 +0100 Subject: Fix error return in xattr_tdb_load_attrs (This used to be commit 64e54ea8f76fe57193955aabc1459fe635233aca) --- source3/modules/vfs_xattr_tdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 29864a8f94..597dd38eaf 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -110,7 +110,7 @@ static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx, status = xattr_tdb_pull_attrs(mem_ctx, &data, presult); TALLOC_FREE(data.dptr); - return NT_STATUS_OK; + return status; } /* -- cgit From 1b976d51928dd6fa923272d277e13e5267188869 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 20:41:15 +0100 Subject: Add the STREAMINFO vfs call Based on jpeach's work, modified the streaminfo prototype Make use of it in trans2.c together with marshall_stream_info() (This used to be commit c34d729c7c0600a8f11bf7e489a634a4e37fe88e) --- source3/modules/vfs_default.c | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 31234f23ec..2e620d04cc 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -942,6 +942,63 @@ static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle, S return file_id_create_dev(dev, inode); } +static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, + struct files_struct *fsp, + const char *fname, + TALLOC_CTX *mem_ctx, + unsigned int *pnum_streams, + struct stream_struct **pstreams) +{ + SMB_STRUCT_STAT sbuf; + NTSTATUS status; + unsigned int num_streams = 0; + struct stream_struct *streams = NULL; + int ret; + + if ((fsp != NULL) && (fsp->is_directory)) { + /* + * No default streams on directories + */ + goto done; + } + + if ((fsp != NULL) && (fsp->fh->fd != -1)) { + ret = SMB_VFS_FSTAT(fsp, &sbuf); + } + else { + ret = SMB_VFS_STAT(handle->conn, fname, &sbuf); + } + + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + + if (S_ISDIR(sbuf.st_mode)) { + goto done; + } + + streams = talloc(mem_ctx, struct stream_struct); + + if (streams == NULL) { + return NT_STATUS_NO_MEMORY; + } + + streams->size = sbuf.st_size; + streams->alloc_size = get_allocation_size(handle->conn, fsp, &sbuf); + + streams->name = talloc_strdup(streams, "::$DATA"); + if (streams->name == NULL) { + TALLOC_FREE(streams); + return NT_STATUS_NO_MEMORY; + } + + num_streams = 1; + done: + *pnum_streams = num_streams; + *pstreams = streams; + return NT_STATUS_OK; +} + static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc) @@ -1367,6 +1424,8 @@ static vfs_op_tuple vfs_default_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_file_id_create), SMB_VFS_OP_FILE_ID_CREATE, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_streaminfo), SMB_VFS_OP_STREAMINFO, + SMB_VFS_LAYER_OPAQUE}, /* NT ACL operations. */ -- cgit From 4ba64fce494b064590a932d53cdbdb5f7bc4a837 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 23:33:11 +0100 Subject: vfs_streams_xattr module Store streams in posix xattrs. A kludge, as xattrs are limited in many ways, but it might be a help for some situations. (This used to be commit 83a805220e52742119546c76a054d50582e33a24) --- source3/modules/vfs_streams_xattr.c | 672 ++++++++++++++++++++++++++++++++++++ 1 file changed, 672 insertions(+) create mode 100644 source3/modules/vfs_streams_xattr.c (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c new file mode 100644 index 0000000000..3701cddfb5 --- /dev/null +++ b/source3/modules/vfs_streams_xattr.c @@ -0,0 +1,672 @@ +/* + * Store streams in xattrs + * + * Copyright (C) Volker Lendecke, 2008 + * + * Partly based on James Peach's Darwin module, which is + * + * Copyright (C) James Peach 2006-2007 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +#define XATTR_DOSSTREAM_PREFIX "user.DosStream." + +struct stream_io { + char *base; + char *xattr_name; +}; + +static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname) +{ + struct MD5Context ctx; + unsigned char hash[16]; + SMB_INO_T result; + char *upper_sname; + + DEBUG(10, ("stream_inode called for %lu/%lu [%s]\n", + (unsigned long)sbuf->st_dev, + (unsigned long)sbuf->st_ino, sname)); + + upper_sname = talloc_strdup_upper(talloc_tos(), sname); + SMB_ASSERT(upper_sname != NULL); + + MD5Init(&ctx); + MD5Update(&ctx, (unsigned char *)&(sbuf->st_dev), + sizeof(sbuf->st_dev)); + MD5Update(&ctx, (unsigned char *)&(sbuf->st_ino), + sizeof(sbuf->st_ino)); + MD5Update(&ctx, (unsigned char *)upper_sname, + talloc_get_size(upper_sname)-1); + MD5Final(hash, &ctx); + + TALLOC_FREE(upper_sname); + + /* Hopefully all the variation is in the lower 4 (or 8) bytes! */ + memcpy(&result, hash, sizeof(result)); + + DEBUG(10, ("stream_inode returns %lu\n", (unsigned long)result)); + + return result; +} + +static ssize_t get_xattr_size(connection_struct *conn, const char *fname, + const char *xattr_name) +{ + NTSTATUS status; + struct ea_struct ea; + ssize_t result; + + status = get_ea_value(talloc_tos(), conn, NULL, fname, + xattr_name, &ea); + + if (!NT_STATUS_IS_OK(status)) { + return -1; + } + + result = ea.value.length-1; + TALLOC_FREE(ea.value.data); + return result; +} + + +static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp, + SMB_STRUCT_STAT *sbuf) +{ + struct stream_io *io = (struct stream_io *) + VFS_FETCH_FSP_EXTENSION(handle, fsp); + + if (io == NULL) { + return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); + } + + if (SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf) == -1) { + return -1; + } + + sbuf->st_size = get_xattr_size(handle->conn, io->base, io->xattr_name); + if (sbuf->st_size == -1) { + return -1; + } + + sbuf->st_ino = stream_inode(sbuf, io->xattr_name); + sbuf->st_mode &= ~S_IFMT; + sbuf->st_mode |= S_IFREG; + sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1; + + return 0; +} + +static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname, + SMB_STRUCT_STAT *sbuf) +{ + NTSTATUS status; + char *base, *sname; + int result = -1; + char *xattr_name; + + if (!is_ntfs_stream_name(fname)) { + return SMB_VFS_NEXT_STAT(handle, fname, sbuf); + } + + status = split_ntfs_stream_name(talloc_tos(), fname, &base, &sname); + if (!NT_STATUS_IS_OK(status)) { + errno = EINVAL; + goto fail; + } + + if (SMB_VFS_NEXT_STAT(handle, base, sbuf) == -1) { + goto fail; + } + + xattr_name = talloc_asprintf(talloc_tos(), "%s%s", + XATTR_DOSSTREAM_PREFIX, sname); + if (xattr_name == NULL) { + errno = ENOMEM; + goto fail; + } + + sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name); + if (sbuf->st_size == -1) { + errno = ENOENT; + goto fail; + } + + sbuf->st_ino = stream_inode(sbuf, xattr_name); + sbuf->st_mode &= ~S_IFMT; + sbuf->st_mode |= S_IFREG; + sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1; + + result = 0; + fail: + TALLOC_FREE(base); + TALLOC_FREE(sname); + return result; +} + +static int streams_xattr_lstat(vfs_handle_struct *handle, const char *fname, + SMB_STRUCT_STAT *sbuf) +{ + NTSTATUS status; + char *base, *sname; + int result = -1; + char *xattr_name; + + if (!is_ntfs_stream_name(fname)) { + return SMB_VFS_NEXT_LSTAT(handle, fname, sbuf); + } + + status = split_ntfs_stream_name(talloc_tos(), fname, &base, &sname); + if (!NT_STATUS_IS_OK(status)) { + errno = EINVAL; + goto fail; + } + + if (SMB_VFS_NEXT_LSTAT(handle, base, sbuf) == -1) { + goto fail; + } + + xattr_name = talloc_asprintf(talloc_tos(), "%s%s", + XATTR_DOSSTREAM_PREFIX, sname); + if (xattr_name == NULL) { + errno = ENOMEM; + goto fail; + } + + sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name); + if (sbuf->st_size == -1) { + errno = ENOENT; + goto fail; + } + + sbuf->st_ino = stream_inode(sbuf, xattr_name); + sbuf->st_mode &= ~S_IFMT; + sbuf->st_mode |= S_IFREG; + sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1; + + result = 0; + fail: + TALLOC_FREE(base); + TALLOC_FREE(sname); + return result; +} + +static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, + files_struct *fsp, int flags, mode_t mode) +{ + TALLOC_CTX *frame; + NTSTATUS status; + struct stream_io *sio; + char *base, *sname; + struct ea_struct ea; + char *xattr_name; + int baseflags; + int hostfd = -1; + + if (!is_ntfs_stream_name(fname)) { + return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + } + + frame = talloc_stackframe(); + + status = split_ntfs_stream_name(talloc_tos(), fname, + &base, &sname); + if (!NT_STATUS_IS_OK(status)) { + errno = EINVAL; + goto fail; + } + + xattr_name = talloc_asprintf(talloc_tos(), "%s%s", + XATTR_DOSSTREAM_PREFIX, sname); + if (xattr_name == NULL) { + errno = ENOMEM; + goto fail; + } + + /* + * We use baseflags to turn off nasty side-effects when opening the + * underlying file. + */ + baseflags = flags; + baseflags &= ~O_TRUNC; + baseflags &= ~O_EXCL; + baseflags &= ~O_CREAT; + + hostfd = SMB_VFS_NEXT_OPEN(handle, base, fsp, baseflags, mode); + + /* It is legit to open a stream on a directory, but the base + * fd has to be read-only. + */ + if ((hostfd == -1) && (errno == EISDIR)) { + baseflags &= ~O_ACCMODE; + baseflags |= O_RDONLY; + hostfd = SMB_VFS_NEXT_OPEN(handle, fname, fsp, baseflags, + mode); + } + + if (hostfd == -1) { + goto fail; + } + + status = get_ea_value(talloc_tos(), handle->conn, fsp, base, + xattr_name, &ea); + + if (!NT_STATUS_IS_OK(status) + && !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { + /* + * The base file is not there. This is an error even if we got + * O_CREAT, the higher levels should have created the base + * file for us. + */ + errno = ENOENT; + goto fail; + } + + if (!NT_STATUS_IS_OK(status)) { + /* + * The attribute does not exist + */ + + if (flags & O_CREAT) { + /* + * Darn, xattrs need at least 1 byte + */ + char null = '\0'; + + if (SMB_VFS_NEXT_SETXATTR( + handle, base, xattr_name, &null, sizeof(null), + flags & O_EXCL ? XATTR_CREATE : 0) == -1) { + goto fail; + } + } + } + + if (flags & O_TRUNC) { + char null = '\0'; + if (SMB_VFS_NEXT_SETXATTR( + handle, base, xattr_name, &null, sizeof(null), + flags & O_EXCL ? XATTR_CREATE : 0) == -1) { + goto fail; + } + } + + sio = (struct stream_io *)VFS_ADD_FSP_EXTENSION(handle, fsp, + struct stream_io); + if (sio == NULL) { + errno = ENOMEM; + goto fail; + } + + sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp), + xattr_name); + sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp), + base); + + if ((sio->xattr_name == NULL) || (sio->base == NULL)) { + errno = ENOMEM; + goto fail; + } + + TALLOC_FREE(frame); + return hostfd; + + fail: + if (hostfd >= 0) { + /* + * BUGBUGBUG -- we would need to call fd_close_posix here, but + * we don't have a full fsp yet + */ + SMB_VFS_NEXT_CLOSE(handle, fsp, hostfd); + } + + TALLOC_FREE(frame); + return -1; +} + +static int streams_xattr_unlink(vfs_handle_struct *handle, const char *fname) +{ + NTSTATUS status; + char *base = NULL; + char *sname = NULL; + int ret = -1; + char *xattr_name; + + if (!is_ntfs_stream_name(fname)) { + return SMB_VFS_NEXT_UNLINK(handle, fname); + } + + status = split_ntfs_stream_name(talloc_tos(), fname, &base, &sname); + if (!NT_STATUS_IS_OK(status)) { + errno = EINVAL; + goto fail; + } + + xattr_name = talloc_asprintf(talloc_tos(), "%s%s", + XATTR_DOSSTREAM_PREFIX, sname); + if (xattr_name == NULL) { + errno = ENOMEM; + goto fail; + } + + ret = SMB_VFS_NEXT_REMOVEXATTR(handle, base, xattr_name); + + if ((ret == -1) && (errno == ENOATTR)) { + errno = ENOENT; + goto fail; + } + + ret = 0; + + fail: + TALLOC_FREE(base); + TALLOC_FREE(sname); + return ret; +} + +static NTSTATUS walk_xattr_streams(connection_struct *conn, files_struct *fsp, + const char *fname, + bool (*fn)(struct ea_struct *ea, + void *private_data), + void *private_data) +{ + NTSTATUS status; + char **names; + size_t i, num_names; + size_t prefix_len = strlen(XATTR_DOSSTREAM_PREFIX); + + status = get_ea_names_from_file(talloc_tos(), conn, fsp, fname, + &names, &num_names); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + for (i=0; imem_ctx, + &state->num_streams, &state->streams, + ea->name, ea->value.length-1, + smb_roundup(state->handle->conn, + ea->value.length-1))) { + state->status = NT_STATUS_NO_MEMORY; + return false; + } + + return true; +} + +static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, + struct files_struct *fsp, + const char *fname, + TALLOC_CTX *mem_ctx, + unsigned int *pnum_streams, + struct stream_struct **pstreams) +{ + SMB_STRUCT_STAT sbuf; + int ret; + NTSTATUS status; + struct streaminfo_state state; + + if ((fsp != NULL) && (fsp->fh->fd != -1)) { + if (is_ntfs_stream_name(fsp->fsp_name)) { + return NT_STATUS_INVALID_PARAMETER; + } + ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &sbuf); + } + else { + if (is_ntfs_stream_name(fname)) { + return NT_STATUS_INVALID_PARAMETER; + } + ret = SMB_VFS_NEXT_STAT(handle, fname, &sbuf); + } + + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + + state.streams = NULL; + state.num_streams = 0; + + if (!S_ISDIR(sbuf.st_mode)) { + if (!add_one_stream(mem_ctx, + &state.num_streams, &state.streams, + "::$DATA", sbuf.st_size, + get_allocation_size(handle->conn, fsp, + &sbuf))) { + return NT_STATUS_NO_MEMORY; + } + } + + state.mem_ctx = mem_ctx; + state.handle = handle; + state.status = NT_STATUS_OK; + + status = walk_xattr_streams(handle->conn, fsp, fname, + collect_one_stream, &state); + + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(state.streams); + return status; + } + + if (!NT_STATUS_IS_OK(state.status)) { + TALLOC_FREE(state.streams); + return state.status; + } + + *pnum_streams = state.num_streams; + *pstreams = state.streams; + return NT_STATUS_OK; +} + +static int streams_xattr_statvfs(struct vfs_handle_struct *handle, + const char *path, + struct vfs_statvfs_struct *statbuf) +{ + int ret; + + ret = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + statbuf->FsCapabilities |= FILE_NAMED_STREAMS; + return ret; + +} + +static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle, + files_struct *fsp, const void *data, + size_t n, SMB_OFF_T offset) +{ + struct stream_io *sio = + (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp); + struct ea_struct ea; + NTSTATUS status; + int ret; + + if (sio == NULL) { + return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); + } + + status = get_ea_value(talloc_tos(), handle->conn, fsp, sio->base, + sio->xattr_name, &ea); + if (!NT_STATUS_IS_OK(status)) { + return -1; + } + + if ((offset + n) > ea.value.length-1) { + uint8 *tmp; + + tmp = TALLOC_REALLOC_ARRAY(talloc_tos(), ea.value.data, uint8, + offset + n + 1); + + if (tmp == NULL) { + TALLOC_FREE(ea.value.data); + errno = ENOMEM; + return -1; + } + ea.value.data = tmp; + ea.value.length = offset + n + 1; + ea.value.data[offset+n] = 0; + } + + memcpy(ea.value.data + offset, data, n); + + ret = SMB_VFS_NEXT_FSETXATTR(handle, fsp, sio->xattr_name, + ea.value.data, ea.value.length, 0); + + TALLOC_FREE(ea.value.data); + + return n; +} + +static ssize_t streams_xattr_pread(vfs_handle_struct *handle, + files_struct *fsp, void *data, + size_t n, SMB_OFF_T offset) +{ + struct stream_io *sio = + (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp); + struct ea_struct ea; + NTSTATUS status; + size_t length, overlap; + + if (sio == NULL) { + return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); + } + + status = get_ea_value(talloc_tos(), handle->conn, fsp, sio->base, + sio->xattr_name, &ea); + if (!NT_STATUS_IS_OK(status)) { + return -1; + } + + length = ea.value.length-1; + + /* Attempt to read past EOF. */ + if (length <= offset) { + errno = EINVAL; + return -1; + } + + overlap = (offset + n) > length ? (length - offset) : n; + memcpy(data, ea.value.data + offset, overlap); + + TALLOC_FREE(ea.value.data); + return overlap; +} + +/* VFS operations structure */ + +static vfs_op_tuple streams_xattr_ops[] = { + {SMB_VFS_OP(streams_xattr_statvfs), SMB_VFS_OP_STATVFS, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_open), SMB_VFS_OP_OPEN, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_stat), SMB_VFS_OP_STAT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_fstat), SMB_VFS_OP_FSTAT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_lstat), SMB_VFS_OP_LSTAT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_pread), SMB_VFS_OP_PREAD, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_pwrite), SMB_VFS_OP_PWRITE, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_lstat), SMB_VFS_OP_LSTAT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_unlink), SMB_VFS_OP_UNLINK, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_xattr_streaminfo), SMB_VFS_OP_STREAMINFO, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_streams_xattr_init(void); +NTSTATUS vfs_streams_xattr_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_xattr", + streams_xattr_ops); +} -- cgit From dfd05b9b65c5ad12dbb64b626d3180fb9e21ccb0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 23:36:34 +0100 Subject: vfs_streams_depot Store streams in a file each. Not 100% finished, and not built by default. (This used to be commit 5f5fc72b01c8e8fc096375c7cb4a97186c387259) --- source3/modules/vfs_streams_depot.c | 648 ++++++++++++++++++++++++++++++++++++ 1 file changed, 648 insertions(+) create mode 100644 source3/modules/vfs_streams_depot.c (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c new file mode 100644 index 0000000000..68e7a75947 --- /dev/null +++ b/source3/modules/vfs_streams_depot.c @@ -0,0 +1,648 @@ +/* + * Store streams in a separate subdirectory + * + * Copyright (C) Volker Lendecke, 2007 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +/* + * Excerpt from a mail from tridge: + * + * Volker, what I'm thinking of is this: + * /mount-point/.streams/XX/YY/aaaa.bbbb/namedstream1 + * /mount-point/.streams/XX/YY/aaaa.bbbb/namedstream2 + * + * where XX/YY is a 2 level hash based on the fsid/inode. "aaaa.bbbb" + * is the fsid/inode. "namedstreamX" is a file named after the stream + * name. + */ + +static uint32_t hash_fn(DATA_BLOB key) +{ + uint32_t value; /* Used to compute the hash value. */ + uint32_t i; /* Used to cycle through random values. */ + + /* Set the initial value from the key size. */ + for (value = 0x238F13AF * key.length, i=0; i < key.length; i++) + value = (value + (key.data[i] << (i*5 % 24))); + + return (1103515243 * value + 12345); +} + +/* + * With the hashing scheme based on the inode we need to protect against + * streams showing up on files with re-used inodes. This can happen if we + * create a stream directory from within Samba, and a local process or NFS + * client deletes the file without deleting the streams directory. When the + * inode is re-used and the stream directory is still around, the streams in + * there would be show up as belonging to the new file. + * + * There are several workarounds for this, probably the easiest one is on + * systems which have a true birthtime stat element: When the file has a later + * birthtime than the streams directory, then we have to recreate the + * directory. + * + * The other workaround is to somehow mark the file as generated by Samba with + * something that a NFS client would not do. The closest one is a special + * xattr value being set. On systems which do not support xattrs, it might be + * an option to put in a special ACL entry for a non-existing group. + */ + +#define SAMBA_XATTR_MARKER "user.SAMBA_STREAMS" + +static bool file_is_valid(vfs_handle_struct *handle, const char *path) +{ + char buf; + + DEBUG(10, ("file_is_valid (%s) called\n", path)); + + if (SMB_VFS_NEXT_GETXATTR(handle, path, SAMBA_XATTR_MARKER, + &buf, sizeof(buf)) != sizeof(buf)) { + DEBUG(10, ("GETXATTR failed: %s\n", strerror(errno))); + return false; + } + + if (buf != '1') { + DEBUG(10, ("got wrong buffer content: '%c'\n", buf)); + return false; + } + + return true; +} + +static bool mark_file_valid(vfs_handle_struct *handle, const char *path) +{ + char buf = '1'; + int ret; + + DEBUG(10, ("marking file %s as valid\n", path)); + + ret = SMB_VFS_NEXT_SETXATTR(handle, path, SAMBA_XATTR_MARKER, + &buf, sizeof(buf), 0); + + if (ret == -1) { + DEBUG(10, ("SETXATTR failed: %s\n", strerror(errno))); + return false; + } + + return true; +} + +static char *stream_dir(vfs_handle_struct *handle, const char *base_path, + const SMB_STRUCT_STAT *base_sbuf, bool create_it) +{ + uint32_t hash; + char *result = NULL; + SMB_STRUCT_STAT sbuf; + uint8_t first, second; + char *tmp; + char *id_hex; + struct file_id id; + uint8 id_buf[16]; + + const char *rootdir = lp_parm_const_string( + SNUM(handle->conn), "streams", "directory", + handle->conn->connectpath); + + if (base_sbuf == NULL) { + if (SMB_VFS_NEXT_STAT(handle, base_path, &sbuf) == -1) { + /* + * base file is not there + */ + goto fail; + } + base_sbuf = &sbuf; + } + + id = SMB_VFS_FILE_ID_CREATE(handle->conn, base_sbuf->st_dev, + base_sbuf->st_ino); + + push_file_id_16((char *)id_buf, &id); + + hash = hash_fn(data_blob_const(id_buf, sizeof(id_buf))); + + first = hash & 0xff; + second = (hash >> 8) & 0xff; + + id_hex = hex_encode(talloc_tos(), id_buf, sizeof(id_buf)); + + if (id_hex == NULL) { + errno = ENOMEM; + goto fail; + } + + result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir, + first, second, id_hex); + + TALLOC_FREE(id_hex); + + if (result == NULL) { + errno = ENOMEM; + return NULL; + } + + if (SMB_VFS_NEXT_STAT(handle, result, &sbuf) == 0) { + char *newname; + + if (!S_ISDIR(sbuf.st_mode)) { + errno = EINVAL; + goto fail; + } + + if (file_is_valid(handle, base_path)) { + return result; + } + + /* + * Someone has recreated a file under an existing inode + * without deleting the streams directory. For now, just move + * it away. + */ + + again: + newname = talloc_asprintf(talloc_tos(), "lost-%lu", random()); + if (newname == NULL) { + errno = ENOMEM; + goto fail; + } + + if (SMB_VFS_NEXT_RENAME(handle, result, newname) == -1) { + if ((errno == EEXIST) || (errno == ENOTEMPTY)) { + TALLOC_FREE(newname); + goto again; + } + goto fail; + } + + TALLOC_FREE(newname); + } + + if (!create_it) { + errno = ENOENT; + goto fail; + } + + if ((SMB_VFS_NEXT_MKDIR(handle, rootdir, 0755) != 0) + && (errno != EEXIST)) { + goto fail; + } + + tmp = talloc_asprintf(result, "%s/%2.2X", rootdir, first); + if (tmp == NULL) { + errno = ENOMEM; + goto fail; + } + + if ((SMB_VFS_NEXT_MKDIR(handle, tmp, 0755) != 0) + && (errno != EEXIST)) { + goto fail; + } + + TALLOC_FREE(tmp); + + tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first, + second); + if (tmp == NULL) { + errno = ENOMEM; + goto fail; + } + + if ((SMB_VFS_NEXT_MKDIR(handle, tmp, 0755) != 0) + && (errno != EEXIST)) { + goto fail; + } + + TALLOC_FREE(tmp); + + if ((SMB_VFS_NEXT_MKDIR(handle, result, 0755) != 0) + && (errno != EEXIST)) { + goto fail; + } + + if (!mark_file_valid(handle, base_path)) { + goto fail; + } + + return result; + + fail: + TALLOC_FREE(result); + return NULL; +} + +static char *stream_name(vfs_handle_struct *handle, const char *fname, + bool create_dir) +{ + char *base = NULL; + char *sname = NULL; + char *id_hex = NULL; + char *dirname, *stream_fname; + + if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), fname, + &base, &sname))) { + DEBUG(10, ("split_ntfs_stream_name failed\n")); + errno = ENOMEM; + goto fail; + } + + dirname = stream_dir(handle, base, NULL, create_dir); + + if (dirname == NULL) { + goto fail; + } + + stream_fname = talloc_asprintf(talloc_tos(), "%s/:%s", dirname, sname); + + if (stream_fname == NULL) { + errno = ENOMEM; + goto fail; + } + + DEBUG(10, ("stream filename = %s\n", stream_fname)); + + TALLOC_FREE(base); + TALLOC_FREE(sname); + TALLOC_FREE(id_hex); + + return stream_fname; + + fail: + DEBUG(5, ("stream_name failed: %s\n", strerror(errno))); + TALLOC_FREE(base); + TALLOC_FREE(sname); + TALLOC_FREE(id_hex); + return NULL; +} + +static NTSTATUS walk_streams(vfs_handle_struct *handle, + const char *fname, + const SMB_STRUCT_STAT *sbuf, + char **pdirname, + bool (*fn)(const char *dirname, + const char *dirent, + void *private_data), + void *private_data) +{ + char *dirname; + SMB_STRUCT_DIR *dirhandle = NULL; + char *dirent; + + dirname = stream_dir(handle, fname, sbuf, false); + + if (dirname == NULL) { + if (errno == ENOENT) { + /* + * no stream around + */ + return NT_STATUS_OK; + } + return map_nt_error_from_unix(errno); + } + + DEBUG(10, ("walk_streams: dirname=%s\n", dirname)); + + dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dirname, NULL, 0); + + if (dirhandle == NULL) { + TALLOC_FREE(dirname); + return map_nt_error_from_unix(errno); + } + + while ((dirent = vfs_readdirname(handle->conn, dirhandle)) != NULL) { + + if (ISDOT(dirent) || ISDOTDOT(dirent)) { + continue; + } + + DEBUG(10, ("walk_streams: dirent=%s\n", dirent)); + + if (!fn(dirname, dirent, private_data)) { + break; + } + } + + SMB_VFS_NEXT_CLOSEDIR(handle, dirhandle); + + if (pdirname != NULL) { + *pdirname = dirname; + } + else { + TALLOC_FREE(dirname); + } + + return NT_STATUS_OK; +} + +static int streams_depot_stat(vfs_handle_struct *handle, const char *fname, + SMB_STRUCT_STAT *sbuf) +{ + char *stream_fname; + int ret = -1; + + DEBUG(10, ("streams_depot_stat called for [%s]\n", fname)); + + if (!is_ntfs_stream_name(fname)) { + return SMB_VFS_NEXT_STAT(handle, fname, sbuf); + } + + stream_fname = stream_name(handle, fname, false); + if (stream_fname == NULL) { + goto done; + } + + ret = SMB_VFS_NEXT_STAT(handle, stream_fname, sbuf); + + done: + TALLOC_FREE(stream_fname); + return ret; +} + +static int streams_depot_lstat(vfs_handle_struct *handle, const char *fname, + SMB_STRUCT_STAT *sbuf) +{ + char *stream_fname; + int ret = -1; + + if (!is_ntfs_stream_name(fname)) { + return SMB_VFS_NEXT_LSTAT(handle, fname, sbuf); + } + + stream_fname = stream_name(handle, fname, false); + if (stream_fname == NULL) { + goto done; + } + + ret = SMB_VFS_NEXT_LSTAT(handle, stream_fname, sbuf); + + done: + TALLOC_FREE(stream_fname); + return ret; +} + +static int streams_depot_open(vfs_handle_struct *handle, const char *fname, + files_struct *fsp, int flags, mode_t mode) +{ + TALLOC_CTX *frame; + char *base = NULL; + SMB_STRUCT_STAT base_sbuf; + char *stream_fname; + int ret = -1; + + if (!is_ntfs_stream_name(fname)) { + return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + } + + frame = talloc_stackframe(); + + if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), fname, + &base, NULL))) { + errno = ENOMEM; + goto done; + } + + ret = SMB_VFS_NEXT_STAT(handle, base, &base_sbuf); + + if (ret == -1) { + goto done; + } + + TALLOC_FREE(base); + + stream_fname = stream_name(handle, fname, true); + if (stream_fname == NULL) { + goto done; + } + + ret = SMB_VFS_NEXT_OPEN(handle, stream_fname, fsp, flags, mode); + + done: + TALLOC_FREE(frame); + return ret; +} + +static int streams_depot_unlink(vfs_handle_struct *handle, const char *fname) +{ + int ret = -1; + SMB_STRUCT_STAT sbuf; + + DEBUG(10, ("streams_depot_unlink called for %s\n", fname)); + + if (is_ntfs_stream_name(fname)) { + char *stream_fname; + + stream_fname = stream_name(handle, fname, false); + if (stream_fname == NULL) { + return -1; + } + + ret = SMB_VFS_NEXT_UNLINK(handle, stream_fname); + + TALLOC_FREE(stream_fname); + return ret; + } + + /* + * We potentially need to delete the per-inode streams directory + */ + + if (SMB_VFS_NEXT_STAT(handle, fname, &sbuf) == -1) { + return -1; + } + + if (sbuf.st_nlink == 1) { + char *dirname = stream_dir(handle, fname, &sbuf, false); + + if (dirname != NULL) { + SMB_VFS_NEXT_RMDIR(handle, dirname); + } + TALLOC_FREE(dirname); + } + + return SMB_VFS_NEXT_UNLINK(handle, fname); +} + +static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams, + struct stream_struct **streams, + const char *name, SMB_OFF_T size, + SMB_OFF_T alloc_size) +{ + struct stream_struct *tmp; + + tmp = TALLOC_REALLOC_ARRAY(mem_ctx, *streams, struct stream_struct, + (*num_streams)+1); + if (tmp == NULL) { + return false; + } + + tmp[*num_streams].name = talloc_strdup(tmp, name); + if (tmp[*num_streams].name == NULL) { + return false; + } + + tmp[*num_streams].size = size; + tmp[*num_streams].alloc_size = alloc_size; + + *streams = tmp; + *num_streams += 1; + return true; +} + +struct streaminfo_state { + TALLOC_CTX *mem_ctx; + vfs_handle_struct *handle; + unsigned int num_streams; + struct stream_struct *streams; + NTSTATUS status; +}; + +static bool collect_one_stream(const char *dirname, + const char *dirent, + void *private_data) +{ + struct streaminfo_state *state = + (struct streaminfo_state *)private_data; + char *full_sname; + SMB_STRUCT_STAT sbuf; + + if (asprintf(&full_sname, "%s/%s", dirname, dirent) == -1) { + state->status = NT_STATUS_NO_MEMORY; + return false; + } + if (SMB_VFS_NEXT_STAT(state->handle, full_sname, &sbuf) == -1) { + DEBUG(10, ("Could not stat %s: %s\n", full_sname, + strerror(errno))); + SAFE_FREE(full_sname); + return true; + } + + SAFE_FREE(full_sname); + + if (!add_one_stream(state->mem_ctx, + &state->num_streams, &state->streams, + dirent, sbuf.st_size, + get_allocation_size( + state->handle->conn, NULL, &sbuf))) { + state->status = NT_STATUS_NO_MEMORY; + return false; + } + + return true; +} + +static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle, + struct files_struct *fsp, + const char *fname, + TALLOC_CTX *mem_ctx, + unsigned int *pnum_streams, + struct stream_struct **pstreams) +{ + SMB_STRUCT_STAT sbuf; + int ret; + NTSTATUS status; + struct streaminfo_state state; + + if ((fsp != NULL) && (fsp->fh->fd != -1)) { + if (is_ntfs_stream_name(fsp->fsp_name)) { + return NT_STATUS_INVALID_PARAMETER; + } + ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &sbuf); + } + else { + if (is_ntfs_stream_name(fname)) { + return NT_STATUS_INVALID_PARAMETER; + } + ret = SMB_VFS_NEXT_STAT(handle, fname, &sbuf); + } + + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + + state.streams = NULL; + state.num_streams = 0; + + if (!S_ISDIR(sbuf.st_mode)) { + if (!add_one_stream(mem_ctx, + &state.num_streams, &state.streams, + "::$DATA", sbuf.st_size, + get_allocation_size(handle->conn, fsp, + &sbuf))) { + return NT_STATUS_NO_MEMORY; + } + } + + state.mem_ctx = mem_ctx; + state.handle = handle; + state.status = NT_STATUS_OK; + + status = walk_streams(handle, fname, &sbuf, NULL, collect_one_stream, + &state); + + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(state.streams); + return status; + } + + if (!NT_STATUS_IS_OK(state.status)) { + TALLOC_FREE(state.streams); + return state.status; + } + + *pnum_streams = state.num_streams; + *pstreams = state.streams; + return NT_STATUS_OK; +} + +static int streams_depot_statvfs(struct vfs_handle_struct *handle, + const char *path, + struct vfs_statvfs_struct *statbuf) +{ + int ret; + + ret = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + statbuf->FsCapabilities |= FILE_NAMED_STREAMS; + return ret; + +} + +/* VFS operations structure */ + +static vfs_op_tuple streams_depot_ops[] = { + {SMB_VFS_OP(streams_depot_statvfs), SMB_VFS_OP_STATVFS, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_depot_open), SMB_VFS_OP_OPEN, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_depot_stat), SMB_VFS_OP_STAT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_depot_lstat), SMB_VFS_OP_LSTAT, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_depot_unlink), SMB_VFS_OP_UNLINK, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(streams_depot_streaminfo), SMB_VFS_OP_STREAMINFO, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_streams_depot_init(void); +NTSTATUS vfs_streams_depot_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot", + streams_depot_ops); +} -- cgit From e1d01878f5e7c4a0f7d90ae0463bd6c11774d910 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 11:10:06 +0100 Subject: Complete the ea->xattr rename in vfs_xattr_tdb (This used to be commit dac468216e7e103b6897f33ec3608412f77265cf) --- source3/modules/vfs_xattr_tdb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 597dd38eaf..0acca51c5d 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -558,7 +558,8 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db) struct db_context *db; const char *dbname; - dbname = lp_parm_const_string(snum, "ea", "tdb", lock_path("eas.tdb")); + dbname = lp_parm_const_string(snum, "xattr", "tdb", + lock_path("xattr.tdb")); if (dbname == NULL) { errno = ENOTSUP; @@ -660,7 +661,7 @@ static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path) * Destructor for the VFS private data */ -static void close_ea_db(void **data) +static void close_xattr_db(void **data) { struct db_context **p_db = (struct db_context **)data; TALLOC_FREE(*p_db); @@ -688,14 +689,14 @@ static int xattr_tdb_connect(vfs_handle_struct *handle, const char *service, } if (!xattr_tdb_init(snum, &db)) { - DEBUG(5, ("Could not init ea tdb\n")); + DEBUG(5, ("Could not init xattr tdb\n")); lp_do_parameter(snum, "ea support", "False"); return 0; } lp_do_parameter(snum, "ea support", "True"); - SMB_VFS_HANDLE_SET_DATA(handle, db, close_ea_db, + SMB_VFS_HANDLE_SET_DATA(handle, db, close_xattr_db, struct db_context, return -1); return 0; -- cgit From 0b9314db5ace99096d7f8afa7f449f8e734a6b64 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 11:20:58 +0100 Subject: Support XATTR_CREATE and XATTR_REPLACE in vfs_xattr_tdb (This used to be commit 3509ee597f0977aadd4c70cfe8830a6aa95cd71f) --- source3/modules/vfs_xattr_tdb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/modules') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 0acca51c5d..7416fa785a 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -269,6 +269,11 @@ static int xattr_tdb_setattr(struct db_context *db_ctx, for (i=0; inum_xattrs; i++) { if (strcmp(attribs->xattrs[i].name, name) == 0) { + if (flags & XATTR_CREATE) { + TALLOC_FREE(rec); + errno = EEXIST; + return -1; + } break; } } @@ -276,6 +281,12 @@ static int xattr_tdb_setattr(struct db_context *db_ctx, if (i == attribs->num_xattrs) { struct tdb_xattr *tmp; + if (flags & XATTR_REPLACE) { + TALLOC_FREE(rec); + errno = ENOATTR; + return -1; + } + tmp = TALLOC_REALLOC_ARRAY( attribs, attribs->xattrs, struct tdb_xattr, attribs->num_xattrs + 1); -- cgit From a6fcaf73d7ae238283cd107260ae215d31b05ac4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 13:49:38 +0100 Subject: Really remove the _NEXT_ from vfs_xattr_tdb.c This must have been lost somewhere in my patch-mangling (This used to be commit c1794375d1fa27d72ec32946bb4bd7b9f96e59fc) --- source3/modules/vfs_streams_xattr.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 3701cddfb5..104ed638db 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -131,7 +131,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname, goto fail; } - if (SMB_VFS_NEXT_STAT(handle, base, sbuf) == -1) { + if (SMB_VFS_STAT(handle->conn, base, sbuf) == -1) { goto fail; } @@ -178,7 +178,7 @@ static int streams_xattr_lstat(vfs_handle_struct *handle, const char *fname, goto fail; } - if (SMB_VFS_NEXT_LSTAT(handle, base, sbuf) == -1) { + if (SMB_VFS_LSTAT(handle->conn, base, sbuf) == -1) { goto fail; } @@ -248,7 +248,7 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, baseflags &= ~O_EXCL; baseflags &= ~O_CREAT; - hostfd = SMB_VFS_NEXT_OPEN(handle, base, fsp, baseflags, mode); + hostfd = SMB_VFS_OPEN(handle->conn, base, fsp, baseflags, mode); /* It is legit to open a stream on a directory, but the base * fd has to be read-only. @@ -256,8 +256,8 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, if ((hostfd == -1) && (errno == EISDIR)) { baseflags &= ~O_ACCMODE; baseflags |= O_RDONLY; - hostfd = SMB_VFS_NEXT_OPEN(handle, fname, fsp, baseflags, - mode); + hostfd = SMB_VFS_OPEN(handle->conn, fname, fsp, baseflags, + mode); } if (hostfd == -1) { @@ -289,8 +289,12 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, */ char null = '\0'; - if (SMB_VFS_NEXT_SETXATTR( - handle, base, xattr_name, &null, sizeof(null), + DEBUG(10, ("creating attribute %s on file %s\n", + xattr_name, base)); + + if (SMB_VFS_SETXATTR( + handle->conn, base, xattr_name, + &null, sizeof(null), flags & O_EXCL ? XATTR_CREATE : 0) == -1) { goto fail; } @@ -299,8 +303,9 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, if (flags & O_TRUNC) { char null = '\0'; - if (SMB_VFS_NEXT_SETXATTR( - handle, base, xattr_name, &null, sizeof(null), + if (SMB_VFS_SETXATTR( + handle->conn, base, xattr_name, + &null, sizeof(null), flags & O_EXCL ? XATTR_CREATE : 0) == -1) { goto fail; } @@ -332,7 +337,7 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, * BUGBUGBUG -- we would need to call fd_close_posix here, but * we don't have a full fsp yet */ - SMB_VFS_NEXT_CLOSE(handle, fsp, hostfd); + SMB_VFS_CLOSE(fsp, hostfd); } TALLOC_FREE(frame); @@ -364,7 +369,7 @@ static int streams_xattr_unlink(vfs_handle_struct *handle, const char *fname) goto fail; } - ret = SMB_VFS_NEXT_REMOVEXATTR(handle, base, xattr_name); + ret = SMB_VFS_REMOVEXATTR(handle->conn, base, xattr_name); if ((ret == -1) && (errno == ENOATTR)) { errno = ENOENT; @@ -497,13 +502,13 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, if (is_ntfs_stream_name(fsp->fsp_name)) { return NT_STATUS_INVALID_PARAMETER; } - ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &sbuf); + ret = SMB_VFS_FSTAT(fsp, &sbuf); } else { if (is_ntfs_stream_name(fname)) { return NT_STATUS_INVALID_PARAMETER; } - ret = SMB_VFS_NEXT_STAT(handle, fname, &sbuf); + ret = SMB_VFS_STAT(handle->conn, fname, &sbuf); } if (ret == -1) { @@ -595,8 +600,8 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle, memcpy(ea.value.data + offset, data, n); - ret = SMB_VFS_NEXT_FSETXATTR(handle, fsp, sio->xattr_name, - ea.value.data, ea.value.length, 0); + ret = SMB_VFS_FSETXATTR(fsp->base_fsp, sio->xattr_name, + ea.value.data, ea.value.length, 0); TALLOC_FREE(ea.value.data); -- cgit From a39771d3d20280b289478da758089a1035415d65 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 13:51:52 +0100 Subject: For pread/pwrite we need to do the setxattr on base_fsp (This used to be commit d481dddc81699aba79e48bca79bfb10e586b5cbb) --- source3/modules/vfs_streams_xattr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 104ed638db..7d7ec02fe7 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -576,8 +576,8 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle, return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); } - status = get_ea_value(talloc_tos(), handle->conn, fsp, sio->base, - sio->xattr_name, &ea); + status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp, + sio->base, sio->xattr_name, &ea); if (!NT_STATUS_IS_OK(status)) { return -1; } @@ -622,8 +622,8 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle, return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); } - status = get_ea_value(talloc_tos(), handle->conn, fsp, sio->base, - sio->xattr_name, &ea); + status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp, + sio->base, sio->xattr_name, &ea); if (!NT_STATUS_IS_OK(status)) { return -1; } -- cgit From 4222fa62e927500f21f386ac57dd599234f7d8b1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 13:55:27 +0100 Subject: Add some DEBUG (This used to be commit 8db25aba63b1dffb0dfbc74012c7ebd0ce4d5682) --- source3/modules/vfs_streams_xattr.c | 12 ++++++++++++ source3/modules/vfs_xattr_tdb.c | 6 ++++++ 2 files changed, 18 insertions(+) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 7d7ec02fe7..e304810a02 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -92,6 +92,8 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp, struct stream_io *io = (struct stream_io *) VFS_FETCH_FSP_EXTENSION(handle, fsp); + DEBUG(10, ("streams_xattr_fstat called for %d\n", fsp->fh->fd)); + if (io == NULL) { return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); } @@ -105,6 +107,8 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp, return -1; } + DEBUG(10, ("sbuf->st_size = %d\n", (int)sbuf->st_size)); + sbuf->st_ino = stream_inode(sbuf, io->xattr_name); sbuf->st_mode &= ~S_IFMT; sbuf->st_mode |= S_IFREG; @@ -219,6 +223,8 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, int baseflags; int hostfd = -1; + DEBUG(10, ("streams_xattr_open called for %s\n", fname)); + if (!is_ntfs_stream_name(fname)) { return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); } @@ -267,6 +273,8 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, status = get_ea_value(talloc_tos(), handle->conn, fsp, base, xattr_name, &ea); + DEBUG(10, ("get_ea_value returned %s\n", nt_errstr(status))); + if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { /* @@ -274,6 +282,8 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, * O_CREAT, the higher levels should have created the base * file for us. */ + DEBUG(10, ("streams_xattr_open: base file %s not around, " + "returning ENOENT\n", base)); errno = ENOENT; goto fail; } @@ -572,6 +582,8 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle, NTSTATUS status; int ret; + DEBUG(10, ("streams_xattr_pwrite called for %d bytes\n", (int)n)); + if (sio == NULL) { return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); } diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 7416fa785a..208066bedc 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -165,6 +165,9 @@ static ssize_t xattr_tdb_getattr(struct db_context *db_ctx, ssize_t result = -1; NTSTATUS status; + DEBUG(10, ("xattr_tdb_getattr called for file %s, name %s\n", + file_id_string_tos(id), name)); + status = xattr_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs); if (!NT_STATUS_IS_OK(status)) { @@ -250,6 +253,9 @@ static int xattr_tdb_setattr(struct db_context *db_ctx, struct tdb_xattrs *attribs; uint32_t i; + DEBUG(10, ("xattr_tdb_setattr called for file %s, name %s\n", + file_id_string_tos(id), name)); + rec = xattr_tdb_lock_attrs(talloc_tos(), db_ctx, id); if (rec == NULL) { -- cgit From 6fcbb1111d06cd158cc6f1178418fe7299830197 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 14:05:36 +0100 Subject: In streams_xattr_pwrite, base_fsp does not have an fd These bugs haven't shown up when I did my tests with real xattrs, not with the xattr_tdb backend. It worked because the stream fsp does has the base file as fd. (This used to be commit b7022f8f7bf83c9c5e73e98d1477b7da766e8c5f) --- source3/modules/vfs_streams_xattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index e304810a02..4fc25f0e83 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -612,7 +612,8 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle, memcpy(ea.value.data + offset, data, n); - ret = SMB_VFS_FSETXATTR(fsp->base_fsp, sio->xattr_name, + ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name, + sio->xattr_name, ea.value.data, ea.value.length, 0); TALLOC_FREE(ea.value.data); -- cgit From fe57c149f0916e895055e2a9faf5eac8724912fb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 14:09:08 +0100 Subject: Do not use an unfinished fsp in streams_xattr_open (This used to be commit 023b313d0d4ed3beb8d77177bc8141cadeb86658) --- source3/modules/vfs_streams_xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 4fc25f0e83..d0112a5d74 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -270,7 +270,7 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, goto fail; } - status = get_ea_value(talloc_tos(), handle->conn, fsp, base, + status = get_ea_value(talloc_tos(), handle->conn, NULL, base, xattr_name, &ea); DEBUG(10, ("get_ea_value returned %s\n", nt_errstr(status))); -- cgit From bf7f13c9a7aebd228d9ba4d45a69809b7a1a8d99 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 15:09:53 +0100 Subject: Fix valgrind errors (This used to be commit d7e6ec2258350c564053371361c8f1d7d0f775b1) --- source3/modules/vfs_streams_xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index d0112a5d74..87bcf22fb3 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -121,7 +121,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf) { NTSTATUS status; - char *base, *sname; + char *base = NULL, *sname = NULL; int result = -1; char *xattr_name; @@ -132,7 +132,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname, status = split_ntfs_stream_name(talloc_tos(), fname, &base, &sname); if (!NT_STATUS_IS_OK(status)) { errno = EINVAL; - goto fail; + return -1; } if (SMB_VFS_STAT(handle->conn, base, sbuf) == -1) { -- cgit From 33f3eeaa00974860dfc45962d5fd34cf05396c76 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 17:35:25 +0100 Subject: Fix some "set but never used" warnings (This used to be commit 4a6dadc5178f4861e9c032321939db3b639734b5) --- source3/modules/vfs_streams_xattr.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 87bcf22fb3..7ce90ab30b 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -618,6 +618,10 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle, TALLOC_FREE(ea.value.data); + if (ret == -1) { + return -1; + } + return n; } -- cgit From 9a226532221b88369b913bc9f9d6ec335620349f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jan 2008 15:10:44 +0100 Subject: Add SMB_VFS_FS_CAPABILITIES It turns out that this is a necessary operation, separate from statvfs. statvfs can fail during tcon, so conn->fs_capabilities would never see that we support streams on a particular share. James, can you check that I got the darwin variant right? Thanks! (This used to be commit 3ad798d803b3b023533bb48e6993885f22b96095) --- source3/modules/vfs_default.c | 13 +++++++++++++ source3/modules/vfs_streams_depot.c | 13 +++---------- source3/modules/vfs_streams_xattr.c | 13 +++---------- 3 files changed, 19 insertions(+), 20 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 2e620d04cc..17d0dfabaf 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -90,6 +90,17 @@ static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, return sys_statvfs(path, statbuf); } +static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle) +{ +#if defined(DARWINOS) + struct statfs sbuf; + ZERO_STRUCT(sbuf); + sys_statvfs(handle->conn->connectpath, &sbuf); + return sbuf.FsCapabilities; +#endif + return FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; +} + /* Directory operations */ static SMB_STRUCT_DIR *vfswrap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr) @@ -1330,6 +1341,8 @@ static vfs_op_tuple vfs_default_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_statvfs), SMB_VFS_OP_STATVFS, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES, + SMB_VFS_LAYER_OPAQUE}, /* Directory operations */ diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 68e7a75947..fa85ea4a57 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -610,22 +610,15 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle, return NT_STATUS_OK; } -static int streams_depot_statvfs(struct vfs_handle_struct *handle, - const char *path, - struct vfs_statvfs_struct *statbuf) +static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle) { - int ret; - - ret = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); - statbuf->FsCapabilities |= FILE_NAMED_STREAMS; - return ret; - + return SMB_VFS_NEXT_FS_CAPABILITIES(handle) | FILE_NAMED_STREAMS; } /* VFS operations structure */ static vfs_op_tuple streams_depot_ops[] = { - {SMB_VFS_OP(streams_depot_statvfs), SMB_VFS_OP_STATVFS, + {SMB_VFS_OP(streams_depot_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(streams_depot_open), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT}, diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 7ce90ab30b..965d57ff88 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -560,16 +560,9 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, return NT_STATUS_OK; } -static int streams_xattr_statvfs(struct vfs_handle_struct *handle, - const char *path, - struct vfs_statvfs_struct *statbuf) +static uint32_t streams_xattr_fs_capabilities(struct vfs_handle_struct *handle) { - int ret; - - ret = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); - statbuf->FsCapabilities |= FILE_NAMED_STREAMS; - return ret; - + return SMB_VFS_NEXT_FS_CAPABILITIES(handle) | FILE_NAMED_STREAMS; } static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle, @@ -663,7 +656,7 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle, /* VFS operations structure */ static vfs_op_tuple streams_xattr_ops[] = { - {SMB_VFS_OP(streams_xattr_statvfs), SMB_VFS_OP_STATVFS, + {SMB_VFS_OP(streams_xattr_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(streams_xattr_open), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT}, -- cgit From 2dbbb375742e508dddf29f3f003d138e64f8e2d6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jan 2008 18:07:38 +0100 Subject: Attempt to fix the darwin build (This used to be commit 5b05e09daf18eaea5e86dfd607c8070228f7571b) --- source3/modules/vfs_default.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 17d0dfabaf..9c5b644a50 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -93,10 +93,10 @@ static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle) { #if defined(DARWINOS) - struct statfs sbuf; - ZERO_STRUCT(sbuf); - sys_statvfs(handle->conn->connectpath, &sbuf); - return sbuf.FsCapabilities; + struct vfs_statvfs_struct statbuf; + ZERO_STRUCT(statbuf); + sys_statvfs(handle->conn->connectpath, &statbuf); + return statbuf.FsCapabilities; #endif return FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; } -- cgit From a4c2b04a2b46fd308e98cc83c26de8307f5196a5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jan 2008 20:24:23 +0100 Subject: Hide streams from the EA API (This used to be commit e9bb3d5067b74a29beb778f85687829778e42b5b) --- source3/modules/vfs_streams_xattr.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 965d57ff88..766e7d10ab 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -26,8 +26,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS -#define XATTR_DOSSTREAM_PREFIX "user.DosStream." - struct stream_io { char *base; char *xattr_name; @@ -140,7 +138,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname, } xattr_name = talloc_asprintf(talloc_tos(), "%s%s", - XATTR_DOSSTREAM_PREFIX, sname); + SAMBA_XATTR_DOSSTREAM_PREFIX, sname); if (xattr_name == NULL) { errno = ENOMEM; goto fail; @@ -187,7 +185,7 @@ static int streams_xattr_lstat(vfs_handle_struct *handle, const char *fname, } xattr_name = talloc_asprintf(talloc_tos(), "%s%s", - XATTR_DOSSTREAM_PREFIX, sname); + SAMBA_XATTR_DOSSTREAM_PREFIX, sname); if (xattr_name == NULL) { errno = ENOMEM; goto fail; @@ -239,7 +237,7 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname, } xattr_name = talloc_asprintf(talloc_tos(), "%s%s", - XATTR_DOSSTREAM_PREFIX, sname); + SAMBA_XATTR_DOSSTREAM_PREFIX, sname); if (xattr_name == NULL) { errno = ENOMEM; goto fail; @@ -373,7 +371,7 @@ static int streams_xattr_unlink(vfs_handle_struct *handle, const char *fname) } xattr_name = talloc_asprintf(talloc_tos(), "%s%s", - XATTR_DOSSTREAM_PREFIX, sname); + SAMBA_XATTR_DOSSTREAM_PREFIX, sname); if (xattr_name == NULL) { errno = ENOMEM; goto fail; @@ -403,7 +401,7 @@ static NTSTATUS walk_xattr_streams(connection_struct *conn, files_struct *fsp, NTSTATUS status; char **names; size_t i, num_names; - size_t prefix_len = strlen(XATTR_DOSSTREAM_PREFIX); + size_t prefix_len = strlen(SAMBA_XATTR_DOSSTREAM_PREFIX); status = get_ea_names_from_file(talloc_tos(), conn, fsp, fname, &names, &num_names); @@ -414,7 +412,7 @@ static NTSTATUS walk_xattr_streams(connection_struct *conn, files_struct *fsp, for (i=0; i Date: Wed, 23 Jan 2008 10:33:36 +0100 Subject: Remove two unused variables (This used to be commit f12ac1ecedd6634d8ccc54d8fce8382514e3322f) --- source3/modules/vfs_default.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 9c5b644a50..cf135dfd03 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -961,7 +961,6 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, struct stream_struct **pstreams) { SMB_STRUCT_STAT sbuf; - NTSTATUS status; unsigned int num_streams = 0; struct stream_struct *streams = NULL; int ret; -- cgit From 587cf54c61c9f1f7bcae431a82035fd942716c32 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Jan 2008 11:04:10 +0100 Subject: strtok -> strtok_r (This used to be commit fd34ce437057bb34cdc37f4b066e424000d36789) --- source3/modules/vfs_recycle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index fef65efa77..da1716719a 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -269,6 +269,7 @@ static bool recycle_create_dir(vfs_handle_struct *handle, const char *dname) char *token; char *tok_str; bool ret = False; + char *saveptr; mode = recycle_directory_mode(handle); @@ -286,7 +287,8 @@ static bool recycle_create_dir(vfs_handle_struct *handle, const char *dname) } /* Create directory tree if neccessary */ - for(token = strtok(tok_str, "/"); token; token = strtok(NULL, "/")) { + for(token = strtok_r(tok_str, "/", &saveptr); token; + token = strtok_r(NULL, "/", &saveptr)) { safe_strcat(new_dir, token, len); if (recycle_directory_exist(handle, new_dir)) DEBUG(10, ("recycle: dir %s already exists\n", new_dir)); -- cgit From 0b10c67c0c2b2bf3ea1f55eff092739e435433c1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 25 Jan 2008 20:52:20 +0100 Subject: Attempt to fix the build on OpenBSD Thanks to metze for pointing this out (This used to be commit c94c04e3e6f6ae243a55534a76654755bff55651) --- source3/modules/vfs_xattr_tdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 208066bedc..171022b01b 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -579,7 +579,7 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db) lock_path("xattr.tdb")); if (dbname == NULL) { - errno = ENOTSUP; + errno = ENOSYS; return false; } -- cgit